Skip to content

Instantly share code, notes, and snippets.

View yossale's full-sized avatar
💭
I may be slow to respond.

Yossale yossale

💭
I may be slow to respond.
View GitHub Profile
const cuid = require('cuid')
const AWS = require('aws-sdk')
// Add these to your lambda's environment variables
const REGION = 'us-east-1'
const SNS_ARN = process.env.SNS_ARN
const TEMPLATE_URL = process.env.TEMPLATE_URL
const TRUSTED_ACCOUNT = process.env.TRUSTED_ACCOUNT
var SNS = new AWS.SNS();
const cuid = require('cuid')
const AWS = require('aws-sdk')
const REGION = 'us-east-1'
const SNS_ARN = process.env.SNS_ARN
const TEMPLATE_URL = process.env.TEMPLATE_URL
const TRUSTED_ACCOUNT = process.env.TRUSTED_ACCOUNT
var SNS = new AWS.SNS();
{
"Parameters" : {
"TrustedAccount" : {
"Type" : "String",
"Description" : "Your account id, to be trusted by the user"
},
"ExternalId" : {
"Type" : "String",
"Description" : "Your secret customer unique id"
},
const response = require('cfn-response-promise')
const util = require('util')
async function replyToResourceRequest(event, context) {
return await response.send(event, context, response.SUCCESS, {});
}
async function saveUserDetailsToDb(AccountId, RoleArn, ExternalID) {
console.log(`Persisting the user info to the database ${AccountId}, ${RoleArn}, ${ExternalID}`)
@yossale
yossale / LogGroupRegistrationLambda.js
Last active June 21, 2020 17:30
LogGroupRegistrationLambda
const util = require('util')
const AWS = require('aws-sdk')
const cloudWatchLogs = new AWS.CloudWatchLogs();
let DESTINATION_ARN = process.env.DESTINATION_ARN
async function registerLogGroupToLogz(logGroupName) {
let filterName = 'sample-filterName-1'
let filterPattern = '' //everything
{
"AWSTemplateFormatVersion":"2010-09-09",
"Transform":"AWS::Serverless-2016-10-31",
"Resources":{
"StackUpdatesListener01":{
"Type":"AWS::Serverless::Function",
"Properties":{
"InlineCode": "module.exports.handler = async (event, context) => { console.log('LOGGING', context); return { statusCode: 200 } }",
"Handler": "index.handler",
"Runtime":"nodejs12.x",
@yossale
yossale / logGroupEvent.json
Created June 22, 2020 07:53
LogGroupCreate CloudWatch Event
{
"source": [
"aws.logs"
],
"detail-type": [
"AWS API Call via CloudTrail"
],
"detail": {
"eventSource": [
"logs.amazonaws.com"
@yossale
yossale / logGroupListener-permission.json
Created June 22, 2020 07:56
logGroupListener-permission.json
{
"Version": "2012–10–17",
"Statement": [
{
"Sid": "Manual",
"Effect": "Allow",
"Action": "logs:PutSubscriptionFilter",
"Resource": "arn:aws:logs:us-east-1:{YOUR_ACCOUNT_ID}:log-group:/aws/Lambda/*"
}
]
@yossale
yossale / additionalFuncResources.json
Created June 22, 2020 08:18
Log Group creation and subscription
"Func01LogGroup": {
"Type": "AWS::Logs::LogGroup",
"Properties": {
"LogGroupName": {
"Fn::Sub": [
"/aws/Lambda/${LambdaName}",
{
"LambdaName": {
"Ref": "Func01Name"
}
@yossale
yossale / ScalableWebhook-CF_template_1.json
Created July 28, 2020 09:06
Scalable Webhook - Basic CloudFormation Template (Before limiting concurrency and adding DLQ)
{
"AWSTemplateFormatVersion": "2010-09-09",
"Transform": "AWS::Serverless-2016-10-31",
"Resources": {
"ApiGateway01": {
"Type": "AWS::Serverless::Api",
"Properties": {
"StageName": "Prod"
}
},