Skip to content

Instantly share code, notes, and snippets.

View AdonousTech's full-sized avatar

Matt Pitts AdonousTech

  • Adonous Tech LLC
View GitHub Profile
@AdonousTech
AdonousTech / index.js
Created January 26, 2021 23:08
A Cloud Coach - Tutorial - Serverless Stripe Store - 008 - Pipeline Deploy Function
const AWS = require('aws-sdk');
exports.handler = (event, context, callback) => {
const sourceBucket = process.env.SourceBucket;
const destBucket = process.env.DestBucket;
const assetPrefix = process.env.AssetPrefix;
const s3 = new AWS.S3({params: {Bucket: sourceBucket}, region: 'us-west-2', "signatureVersion":"v4"});
const codepipeline = new AWS.CodePipeline();
//job id passed into fn by CP
const jobId = event["CodePipeline.job"].id;
@AdonousTech
AdonousTech / index.js
Created January 26, 2021 23:06
A Cloud Coach - Tutorial - Serverless Stripe Store - 008 - Pipeline Cache Function
const AWS = require('aws-sdk');
exports.handler = (event, context, callback) => {
const cloudfront = new AWS.CloudFront();
const codepipeline = new AWS.CodePipeline();
//job id passed into fn by CP
const jobId = event["CodePipeline.job"].id;
let cfInvalidationParams = {
DistributionId: process.env.CloudfrontDistId,
@AdonousTech
AdonousTech / demostore-spa.json
Created January 26, 2021 22:54
A Cloud Coach - Tutorial - Serverless Stripe Store - 008 - SPA Infra CloudFormation Template
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "SPA Infrastructure Template",
"Parameters": {
"CodeBuildProjectNameParameter": {
"Type": "String",
"Description": "A name for the CodeBuild project. The name must be unique across all of the projects in your AWS account."
},
"CodeBuildImageParameter": {
"Type": "String",
@AdonousTech
AdonousTech / gist:c4e367bd9ef0f65ce5d430100d01d755
Created January 26, 2021 21:43
A Cloud Coach - Tutorial - Serverless Stripe Store - 007 - NPM Scripts
"scripts": {
"create-stack-dev": "npm run private-zip-pipeline-functions && npm run private-setup-template-bucket-dev && npm run private-push-stack-to-s3-dev && npm run private-create-stack-dev",
"update-stack-dev": "npm run private-zip-pipeline-functions && npm run private-push-stack-to-s3-dev && npm run private-update-stack-dev",
"private-setup-template-bucket-dev": "(aws s3api get-bucket-location --profile %npm_package_config_profileDev% --bucket %npm_package_config_s3TemplateBucketDev% --region %npm_package_config_region% || npm run private-create-template-bucket-dev)",
"private-create-template-bucket-dev": "aws s3 mb %npm_package_config_s3TemplateBucketLocationDev% --profile %npm_package_config_profileDev% --region %npm_package_config_region%",
"private-push-stack-to-s3-dev": "aws s3 cp %npm_package_config_template% %npm_package_config_s3TemplateBucketLocationDev% --profile %npm_package_config_profileDev% --region %npm_package_config_region%",
"private-create-stack-dev": "aws cl
@AdonousTech
AdonousTech / sample-handler-auto-delegated.js
Last active October 19, 2019 04:55
Sample Alexa Skill handler for Auto-Delegated Dialog
export class FindDogIntentHandler implements RequestHandler {
canHandle(handlerInput: HandlerInput): boolean {
const request = handlerInput.requestEnvelope.request;
return ((request.type === 'IntentRequest' && request.intent.name === 'FindADogIntent' && request.dialogState == 'COMPLETED')
|| (handlerInput.requestEnvelope.request.type === 'LaunchRequest'));
}
async handle(handlerInput: HandlerInput): Promise<Response> {
const { requestEnvelope, serviceClientFactory, responseBuilder } = handlerInput
@AdonousTech
AdonousTech / dialog-model-always.json
Created October 19, 2019 03:56
Snippet of ASK Dialog Model with Auto Delegation Strategy
{
"interactionModel": {
"languageModel": {
"invocationName": "",
"intents": [
{
"name": "AMAZON.CancelIntent",
"samples": []
},
{