Skip to content

Instantly share code, notes, and snippets.

Avatar
🐢

Fabio Gollinucci daaru00

🐢
View GitHub Profile
@daaru00
daaru00 / template.yaml
Last active Oct 3, 2022
Use EventBridge events to execute code when the CloudFormation stack itself is created
View template.yaml
AWSTemplateFormatVersion: "2010-09-09"
Transform: "AWS::Serverless-2016-10-31"
Resources:
LogGroup:
Type: AWS::Logs::LogGroup
Properties:
LogGroupName: !Sub /aws/lambda/${StackCreatedFunction}
RetentionInDays: 7
@daaru00
daaru00 / index.js
Created Aug 5, 2022
X-Ray integration with Lambda
View index.js
const AWSXRay = require('aws-xray-sdk')
AWSXRay.setLogger(console)
/**
* Lambda handler
*/
exports.handler = async (event) => {
console.log(JSON.stringify(event))
@daaru00
daaru00 / useEvents.js
Last active Dec 28, 2021
Vue 3 composition API events bus implementation
View useEvents.js
const eventBus = new Comment('global-event-bus');
const listeners = {};
export const EVENT_NAME = 'MyEventName';
export default function () {
/**
* @param {string} event
* @param {function} callback
* @returns {number} index
@daaru00
daaru00 / template.yml
Created Jul 8, 2021
A SAM template that describe an AWS CodeBuild pipeline that build a static website and deploy it to an S3 Bucket and invalidate the CloudFront distribution.
View template.yml
AWSTemplateFormatVersion: 2010-09-09
Transform:
- AWS::Serverless-2016-10-31
# Template Information
Description: "Personal Website Deploy Pipeline"
# Template Parameters
@daaru00
daaru00 / template.yml
Created Jul 8, 2021
A SAM template that describe an Amazon CloudFront distribution that serve a static website from an S3 Bucket.
View template.yml
AWSTemplateFormatVersion: 2010-09-09
Transform:
- AWS::Serverless-2016-10-31
# Template Information
Description: "Personal Website"
# Template Parameters
@daaru00
daaru00 / template.yml
Created Jun 15, 2021
A SAM template that describe an Amazon CloudFront distribution that redirect all request to a specific URL using a CloudFront Function
View template.yml
AWSTemplateFormatVersion: 2010-09-09
Transform:
- AWS::Serverless-2016-10-31
# Template Information
Description: "Website redirect"
# Template Parameters
@daaru00
daaru00 / lambda.js
Last active Feb 13, 2021
AWS CloudFormation manage secrets with System Manager Parameter
View lambda.js
const axios = require('axios')
/**
* AWS clients
*/
const SSM = require('aws-sdk/clients/ssm')
const ssm = new SSM()
/**
* Lambda handler
@daaru00
daaru00 / App.vue
Last active Nov 21, 2020
Storyblok rich text render component
View App.vue
<template>
<div id="app">
<!-- get page data -->
<vs-rich-text :document="doc" />
</div>
</template>
@daaru00
daaru00 / abstract.js
Last active Feb 13, 2021
DynamoDB model helper (with promise wrapper)
View abstract.js
const DynamoDB = require('aws-sdk/clients/dynamodb')
const documentClient = new DynamoDB.DocumentClient({
apiVersion: '2012-08-10',
// logger: console
})
module.exports = class Model {
/**
* Model constructor
@daaru00
daaru00 / authorizer.js
Last active Jun 15, 2021
Lambda authorizer to check OAuth2 authorization token
View authorizer.js
const https = require('https');
const jose = require('node-jose');
const region = process.env.COGNITO_REGION;
const userpool_id = process.env.COGNITO_USER_POOL_ID;
const app_client_id = process.env.COGNITO_CLIENT_ID;
const keys_url = 'https://cognito-idp.' + region + '.amazonaws.com/' + userpool_id + '/.well-known/jwks.json';
/**
* Lambda handler