View AppSync-Example.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
Description: AWSAppSync DynamoDB Example | |
Resources: | |
GraphQLApi: | |
Type: "AWS::AppSync::GraphQLApi" | |
Properties: | |
Name: AWSAppSync DynamoDB Example | |
AuthenticationType: AWS_IAM | |
PostDynamoDBTableDataSource: |
View verify.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const jwt = require('jsonwebtoken'); | |
const fs = require('fs') | |
function decode(token, pemFile) { | |
let cert = fs.readFileSync(pemFile); // get public key | |
jwt.verify(token, cert, function (err, decoded) { | |
if (err) { | |
console.error("Error", err) | |
} | |
console.log(`${JSON.stringify(decoded)}`) |
View sign.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const AWS = require("aws-sdk"); | |
const kms = new AWS.KMS(); | |
const util = require('util') | |
const base64url = require("base64url"); | |
const keyId = '<YOUR_KEY_ID>' | |
async function sign(headers, payload, key_arn) { | |
payload.iat = Math.floor(Date.now() / 1000); |
View ScalableWebhook-processing.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const util = require('util') | |
const AWS = require('aws-sdk') | |
const docClient = new AWS.DynamoDB.DocumentClient(); | |
const REQ_TABLE = process.env.TABLE_REQUESTSTABLE01 | |
async function updateUserProductsByEmailId(emailId) { | |
console.info(`Updating user products for email: ${emailId}`) | |
//Update all the user-specific products as seen |
View ScalableWebhook-enqueue.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const AWS = require('aws-sdk') | |
const sqs = new AWS.SQS({ apiVersion: '2012-11-05' }); | |
const queueUrl = process.env.QUEUE_REQUESTSQUEUE01 | |
function isValidMessage(msg) { | |
console.info(`Verifying message [${msg}]`) | |
//Do some verification logic here | |
return true |
View ScalableWebhook-CF_template_1.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"AWSTemplateFormatVersion": "2010-09-09", | |
"Transform": "AWS::Serverless-2016-10-31", | |
"Resources": { | |
"ApiGateway01": { | |
"Type": "AWS::Serverless::Api", | |
"Properties": { | |
"StageName": "Prod" | |
} | |
}, |
View additionalFuncResources.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"Func01LogGroup": { | |
"Type": "AWS::Logs::LogGroup", | |
"Properties": { | |
"LogGroupName": { | |
"Fn::Sub": [ | |
"/aws/Lambda/${LambdaName}", | |
{ | |
"LambdaName": { | |
"Ref": "Func01Name" | |
} |
View logGroupListener-permission.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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/*" | |
} | |
] |
View logGroupEvent.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"source": [ | |
"aws.logs" | |
], | |
"detail-type": [ | |
"AWS API Call via CloudTrail" | |
], | |
"detail": { | |
"eventSource": [ | |
"logs.amazonaws.com" |
View LogGroupListenerTemplate.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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", |
NewerOlder