Skip to content

Instantly share code, notes, and snippets.

View fideliocc's full-sized avatar

Fidelio Camino fideliocc

View GitHub Profile
@fideliocc
fideliocc / reports.js
Created April 5, 2020 18:26
PDF Generator Function
'use strict'
const chromium = require('chrome-aws-lambda');
const AWS = require('aws-sdk')
const s3 = new AWS.S3();
exports.handler = async (event, context, callback) => {
let browser = null
try {
@fideliocc
fideliocc / serverless.yml
Created April 5, 2020 17:41
PDF Generator Serverless Template
service: pdf-service
plugins:
- serverless-apigw-binary
package:
exclude:
- pdf_generation/**
layers:
@fideliocc
fideliocc / container.html
Created February 28, 2020 01:49
QuickSight Dashboard container HTML Angular template
<div class="main-content">
<div class="container-fluid">
<div id="dashboardContainer" style="height: 100% !important; width: 100% !important;"></div>
</div>
</div>
@fideliocc
fideliocc / user-service.ts
Created February 28, 2020 01:46
Angular service to perform GET request and returns an observable with QuickSight Dashboard URL
getDashboardUrl(email) {
const url = environment.GET_DASHBOARD_URL + `?email=${email}`;
return this.http.get(url);
}
@fideliocc
fideliocc / getDashboardFunction.js
Created February 28, 2020 01:31
A function to use amazon-quicksight-embedding-sdk to embed a ready QuickSight dashboard in an Angular 8 app component
this.auth.getDashboardUrl()
.subscribe(url => {
console.log(url['payload'].EmbedUrl);
const embedUrl = url['payload'].EmbedUrl;
const options = {
url: embedUrl,
container: document.getElementById('dashboardContainer'),
parameters: {
country: 'Ecuador'
},
@fideliocc
fideliocc / getDashboardUrl.js
Last active May 2, 2024 20:52
Lambda function hooked to API Gateway GET endpoint to attend: role assuming, registering for QuickSight and dashboard URL resolving for web app embedding feature
'use strict'
// IMPORTANT: Replace environment variables with your current values
const aws = require('aws-sdk')
aws.config.region = process.env.REGION
const sts = new aws.STS({apiVersion: '2011-06-15'})
module.exports.handler = (event, context, callback) => {
console.log('User email', event.queryStringParameters.email)
@fideliocc
fideliocc / serverless.yml
Last active August 14, 2020 10:53
A serverless project template to deploy Quicksight URL Resolver
service: quicksight-resolver-service
app: quicksight-resolver-app
# TIP: I prefer to use a secret file for sensitive information as a security practice
custom:
secrets: ${file(./secrets.json)}
quickSightEmbedRoleArn:
Fn::GetAtt: [quickSightEmbedRole, Arn]
provider: