├── cdk-bundle-go-lambda-example ├── cdk.json ├── .npmignore ├── functions │ └── hello │ │ ├── go.mod │ │ ├── vendor │ │ ├── github.com │ │ │ └── aws │ │ │ │ └── aws-lambda-go │ │ │ │ ├── lambda │ │ │ │ ├── README.md │ │ │ │ ├── messages │ │ │ │ │ ├── README.md │ │ │ │ │ └── messages.go │ │ │ │ ├── rpc.go │ │ │ │ ├── errors.go │ │ │ │ ├── handlertrace │ │ │ │ │ └── trace.go │ │ │ │ ├── function.go │ │ │ │ ├── panic.go │ │ │ │ ├── entry.go │ │ │ │ ├── invoke_loop.go │ │ │ │ ├── handler.go │ │ │ │ └── runtime_api_client.go │ │ │ │ ├── lambdacontext │ │ │ │ ├── README.md │ │ │ │ └── context.go │ │ │ │ ├── events │ │ │ │ ├── codepipeline.go │ │ │ │ ├── iot_button.go │ │ │ │ ├── README_CodeBuild.md │ │ │ │ ├── README_CodeDeploy.md │ │ │ │ ├── README_CodeCommit.md │ │ │ │ ├── README_CloudWatch_Logs.md │ │ │ │ ├── README_AutoScaling.md │ │ │ │ ├── README_Config.md │ │ │ │ ├── README_SNS.md │ │ │ │ ├── cloudwatch_events.go │ │ │ │ ├── README_SQS.md │ │ │ │ ├── README_S3.md │ │ │ │ ├── README_SES.md │ │ │ │ ├── autoscaling.go │ │ │ │ ├── README_Kinesis.md │ │ │ │ ├── kafka.go │ │ │ │ ├── README_Cognito.md │ │ │ │ ├── clientvpn.go │ │ │ │ ├── README_Cognito_UserPools_PostConfirmation.md │ │ │ │ ├── README_Cognito_UserPools_PreAuthentication.md │ │ │ │ ├── README_Lex.md │ │ │ │ ├── README_Cognito_UserPools_PreTokenGen.md │ │ │ │ ├── kinesis_analytics.go │ │ │ │ ├── README_Cognito_UserPools_PreSignup.md │ │ │ │ ├── README_Connect.md │ │ │ │ ├── README_CloudWatch_Events.md │ │ │ │ ├── chime_bot.go │ │ │ │ ├── streams.go │ │ │ │ ├── iot_1_click.go │ │ │ │ ├── kinesis.go │ │ │ │ ├── activemq.go │ │ │ │ ├── ecr_scan.go │ │ │ │ ├── config.go │ │ │ │ ├── duration.go │ │ │ │ ├── README_ApiGatewayEvent.md │ │ │ │ ├── README_KinesisFirehose.md │ │ │ │ ├── sqs.go │ │ │ │ ├── iot.go │ │ │ │ ├── README_S3_Batch_Job.md │ │ │ │ ├── rabbitmq.go │ │ │ │ ├── s3_batch_job.go │ │ │ │ ├── README_ALBTargetGroupEvents.md │ │ │ │ ├── cloudwatch_logs.go │ │ │ │ ├── epoch_time.go │ │ │ │ ├── README_KinesisDataAnalytics.md │ │ │ │ ├── alb.go │ │ │ │ ├── README.md │ │ │ │ ├── README_ClientVPN.md │ │ │ │ ├── connect.go │ │ │ │ ├── README_Cognito_UserPools_CustomAuthLambdaTriggers.md │ │ │ │ ├── README_Chime_Bots.md │ │ │ │ ├── s3.go │ │ │ │ ├── firehose.go │ │ │ │ ├── README_ApiGatewayCustomAuthorizer.md │ │ │ │ ├── codedeploy.go │ │ │ │ ├── codepipeline_job.go │ │ │ │ ├── appsync.go │ │ │ │ ├── README_DynamoDB.md │ │ │ │ ├── lex.go │ │ │ │ ├── codepipeline_cloudwatch.go │ │ │ │ ├── code_commit.go │ │ │ │ ├── ses.go │ │ │ │ ├── sns.go │ │ │ │ ├── dynamodb.go │ │ │ │ └── codebuild.go │ │ │ │ ├── LICENSE-SUMMARY │ │ │ │ ├── LICENSE-LAMBDACODE │ │ │ │ └── LICENSE │ │ └── modules.txt │ │ ├── main.go │ │ ├── main_test.go │ │ └── go.sum ├── jest.config.js ├── .gitignore ├── test │ └── cdk.test.ts ├── lib │ ├── app-stage.ts │ ├── pipeline-stack.ts │ └── api-stack.ts ├── README.md ├── bin │ └── cdk.ts ├── tsconfig.json └── package.json ├── cdk-bundle-static-site-example ├── cdk.json ├── .npmignore ├── frontend │ ├── static │ │ ├── favicon.ico │ │ └── README.md │ ├── components │ │ ├── README.md │ │ └── Logo.vue │ ├── jsconfig.json │ ├── layouts │ │ ├── README.md │ │ └── default.vue │ ├── pages │ │ ├── README.md │ │ └── index.vue │ ├── assets │ │ └── README.md │ ├── plugins │ │ └── README.md │ ├── package.json │ ├── middleware │ │ └── README.md │ ├── README.md │ ├── store │ │ └── README.md │ ├── .gitignore │ └── nuxt.config.js ├── jest.config.js ├── .gitignore ├── test │ └── cdk.test.ts ├── README.md ├── lib │ ├── app-stage.ts │ ├── pipeline-stack.ts │ └── static-site-stack.ts ├── tsconfig.json ├── package.json └── bin │ └── cdk.ts ├── images ├── frontend-website.png ├── api-deliverypipeline.png └── frontend-deliverypipeline.png ├── CODE_OF_CONDUCT.md ├── LICENSE └── CONTRIBUTING.md /cdk-bundle-go-lambda-example/cdk.json: -------------------------------------------------------------------------------- 1 | { 2 | "app": "npx ts-node bin/cdk.ts", 3 | "context": { } 4 | } 5 | -------------------------------------------------------------------------------- /cdk-bundle-static-site-example/cdk.json: -------------------------------------------------------------------------------- 1 | { 2 | "app": "npx ts-node bin/cdk.ts", 3 | "context": { } 4 | } 5 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/.npmignore: -------------------------------------------------------------------------------- 1 | *.ts 2 | !*.d.ts 3 | 4 | # CDK asset staging directory 5 | .cdk.staging 6 | cdk.out 7 | -------------------------------------------------------------------------------- /cdk-bundle-static-site-example/.npmignore: -------------------------------------------------------------------------------- 1 | *.ts 2 | !*.d.ts 3 | 4 | # CDK asset staging directory 5 | .cdk.staging 6 | cdk.out 7 | -------------------------------------------------------------------------------- /images/frontend-website.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/cdk-build-bundle-deploy-example/HEAD/images/frontend-website.png -------------------------------------------------------------------------------- /images/api-deliverypipeline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/cdk-build-bundle-deploy-example/HEAD/images/api-deliverypipeline.png -------------------------------------------------------------------------------- /images/frontend-deliverypipeline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/cdk-build-bundle-deploy-example/HEAD/images/frontend-deliverypipeline.png -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/aws-samples/cdk-bundle-go-lambda-example/hello 2 | 3 | go 1.13 4 | 5 | require github.com/aws/aws-lambda-go v1.28.0 6 | -------------------------------------------------------------------------------- /cdk-bundle-static-site-example/frontend/static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/cdk-build-bundle-deploy-example/HEAD/cdk-bundle-static-site-example/frontend/static/favicon.ico -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | roots: ['/test'], 3 | testMatch: ['**/*.test.ts'], 4 | transform: { 5 | '^.+\\.tsx?$': 'ts-jest' 6 | } 7 | }; 8 | -------------------------------------------------------------------------------- /cdk-bundle-static-site-example/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | roots: ['/test'], 3 | testMatch: ['**/*.test.ts'], 4 | transform: { 5 | '^.+\\.tsx?$': 'ts-jest' 6 | } 7 | }; 8 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/.gitignore: -------------------------------------------------------------------------------- 1 | *.js 2 | !jest.config.js 3 | *.d.ts 4 | node_modules 5 | 6 | # CDK asset staging directory 7 | .cdk.staging 8 | cdk.out 9 | 10 | # Parcel default cache directory 11 | .parcel-cache 12 | -------------------------------------------------------------------------------- /cdk-bundle-static-site-example/.gitignore: -------------------------------------------------------------------------------- 1 | *.js 2 | !jest.config.js 3 | *.d.ts 4 | node_modules 5 | !frontend/*.js 6 | 7 | # CDK asset staging directory 8 | .cdk.staging 9 | cdk.out 10 | 11 | # Parcel default cache directory 12 | .parcel-cache 13 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/lambda/README.md: -------------------------------------------------------------------------------- 1 | # Overview 2 | 3 | [![Go Reference](https://pkg.go.dev/badge/github.com/aws/aws-lambda-go/lambda.svg)](https://pkg.go.dev/github.com/aws/aws-lambda-go/lambda) 4 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/lambdacontext/README.md: -------------------------------------------------------------------------------- 1 | # Overview 2 | 3 | [![Go Reference](https://pkg.go.dev/badge/github.com/aws/aws-lambda-go/lambdacontext.svg)](https://pkg.go.dev/github.com/aws/aws-lambda-go/lambdacontext) 4 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/lambda/messages/README.md: -------------------------------------------------------------------------------- 1 | # Overview 2 | 3 | [![Go Reference](https://pkg.go.dev/badge/github.com/aws/aws-lambda-go/lambda/messages.svg)](https://pkg.go.dev/github.com/aws/aws-lambda-go/lambda/messages) 4 | -------------------------------------------------------------------------------- /cdk-bundle-static-site-example/frontend/components/README.md: -------------------------------------------------------------------------------- 1 | # COMPONENTS 2 | 3 | **This directory is not required, you can delete it if you don't want to use it.** 4 | 5 | The components directory contains your Vue.js Components. 6 | 7 | _Nuxt.js doesn't supercharge these components._ 8 | -------------------------------------------------------------------------------- /cdk-bundle-static-site-example/frontend/jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": ".", 4 | "paths": { 5 | "~/*": ["./*"], 6 | "@/*": ["./*"], 7 | "~~/*": ["./*"], 8 | "@@/*": ["./*"] 9 | } 10 | }, 11 | "exclude": ["node_modules", ".nuxt", "dist"] 12 | } 13 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/modules.txt: -------------------------------------------------------------------------------- 1 | # github.com/aws/aws-lambda-go v1.28.0 2 | github.com/aws/aws-lambda-go/events 3 | github.com/aws/aws-lambda-go/lambda 4 | github.com/aws/aws-lambda-go/lambda/handlertrace 5 | github.com/aws/aws-lambda-go/lambda/messages 6 | github.com/aws/aws-lambda-go/lambdacontext 7 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | ## Code of Conduct 2 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). 3 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact 4 | opensource-codeofconduct@amazon.com with any additional questions or comments. 5 | -------------------------------------------------------------------------------- /cdk-bundle-static-site-example/frontend/layouts/README.md: -------------------------------------------------------------------------------- 1 | # LAYOUTS 2 | 3 | **This directory is not required, you can delete it if you don't want to use it.** 4 | 5 | This directory contains your Application Layouts. 6 | 7 | More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/views#layouts). 8 | -------------------------------------------------------------------------------- /cdk-bundle-static-site-example/frontend/pages/README.md: -------------------------------------------------------------------------------- 1 | # PAGES 2 | 3 | This directory contains your Application Views and Routes. 4 | The framework reads all the `*.vue` files inside this directory and creates the router of your application. 5 | 6 | More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/routing). 7 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/codepipeline.go: -------------------------------------------------------------------------------- 1 | package events 2 | 3 | // CodePipelineJob has been incorrectly assigned as CodePipelineEvent 4 | // - https://github.com/aws/aws-lambda-go/issues/244 5 | // This maintains backwards compatability until a v2 release 6 | type CodePipelineEvent = CodePipelineJobEvent 7 | -------------------------------------------------------------------------------- /cdk-bundle-static-site-example/frontend/assets/README.md: -------------------------------------------------------------------------------- 1 | # ASSETS 2 | 3 | **This directory is not required, you can delete it if you don't want to use it.** 4 | 5 | This directory contains your un-compiled assets such as LESS, SASS, or JavaScript. 6 | 7 | More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/assets#webpacked). 8 | -------------------------------------------------------------------------------- /cdk-bundle-static-site-example/frontend/plugins/README.md: -------------------------------------------------------------------------------- 1 | # PLUGINS 2 | 3 | **This directory is not required, you can delete it if you don't want to use it.** 4 | 5 | This directory contains Javascript plugins that you want to run before mounting the root Vue.js application. 6 | 7 | More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/plugins). 8 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/iot_button.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | 3 | package events 4 | 5 | type IoTButtonEvent struct { 6 | SerialNumber string `json:"serialNumber"` 7 | ClickType string `json:"clickType"` 8 | BatteryVoltage string `json:"batteryVoltage"` 9 | } 10 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/LICENSE-SUMMARY: -------------------------------------------------------------------------------- 1 | Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | 3 | Lambda functions are made available under a modified MIT license. 4 | See LICENSE-LAMBDACODE for details. 5 | 6 | The remainder of the project is made available under the terms of the 7 | Apache License, version 2.0. See LICENSE for details. 8 | -------------------------------------------------------------------------------- /cdk-bundle-static-site-example/frontend/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "front-end", 3 | "version": "1.0.0", 4 | "private": true, 5 | "scripts": { 6 | "dev": "nuxt", 7 | "build": "nuxt build", 8 | "start": "nuxt start", 9 | "generate": "nuxt generate" 10 | }, 11 | "dependencies": { 12 | "@nuxtjs/axios": "^5.13.6", 13 | "nuxt": "^3.4.3" 14 | }, 15 | "devDependencies": {} 16 | } 17 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/README_CodeBuild.md: -------------------------------------------------------------------------------- 1 | # Sample Function 2 | 3 | The following is a sample Lambda function that receives an Amazon CodeBuild event 4 | and writes it to standard output. 5 | 6 | ```go 7 | import ( 8 | "fmt" 9 | "github.com/aws/aws-lambda-go/events" 10 | ) 11 | 12 | func handleRequest(evt events.CodeBuildEvent) { 13 | fmt.Println(evt) 14 | } 15 | ``` 16 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/README_CodeDeploy.md: -------------------------------------------------------------------------------- 1 | # Sample Function 2 | 3 | The following is a sample Lambda function that receives an Amazon CodeDeploy event 4 | and writes it to standard output. 5 | 6 | ```go 7 | import ( 8 | "fmt" 9 | "github.com/aws/aws-lambda-go/events" 10 | ) 11 | 12 | func handleRequest(evt events.CodeDeployEvent) { 13 | fmt.Println(evt) 14 | } 15 | ``` 16 | -------------------------------------------------------------------------------- /cdk-bundle-static-site-example/frontend/middleware/README.md: -------------------------------------------------------------------------------- 1 | # MIDDLEWARE 2 | 3 | **This directory is not required, you can delete it if you don't want to use it.** 4 | 5 | This directory contains your application middleware. 6 | Middleware let you define custom functions that can be run before rendering either a page or a group of pages. 7 | 8 | More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/routing#middleware). 9 | -------------------------------------------------------------------------------- /cdk-bundle-static-site-example/frontend/README.md: -------------------------------------------------------------------------------- 1 | # front-end 2 | 3 | ## Build Setup 4 | 5 | ```bash 6 | # install dependencies 7 | $ npm install 8 | 9 | # serve with hot reload at localhost:3000 10 | $ npm run dev 11 | 12 | # build for production and launch server 13 | $ npm run build 14 | $ npm run start 15 | 16 | # generate static project 17 | $ npm run generate 18 | ``` 19 | 20 | For detailed explanation on how things work, check out [Nuxt.js docs](https://nuxtjs.org). 21 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/test/cdk.test.ts: -------------------------------------------------------------------------------- 1 | import { expect as expectCDK, matchTemplate, MatchStyle } from '@aws-cdk/assert'; 2 | import * as cdk from '@aws-cdk/core'; 3 | import * as Cdk from '../lib/api-stack'; 4 | 5 | test('Empty Stack', () => { 6 | const app = new cdk.App(); 7 | // WHEN 8 | const stack = new Cdk.ApiStack(app, 'MyTestStack'); 9 | // THEN 10 | expectCDK(stack).to(matchTemplate({ 11 | "Resources": {} 12 | }, MatchStyle.EXACT)) 13 | }); 14 | -------------------------------------------------------------------------------- /cdk-bundle-static-site-example/frontend/store/README.md: -------------------------------------------------------------------------------- 1 | # STORE 2 | 3 | **This directory is not required, you can delete it if you don't want to use it.** 4 | 5 | This directory contains your Vuex Store files. 6 | Vuex Store option is implemented in the Nuxt.js framework. 7 | 8 | Creating a file in this directory automatically activates the option in the framework. 9 | 10 | More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/vuex-store). 11 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/aws/aws-lambda-go/events" 7 | "github.com/aws/aws-lambda-go/lambda" 8 | ) 9 | 10 | func handler(ctx context.Context, event events.APIGatewayV2HTTPRequest) (events.APIGatewayV2HTTPResponse, error) { 11 | return events.APIGatewayV2HTTPResponse{ 12 | StatusCode: 200, 13 | Body: "CDK!", 14 | }, nil 15 | } 16 | 17 | func main() { 18 | lambda.Start(handler) 19 | } 20 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/lib/app-stage.ts: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: MIT-0 3 | import * as cdk from 'aws-cdk-lib'; 4 | import { ApiStack } from './api-stack'; 5 | import { Construct } from 'constructs'; 6 | 7 | export class AppStage extends cdk.Stage { 8 | constructor(scope: Construct, id: string, props?: cdk.StageProps) { 9 | super(scope, id, props); 10 | 11 | new ApiStack(this, 'ApiStack'); 12 | } 13 | } 14 | 15 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/README_CodeCommit.md: -------------------------------------------------------------------------------- 1 | # Sample Function 2 | 3 | The following is a sample Lambda function that receives Amazon CodeCommit event 4 | records input and prints them to `os.Stdout`.) 5 | 6 | ```go 7 | import ( 8 | "fmt" 9 | "github.com/aws/aws-lambda-go/events" 10 | ) 11 | 12 | func handleRequest(evt events.CodeCommitEvent) { 13 | for _, record := range evt.Records { 14 | fmt.Println(record) 15 | } 16 | } 17 | ``` 18 | -------------------------------------------------------------------------------- /cdk-bundle-static-site-example/frontend/static/README.md: -------------------------------------------------------------------------------- 1 | # STATIC 2 | 3 | **This directory is not required, you can delete it if you don't want to use it.** 4 | 5 | This directory contains your static files. 6 | Each file inside this directory is mapped to `/`. 7 | Thus you'd want to delete this README.md before deploying to production. 8 | 9 | Example: `/static/robots.txt` is mapped as `/robots.txt`. 10 | 11 | More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/assets#static). 12 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/main_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "reflect" 6 | "testing" 7 | 8 | "github.com/aws/aws-lambda-go/events" 9 | ) 10 | 11 | func TestHandler(t *testing.T) { 12 | got, err := handler(context.Background(), events.APIGatewayV2HTTPRequest{}) 13 | if err != nil { 14 | t.Errorf("got an error: %s", err) 15 | } 16 | want := events.APIGatewayV2HTTPResponse{StatusCode: 200, Body: "CDK!"} 17 | if !reflect.DeepEqual(got, want) { 18 | t.Errorf("got %v want %v", got, want) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /cdk-bundle-static-site-example/test/cdk.test.ts: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: MIT-0 3 | import { expect as expectCDK, matchTemplate, MatchStyle } from '@aws-cdk/assert'; 4 | import * as cdk from '@aws-cdk/core'; 5 | import * as Cdk from '../lib/static-site-stack'; 6 | 7 | test('Empty Stack', () => { 8 | const app = new cdk.App(); 9 | // WHEN 10 | const stack = new Cdk.StaticSiteStack(app, 'MyTestStack'); 11 | // THEN 12 | expectCDK(stack).to(matchTemplate({ 13 | "Resources": {} 14 | }, MatchStyle.EXACT)) 15 | }); 16 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/README.md: -------------------------------------------------------------------------------- 1 | # Welcome to your CDK TypeScript project! 2 | 3 | This is a blank project for TypeScript development with CDK. 4 | 5 | The `cdk.json` file tells the CDK Toolkit how to execute your app. 6 | 7 | ## Useful commands 8 | 9 | * `npm run build` compile typescript to js 10 | * `npm run watch` watch for changes and compile 11 | * `npm run test` perform the jest unit tests 12 | * `cdk deploy` deploy this stack to your default AWS account/region 13 | * `cdk diff` compare deployed stack with current state 14 | * `cdk synth` emits the synthesized CloudFormation template 15 | -------------------------------------------------------------------------------- /cdk-bundle-static-site-example/README.md: -------------------------------------------------------------------------------- 1 | # Welcome to your CDK TypeScript project! 2 | 3 | This is a blank project for TypeScript development with CDK. 4 | 5 | The `cdk.json` file tells the CDK Toolkit how to execute your app. 6 | 7 | ## Useful commands 8 | 9 | * `npm run build` compile typescript to js 10 | * `npm run watch` watch for changes and compile 11 | * `npm run test` perform the jest unit tests 12 | * `cdk deploy` deploy this stack to your default AWS account/region 13 | * `cdk diff` compare deployed stack with current state 14 | * `cdk synth` emits the synthesized CloudFormation template 15 | -------------------------------------------------------------------------------- /cdk-bundle-static-site-example/lib/app-stage.ts: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: MIT-0 3 | import * as cdk from 'aws-cdk-lib'; 4 | import { StaticSiteStack } from './static-site-stack'; 5 | import { Construct } from 'constructs'; 6 | 7 | export interface AppStageProps extends cdk.StageProps { 8 | apiUrl: string; 9 | } 10 | 11 | export class AppStage extends cdk.Stage { 12 | constructor(scope: Construct, id: string, props: AppStageProps) { 13 | super(scope, id, props); 14 | 15 | new StaticSiteStack(this, 'StaticSite', { 16 | buildEnvironment: { 17 | API_URL: props.apiUrl, 18 | } 19 | }); 20 | } 21 | } 22 | 23 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/bin/cdk.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | // SPDX-License-Identifier: MIT-0 4 | import * as cdk from 'aws-cdk-lib'; 5 | import { AppStage } from '../lib/app-stage'; 6 | import { PipelineStack } from '../lib/pipeline-stack'; 7 | 8 | const app = new cdk.App(); 9 | 10 | const delivery = new PipelineStack(app, 'Api-DeliveryPipeline', { 11 | name: 'Api', 12 | env: { 13 | account: '12345678910', 14 | region: 'us-east-1' 15 | } 16 | }); 17 | 18 | delivery.pipeline.addStage( 19 | new AppStage(app, 'App', { 20 | env: { 21 | account: '01987654321', 22 | region: 'us-east-1', 23 | }, 24 | }) 25 | ); 26 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2018", 4 | "module": "commonjs", 5 | "lib": ["es2018"], 6 | "declaration": true, 7 | "strict": true, 8 | "noImplicitAny": true, 9 | "strictNullChecks": true, 10 | "noImplicitThis": true, 11 | "alwaysStrict": true, 12 | "noUnusedLocals": false, 13 | "noUnusedParameters": false, 14 | "noImplicitReturns": true, 15 | "noFallthroughCasesInSwitch": false, 16 | "inlineSourceMap": true, 17 | "inlineSources": true, 18 | "experimentalDecorators": true, 19 | "strictPropertyInitialization": false, 20 | "typeRoots": ["./node_modules/@types"] 21 | }, 22 | "exclude": ["cdk.out"] 23 | } 24 | -------------------------------------------------------------------------------- /cdk-bundle-static-site-example/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2018", 4 | "module": "commonjs", 5 | "lib": ["es2018"], 6 | "declaration": true, 7 | "strict": true, 8 | "noImplicitAny": true, 9 | "strictNullChecks": true, 10 | "noImplicitThis": true, 11 | "alwaysStrict": true, 12 | "noUnusedLocals": false, 13 | "noUnusedParameters": false, 14 | "noImplicitReturns": true, 15 | "noFallthroughCasesInSwitch": false, 16 | "inlineSourceMap": true, 17 | "inlineSources": true, 18 | "experimentalDecorators": true, 19 | "strictPropertyInitialization": false, 20 | "typeRoots": ["./node_modules/@types"] 21 | }, 22 | "exclude": ["cdk.out"] 23 | } 24 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/README_CloudWatch_Logs.md: -------------------------------------------------------------------------------- 1 | 2 | # Sample Function 3 | 4 | The following is a Lambda function that receives Amazon CloudWatch Logs event record data as input and writes message part to Lambda's CloudWatch Logs. Note that by default anything written to Console will be logged as CloudWatch Logs events. 5 | 6 | ```go 7 | import ( 8 | "context" 9 | "fmt" 10 | 11 | "github.com/aws/aws-lambda-go/events" 12 | ) 13 | 14 | func handler(ctx context.Context, logsEvent events.CloudwatchLogsEvent) { 15 | data, _ := logsEvent.AWSLogs.Parse() 16 | for _, logEvent := range data.LogEvents { 17 | fmt.Printf("Message = %s\n", logEvent.Message) 18 | } 19 | } 20 | ``` 21 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/README_AutoScaling.md: -------------------------------------------------------------------------------- 1 | # Sample Function 2 | 3 | The following is a sample Lambda function that receives an Auto Scaling event as an input and logs the EC2 instance ID to CloudWatch Logs. (Note that anything written to stdout or stderr will be logged as CloudWatch Logs events.) 4 | 5 | ```go 6 | import ( 7 | "context" 8 | "fmt" 9 | 10 | "github.com/aws/aws-lambda-go/events" 11 | "github.com/aws/aws-lambda-go/lambda" 12 | ) 13 | 14 | func handler(ctx context.Context, autoScalingEvent events.AutoScalingEvent) { 15 | fmt.Printf("Instance-Id available in event is %s \n", autoScalingEvent.Detail["EC2InstanceId"]) 16 | } 17 | 18 | func main() { 19 | lambda.Start(handler) 20 | } 21 | ``` 22 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/README_Config.md: -------------------------------------------------------------------------------- 1 | # Sample Function 2 | 3 | The following is a sample Lambda function that receives Amazon Config event record data as an input and writes some of the record data to CloudWatch Logs. (Note that anything written to stdout or stderr will be logged as CloudWatch Logs events.) 4 | 5 | ```go 6 | 7 | import ( 8 | "strings" 9 | "github.com/aws/aws-lambda-go/events" 10 | ) 11 | 12 | func handleRequest(ctx context.Context, configEvent events.ConfigEvent) { 13 | fmt.Printf("AWS Config rule: %s\n", configEvent.ConfigRuleName) 14 | fmt.Printf("Invoking event JSON: %s\n", configEvent.InvokingEvent) 15 | fmt.Printf("Event version: %s\n", configEvent.Version) 16 | } 17 | 18 | ``` 19 | -------------------------------------------------------------------------------- /cdk-bundle-static-site-example/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cdk", 3 | "author": "Cory Hall", 4 | "license": "MIT-0", 5 | "version": "0.1.0", 6 | "bin": { 7 | "cdk": "bin/cdk.js" 8 | }, 9 | "scripts": { 10 | "build": "tsc", 11 | "watch": "tsc -w", 12 | "test": "jest", 13 | "cdk": "cdk" 14 | }, 15 | "devDependencies": { 16 | "@types/jest": "^27.4.1", 17 | "@types/node": "17.0.21", 18 | "aws-cdk": "2.14.0", 19 | "jest": "^27.5.1", 20 | "ts-jest": "^27.1.3", 21 | "ts-node": "^10.5.0", 22 | "typescript": "~4.5.5" 23 | }, 24 | "dependencies": { 25 | "@types/fs-extra": "^9.0.13", 26 | "aws-cdk-lib": "^2.14.0", 27 | "constructs": "^10.0.74", 28 | "fs-extra": "^10.0.1", 29 | "source-map-support": "^0.5.21" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/README_SNS.md: -------------------------------------------------------------------------------- 1 | 2 | # Sample Function 3 | 4 | The following is a sample class and Lambda function that receives Amazon SNS event record data as input, writes some of the record data to CloudWatch Logs, and responds with a 200 status and the same body as the request. (Note that anything written to stdout or stderr will be logged as CloudWatch Logs events.) 5 | 6 | ```go 7 | import ( 8 | "context" 9 | "fmt" 10 | 11 | "github.com/aws/aws-lambda-go/events" 12 | ) 13 | 14 | func handler(ctx context.Context, snsEvent events.SNSEvent) { 15 | for _, record := range snsEvent.Records { 16 | snsRecord := record.SNS 17 | 18 | fmt.Printf("[%s %s] Message = %s \n", record.EventSource, snsRecord.Timestamp, snsRecord.Message) 19 | } 20 | } 21 | ``` 22 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cdk", 3 | "version": "0.1.0", 4 | "license": "MIT-0", 5 | "bin": { 6 | "cdk": "bin/cdk.js" 7 | }, 8 | "scripts": { 9 | "build": "tsc", 10 | "watch": "tsc -w", 11 | "test": "jest", 12 | "cdk": "cdk" 13 | }, 14 | "devDependencies": { 15 | "@types/jest": "^27.4.1", 16 | "@types/node": "17.0.21", 17 | "aws-cdk": "2.14.0", 18 | "jest": "^27.5.1", 19 | "ts-jest": "^27.1.3", 20 | "ts-node": "^10.5.0", 21 | "typescript": "~4.5.5" 22 | }, 23 | "dependencies": { 24 | "@aws-cdk/aws-apigatewayv2-alpha": "^2.14.0-alpha.0", 25 | "@aws-cdk/aws-apigatewayv2-integrations-alpha": "^2.14.0-alpha.0", 26 | "aws-cdk-lib": "^2.14.0", 27 | "constructs": "^10.0.74", 28 | "source-map-support": "^0.5.21" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /cdk-bundle-static-site-example/bin/cdk.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | // SPDX-License-Identifier: MIT-0 4 | import * as cdk from 'aws-cdk-lib'; 5 | import { PipelineStack } from '../lib/pipeline-stack'; 6 | import { AppStage } from '../lib/app-stage'; 7 | 8 | const app = new cdk.App(); 9 | 10 | const delivery = new PipelineStack(app, 'Frontend-DeliveryPipeline', { 11 | name: 'Frontend', 12 | env: { 13 | account: '12345678910', 14 | region: 'us-east-1' 15 | } 16 | }); 17 | 18 | delivery.pipeline.addStage( 19 | new AppStage(app, 'App', { 20 | apiUrl: 'REPLACE_WITH_API_URL', // this should be the HTTP API url from the cdk-bundle-go-lambda-example app 21 | env: { 22 | account: '01987654321', 23 | region: 'us-east-1', 24 | }, 25 | }) 26 | ); 27 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/cloudwatch_events.go: -------------------------------------------------------------------------------- 1 | package events 2 | 3 | import ( 4 | "encoding/json" 5 | "time" 6 | ) 7 | 8 | // CloudWatchEvent is the outer structure of an event sent via CloudWatch Events. 9 | // For examples of events that come via CloudWatch Events, see https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/EventTypes.html 10 | type CloudWatchEvent struct { 11 | Version string `json:"version"` 12 | ID string `json:"id"` 13 | DetailType string `json:"detail-type"` 14 | Source string `json:"source"` 15 | AccountID string `json:"account"` 16 | Time time.Time `json:"time"` 17 | Region string `json:"region"` 18 | Resources []string `json:"resources"` 19 | Detail json.RawMessage `json:"detail"` 20 | } 21 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/README_SQS.md: -------------------------------------------------------------------------------- 1 | 2 | # Sample Function 3 | 4 | The following is a sample class and Lambda function that receives Amazon SQS event message data as input, writes some of the message data to CloudWatch Logs, and responds with a 200 status and the same body as the request. (Note that anything written to stdout or stderr will be logged as CloudWatch Logs events.) 5 | 6 | ```go 7 | package main 8 | 9 | import ( 10 | "context" 11 | "fmt" 12 | 13 | "github.com/aws/aws-lambda-go/events" 14 | "github.com/aws/aws-lambda-go/lambda" 15 | ) 16 | 17 | func handler(ctx context.Context, sqsEvent events.SQSEvent) error { 18 | for _, message := range sqsEvent.Records { 19 | fmt.Printf("The message %s for event source %s = %s \n", message.MessageId, message.EventSource, message.Body) 20 | } 21 | 22 | return nil 23 | } 24 | 25 | func main() { 26 | lambda.Start(handler) 27 | } 28 | 29 | ``` 30 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software is furnished to do so. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 10 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 11 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 12 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 13 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 14 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 15 | 16 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/README_S3.md: -------------------------------------------------------------------------------- 1 | # Sample Function 2 | 3 | The following is a sample class and Lambda function that receives Amazon S3 event record data as an input and writes some of the record data to CloudWatch Logs. (Note that anything written to stdout or stderr will be logged as CloudWatch Logs events.) 4 | 5 | ```go 6 | 7 | // main.go 8 | package main 9 | 10 | import ( 11 | "fmt" 12 | "context" 13 | "github.com/aws/aws-lambda-go/lambda" 14 | "github.com/aws/aws-lambda-go/events" 15 | ) 16 | 17 | func handler(ctx context.Context, s3Event events.S3Event) { 18 | for _, record := range s3Event.Records { 19 | s3 := record.S3 20 | fmt.Printf("[%s - %s] Bucket = %s, Key = %s \n", record.EventSource, record.EventTime, s3.Bucket.Name, s3.Object.Key) 21 | } 22 | } 23 | 24 | 25 | func main() { 26 | // Make the handler available for Remote Procedure Call by AWS Lambda 27 | lambda.Start(handler) 28 | } 29 | 30 | ``` 31 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/README_SES.md: -------------------------------------------------------------------------------- 1 | 2 | # Sample Function 3 | 4 | The following is a sample class and Lambda function that receives Amazon SES event message data as input, writes some of the message data to CloudWatch Logs, and responds with a 200 status and the same body as the request. (Note that anything written to stdout or stderr will be logged as CloudWatch Logs events.) 5 | 6 | ```go 7 | package main 8 | 9 | import ( 10 | "context" 11 | "fmt" 12 | 13 | "github.com/aws/aws-lambda-go/events" 14 | "github.com/aws/aws-lambda-go/lambda" 15 | ) 16 | 17 | func handler(ctx context.Context, sesEvent events.SimpleEmailEvent) error { 18 | for _, record := range sesEvent.Records { 19 | ses := record.SES 20 | fmt.Printf("[%s - %s] Mail = %+v, Receipt = %+v \n", record.EventVersion, record.EventSource, ses.Mail, ses.Receipt) 21 | } 22 | 23 | return nil 24 | } 25 | 26 | func main() { 27 | lambda.Start(handler) 28 | } 29 | 30 | ``` 31 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/autoscaling.go: -------------------------------------------------------------------------------- 1 | package events 2 | 3 | import ( 4 | "time" 5 | ) 6 | 7 | // AutoScalingEvent struct is used to parse the json for auto scaling event types // 8 | type AutoScalingEvent struct { 9 | Version string `json:"version"` // The version of event data 10 | ID string `json:"id"` // The unique ID of the event 11 | DetailType string `json:"detail-type"` //Details about event type 12 | Source string `json:"source"` //Source of the event 13 | AccountID string `json:"account"` //AccountId 14 | Time time.Time `json:"time"` //Event timestamp 15 | Region string `json:"region"` //Region of event 16 | Resources []string `json:"resources"` //Information about resources impacted by event 17 | Detail map[string]interface{} `json:"detail"` 18 | } 19 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/LICENSE-LAMBDACODE: -------------------------------------------------------------------------------- 1 | MIT No Attribution 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this 4 | software and associated documentation files (the "Software"), to deal in the Software 5 | without restriction, including without limitation the rights to use, copy, modify, 6 | merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 7 | permit persons to whom the Software is furnished to do so. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 10 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 11 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 12 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 13 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 14 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 15 | 16 | -------------------------------------------------------------------------------- /cdk-bundle-static-site-example/frontend/components/Logo.vue: -------------------------------------------------------------------------------- 1 | 17 | 18 | 30 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/README_Kinesis.md: -------------------------------------------------------------------------------- 1 | # Sample Function 2 | 3 | The following is a sample class and Lambda function that receives Amazon Kinesis event record data as an input and writes some of the record data to CloudWatch Logs. (Note that anything written to stdout or stderr will be logged as CloudWatch Logs events.) 4 | 5 | ```go 6 | 7 | package main 8 | 9 | import ( 10 | "context" 11 | "fmt" 12 | 13 | "github.com/aws/aws-lambda-go/events" 14 | "github.com/aws/aws-lambda-go/lambda" 15 | ) 16 | 17 | func handler(ctx context.Context, kinesisEvent events.KinesisEvent) error { 18 | for _, record := range kinesisEvent.Records { 19 | kinesisRecord := record.Kinesis 20 | dataBytes := kinesisRecord.Data 21 | dataText := string(dataBytes) 22 | 23 | fmt.Printf("%s Data = %s \n", record.EventName, dataText) 24 | } 25 | 26 | return nil 27 | } 28 | 29 | func main() { 30 | lambda.Start(handler) 31 | } 32 | 33 | ``` 34 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/kafka.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | 3 | package events 4 | 5 | type KafkaEvent struct { 6 | EventSource string `json:"eventSource"` 7 | EventSourceARN string `json:"eventSourceArn"` 8 | Records map[string][]KafkaRecord `json:"records"` 9 | BootstrapServers string `json:"bootstrapServers"` 10 | } 11 | 12 | type KafkaRecord struct { 13 | Topic string `json:"topic"` 14 | Partition int64 `json:"partition"` 15 | Offset int64 `json:"offset"` 16 | Timestamp MilliSecondsEpochTime `json:"timestamp"` 17 | TimestampType string `json:"timestampType"` 18 | Key string `json:"key,omitempty"` 19 | Value string `json:"value,omitempty"` 20 | Headers []map[string][]byte `json:"headers"` 21 | } 22 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/README_Cognito.md: -------------------------------------------------------------------------------- 1 | # Sample Function 2 | 3 | The following is a sample Lambda function that receives Amazon Cognito Sync event record data as an input and writes some of the record data to CloudWatch Logs. (Note that anything written to stdout or stderr will be logged as CloudWatch Logs events.) 4 | 5 | ```go 6 | 7 | package main 8 | 9 | import ( 10 | "fmt" 11 | 12 | "github.com/aws/aws-lambda-go/lambda" 13 | "github.com/aws/aws-lambda-go/events" 14 | ) 15 | 16 | func handler(cognitoEvent events.CognitoEvent) error { 17 | for datasetName, datasetRecord := range cognitoEvent.DatasetRecords { 18 | fmt.Printf("[%s -- %s] %s -> %s -> %s \n", 19 | cognitoEvent.EventType, 20 | datasetName, 21 | datasetRecord.OldValue, 22 | datasetRecord.Op, 23 | datasetRecord.NewValue) 24 | } 25 | return nil 26 | } 27 | 28 | func main() { 29 | lambda.Start(handler) 30 | } 31 | 32 | ``` 33 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/clientvpn.go: -------------------------------------------------------------------------------- 1 | package events 2 | 3 | type ClientVPNConnectionHandlerRequest struct { 4 | ConnectionID string `json:"connection-id"` 5 | EndpointID string `json:"endpoint-id"` 6 | CommonName string `json:"common-name"` 7 | Username string `json:"username"` 8 | OSPlatform string `json:"platform"` 9 | OSPlatformVersion string `json:"platform-version"` 10 | PublicIP string `json:"public-ip"` 11 | ClientOpenVPNVersion string `json:"client-openvpn-version"` 12 | SchemaVersion string `json:"schema-version"` 13 | } 14 | 15 | type ClientVPNConnectionHandlerResponse struct { 16 | Allow bool `json:"allow"` 17 | ErrorMsgOnFailedPostureCompliance string `json:"error-msg-on-failed-posture-compliance"` 18 | PostureComplianceStatuses []string `json:"posture-compliance-statuses"` 19 | SchemaVersion string `json:"schema-version"` 20 | } 21 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/README_Cognito_UserPools_PostConfirmation.md: -------------------------------------------------------------------------------- 1 | # Sample Function 2 | 3 | The following is a sample Lambda function that receives Amazon Cognito User Pools post-confirmation event as an input and writes some of the record data to CloudWatch Logs. (Note that anything written to stdout or stderr will be logged as CloudWatch Logs events.) 4 | 5 | Please see instructions for setting up the Cognito triggers at https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-identity-pools-working-with-aws-lambda-triggers.html . 6 | 7 | ```go 8 | package main 9 | 10 | import ( 11 | "fmt" 12 | 13 | "github.com/aws/aws-lambda-go/lambda" 14 | "github.com/aws/aws-lambda-go/events" 15 | ) 16 | 17 | func handler(event events.CognitoEventUserPoolsPostConfirmation) (events.CognitoEventUserPoolsPostConfirmation, error) { 18 | fmt.Printf("PostConfirmation for user: %s\n", event.UserName) 19 | return event, nil 20 | } 21 | 22 | func main() { 23 | lambda.Start(handler) 24 | } 25 | ``` 26 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/README_Cognito_UserPools_PreAuthentication.md: -------------------------------------------------------------------------------- 1 | # Sample Function 2 | 3 | The following is a sample Lambda function that receives Amazon Cognito User Pools pre-authentication event as an input and writes some of the record data to CloudWatch Logs. (Note that anything written to stdout or stderr will be logged as CloudWatch Logs events.) 4 | 5 | Please see instructions for setting up the Cognito triggers at https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-identity-pools-working-with-aws-lambda-triggers.html . 6 | 7 | ```go 8 | package main 9 | 10 | import ( 11 | "fmt" 12 | 13 | "github.com/aws/aws-lambda-go/lambda" 14 | "github.com/aws/aws-lambda-go/events" 15 | ) 16 | 17 | func handler(event events.CognitoEventUserPoolsPreAuthentication) (events.CognitoEventUserPoolsPreAuthentication, error) { 18 | fmt.Printf("PreAuthentication of user: %s\n", event.UserName) 19 | return event, nil 20 | } 21 | 22 | func main() { 23 | lambda.Start(handler) 24 | } 25 | ``` 26 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/README_Lex.md: -------------------------------------------------------------------------------- 1 | 2 | # Sample Function 3 | 4 | The following is a sample class and Lambda function that receives Amazon Lex event data as input, writes some of the record data to CloudWatch Logs, and responds back to Lex. (Note that anything written to stdout or stderr will be logged as CloudWatch Logs events.) 5 | 6 | ```go 7 | import ( 8 | "context" 9 | "fmt" 10 | 11 | "github.com/aws/aws-lambda-go/events" 12 | ) 13 | 14 | func Handler(ctx context.Context, event events.LexEvent) (*lex.LexResponse, error) { 15 | fmt.Printf("Received an input from Amazon Lex. Current Intent: %s", event.CurrentIntent.Name) 16 | 17 | messageContent := "Hello from AWS Lambda!" 18 | 19 | return &LexResponse{ 20 | SessionAttributes: event.SessionAttributes, 21 | DialogAction: events.LexDialogAction{ 22 | Type: "Close", 23 | Message: map[string]string{ 24 | "content": messageContent, 25 | "contentType": "PlainText", 26 | }, 27 | FulfillmentState: "Fulfilled", 28 | }, 29 | }, nil 30 | } 31 | ``` 32 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/lambda/rpc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved 2 | 3 | // +build !lambda.norpc 4 | 5 | package lambda 6 | 7 | import ( 8 | "context" 9 | "errors" 10 | "log" 11 | "net" 12 | "net/rpc" 13 | ) 14 | 15 | func init() { 16 | // Register `startFunctionRPC` to be run if the _LAMBDA_SERVER_PORT environment variable is set. 17 | // This happens when the runtime for the function is configured as `go1.x`. 18 | // The value of the environment variable will be passed as the first argument to `startFunctionRPC`. 19 | rpcStartFunction.f = startFunctionRPC 20 | } 21 | 22 | func startFunctionRPC(ctx context.Context, port string, handler Handler) error { 23 | lis, err := net.Listen("tcp", "localhost:"+port) 24 | if err != nil { 25 | log.Fatal(err) 26 | } 27 | err = rpc.Register(NewFunction(handler).withContext(ctx)) 28 | if err != nil { 29 | log.Fatal("failed to register handler function") 30 | } 31 | rpc.Accept(lis) 32 | return errors.New("accept should not have returned") 33 | } 34 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/README_Cognito_UserPools_PreTokenGen.md: -------------------------------------------------------------------------------- 1 | # Sample Function 2 | 3 | The following is a sample Lambda function that receives Amazon Cognito User Pools pre-token-gen event as an input and writes some of the record data to CloudWatch Logs. (Note that anything written to stdout or stderr will be logged as CloudWatch Logs events.) 4 | 5 | Please see instructions for setting up the Cognito triggers at https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-identity-pools-working-with-aws-lambda-triggers.html . 6 | 7 | ```go 8 | package main 9 | 10 | import ( 11 | "fmt" 12 | 13 | "github.com/aws/aws-lambda-go/lambda" 14 | "github.com/aws/aws-lambda-go/events" 15 | ) 16 | 17 | func handler(event events.CognitoEventUserPoolsPreTokenGen) (events.CognitoEventUserPoolsPreTokenGen, error) { 18 | fmt.Printf("PreTokenGen of user: %s\n", event.UserName) 19 | event.Response.ClaimsOverrideDetails.ClaimsToSuppress = []string{"family_name"} 20 | return event, nil 21 | } 22 | 23 | func main() { 24 | lambda.Start(handler) 25 | } 26 | ``` 27 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/kinesis_analytics.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | 3 | package events 4 | 5 | type KinesisAnalyticsOutputDeliveryEvent struct { 6 | InvocationID string `json:"invocationId"` 7 | ApplicationARN string `json:"applicationArn"` 8 | Records []KinesisAnalyticsOutputDeliveryEventRecord `json:"records"` 9 | } 10 | 11 | type KinesisAnalyticsOutputDeliveryEventRecord struct { 12 | RecordID string `json:"recordId"` 13 | Data []byte `json:"data"` 14 | } 15 | 16 | type KinesisAnalyticsOutputDeliveryResponse struct { 17 | Records []KinesisAnalyticsOutputDeliveryResponseRecord `json:"records"` 18 | } 19 | 20 | const ( 21 | KinesisAnalyticsOutputDeliveryOK = "Ok" 22 | KinesisAnalyticsOutputDeliveryFailed = "DeliveryFailed" 23 | ) 24 | 25 | type KinesisAnalyticsOutputDeliveryResponseRecord struct { 26 | RecordID string `json:"recordId"` 27 | Result string `json:"result"` //possible values include Ok and DeliveryFailed 28 | } 29 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/lib/pipeline-stack.ts: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: MIT-0 3 | import * as cdk from 'aws-cdk-lib'; 4 | import * as pipelines from 'aws-cdk-lib/pipelines' 5 | import { Construct } from 'constructs'; 6 | 7 | export interface PipelineStackProps extends cdk.StackProps { 8 | name: string; 9 | } 10 | 11 | export class PipelineStack extends cdk.Stack { 12 | public readonly pipeline: pipelines.CodePipeline; 13 | 14 | constructor(scope: Construct, id: string, props: PipelineStackProps) { 15 | super(scope, id, props); 16 | 17 | this.pipeline = new pipelines.CodePipeline(this, 'Pipeline', { 18 | synth: new pipelines.ShellStep('synth', { 19 | input: pipelines.CodePipelineSource.connection('REPLACE_WITH_OWNER/cdk-bundle-go-lambda-example', 'main', { 20 | connectionArn: 'REPLACE_WITH_CONNECTION_ARN', 21 | }), 22 | commands: [ 23 | 'npm ci', 24 | 'npx cdk synth', 25 | ], 26 | }), 27 | crossAccountKeys: true, 28 | dockerEnabledForSynth: true, 29 | }); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/README_Cognito_UserPools_PreSignup.md: -------------------------------------------------------------------------------- 1 | # Sample Function 2 | 3 | The following is a sample Lambda function that receives Amazon Cognito User Pools pre-signup event as an input and writes some of the record data to CloudWatch Logs. (Note that anything written to stdout or stderr will be logged as CloudWatch Logs events.) 4 | 5 | Please see instructions for setting up the Cognito triggers at https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-identity-pools-working-with-aws-lambda-triggers.html . 6 | 7 | ```go 8 | package main 9 | 10 | import ( 11 | "fmt" 12 | 13 | "github.com/aws/aws-lambda-go/events" 14 | "github.com/aws/aws-lambda-go/lambda" 15 | ) 16 | 17 | // handler is the lambda handler invoked by the `lambda.Start` function call 18 | func handler(event events.CognitoEventUserPoolsPreSignup) (events.CognitoEventUserPoolsPreSignup, error) { 19 | fmt.Printf("PreSignup of user: %s\n", event.UserName) 20 | event.Response.AutoConfirmUser = true 21 | return event, nil 22 | } 23 | 24 | func main() { 25 | lambda.Start(handler) 26 | } 27 | ``` 28 | -------------------------------------------------------------------------------- /cdk-bundle-static-site-example/lib/pipeline-stack.ts: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: MIT-0 3 | import * as cdk from 'aws-cdk-lib'; 4 | import * as pipelines from 'aws-cdk-lib/pipelines' 5 | import { Construct } from 'constructs'; 6 | 7 | export interface PipelineStackProps extends cdk.StackProps { 8 | name: string; 9 | } 10 | 11 | export class PipelineStack extends cdk.Stack { 12 | public readonly pipeline: pipelines.CodePipeline; 13 | 14 | constructor(scope: Construct, id: string, props: PipelineStackProps) { 15 | super(scope, id, props); 16 | 17 | this.pipeline = new pipelines.CodePipeline(this, 'Pipeline', { 18 | synth: new pipelines.ShellStep('synth', { 19 | input: pipelines.CodePipelineSource.connection('REPLACE_WITH_OWNER/cdk-bundle-static-site-example', 'main', { 20 | connectionArn: 'REPLACE_WITH_CONNECTION_ARN', 21 | }), 22 | commands: [ 23 | 'npm ci', 24 | 'npx cdk synth', 25 | ], 26 | }), 27 | crossAccountKeys: true, 28 | dockerEnabledForSynth: true, 29 | }); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/README_Connect.md: -------------------------------------------------------------------------------- 1 | # Sample Function 2 | 3 | The following is a sample Lambda function that receives an Amazon Connect event as an input and writes some of the record data to CloudWatch Logs. (Note that anything written to stdout or stderr will be logged as CloudWatch Logs events.) 4 | 5 | ```go 6 | package main 7 | 8 | import ( 9 | "context" 10 | "fmt" 11 | 12 | "github.com/aws/aws-lambda-go/events" 13 | "github.com/aws/aws-lambda-go/lambda" 14 | ) 15 | 16 | func main() { 17 | lambda.Start(handler) 18 | } 19 | 20 | func handler(ctx context.Context, connectEvent events.ConnectEvent) (events.ConnectResponse, error) { 21 | fmt.Printf("Processing Connect event with ContactID %s.\n", connectEvent.Details.ContactData.ContactID) 22 | 23 | fmt.Printf("Invoked with %d parameters\n", len(connectEvent.Details.Parameters)) 24 | for k, v := range connectEvent.Details.Parameters { 25 | fmt.Printf("%s : %s\n", k, v) 26 | } 27 | 28 | resp := events.ConnectResponse{ 29 | "Result": "Success", 30 | "NewAttribute": "NewValue", 31 | } 32 | 33 | return resp, nil 34 | } 35 | ``` 36 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/README_CloudWatch_Events.md: -------------------------------------------------------------------------------- 1 | 2 | # Sample Function 3 | 4 | The following is a Lambda function that receives Amazon CloudWatch event record data as input and writes event detail to Lambda's CloudWatch Logs. Note that by default anything written to Console will be logged as CloudWatch Logs events. 5 | 6 | ```go 7 | import ( 8 | "context" 9 | "fmt" 10 | 11 | "github.com/aws/aws-lambda-go/events" 12 | ) 13 | 14 | func handler(ctx context.Context, event events.CloudWatchEvent) { 15 | fmt.Printf("Detail = %s\n", event.Detail) 16 | } 17 | ``` 18 | 19 | ## CloudWatch Scheduled Events 20 | 21 | If you have a constant JSON text in a CloudWatch Scheduled Event, it can be accessed either by explicitly defining a structure for the json payload you would expect: 22 | 23 | ```go 24 | type MyRequest struct { 25 | Name string `json:"name"` 26 | } 27 | 28 | func handler(ctx context.Context, req MyRequest) { 29 | } 30 | ``` 31 | 32 | or by accepting raw json blob as is: 33 | 34 | ```go 35 | func handler(ctx context.Context, b json.RawMessage) { 36 | // json.RawMessage is basically []byte which can be unmarshalled 37 | } 38 | ``` 39 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/chime_bot.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | 3 | package events 4 | 5 | import ( 6 | "time" 7 | ) 8 | 9 | type ChimeBotEvent struct { 10 | Sender ChimeBotEventSender `json:"Sender"` 11 | Discussion ChimeBotEventDiscussion `json:"Discussion"` 12 | EventType string `json:"EventType"` 13 | InboundHTTPSEndpoint *ChimeBotEventInboundHTTPSEndpoint `json:"InboundHttpsEndpoint,omitempty"` 14 | EventTimestamp time.Time `json:"EventTimestamp"` 15 | Message string `json:"Message,omitempty"` 16 | } 17 | 18 | type ChimeBotEventSender struct { 19 | SenderID string `json:"SenderId"` 20 | SenderIDType string `json:"SenderIdType"` 21 | } 22 | 23 | type ChimeBotEventDiscussion struct { 24 | DiscussionID string `json:"DiscussionId"` 25 | DiscussionType string `json:"DiscussionType"` 26 | } 27 | 28 | type ChimeBotEventInboundHTTPSEndpoint struct { 29 | EndpointType string `json:"EndpointType"` 30 | URL string `json:"Url"` 31 | } 32 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/streams.go: -------------------------------------------------------------------------------- 1 | package events 2 | 3 | // KinesisEventResponse is the outer structure to report batch item failures for KinesisEvent. 4 | type KinesisEventResponse struct { 5 | BatchItemFailures []KinesisBatchItemFailure `json:"batchItemFailures"` 6 | } 7 | 8 | // KinesisBatchItemFailure is the individual record which failed processing. 9 | type KinesisBatchItemFailure struct { 10 | ItemIdentifier string `json:"itemIdentifier"` 11 | } 12 | 13 | // DynamoDBEventResponse is the outer structure to report batch item failures for DynamoDBEvent. 14 | type DynamoDBEventResponse struct { 15 | BatchItemFailures []DynamoDBBatchItemFailure `json:"batchItemFailures"` 16 | } 17 | 18 | // DynamoDBBatchItemFailure is the individual record which failed processing. 19 | type DynamoDBBatchItemFailure struct { 20 | ItemIdentifier string `json:"itemIdentifier"` 21 | } 22 | 23 | // SQSEventResponse is the outer structure to report batch item failures for SQSEvent. 24 | type SQSEventResponse struct { 25 | BatchItemFailures []SQSBatchItemFailure `json:"batchItemFailures"` 26 | } 27 | 28 | // SQSBatchItemFailure is the individual record which failed processing. 29 | type SQSBatchItemFailure struct { 30 | ItemIdentifier string `json:"itemIdentifier"` 31 | } 32 | -------------------------------------------------------------------------------- /cdk-bundle-static-site-example/frontend/layouts/default.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 63 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/iot_1_click.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | 3 | package events 4 | 5 | // IoTOneClickEvent represents a click event published by clicking button type 6 | // device. 7 | type IoTOneClickEvent struct { 8 | DeviceEvent IoTOneClickDeviceEvent `json:"deviceEvent"` 9 | DeviceInfo IoTOneClickDeviceInfo `json:"deviceInfo"` 10 | PlacementInfo IoTOneClickPlacementInfo `json:"placementInfo"` 11 | } 12 | 13 | type IoTOneClickDeviceEvent struct { 14 | ButtonClicked IoTOneClickButtonClicked `json:"buttonClicked"` 15 | } 16 | 17 | type IoTOneClickButtonClicked struct { 18 | ClickType string `json:"clickType"` 19 | ReportedTime string `json:"reportedTime"` 20 | } 21 | 22 | type IoTOneClickDeviceInfo struct { 23 | Attributes map[string]string `json:"attributes"` 24 | Type string `json:"type"` 25 | DeviceID string `json:"deviceId"` 26 | RemainingLife float64 `json:"remainingLife"` 27 | } 28 | 29 | type IoTOneClickPlacementInfo struct { 30 | ProjectName string `json:"projectName"` 31 | PlacementName string `json:"placementName"` 32 | Attributes map[string]string `json:"attributes"` 33 | Devices map[string]string `json:"devices"` 34 | } 35 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/kinesis.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | 3 | package events 4 | 5 | type KinesisEvent struct { 6 | Records []KinesisEventRecord `json:"Records"` 7 | } 8 | 9 | type KinesisEventRecord struct { 10 | AwsRegion string `json:"awsRegion"` //nolint: stylecheck 11 | EventID string `json:"eventID"` 12 | EventName string `json:"eventName"` 13 | EventSource string `json:"eventSource"` 14 | EventSourceArn string `json:"eventSourceARN"` //nolint: stylecheck 15 | EventVersion string `json:"eventVersion"` 16 | InvokeIdentityArn string `json:"invokeIdentityArn"` //nolint: stylecheck 17 | Kinesis KinesisRecord `json:"kinesis"` 18 | } 19 | 20 | type KinesisRecord struct { 21 | ApproximateArrivalTimestamp SecondsEpochTime `json:"approximateArrivalTimestamp"` 22 | Data []byte `json:"data"` 23 | EncryptionType string `json:"encryptionType,omitempty"` 24 | PartitionKey string `json:"partitionKey"` 25 | SequenceNumber string `json:"sequenceNumber"` 26 | KinesisSchemaVersion string `json:"kinesisSchemaVersion"` 27 | } 28 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/activemq.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | 3 | package events 4 | 5 | type ActiveMQEvent struct { 6 | EventSource string `json:"eventSource"` 7 | EventSourceARN string `json:"eventSourceArn"` 8 | Messages []ActiveMQMessage `json:"messages"` 9 | } 10 | 11 | type ActiveMQMessage struct { 12 | MessageID string `json:"messageID"` 13 | MessageType string `json:"messageType"` 14 | Timestamp int64 `json:"timestamp"` 15 | DeliveryMode int `json:"deliveryMode"` 16 | CorrelationID string `json:"correlationID"` 17 | ReplyTo string `json:"replyTo"` 18 | Destination ActiveMQDestination `json:"destination"` 19 | Redelivered bool `json:"redelivered"` 20 | Type string `json:"type"` 21 | Expiration int64 `json:"expiration"` 22 | Priority int `json:"priority"` 23 | Data string `json:"data"` 24 | BrokerInTime int64 `json:"brokerInTime"` 25 | BrokerOutTime int64 `json:"brokerOutTime"` 26 | } 27 | 28 | type ActiveMQDestination struct { 29 | PhysicalName string `json:"physicalName"` 30 | } 31 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/lambda/errors.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved 2 | 3 | package lambda 4 | 5 | import ( 6 | "reflect" 7 | 8 | "github.com/aws/aws-lambda-go/lambda/messages" 9 | ) 10 | 11 | func getErrorType(err interface{}) string { 12 | errorType := reflect.TypeOf(err) 13 | if errorType.Kind() == reflect.Ptr { 14 | return errorType.Elem().Name() 15 | } 16 | return errorType.Name() 17 | } 18 | 19 | func lambdaErrorResponse(invokeError error) *messages.InvokeResponse_Error { 20 | if ive, ok := invokeError.(messages.InvokeResponse_Error); ok { 21 | return &ive 22 | } 23 | var errorName string 24 | if errorType := reflect.TypeOf(invokeError); errorType.Kind() == reflect.Ptr { 25 | errorName = errorType.Elem().Name() 26 | } else { 27 | errorName = errorType.Name() 28 | } 29 | return &messages.InvokeResponse_Error{ 30 | Message: invokeError.Error(), 31 | Type: errorName, 32 | } 33 | } 34 | 35 | func lambdaPanicResponse(err interface{}) *messages.InvokeResponse_Error { 36 | if ive, ok := err.(messages.InvokeResponse_Error); ok { 37 | return &ive 38 | } 39 | panicInfo := getPanicInfo(err) 40 | return &messages.InvokeResponse_Error{ 41 | Message: panicInfo.Message, 42 | Type: getErrorType(err), 43 | StackTrace: panicInfo.StackTrace, 44 | ShouldExit: true, 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/ecr_scan.go: -------------------------------------------------------------------------------- 1 | package events 2 | 3 | type ECRScanEvent struct { 4 | Version string `json:"version"` 5 | ID string `json:"id"` 6 | DetailType string `json:"detail-type"` 7 | Source string `json:"source"` 8 | Time string `json:"time"` 9 | Region string `json:"region"` 10 | Resources []string `json:"resources"` 11 | Account string `json:"account"` 12 | Detail ECRScanEventDetailType `json:"detail"` 13 | } 14 | 15 | type ECRScanEventDetailType struct { 16 | ScanStatus string `json:"scan-status"` 17 | RepositoryName string `json:"repository-name"` 18 | FindingSeverityCounts ECRScanEventFindingSeverityCounts `json:"finding-severity-counts"` 19 | ImageDigest string `json:"image-digest"` 20 | ImageTags []string `json:"image-tags"` 21 | } 22 | 23 | type ECRScanEventFindingSeverityCounts struct { 24 | Critical int64 `json:"CRITICAL"` 25 | High int64 `json:"HIGH"` 26 | Medium int64 `json:"MEDIUM"` 27 | Low int64 `json:"LOW"` 28 | Informational int64 `json:"INFORMATIONAL"` 29 | Undefined int64 `json:"UNDEFINED"` 30 | } 31 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/config.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | 3 | package events 4 | 5 | // ConfigEvent contains data from an event sent from AWS Config 6 | type ConfigEvent struct { 7 | // The ID of the AWS account that owns the rule 8 | AccountID string `json:"accountId"` 9 | // The ARN that AWS Config assigned to the rule 10 | ConfigRuleArn string `json:"configRuleArn"` //nolint:stylecheck 11 | ConfigRuleID string `json:"configRuleId"` //nolint:stylecheck 12 | // The name that you assigned to the rule that caused AWS Config to publish the event 13 | ConfigRuleName string `json:"configRuleName"` 14 | // A boolean value that indicates whether the AWS resource to be evaluated has been removed from the rule's scope 15 | EventLeftScope bool `json:"eventLeftScope"` 16 | ExecutionRoleArn string `json:"executionRoleArn"` //nolint:stylecheck 17 | // If the event is published in response to a resource configuration change, this value contains a JSON configuration item 18 | InvokingEvent string `json:"invokingEvent"` 19 | // A token that the function must pass to AWS Config with the PutEvaluations call 20 | ResultToken string `json:"resultToken"` 21 | // Key/value pairs that the function processes as part of its evaluation logic 22 | RuleParameters string `json:"ruleParameters"` 23 | Version string `json:"version"` 24 | } 25 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/duration.go: -------------------------------------------------------------------------------- 1 | package events 2 | 3 | import ( 4 | "encoding/json" 5 | "math" 6 | "time" 7 | ) 8 | 9 | type DurationSeconds time.Duration 10 | 11 | // UnmarshalJSON converts a given json to a DurationSeconds 12 | func (duration *DurationSeconds) UnmarshalJSON(data []byte) error { 13 | var seconds float64 14 | if err := json.Unmarshal(data, &seconds); err != nil { 15 | return err 16 | } 17 | 18 | *duration = DurationSeconds(time.Duration(seconds) * time.Second) 19 | return nil 20 | } 21 | 22 | // MarshalJSON converts a given DurationSeconds to json 23 | func (duration DurationSeconds) MarshalJSON() ([]byte, error) { 24 | seconds := time.Duration(duration).Seconds() 25 | return json.Marshal(int64(math.Ceil(seconds))) 26 | } 27 | 28 | type DurationMinutes time.Duration 29 | 30 | // UnmarshalJSON converts a given json to a DurationMinutes 31 | func (duration *DurationMinutes) UnmarshalJSON(data []byte) error { 32 | var minutes float64 33 | if err := json.Unmarshal(data, &minutes); err != nil { 34 | return err 35 | } 36 | 37 | *duration = DurationMinutes(time.Duration(minutes) * time.Minute) 38 | return nil 39 | } 40 | 41 | // MarshalJSON converts a given DurationMinutes to json 42 | func (duration DurationMinutes) MarshalJSON() ([]byte, error) { 43 | minutes := time.Duration(duration).Minutes() 44 | return json.Marshal(int64(math.Ceil(minutes))) 45 | } 46 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/README_ApiGatewayEvent.md: -------------------------------------------------------------------------------- 1 | # Overview 2 | 3 | API Gateway events consist of a request that was routed to a Lambda function by API Gateway. When this happens, API Gateway expects the result of the function to be the response that API Gateway should respond with. 4 | 5 | # Sample Function 6 | 7 | The following is a sample class and Lambda function that receives Amazon API Gateway event record data as an input, writes some of the record data to CloudWatch Logs, and responds with a 200 status and the same body as the request. (Note that anything written to stdout or stderr will be logged as CloudWatch Logs events.) 8 | 9 | ```go 10 | 11 | package main 12 | 13 | import ( 14 | "context" 15 | "fmt" 16 | 17 | "github.com/aws/aws-lambda-go/events" 18 | "github.com/aws/aws-lambda-go/lambda" 19 | ) 20 | 21 | func handleRequest(ctx context.Context, request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) { 22 | fmt.Printf("Processing request data for request %s.\n", request.RequestContext.RequestID) 23 | fmt.Printf("Body size = %d.\n", len(request.Body)) 24 | 25 | fmt.Println("Headers:") 26 | for key, value := range request.Headers { 27 | fmt.Printf(" %s: %s\n", key, value) 28 | } 29 | 30 | return events.APIGatewayProxyResponse{Body: request.Body, StatusCode: 200}, nil 31 | } 32 | 33 | func main() { 34 | lambda.Start(handleRequest) 35 | } 36 | ``` 37 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/README_KinesisFirehose.md: -------------------------------------------------------------------------------- 1 | # Sample Function 2 | 3 | The following is a sample Lambda function that transforms Kinesis Firehose records by doing a ToUpper on the data. 4 | 5 | ```go 6 | 7 | package main 8 | 9 | import ( 10 | "fmt" 11 | "strings" 12 | 13 | "github.com/aws/aws-lambda-go/events" 14 | "github.com/aws/aws-lambda-go/lambda" 15 | ) 16 | 17 | func handleRequest(evnt events.KinesisFirehoseEvent) (events.KinesisFirehoseResponse, error) { 18 | 19 | fmt.Printf("InvocationID: %s\n", evnt.InvocationID) 20 | fmt.Printf("DeliveryStreamArn: %s\n", evnt.DeliveryStreamArn) 21 | fmt.Printf("Region: %s\n", evnt.Region) 22 | 23 | var response events.KinesisFirehoseResponse 24 | 25 | for _, record := range evnt.Records { 26 | fmt.Printf("RecordID: %s\n", record.RecordID) 27 | fmt.Printf("ApproximateArrivalTimestamp: %s\n", record.ApproximateArrivalTimestamp) 28 | 29 | // Transform data: ToUpper the data 30 | var transformedRecord events.KinesisFirehoseResponseRecord 31 | transformedRecord.RecordID = record.RecordID 32 | transformedRecord.Result = events.KinesisFirehoseTransformedStateOk 33 | transformedRecord.Data = []byte(strings.ToUpper(string(record.Data))) 34 | 35 | response.Records = append(response.Records, transformedRecord) 36 | } 37 | 38 | return response, nil 39 | } 40 | 41 | func main() { 42 | lambda.Start(handleRequest) 43 | } 44 | 45 | ``` 46 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/sqs.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | 3 | package events 4 | 5 | type SQSEvent struct { 6 | Records []SQSMessage `json:"Records"` 7 | } 8 | 9 | type SQSMessage struct { 10 | MessageId string `json:"messageId"` //nolint: stylecheck 11 | ReceiptHandle string `json:"receiptHandle"` 12 | Body string `json:"body"` 13 | Md5OfBody string `json:"md5OfBody"` 14 | Md5OfMessageAttributes string `json:"md5OfMessageAttributes"` 15 | Attributes map[string]string `json:"attributes"` 16 | MessageAttributes map[string]SQSMessageAttribute `json:"messageAttributes"` 17 | EventSourceARN string `json:"eventSourceARN"` 18 | EventSource string `json:"eventSource"` 19 | AWSRegion string `json:"awsRegion"` 20 | } 21 | 22 | type SQSMessageAttribute struct { 23 | StringValue *string `json:"stringValue,omitempty"` 24 | BinaryValue []byte `json:"binaryValue,omitempty"` 25 | StringListValues []string `json:"stringListValues"` 26 | BinaryListValues [][]byte `json:"binaryListValues"` 27 | DataType string `json:"dataType"` 28 | } 29 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/iot.go: -------------------------------------------------------------------------------- 1 | package events 2 | 3 | // IoTCustomAuthorizerRequest contains data coming in to a custom IoT device gateway authorizer function. 4 | type IoTCustomAuthorizerRequest struct { 5 | HTTPContext *IoTHTTPContext `json:"httpContext,omitempty"` 6 | MQTTContext *IoTMQTTContext `json:"mqttContext,omitempty"` 7 | TLSContext *IoTTLSContext `json:"tlsContext,omitempty"` 8 | AuthorizationToken string `json:"token"` 9 | TokenSignature string `json:"tokenSignature"` 10 | } 11 | 12 | type IoTHTTPContext struct { 13 | Headers map[string]string `json:"headers,omitempty"` 14 | QueryString string `json:"queryString"` 15 | } 16 | 17 | type IoTMQTTContext struct { 18 | ClientID string `json:"clientId"` 19 | Password []byte `json:"password"` 20 | Username string `json:"username"` 21 | } 22 | 23 | type IoTTLSContext struct { 24 | ServerName string `json:"serverName"` 25 | } 26 | 27 | // IoTCustomAuthorizerResponse represents the expected format of an IoT device gateway authorization response. 28 | type IoTCustomAuthorizerResponse struct { 29 | IsAuthenticated bool `json:"isAuthenticated"` 30 | PrincipalID string `json:"principalId"` 31 | DisconnectAfterInSeconds int32 `json:"disconnectAfterInSeconds"` 32 | RefreshAfterInSeconds int32 `json:"refreshAfterInSeconds"` 33 | PolicyDocuments []string `json:"policyDocuments"` 34 | } 35 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/README_S3_Batch_Job.md: -------------------------------------------------------------------------------- 1 | # Sample Function 2 | 3 | The following is a sample class and Lambda function that receives Amazon S3 event record data as an input and writes some of the record data to CloudWatch Logs. (Note that anything written to stdout or stderr will be logged as CloudWatch Logs events.) 4 | 5 | ```go 6 | 7 | import ( 8 | "fmt" 9 | "context" 10 | "github.com/aws/aws-lambda-go/events" 11 | ) 12 | 13 | func handler(ctx context.Context, e events.S3BatchJobEvent) (response events.S3BatchJobResponse, err error) { 14 | fmt.Printf("InvocationSchemaVersion: %s\n", e.InvocationSchemaVersion) 15 | fmt.Printf("InvocationID: %s\n", e.InvocationID) 16 | fmt.Printf("Job.ID: %s\n", e.Job.ID) 17 | 18 | for _, task := range e.Tasks { 19 | fmt.Printf("TaskID: %s\n", task.TaskID) 20 | fmt.Printf("S3Key: %s\n", task.S3Key) 21 | fmt.Printf("S3VersionID: %s\n", task.S3VersionID) 22 | fmt.Printf("S3BucketARN: %s\n", task.S3BucketARN) 23 | 24 | } 25 | 26 | fmt.Printf("InvocationSchemaVersion: %s\n", response.InvocationSchemaVersion) 27 | fmt.Printf("TreatMissingKeysAs: %s\n", response.TreatMissingKeysAs) 28 | fmt.Printf("InvocationID: %s\n", response.InvocationID) 29 | 30 | for _, result := range response.Results { 31 | fmt.Printf("TaskID: %s\n", result.TaskID) 32 | fmt.Printf("ResultCode: %s\n", result.ResultCode) 33 | fmt.Printf("ResultString: %s\n", result.ResultString) 34 | } 35 | 36 | return 37 | } 38 | 39 | ``` 40 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/lambda/messages/messages.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | 3 | package messages 4 | 5 | import "fmt" 6 | 7 | type PingRequest struct { 8 | } 9 | 10 | type PingResponse struct { 11 | } 12 | 13 | //nolint:stylecheck 14 | type InvokeRequest_Timestamp struct { 15 | Seconds int64 16 | Nanos int64 17 | } 18 | 19 | //nolint:stylecheck 20 | type InvokeRequest struct { 21 | Payload []byte 22 | RequestId string //nolint:stylecheck 23 | XAmznTraceId string 24 | Deadline InvokeRequest_Timestamp 25 | InvokedFunctionArn string 26 | CognitoIdentityId string //nolint:stylecheck 27 | CognitoIdentityPoolId string //nolint:stylecheck 28 | ClientContext []byte 29 | } 30 | 31 | type InvokeResponse struct { 32 | Payload []byte 33 | Error *InvokeResponse_Error 34 | } 35 | 36 | //nolint:stylecheck 37 | type InvokeResponse_Error struct { 38 | Message string `json:"errorMessage"` 39 | Type string `json:"errorType"` 40 | StackTrace []*InvokeResponse_Error_StackFrame `json:"stackTrace,omitempty"` 41 | ShouldExit bool `json:"-"` 42 | } 43 | 44 | func (e InvokeResponse_Error) Error() string { 45 | return fmt.Sprintf("%#v", e) 46 | } 47 | 48 | //nolint:stylecheck 49 | type InvokeResponse_Error_StackFrame struct { 50 | Path string `json:"path"` 51 | Line int32 `json:"line"` 52 | Label string `json:"label"` 53 | } 54 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/rabbitmq.go: -------------------------------------------------------------------------------- 1 | package events 2 | 3 | type RabbitMQEvent struct { 4 | EventSource string `json:"eventSource"` 5 | EventSourceARN string `json:"eventSourceArn"` 6 | MessagesByQueue map[string][]RabbitMQMessage `json:"rmqMessagesByQueue"` 7 | } 8 | 9 | type RabbitMQMessage struct { 10 | BasicProperties RabbitMQBasicProperties `json:"basicProperties"` 11 | Data string `json:"data"` 12 | Redelivered bool `json:"redelivered"` 13 | } 14 | 15 | type RabbitMQBasicProperties struct { 16 | ContentType string `json:"contentType"` 17 | ContentEncoding *string `json:"contentEncoding"` 18 | Headers map[string]interface{} `json:"headers"` // Application or header exchange table 19 | DeliveryMode uint8 `json:"deliveryMode"` 20 | Priority uint8 `json:"priority"` 21 | CorrelationID *string `json:"correlationId"` 22 | ReplyTo *string `json:"replyTo"` 23 | Expiration string `json:"expiration"` 24 | MessageID *string `json:"messageId"` 25 | Timestamp string `json:"timestamp"` 26 | Type *string `json:"type"` 27 | UserID string `json:"userId"` 28 | AppID *string `json:"appId"` 29 | ClusterID *string `json:"clusterId"` 30 | BodySize uint64 `json:"bodySize"` 31 | } 32 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/s3_batch_job.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | 3 | package events 4 | 5 | // S3BatchJobEvent encapsulates the detail of a s3 batch job 6 | type S3BatchJobEvent struct { 7 | InvocationSchemaVersion string `json:"invocationSchemaVersion"` 8 | InvocationID string `json:"invocationId"` 9 | Job S3BatchJob `json:"job"` 10 | Tasks []S3BatchJobTask `json:"tasks"` 11 | } 12 | 13 | // S3BatchJob whichs have the job id 14 | type S3BatchJob struct { 15 | ID string `json:"id"` 16 | } 17 | 18 | // S3BatchJobTask represents one task in the s3 batch job and have all task details 19 | type S3BatchJobTask struct { 20 | TaskID string `json:"taskId"` 21 | S3Key string `json:"s3Key"` 22 | S3VersionID string `json:"s3VersionId"` 23 | S3BucketARN string `json:"s3BucketArn"` 24 | } 25 | 26 | // S3BatchJobResponse is the response of a iven s3 batch job with the results 27 | type S3BatchJobResponse struct { 28 | InvocationSchemaVersion string `json:"invocationSchemaVersion"` 29 | TreatMissingKeysAs string `json:"treatMissingKeysAs"` 30 | InvocationID string `json:"invocationId"` 31 | Results []S3BatchJobResult `json:"results"` 32 | } 33 | 34 | // S3BatchJobResult represents the result of a given task 35 | type S3BatchJobResult struct { 36 | TaskID string `json:"taskId"` 37 | ResultCode string `json:"resultCode"` 38 | ResultString string `json:"resultString"` 39 | } 40 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/README_ALBTargetGroupEvents.md: -------------------------------------------------------------------------------- 1 | # Overview 2 | 3 | ALB Target Group events consist of a request that was routed to a Lambda function which is a registered target of an Application Load Balancer Target Group. When this happens, ALB expects the result of the function to be the response that ALB should respond with. 4 | 5 | https://docs.aws.amazon.com/elasticloadbalancing/latest/application/lambda-functions.html 6 | 7 | # Sample Function 8 | 9 | The following is a sample class and Lambda function that receives an ALB Target Group event as an input, writes some of the incoming data to CloudWatch Logs, and responds with a 200 status and the same body as the request. (Note that anything written to stdout or stderr will be logged as CloudWatch Logs events.) 10 | 11 | ```go 12 | 13 | package main 14 | 15 | import ( 16 | "context" 17 | "fmt" 18 | 19 | "github.com/aws/aws-lambda-go/events" 20 | "github.com/aws/aws-lambda-go/lambda" 21 | ) 22 | 23 | func handleRequest(ctx context.Context, request events.ALBTargetGroupRequest) (events.ALBTargetGroupResponse, error) { 24 | fmt.Printf("Processing request data for traceId %s.\n", request.Headers["x-amzn-trace-id"]) 25 | fmt.Printf("Body size = %d.\n", len(request.Body)) 26 | 27 | fmt.Println("Headers:") 28 | for key, value := range request.Headers { 29 | fmt.Printf(" %s: %s\n", key, value) 30 | } 31 | 32 | return events.ALBTargetGroupResponse{Body: request.Body, StatusCode: 200, StatusDescription: "200 OK", IsBase64Encoded: false, Headers: map[string]string{}}, nil 33 | } 34 | 35 | func main() { 36 | lambda.Start(handleRequest) 37 | } 38 | ``` 39 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/lambda/handlertrace/trace.go: -------------------------------------------------------------------------------- 1 | // Package handlertrace allows middleware authors using lambda.NewHandler to 2 | // instrument request and response events. 3 | package handlertrace 4 | 5 | import ( 6 | "context" 7 | ) 8 | 9 | // HandlerTrace allows handlers which wrap the return value of lambda.NewHandler 10 | // to access to the request and response events. 11 | type HandlerTrace struct { 12 | RequestEvent func(context.Context, interface{}) 13 | ResponseEvent func(context.Context, interface{}) 14 | } 15 | 16 | func callbackCompose(f1, f2 func(context.Context, interface{})) func(context.Context, interface{}) { 17 | return func(ctx context.Context, event interface{}) { 18 | if nil != f1 { 19 | f1(ctx, event) 20 | } 21 | if nil != f2 { 22 | f2(ctx, event) 23 | } 24 | } 25 | } 26 | 27 | type handlerTraceKey struct{} 28 | 29 | // NewContext adds callbacks to the provided context which allows handlers which 30 | // wrap the return value of lambda.NewHandler to access to the request and 31 | // response events. 32 | func NewContext(ctx context.Context, trace HandlerTrace) context.Context { 33 | existing := FromContext(ctx) 34 | return context.WithValue(ctx, handlerTraceKey{}, HandlerTrace{ 35 | RequestEvent: callbackCompose(existing.RequestEvent, trace.RequestEvent), 36 | ResponseEvent: callbackCompose(existing.ResponseEvent, trace.ResponseEvent), 37 | }) 38 | } 39 | 40 | // FromContext returns the HandlerTrace associated with the provided context. 41 | func FromContext(ctx context.Context) HandlerTrace { 42 | trace, _ := ctx.Value(handlerTraceKey{}).(HandlerTrace) 43 | return trace 44 | } 45 | -------------------------------------------------------------------------------- /cdk-bundle-static-site-example/frontend/.gitignore: -------------------------------------------------------------------------------- 1 | # Created by .ignore support plugin (hsz.mobi) 2 | ### Node template 3 | # Logs 4 | /logs 5 | *.log 6 | npm-debug.log* 7 | yarn-debug.log* 8 | yarn-error.log* 9 | 10 | # Runtime data 11 | pids 12 | *.pid 13 | *.seed 14 | *.pid.lock 15 | 16 | # Directory for instrumented libs generated by jscoverage/JSCover 17 | lib-cov 18 | 19 | # Coverage directory used by tools like istanbul 20 | coverage 21 | 22 | # nyc test coverage 23 | .nyc_output 24 | 25 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 26 | .grunt 27 | 28 | # Bower dependency directory (https://bower.io/) 29 | bower_components 30 | 31 | # node-waf configuration 32 | .lock-wscript 33 | 34 | # Compiled binary addons (https://nodejs.org/api/addons.html) 35 | build/Release 36 | 37 | # Dependency directories 38 | node_modules/ 39 | jspm_packages/ 40 | 41 | # TypeScript v1 declaration files 42 | typings/ 43 | 44 | # Optional npm cache directory 45 | .npm 46 | 47 | # Optional eslint cache 48 | .eslintcache 49 | 50 | # Optional REPL history 51 | .node_repl_history 52 | 53 | # Output of 'npm pack' 54 | *.tgz 55 | 56 | # Yarn Integrity file 57 | .yarn-integrity 58 | 59 | # dotenv environment variables file 60 | .env 61 | 62 | # parcel-bundler cache (https://parceljs.org/) 63 | .cache 64 | 65 | # next.js build output 66 | .next 67 | 68 | # nuxt.js build output 69 | .nuxt 70 | 71 | # Nuxt generate 72 | dist 73 | 74 | # vuepress build output 75 | .vuepress/dist 76 | 77 | # Serverless directories 78 | .serverless 79 | 80 | # IDE / Editor 81 | .idea 82 | 83 | # Service worker 84 | sw.* 85 | 86 | # macOS 87 | .DS_Store 88 | 89 | # Vim swap files 90 | *.swp 91 | -------------------------------------------------------------------------------- /cdk-bundle-static-site-example/frontend/pages/index.vue: -------------------------------------------------------------------------------- 1 | 30 | 31 | 40 | 41 | 73 | -------------------------------------------------------------------------------- /cdk-bundle-static-site-example/frontend/nuxt.config.js: -------------------------------------------------------------------------------- 1 | export default { 2 | publicRuntimeConfig: { 3 | apiUrl: process.env.API_URL, 4 | }, 5 | server: { 6 | port: 8080, 7 | 8 | host: "0.0.0.0", 9 | }, 10 | /* 11 | ** Nuxt rendering mode 12 | ** See https://nuxtjs.org/api/configuration-mode 13 | */ 14 | ssr: false, 15 | /* 16 | ** Nuxt target 17 | ** See https://nuxtjs.org/api/configuration-target 18 | */ 19 | target: "static", 20 | /* 21 | ** Headers of the page 22 | ** See https://nuxtjs.org/api/configuration-head 23 | */ 24 | head: { 25 | title: process.env.npm_package_name || "", 26 | meta: [ 27 | { charset: "utf-8" }, 28 | { name: "viewport", content: "width=device-width, initial-scale=1" }, 29 | { 30 | hid: "description", 31 | name: "description", 32 | content: process.env.npm_package_description || "", 33 | }, 34 | ], 35 | link: [{ rel: "icon", type: "image/x-icon", href: "/favicon.ico" }], 36 | }, 37 | /* 38 | ** Global CSS 39 | */ 40 | css: [], 41 | /* 42 | ** Plugins to load before mounting the App 43 | ** https://nuxtjs.org/guide/plugins 44 | */ 45 | plugins: [], 46 | /* 47 | ** Auto import components 48 | ** See https://nuxtjs.org/api/configuration-components 49 | */ 50 | components: true, 51 | /* 52 | ** Nuxt.js dev-modules 53 | */ 54 | buildModules: [], 55 | /* 56 | ** Nuxt.js modules 57 | */ 58 | modules: [ 59 | // Doc: https://axios.nuxtjs.org/usage 60 | "@nuxtjs/axios", 61 | ], 62 | /* 63 | ** Axios module configuration 64 | ** See https://axios.nuxtjs.org/options 65 | */ 66 | axios: {}, 67 | /* 68 | ** Build configuration 69 | ** See https://nuxtjs.org/api/configuration-build/ 70 | */ 71 | build: {}, 72 | }; 73 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/cloudwatch_logs.go: -------------------------------------------------------------------------------- 1 | package events 2 | 3 | import ( 4 | "bytes" 5 | "compress/gzip" 6 | "encoding/base64" 7 | "encoding/json" 8 | ) 9 | 10 | // CloudwatchLogsEvent represents raw data from a cloudwatch logs event 11 | type CloudwatchLogsEvent struct { 12 | AWSLogs CloudwatchLogsRawData `json:"awslogs"` 13 | } 14 | 15 | // CloudwatchLogsRawData contains gzipped base64 json representing the bulk 16 | // of a cloudwatch logs event 17 | type CloudwatchLogsRawData struct { 18 | Data string `json:"data"` 19 | } 20 | 21 | // Parse returns a struct representing a usable CloudwatchLogs event 22 | func (c CloudwatchLogsRawData) Parse() (d CloudwatchLogsData, err error) { 23 | data, err := base64.StdEncoding.DecodeString(c.Data) 24 | if err != nil { 25 | return 26 | } 27 | 28 | zr, err := gzip.NewReader(bytes.NewBuffer(data)) 29 | if err != nil { 30 | return 31 | } 32 | defer zr.Close() 33 | 34 | dec := json.NewDecoder(zr) 35 | err = dec.Decode(&d) 36 | 37 | return 38 | } 39 | 40 | // CloudwatchLogsData is an unmarshal'd, ungzip'd, cloudwatch logs event 41 | type CloudwatchLogsData struct { 42 | Owner string `json:"owner"` 43 | LogGroup string `json:"logGroup"` 44 | LogStream string `json:"logStream"` 45 | SubscriptionFilters []string `json:"subscriptionFilters"` 46 | MessageType string `json:"messageType"` 47 | LogEvents []CloudwatchLogsLogEvent `json:"logEvents"` 48 | } 49 | 50 | // CloudwatchLogsLogEvent represents a log entry from cloudwatch logs 51 | type CloudwatchLogsLogEvent struct { 52 | ID string `json:"id"` 53 | Timestamp int64 `json:"timestamp"` 54 | Message string `json:"message"` 55 | } 56 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/epoch_time.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | 3 | package events 4 | 5 | import ( 6 | "encoding/json" 7 | "time" 8 | ) 9 | 10 | // SecondsEpochTime serializes a time.Time in JSON as a UNIX epoch time in seconds 11 | type SecondsEpochTime struct { 12 | time.Time 13 | } 14 | 15 | // MilliSecondsEpochTime serializes a time.Time in JSON as a UNIX epoch time in milliseconds. 16 | type MilliSecondsEpochTime struct { 17 | time.Time 18 | } 19 | 20 | const secondsToNanoSecondsFactor = 1000000000 21 | const milliSecondsToNanoSecondsFactor = 1000000 22 | 23 | func (e SecondsEpochTime) MarshalJSON() ([]byte, error) { 24 | // UnixNano() returns the epoch in nanoseconds 25 | unixTime := float64(e.UnixNano()) / float64(secondsToNanoSecondsFactor) 26 | return json.Marshal(unixTime) 27 | } 28 | 29 | func (e *SecondsEpochTime) UnmarshalJSON(b []byte) error { 30 | var epoch float64 31 | err := json.Unmarshal(b, &epoch) 32 | if err != nil { 33 | return err 34 | } 35 | 36 | epochSec := int64(epoch) 37 | epochNano := int64((epoch - float64(epochSec)) * float64(secondsToNanoSecondsFactor)) 38 | 39 | // time.Unix(sec, nsec) expects the epoch integral seconds in the first parameter 40 | // and remaining nanoseconds in the second parameter 41 | *e = SecondsEpochTime{time.Unix(epochSec, epochNano)} 42 | return nil 43 | } 44 | 45 | func (e MilliSecondsEpochTime) MarshalJSON() ([]byte, error) { 46 | // UnixNano() returns the epoch in nanoseconds 47 | unixTimeMs := e.UnixNano() / milliSecondsToNanoSecondsFactor 48 | return json.Marshal(unixTimeMs) 49 | } 50 | 51 | func (e *MilliSecondsEpochTime) UnmarshalJSON(b []byte) error { 52 | var epoch int64 53 | err := json.Unmarshal(b, &epoch) 54 | if err != nil { 55 | return err 56 | } 57 | *e = MilliSecondsEpochTime{time.Unix(epoch/1000, (epoch%1000)*1000000)} 58 | return nil 59 | } 60 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/README_KinesisDataAnalytics.md: -------------------------------------------------------------------------------- 1 | # Sample function 2 | 3 | The following is an example for an Application Destination Lambda function that receives Amazon Kinesis Data Analytics event records as an input. To send Kinesis Data Analytics output records the Lamdbda function must be compliant with the (required input and return data models)[https://docs.aws.amazon.com/kinesisanalytics/latest/dev/how-it-works-output-lambda.html], so the handler returns a list of delivery statuses for each record. 4 | 5 | The following Lambda function receives Amazon Kinesis Data Analytics event record data as an input and writes some of the record data to CloudWatch Logs. For each entry it adds an element to the response slice, marking it delivered. When the logic considers the delivery to be failed the `events.KinesisAnalyticsOutputDeliveryFailed` value should be used for the response `Result` field. 6 | 7 | 8 | ```go 9 | package main 10 | 11 | import ( 12 | "context" 13 | "encoding/json" 14 | "fmt" 15 | "log" 16 | 17 | "github.com/aws/aws-lambda-go/events" 18 | "github.com/aws/aws-lambda-go/lambda" 19 | ) 20 | 21 | func handler(ctx context.Context, kinesisAnalyticsEvent events.KinesisAnalyticsOutputDeliveryEvent) (events.KinesisAnalyticsOutputDeliveryResponse, error) { 22 | var err error 23 | 24 | var responses events.KinesisAnalyticsOutputDeliveryResponse 25 | responses.Records = make([]events.KinesisAnalyticsOutputDeliveryResponseRecord, len(kinesisAnalyticsEvent.Records)) 26 | 27 | for i, record := range kinesisAnalyticsEvent.Records { 28 | responses.Records[i] = events.KinesisAnalyticsOutputDeliveryResponseRecord{ 29 | RecordID: record.RecordID, 30 | Result: events.KinesisAnalyticsOutputDeliveryOK, 31 | } 32 | 33 | dataBytes := record.Data 34 | dataText := string(dataBytes) 35 | 36 | fmt.Printf("%s Data = %s \n", record.RecordID, dataText) 37 | } 38 | return responses, err 39 | } 40 | 41 | func main() { 42 | lambda.Start(handler) 43 | } 44 | 45 | ``` 46 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/alb.go: -------------------------------------------------------------------------------- 1 | package events 2 | 3 | // ALBTargetGroupRequest contains data originating from the ALB Lambda target group integration 4 | type ALBTargetGroupRequest struct { 5 | HTTPMethod string `json:"httpMethod"` 6 | Path string `json:"path"` 7 | QueryStringParameters map[string]string `json:"queryStringParameters,omitempty"` 8 | MultiValueQueryStringParameters map[string][]string `json:"multiValueQueryStringParameters,omitempty"` 9 | Headers map[string]string `json:"headers,omitempty"` 10 | MultiValueHeaders map[string][]string `json:"multiValueHeaders,omitempty"` 11 | RequestContext ALBTargetGroupRequestContext `json:"requestContext"` 12 | IsBase64Encoded bool `json:"isBase64Encoded"` 13 | Body string `json:"body,omitempty"` 14 | } 15 | 16 | // ALBTargetGroupRequestContext contains the information to identify the load balancer invoking the lambda 17 | type ALBTargetGroupRequestContext struct { 18 | ELB ELBContext `json:"elb"` 19 | } 20 | 21 | // ELBContext contains the information to identify the ARN invoking the lambda 22 | type ELBContext struct { 23 | TargetGroupArn string `json:"targetGroupArn"` //nolint: stylecheck 24 | } 25 | 26 | // ALBTargetGroupResponse configures the response to be returned by the ALB Lambda target group for the request 27 | type ALBTargetGroupResponse struct { 28 | StatusCode int `json:"statusCode"` 29 | StatusDescription string `json:"statusDescription"` 30 | Headers map[string]string `json:"headers"` 31 | MultiValueHeaders map[string][]string `json:"multiValueHeaders"` 32 | Body string `json:"body"` 33 | IsBase64Encoded bool `json:"isBase64Encoded"` 34 | } 35 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/README.md: -------------------------------------------------------------------------------- 1 | # Overview 2 | 3 | [![Go Reference](https://pkg.go.dev/badge/github.com/aws/aws-lambda-go/events.svg)](https://pkg.go.dev/github.com/aws/aws-lambda-go/events) 4 | 5 | This package provides input types for Lambda functions that process AWS events. 6 | 7 | # Samples 8 | 9 | [ALB Target Group Events](README_ALBTargetGroupEvents.md) 10 | 11 | [API Gateway](README_ApiGatewayEvent.md) 12 | 13 | [API Gateway Custom Authorizer](README_ApiGatewayCustomAuthorizer.md) 14 | 15 | [AppSync](README_AppSync.md) 16 | 17 | [AutoScaling](README_AutoScaling.md) 18 | 19 | [ClientVPN Connection Handler](README_ClientVPN.md) 20 | 21 | [CloudFormation Events](../cfn/README.md) 22 | 23 | [CloudWatch Events](README_CloudWatch_Events.md) 24 | 25 | [CloudWatch Logs](README_CloudWatch_Logs.md) 26 | 27 | [Chime Bot Events](README_Chime_Bots.md) 28 | 29 | [CodeBuild Events](README_CodeBuild.md) 30 | 31 | [CodeCommit Events](README_CodeCommit.md) 32 | 33 | [CodeDeploy Events](README_CodeDeploy.md) 34 | 35 | [Cognito Events](README_Cognito.md) 36 | 37 | [Cognito Custom Authentication](README_Cognito_UserPools_CustomAuthLambdaTriggers.md) 38 | 39 | [Cognito PostConfirmation](README_Cognito_UserPools_PostConfirmation.md) 40 | 41 | [Cognito PreAuthentication](README_Cognito_UserPools_PreAuthentication.md) 42 | 43 | [Cognito PreSignup](README_Cognito_UserPools_PreSignup.md) 44 | 45 | [Cognito PreTokenGen](README_Cognito_UserPools_PreTokenGen.md) 46 | 47 | [Config Events](README_Config.md) 48 | 49 | [Connect Events](README_Connect.md) 50 | 51 | [DynamoDB Events](README_DynamoDB.md) 52 | 53 | [Kinesis Events](README_Kinesis.md) 54 | 55 | [Kinesis Data Analytics Events](README_KinesisDataAnalytics.md) 56 | 57 | [Kinesis Firehose Events](README_KinesisFirehose.md) 58 | 59 | [Lex Events](README_Lex.md) 60 | 61 | [S3 Events](README_S3.md) 62 | 63 | [S3 Batch Job Events](README_S3_Batch_Job.md) 64 | 65 | [SES Events](README_SES.md) 66 | 67 | [SNS Events](README_SNS.md) 68 | 69 | [SQS Events](README_SQS.md) 70 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/README_ClientVPN.md: -------------------------------------------------------------------------------- 1 | # Sample Function 2 | 3 | The following is a sample Lambda function that receives a Client VPN connection handler request as an input and then validates the IP address input and checks whether the connection source IP is on the allowed list defined as a map inside the function. If the source IP matches an allowed IP address it allows the access, otherwise an error message is presented to the user. Debug logs are generated to CloudWatch Logs. (Note that anything written to stdout or stderr will be logged as CloudWatch Logs events.) 4 | 5 | ```go 6 | import ( 7 | "fmt" 8 | "log" 9 | "net" 10 | 11 | "encoding/json" 12 | 13 | "github.com/aws/aws-lambda-go/events" 14 | "github.com/aws/aws-lambda-go/lambda" 15 | ) 16 | 17 | var ( 18 | AllowedIPs = map[string]bool{ 19 | "10.11.12.13": true, 20 | } 21 | ) 22 | 23 | func handler(request events.ClientVPNConnectionHandlerRequest) (events.ClientVPNConnectionHandlerResponse, error) { 24 | requestJson, _ := json.MarshalIndent(request, "", " ") 25 | log.Printf("REQUEST: %s", requestJson) 26 | 27 | sourceIP := request.PublicIP 28 | if net.ParseIP(sourceIP) == nil { 29 | return events.ClientVPNConnectionHandlerResponse{}, fmt.Errorf("Invalid parameter PublicIP passed in request: %q", sourceIP) 30 | } 31 | 32 | log.Printf("SOURCE IP: %q", sourceIP) 33 | 34 | if allowed, ok := AllowedIPs[sourceIP]; ok && allowed { 35 | log.Printf("Allowing access from: %q", sourceIP) 36 | return events.ClientVPNConnectionHandlerResponse{ 37 | Allow: true, 38 | ErrorMsgOnFailedPostureCompliance: "", 39 | PostureComplianceStatuses: []string{}, 40 | SchemaVersion: "v1", 41 | }, nil 42 | } 43 | 44 | log.Printf("Blocking access from: %q", sourceIP) 45 | return events.ClientVPNConnectionHandlerResponse{ 46 | Allow: false, 47 | ErrorMsgOnFailedPostureCompliance: "You're trying to connect from an IP address that is not allowed.", 48 | PostureComplianceStatuses: []string{"BlockedSourceIP"}, 49 | SchemaVersion: "v1", 50 | }, nil 51 | } 52 | 53 | func main() { 54 | lambda.Start(handler) 55 | } 56 | ``` 57 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/go.sum: -------------------------------------------------------------------------------- 1 | github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= 2 | github.com/aws/aws-lambda-go v1.28.0 h1:fZiik1PZqW2IyAN4rj+Y0UBaO1IDFlsNo9Zz/XnArK4= 3 | github.com/aws/aws-lambda-go v1.28.0/go.mod h1:jJmlefzPfGnckuHdXX7/80O3BvUUi12XOkbv4w9SGLU= 4 | github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= 5 | github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= 6 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 7 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 8 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 9 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 10 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 11 | github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= 12 | github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= 13 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 14 | github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= 15 | github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= 16 | github.com/urfave/cli/v2 v2.2.0/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ= 17 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= 18 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 19 | gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 20 | gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 21 | gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 h1:tQIYjPdBoyREyB9XMu+nnTclpTYkz2zFM+lzLJFO4gQ= 22 | gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 23 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/connect.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | 3 | package events 4 | 5 | // ConnectEvent contains the data structure for a Connect event. 6 | type ConnectEvent struct { 7 | Details ConnectDetails `json:"Details"` 8 | Name string `json:"Name"` // The name of the event. 9 | } 10 | 11 | // ConnectDetails holds the details of a Connect event 12 | type ConnectDetails struct { 13 | ContactData ConnectContactData `json:"ContactData"` 14 | 15 | // The parameters that have been set in the Connect instance at the time of the Lambda invocation. 16 | Parameters map[string]string `json:"Parameters"` 17 | } 18 | 19 | // ConnectContactData holds all of the contact information for the user that invoked the Connect event. 20 | type ConnectContactData struct { 21 | // The custom attributes from Connect that the Lambda function was invoked with. 22 | Attributes map[string]string `json:"Attributes"` 23 | Channel string `json:"Channel"` 24 | ContactID string `json:"ContactId"` 25 | CustomerEndpoint ConnectEndpoint `json:"CustomerEndpoint"` 26 | InitialContactID string `json:"InitialContactId"` 27 | 28 | // Either: INBOUND/OUTBOUND/TRANSFER/CALLBACK 29 | InitiationMethod string `json:"InitiationMethod"` 30 | PreviousContactID string `json:"PreviousContactId"` 31 | Queue ConnectQueue `json:"Queue"` 32 | SystemEndpoint ConnectEndpoint `json:"SystemEndpoint"` 33 | InstanceARN string `json:"InstanceARN"` 34 | } 35 | 36 | // ConnectEndpoint represents routing information. 37 | type ConnectEndpoint struct { 38 | Address string `json:"Address"` 39 | Type string `json:"Type"` 40 | } 41 | 42 | // ConnectQueue represents a queue object. 43 | type ConnectQueue struct { 44 | Name string `json:"Name"` 45 | ARN string `json:"ARN"` 46 | } 47 | 48 | // ConnectResponse is the structure that Connect expects to get back from Lambda. 49 | // These return values can be used in Connect to perform further routing decisions. 50 | type ConnectResponse map[string]string 51 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/README_Cognito_UserPools_CustomAuthLambdaTriggers.md: -------------------------------------------------------------------------------- 1 | # Sample Function 2 | 3 | The following is a sample Lambda functions that are used for custom authentication with Cognito User Pools. 4 | These Lambda triggers issue and verify their own challenges as part of a user pool [custom authentication flow](https://docs.aws.amazon.com/cognito/latest/developerguide/amazon-cognito-user-pools-authentication-flow.html#amazon-cognito-user-pools-custom-authentication-flow). 5 | 6 | Please see instructions for setting up the Cognito triggers at https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-challenge.html 7 | 8 | Define Auth Challenge Lambda Trigger: 9 | ```go 10 | package main 11 | 12 | import ( 13 | "fmt" 14 | 15 | "github.com/aws/aws-lambda-go/lambda" 16 | "github.com/aws/aws-lambda-go/events" 17 | ) 18 | 19 | func handler(event *events.CognitoEventUserPoolsDefineAuthChallenge) (*events.CognitoEventUserPoolsDefineAuthChallenge, error) { 20 | fmt.Printf("Define Auth Challenge: %+v\n", event) 21 | return event, nil 22 | } 23 | 24 | func main() { 25 | lambda.Start(handler) 26 | } 27 | ``` 28 | 29 | Create Auth Challenge Lambda Trigger: 30 | ```go 31 | package main 32 | 33 | import ( 34 | "fmt" 35 | 36 | "github.com/aws/aws-lambda-go/lambda" 37 | "github.com/aws/aws-lambda-go/events" 38 | ) 39 | 40 | func handler(event *events.CognitoEventUserPoolsCreateAuthChallenge) (*events.CognitoEventUserPoolsCreateAuthChallenge, error) { 41 | fmt.Printf("Create Auth Challenge: %+v\n", event) 42 | return event, nil 43 | } 44 | 45 | func main() { 46 | lambda.Start(handler) 47 | } 48 | ``` 49 | 50 | Verify Auth Challenge Response Lambda Trigger: 51 | ```go 52 | package main 53 | 54 | import ( 55 | "fmt" 56 | 57 | "github.com/aws/aws-lambda-go/lambda" 58 | "github.com/aws/aws-lambda-go/events" 59 | ) 60 | 61 | func handler(event *events.CognitoEventUserPoolsVerifyAuthChallenge) (*events.CognitoEventUserPoolsVerifyAuthChallenge, error) { 62 | fmt.Printf("Verify Auth Challenge: %+v\n", event) 63 | return event, nil 64 | } 65 | 66 | func main() { 67 | lambda.Start(handler) 68 | } 69 | ``` 70 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/README_Chime_Bots.md: -------------------------------------------------------------------------------- 1 | # Sample Function 2 | 3 | The following is a sample class and Lambda function that receives a Amazon Chime Bot event and handles the various event types accordingly. 4 | 5 | ```go 6 | 7 | package main 8 | 9 | import ( 10 | "fmt" 11 | "context" 12 | "net/http" 13 | "bytes" 14 | "encoding/json" 15 | "errors" 16 | "strconv" 17 | 18 | "github.com/aws/aws-lambda-go/events" 19 | ) 20 | 21 | func handler(_ context.Context, chimeBotEvent events.ChimeBotEvent) error { 22 | switch chimeBotEvent.EventType { 23 | case "Invite": 24 | if err := message(chimeBotEvent.InboundHTTPSEndpoint.URL, "Thanks for inviting me to this room " + chimeBotEvent.Sender.SenderID); err != nil { 25 | return fmt.Errorf("failed to send webhook message: %v", err) 26 | } 27 | return nil 28 | case "Mention": 29 | if err := message(chimeBotEvent.InboundHTTPSEndpoint.URL, "Thanks for mentioning me " + chimeBotEvent.Sender.SenderID); err != nil { 30 | return fmt.Errorf("failed to send webhook message: %v", err) 31 | } 32 | return nil 33 | case "Remove": 34 | fmt.Printf("I have been removed from %q by %q", chimeBotEvent.Discussion.DiscussionType, chimeBotEvent.Sender.SenderID) 35 | return nil 36 | default: 37 | return fmt.Errorf("event type %q is unsupported", chimeBotEvent.EventType) 38 | } 39 | } 40 | 41 | func message(url, content string) (error) { 42 | input := &bytes.Buffer{} 43 | if err := json.NewEncoder(input).Encode(webhookInput{Content:content}); err != nil { 44 | return errors.New("failed to marshal request: " + err.Error()) 45 | } 46 | 47 | resp, err := http.Post("POST", url, input) 48 | if err != nil { 49 | return errors.New("failed to execute post http request: " + err.Error()) 50 | } 51 | 52 | if resp != nil && resp.Body != nil { 53 | defer resp.Body.Close() 54 | } 55 | 56 | if resp.StatusCode != http.StatusOK { 57 | return errors.New("bad response: status code not is " + strconv.Itoa(http.StatusOK) + " not " + strconv.Itoa(resp.StatusCode)) 58 | } 59 | 60 | return nil 61 | } 62 | 63 | type webhookInput struct { 64 | Content string `json:"Content"` 65 | } 66 | 67 | ``` 68 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/s3.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | 3 | package events 4 | 5 | import ( 6 | "encoding/json" 7 | "net/url" 8 | "time" 9 | ) 10 | 11 | // S3Event which wrap an array of S3EventRecord 12 | type S3Event struct { 13 | Records []S3EventRecord `json:"Records"` 14 | } 15 | 16 | // S3EventRecord which wrap record data 17 | type S3EventRecord struct { 18 | EventVersion string `json:"eventVersion"` 19 | EventSource string `json:"eventSource"` 20 | AWSRegion string `json:"awsRegion"` 21 | EventTime time.Time `json:"eventTime"` 22 | EventName string `json:"eventName"` 23 | PrincipalID S3UserIdentity `json:"userIdentity"` 24 | RequestParameters S3RequestParameters `json:"requestParameters"` 25 | ResponseElements map[string]string `json:"responseElements"` 26 | S3 S3Entity `json:"s3"` 27 | } 28 | 29 | type S3UserIdentity struct { 30 | PrincipalID string `json:"principalId"` 31 | } 32 | 33 | type S3RequestParameters struct { 34 | SourceIPAddress string `json:"sourceIPAddress"` 35 | } 36 | 37 | type S3Entity struct { 38 | SchemaVersion string `json:"s3SchemaVersion"` 39 | ConfigurationID string `json:"configurationId"` 40 | Bucket S3Bucket `json:"bucket"` 41 | Object S3Object `json:"object"` 42 | } 43 | 44 | type S3Bucket struct { 45 | Name string `json:"name"` 46 | OwnerIdentity S3UserIdentity `json:"ownerIdentity"` 47 | Arn string `json:"arn"` //nolint: stylecheck 48 | } 49 | 50 | type S3Object struct { 51 | Key string `json:"key"` 52 | Size int64 `json:"size,omitempty"` 53 | URLDecodedKey string `json:"urlDecodedKey"` 54 | VersionID string `json:"versionId"` 55 | ETag string `json:"eTag"` 56 | Sequencer string `json:"sequencer"` 57 | } 58 | 59 | func (o *S3Object) UnmarshalJSON(data []byte) error { 60 | type rawS3Object S3Object 61 | if err := json.Unmarshal(data, (*rawS3Object)(o)); err != nil { 62 | return err 63 | } 64 | key, err := url.QueryUnescape(o.Key) 65 | if err != nil { 66 | return err 67 | } 68 | o.URLDecodedKey = key 69 | 70 | return nil 71 | } 72 | 73 | type S3TestEvent struct { 74 | Service string `json:"Service"` 75 | Bucket string `json:"Bucket"` 76 | Event string `json:"Event"` 77 | Time time.Time `json:"Time"` 78 | RequestID string `json:"RequestId"` 79 | HostID string `json:"HostId"` 80 | } 81 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/firehose.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | 3 | package events 4 | 5 | // KinesisFirehoseEvent represents the input event from Amazon Kinesis Firehose. It is used as the input parameter. 6 | type KinesisFirehoseEvent struct { 7 | InvocationID string `json:"invocationId"` 8 | DeliveryStreamArn string `json:"deliveryStreamArn"` //nolint: stylecheck 9 | SourceKinesisStreamArn string `json:"sourceKinesisStreamArn"` //nolint: stylecheck 10 | Region string `json:"region"` 11 | Records []KinesisFirehoseEventRecord `json:"records"` 12 | } 13 | 14 | type KinesisFirehoseEventRecord struct { 15 | RecordID string `json:"recordId"` 16 | ApproximateArrivalTimestamp MilliSecondsEpochTime `json:"approximateArrivalTimestamp"` 17 | Data []byte `json:"data"` 18 | KinesisFirehoseRecordMetadata KinesisFirehoseRecordMetadata `json:"kinesisRecordMetadata"` 19 | } 20 | 21 | // Constants used for describing the transformation result 22 | const ( 23 | KinesisFirehoseTransformedStateOk = "Ok" 24 | KinesisFirehoseTransformedStateDropped = "Dropped" 25 | KinesisFirehoseTransformedStateProcessingFailed = "ProcessingFailed" 26 | ) 27 | 28 | type KinesisFirehoseResponse struct { 29 | Records []KinesisFirehoseResponseRecord `json:"records"` 30 | } 31 | 32 | type KinesisFirehoseResponseRecord struct { 33 | RecordID string `json:"recordId"` 34 | Result string `json:"result"` // The status of the transformation. May be TransformedStateOk, TransformedStateDropped or TransformedStateProcessingFailed 35 | Data []byte `json:"data"` 36 | Metadata KinesisFirehoseResponseRecordMetadata `json:"metadata"` 37 | } 38 | 39 | type KinesisFirehoseResponseRecordMetadata struct { 40 | PartitionKeys map[string]string `json:"partitionKeys"` 41 | } 42 | 43 | type KinesisFirehoseRecordMetadata struct { 44 | ShardID string `json:"shardId"` 45 | PartitionKey string `json:"partitionKey"` 46 | SequenceNumber string `json:"sequenceNumber"` 47 | SubsequenceNumber int64 `json:"subsequenceNumber"` 48 | ApproximateArrivalTimestamp MilliSecondsEpochTime `json:"approximateArrivalTimestamp"` 49 | } 50 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/README_ApiGatewayCustomAuthorizer.md: -------------------------------------------------------------------------------- 1 | # Sample Function 2 | 3 | The following is a simple TOKEN authorizer example to demonstrate how to use an authorization 4 | token to allow or deny a request. In this example, the caller named "user" is allowed to invoke 5 | a request if the client-supplied token value is "allow". The caller is not allowed to invoke 6 | the request if the token value is "deny". If the token value is "Unauthorized", the function 7 | returns the "Unauthorized" error with an HTTP status code of 401. For any other token value, 8 | the authorizer returns an "Invalid token" error. 9 | 10 | This example is based on the [JavaScript sample](https://docs.aws.amazon.com/apigateway/latest/developerguide/use-custom-authorizer.html#api-gateway-custom-authorizer-token-lambda-function-create) from the API Gateway documentation 11 | 12 | ```go 13 | package main 14 | 15 | import ( 16 | "context" 17 | "errors" 18 | "strings" 19 | 20 | "github.com/aws/aws-lambda-go/events" 21 | "github.com/aws/aws-lambda-go/lambda" 22 | ) 23 | 24 | // Help function to generate an IAM policy 25 | func generatePolicy(principalId, effect, resource string) events.APIGatewayCustomAuthorizerResponse { 26 | authResponse := events.APIGatewayCustomAuthorizerResponse{PrincipalID: principalId} 27 | 28 | if effect != "" && resource != "" { 29 | authResponse.PolicyDocument = events.APIGatewayCustomAuthorizerPolicy{ 30 | Version: "2012-10-17", 31 | Statement: []events.IAMPolicyStatement{ 32 | { 33 | Action: []string{"execute-api:Invoke"}, 34 | Effect: effect, 35 | Resource: []string{resource}, 36 | }, 37 | }, 38 | } 39 | } 40 | 41 | // Optional output with custom properties of the String, Number or Boolean type. 42 | authResponse.Context = map[string]interface{}{ 43 | "stringKey": "stringval", 44 | "numberKey": 123, 45 | "booleanKey": true, 46 | } 47 | return authResponse 48 | } 49 | 50 | func handleRequest(ctx context.Context, event events.APIGatewayCustomAuthorizerRequest) (events.APIGatewayCustomAuthorizerResponse, error) { 51 | token := event.AuthorizationToken 52 | switch strings.ToLower(token) { 53 | case "allow": 54 | return generatePolicy("user", "Allow", event.MethodArn), nil 55 | case "deny": 56 | return generatePolicy("user", "Deny", event.MethodArn), nil 57 | case "unauthorized": 58 | return events.APIGatewayCustomAuthorizerResponse{}, errors.New("Unauthorized") // Return a 401 Unauthorized response 59 | default: 60 | return events.APIGatewayCustomAuthorizerResponse{}, errors.New("Error: Invalid token") 61 | } 62 | } 63 | 64 | func main() { 65 | lambda.Start(handleRequest) 66 | } 67 | ``` 68 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/lambda/function.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | 3 | package lambda 4 | 5 | import ( 6 | "context" 7 | "encoding/json" 8 | "os" 9 | "time" 10 | 11 | "github.com/aws/aws-lambda-go/lambda/messages" 12 | "github.com/aws/aws-lambda-go/lambdacontext" 13 | ) 14 | 15 | // Function struct which wrap the Handler 16 | type Function struct { 17 | handler Handler 18 | ctx context.Context 19 | } 20 | 21 | // NewFunction which creates a Function with a given Handler 22 | func NewFunction(handler Handler) *Function { 23 | return &Function{handler: handler} 24 | } 25 | 26 | // Ping method which given a PingRequest and a PingResponse parses the PingResponse 27 | func (fn *Function) Ping(req *messages.PingRequest, response *messages.PingResponse) error { 28 | *response = messages.PingResponse{} 29 | return nil 30 | } 31 | 32 | // Invoke method try to perform a command given an InvokeRequest and an InvokeResponse 33 | func (fn *Function) Invoke(req *messages.InvokeRequest, response *messages.InvokeResponse) error { 34 | defer func() { 35 | if err := recover(); err != nil { 36 | response.Error = lambdaPanicResponse(err) 37 | } 38 | }() 39 | 40 | deadline := time.Unix(req.Deadline.Seconds, req.Deadline.Nanos).UTC() 41 | invokeContext, cancel := context.WithDeadline(fn.context(), deadline) 42 | defer cancel() 43 | 44 | lc := &lambdacontext.LambdaContext{ 45 | AwsRequestID: req.RequestId, 46 | InvokedFunctionArn: req.InvokedFunctionArn, 47 | Identity: lambdacontext.CognitoIdentity{ 48 | CognitoIdentityID: req.CognitoIdentityId, 49 | CognitoIdentityPoolID: req.CognitoIdentityPoolId, 50 | }, 51 | } 52 | if len(req.ClientContext) > 0 { 53 | if err := json.Unmarshal(req.ClientContext, &lc.ClientContext); err != nil { 54 | response.Error = lambdaErrorResponse(err) 55 | return nil 56 | } 57 | } 58 | invokeContext = lambdacontext.NewContext(invokeContext, lc) 59 | 60 | // nolint:staticcheck 61 | invokeContext = context.WithValue(invokeContext, "x-amzn-trace-id", req.XAmznTraceId) 62 | os.Setenv("_X_AMZN_TRACE_ID", req.XAmznTraceId) 63 | 64 | payload, err := fn.handler.Invoke(invokeContext, req.Payload) 65 | if err != nil { 66 | response.Error = lambdaErrorResponse(err) 67 | return nil 68 | } 69 | response.Payload = payload 70 | return nil 71 | } 72 | 73 | // context returns the base context used for the fn. 74 | func (fn *Function) context() context.Context { 75 | if fn.ctx == nil { 76 | return context.Background() 77 | } 78 | 79 | return fn.ctx 80 | } 81 | 82 | // withContext returns a shallow copy of Function with its context changed 83 | // to the provided ctx. If the provided ctx is non-nil a Background context is set. 84 | func (fn *Function) withContext(ctx context.Context) *Function { 85 | if ctx == nil { 86 | ctx = context.Background() 87 | } 88 | 89 | fn2 := new(Function) 90 | *fn2 = *fn 91 | 92 | fn2.ctx = ctx 93 | 94 | return fn2 95 | } 96 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/lambda/panic.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | 3 | package lambda 4 | 5 | import ( 6 | "fmt" 7 | "runtime" 8 | "strings" 9 | 10 | "github.com/aws/aws-lambda-go/lambda/messages" 11 | ) 12 | 13 | type panicInfo struct { 14 | Message string // Value passed to panic call, converted to string 15 | StackTrace []*messages.InvokeResponse_Error_StackFrame // Stack trace of the panic 16 | } 17 | 18 | func getPanicInfo(value interface{}) panicInfo { 19 | message := getPanicMessage(value) 20 | stack := getPanicStack() 21 | 22 | return panicInfo{Message: message, StackTrace: stack} 23 | } 24 | 25 | func getPanicMessage(value interface{}) string { 26 | return fmt.Sprintf("%v", value) 27 | } 28 | 29 | var defaultErrorFrameCount = 32 30 | 31 | func getPanicStack() []*messages.InvokeResponse_Error_StackFrame { 32 | s := make([]uintptr, defaultErrorFrameCount) 33 | const framesToHide = 3 // this (getPanicStack) -> getPanicInfo -> handler defer func 34 | n := runtime.Callers(framesToHide, s) 35 | if n == 0 { 36 | return make([]*messages.InvokeResponse_Error_StackFrame, 0) 37 | } 38 | 39 | s = s[:n] 40 | 41 | return convertStack(s) 42 | } 43 | 44 | func convertStack(s []uintptr) []*messages.InvokeResponse_Error_StackFrame { 45 | var converted []*messages.InvokeResponse_Error_StackFrame 46 | frames := runtime.CallersFrames(s) 47 | 48 | for { 49 | frame, more := frames.Next() 50 | 51 | formattedFrame := formatFrame(frame) 52 | converted = append(converted, formattedFrame) 53 | 54 | if !more { 55 | break 56 | } 57 | } 58 | return converted 59 | } 60 | 61 | func formatFrame(inputFrame runtime.Frame) *messages.InvokeResponse_Error_StackFrame { 62 | path := inputFrame.File 63 | line := int32(inputFrame.Line) 64 | label := inputFrame.Function 65 | 66 | // Strip GOPATH from path by counting the number of seperators in label & path 67 | // 68 | // For example given this: 69 | // GOPATH = /home/user 70 | // path = /home/user/src/pkg/sub/file.go 71 | // label = pkg/sub.Type.Method 72 | // 73 | // We want to set: 74 | // path = pkg/sub/file.go 75 | // label = Type.Method 76 | 77 | i := len(path) 78 | for n, g := 0, strings.Count(label, "/")+2; n < g; n++ { 79 | i = strings.LastIndex(path[:i], "/") 80 | if i == -1 { 81 | // Something went wrong and path has less seperators than we expected 82 | // Abort and leave i as -1 to counteract the +1 below 83 | break 84 | } 85 | } 86 | 87 | path = path[i+1:] // Trim the initial / 88 | 89 | // Strip the path from the function name as it's already in the path 90 | label = label[strings.LastIndex(label, "/")+1:] 91 | // Likewise strip the package name 92 | label = label[strings.Index(label, ".")+1:] 93 | 94 | return &messages.InvokeResponse_Error_StackFrame{ 95 | Path: path, 96 | Line: line, 97 | Label: label, 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/codedeploy.go: -------------------------------------------------------------------------------- 1 | package events 2 | 3 | import ( 4 | "time" 5 | ) 6 | 7 | const ( 8 | CodeDeployEventSource = "aws.codedeploy" 9 | CodeDeployDeploymentEventDetailType = "CodeDeploy Deployment State-change Notification" 10 | CodeDeployInstanceEventDetailType = "CodeDeploy Instance State-change Notification" 11 | ) 12 | 13 | type CodeDeployDeploymentState string 14 | 15 | const ( 16 | CodeDeployDeploymentStateFailure CodeDeployDeploymentState = "FAILURE" 17 | CodeDeployDeploymentStateReady CodeDeployDeploymentState = "READY" 18 | CodeDeployDeploymentStateStart CodeDeployDeploymentState = "START" 19 | CodeDeployDeploymentStateStop CodeDeployDeploymentState = "STOP" 20 | CodeDeployDeploymentStateSuccess CodeDeployDeploymentState = "SUCCESS" 21 | ) 22 | 23 | // CodeDeployEvent is documented at: 24 | // https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/EventTypes.html#acd_event_types 25 | type CodeDeployEvent struct { 26 | // AccountID is the id of the AWS account from which the event originated. 27 | AccountID string `json:"account"` 28 | 29 | // Region is the AWS region from which the event originated. 30 | Region string `json:"region"` 31 | 32 | // DetailType informs the schema of the Detail field. For deployment state-change 33 | // events, the value should be equal to CodeDeployDeploymentEventDetailType. 34 | // For instance state-change events, the value should be equal to 35 | // CodeDeployInstanceEventDetailType. 36 | DetailType string `json:"detail-type"` 37 | 38 | // Source should be equal to CodeDeployEventSource. 39 | Source string `json:"source"` 40 | 41 | // Version is the version of the event's schema. 42 | Version string `json:"version"` 43 | 44 | // Time is the event's timestamp. 45 | Time time.Time `json:"time"` 46 | 47 | // ID is the GUID of this event. 48 | ID string `json:"id"` 49 | 50 | // Resources is a list of ARNs of CodeDeploy applications and deployment 51 | // groups that this event pertains to. 52 | Resources []string `json:"resources"` 53 | 54 | // Detail contains information specific to a deployment event. 55 | Detail CodeDeployEventDetail `json:"detail"` 56 | } 57 | 58 | type CodeDeployEventDetail struct { 59 | // InstanceGroupID is the ID of the instance group. 60 | InstanceGroupID string `json:"instanceGroupId"` 61 | 62 | // InstanceID is the id of the instance. This field is non-empty only if 63 | // the DetailType of the complete event is CodeDeployInstanceEventDetailType. 64 | InstanceID string `json:"instanceId,omitempty"` 65 | 66 | // Region is the AWS region that the event originated from. 67 | Region string `json:"region"` 68 | 69 | // Application is the name of the CodeDeploy application. 70 | Application string `json:"application"` 71 | 72 | // DeploymentID is the id of the deployment. 73 | DeploymentID string `json:"deploymentId"` 74 | 75 | // State is the new state of the deployment. 76 | State CodeDeployDeploymentState `json:"state"` 77 | 78 | // DeploymentGroup is the name of the deployment group. 79 | DeploymentGroup string `json:"deploymentGroup"` 80 | } 81 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/codepipeline_job.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | 3 | package events 4 | 5 | // CodePipelineJobEvent contains data from an event sent from AWS CodePipeline 6 | type CodePipelineJobEvent struct { 7 | CodePipelineJob CodePipelineJob `json:"CodePipeline.job"` 8 | } 9 | 10 | // CodePipelineJob represents a job from an AWS CodePipeline event 11 | type CodePipelineJob struct { 12 | ID string `json:"id"` 13 | AccountID string `json:"accountId"` 14 | Data CodePipelineData `json:"data"` 15 | } 16 | 17 | // CodePipelineData represents a job from an AWS CodePipeline event 18 | type CodePipelineData struct { 19 | ActionConfiguration CodePipelineActionConfiguration `json:"actionConfiguration"` 20 | InputArtifacts []CodePipelineInputArtifact `json:"inputArtifacts"` 21 | OutPutArtifacts []CodePipelineOutputArtifact `json:"outputArtifacts"` 22 | ArtifactCredentials CodePipelineArtifactCredentials `json:"artifactCredentials"` 23 | ContinuationToken string `json:"continuationToken"` 24 | } 25 | 26 | // CodePipelineActionConfiguration represents an Action Configuration 27 | type CodePipelineActionConfiguration struct { 28 | Configuration CodePipelineConfiguration `json:"configuration"` 29 | } 30 | 31 | // CodePipelineConfiguration represents a configuration for an Action Configuration 32 | type CodePipelineConfiguration struct { 33 | FunctionName string `json:"FunctionName"` 34 | UserParameters string `json:"UserParameters"` 35 | } 36 | 37 | // CodePipelineInputArtifact represents an input artifact 38 | type CodePipelineInputArtifact struct { 39 | Location CodePipelineInputLocation `json:"location"` 40 | Revision *string `json:"revision"` 41 | Name string `json:"name"` 42 | } 43 | 44 | // CodePipelineInputLocation represents a input location 45 | type CodePipelineInputLocation struct { 46 | S3Location CodePipelineS3Location `json:"s3Location"` 47 | LocationType string `json:"type"` 48 | } 49 | 50 | // CodePipelineS3Location represents an s3 input location 51 | type CodePipelineS3Location struct { 52 | BucketName string `json:"bucketName"` 53 | ObjectKey string `json:"objectKey"` 54 | } 55 | 56 | // CodePipelineOutputArtifact represents an output artifact 57 | type CodePipelineOutputArtifact struct { 58 | Location CodePipelineInputLocation `json:"location"` 59 | Revision *string `json:"revision"` 60 | Name string `json:"name"` 61 | } 62 | 63 | // CodePipelineOutputLocation represents a output location 64 | type CodePipelineOutputLocation struct { 65 | S3Location CodePipelineS3Location `json:"s3Location"` 66 | LocationType string `json:"type"` 67 | } 68 | 69 | // CodePipelineArtifactCredentials represents CodePipeline artifact credentials 70 | type CodePipelineArtifactCredentials struct { 71 | SecretAccessKey string `json:"secretAccessKey"` 72 | SessionToken string `json:"sessionToken"` 73 | AccessKeyID string `json:"accessKeyId"` 74 | } 75 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/appsync.go: -------------------------------------------------------------------------------- 1 | package events 2 | 3 | import "encoding/json" 4 | 5 | // AppSyncResolverTemplate represents the requests from AppSync to Lambda 6 | type AppSyncResolverTemplate struct { 7 | Version string `json:"version"` 8 | Operation AppSyncOperation `json:"operation"` 9 | Payload json.RawMessage `json:"payload"` 10 | } 11 | 12 | // AppSyncIAMIdentity contains information about the caller authed via IAM. 13 | type AppSyncIAMIdentity struct { 14 | AccountID string `json:"accountId"` 15 | CognitoIdentityPoolID string `json:"cognitoIdentityPoolId"` 16 | CognitoIdentityID string `json:"cognitoIdentityId"` 17 | SourceIP []string `json:"sourceIp"` 18 | Username string `json:"username"` 19 | UserARN string `json:"userArn"` 20 | } 21 | 22 | // AppSyncCognitoIdentity contains information about the caller authed via Cognito. 23 | type AppSyncCognitoIdentity struct { 24 | Sub string `json:"sub"` 25 | Issuer string `json:"issuer"` 26 | Username string `json:"username"` 27 | Claims map[string]interface{} `json:"claims"` 28 | SourceIP []string `json:"sourceIp"` 29 | DefaultAuthStrategy string `json:"defaultAuthStrategy"` 30 | } 31 | 32 | // AppSyncOperation specifies the operation type supported by Lambda operations 33 | type AppSyncOperation string 34 | 35 | const ( 36 | // OperationInvoke lets AWS AppSync know to call your Lambda function for every GraphQL field resolver 37 | OperationInvoke AppSyncOperation = "Invoke" 38 | // OperationBatchInvoke instructs AWS AppSync to batch requests for the current GraphQL field 39 | OperationBatchInvoke AppSyncOperation = "BatchInvoke" 40 | ) 41 | 42 | // AppSyncLambdaAuthorizerRequest contains an authorization request from AppSync. 43 | type AppSyncLambdaAuthorizerRequest struct { 44 | AuthorizationToken string `json:"authorizationToken"` 45 | RequestContext AppSyncLambdaAuthorizerRequestContext `json:"requestContext"` 46 | } 47 | 48 | // AppSyncLambdaAuthorizerRequestContext contains the parameters of the AppSync invocation which triggered 49 | // this authorization request. 50 | type AppSyncLambdaAuthorizerRequestContext struct { 51 | APIID string `json:"apiId"` 52 | AccountID string `json:"accountId"` 53 | RequestID string `json:"requestId"` 54 | QueryString string `json:"queryString"` 55 | OperationName string `json:"operationName"` 56 | Variables map[string]interface{} `json:"variables"` 57 | } 58 | 59 | // AppSyncLambdaAuthorizerResponse represents the expected format of an authorization response to AppSync. 60 | type AppSyncLambdaAuthorizerResponse struct { 61 | IsAuthorized bool `json:"isAuthorized"` 62 | ResolverContext map[string]interface{} `json:"resolverContext,omitempty"` 63 | DeniedFields []string `json:"deniedFields,omitempty"` 64 | TTLOverride *int `json:"ttlOverride,omitempty"` 65 | } 66 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing Guidelines 2 | 3 | Thank you for your interest in contributing to our project. Whether it's a bug report, new feature, correction, or additional 4 | documentation, we greatly value feedback and contributions from our community. 5 | 6 | Please read through this document before submitting any issues or pull requests to ensure we have all the necessary 7 | information to effectively respond to your bug report or contribution. 8 | 9 | 10 | ## Reporting Bugs/Feature Requests 11 | 12 | We welcome you to use the GitHub issue tracker to report bugs or suggest features. 13 | 14 | When filing an issue, please check existing open, or recently closed, issues to make sure somebody else hasn't already 15 | reported the issue. Please try to include as much information as you can. Details like these are incredibly useful: 16 | 17 | * A reproducible test case or series of steps 18 | * The version of our code being used 19 | * Any modifications you've made relevant to the bug 20 | * Anything unusual about your environment or deployment 21 | 22 | 23 | ## Contributing via Pull Requests 24 | Contributions via pull requests are much appreciated. Before sending us a pull request, please ensure that: 25 | 26 | 1. You are working against the latest source on the *master* branch. 27 | 2. You check existing open, and recently merged, pull requests to make sure someone else hasn't addressed the problem already. 28 | 3. You open an issue to discuss any significant work - we would hate for your time to be wasted. 29 | 30 | To send us a pull request, please: 31 | 32 | 1. Fork the repository. 33 | 2. Modify the source; please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change. 34 | 3. Ensure local tests pass. 35 | 4. Commit to your fork using clear commit messages. 36 | 5. Send us a pull request, answering any default questions in the pull request interface. 37 | 6. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation. 38 | 39 | GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and 40 | [creating a pull request](https://help.github.com/articles/creating-a-pull-request/). 41 | 42 | 43 | ## Finding contributions to work on 44 | Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels (enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any 'help wanted' issues is a great place to start. 45 | 46 | 47 | ## Code of Conduct 48 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). 49 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact 50 | opensource-codeofconduct@amazon.com with any additional questions or comments. 51 | 52 | 53 | ## Security issue notifications 54 | If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/). Please do **not** create a public github issue. 55 | 56 | 57 | ## Licensing 58 | 59 | See the [LICENSE](LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution. 60 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/lambdacontext/context.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // 3 | // Helpers for accessing context information from an Invoke request. Context information 4 | // is stored in a https://golang.org/pkg/context/#Context. The functions FromContext and NewContext 5 | // are used to retrieving and inserting an instance of LambdaContext. 6 | 7 | package lambdacontext 8 | 9 | import ( 10 | "context" 11 | "os" 12 | "strconv" 13 | ) 14 | 15 | // LogGroupName is the name of the log group that contains the log streams of the current Lambda Function 16 | var LogGroupName string 17 | 18 | // LogStreamName name of the log stream that the current Lambda Function's logs will be sent to 19 | var LogStreamName string 20 | 21 | // FunctionName the name of the current Lambda Function 22 | var FunctionName string 23 | 24 | // MemoryLimitInMB is the configured memory limit for the current instance of the Lambda Function 25 | var MemoryLimitInMB int 26 | 27 | // FunctionVersion is the published version of the current instance of the Lambda Function 28 | var FunctionVersion string 29 | 30 | func init() { 31 | LogGroupName = os.Getenv("AWS_LAMBDA_LOG_GROUP_NAME") 32 | LogStreamName = os.Getenv("AWS_LAMBDA_LOG_STREAM_NAME") 33 | FunctionName = os.Getenv("AWS_LAMBDA_FUNCTION_NAME") 34 | if limit, err := strconv.Atoi(os.Getenv("AWS_LAMBDA_FUNCTION_MEMORY_SIZE")); err != nil { 35 | MemoryLimitInMB = 0 36 | } else { 37 | MemoryLimitInMB = limit 38 | } 39 | FunctionVersion = os.Getenv("AWS_LAMBDA_FUNCTION_VERSION") 40 | } 41 | 42 | // ClientApplication is metadata about the calling application. 43 | type ClientApplication struct { 44 | InstallationID string `json:"installation_id"` 45 | AppTitle string `json:"app_title"` 46 | AppVersionCode string `json:"app_version_code"` 47 | AppPackageName string `json:"app_package_name"` 48 | } 49 | 50 | // ClientContext is information about the client application passed by the calling application. 51 | type ClientContext struct { 52 | Client ClientApplication 53 | Env map[string]string `json:"env"` 54 | Custom map[string]string `json:"custom"` 55 | } 56 | 57 | // CognitoIdentity is the cognito identity used by the calling application. 58 | type CognitoIdentity struct { 59 | CognitoIdentityID string 60 | CognitoIdentityPoolID string 61 | } 62 | 63 | // LambdaContext is the set of metadata that is passed for every Invoke. 64 | type LambdaContext struct { 65 | AwsRequestID string //nolint: stylecheck 66 | InvokedFunctionArn string //nolint: stylecheck 67 | Identity CognitoIdentity 68 | ClientContext ClientContext 69 | } 70 | 71 | // An unexported type to be used as the key for types in this package. 72 | // This prevents collisions with keys defined in other packages. 73 | type key struct{} 74 | 75 | // The key for a LambdaContext in Contexts. 76 | // Users of this package must use lambdacontext.NewContext and lambdacontext.FromContext 77 | // instead of using this key directly. 78 | var contextKey = &key{} 79 | 80 | // NewContext returns a new Context that carries value lc. 81 | func NewContext(parent context.Context, lc *LambdaContext) context.Context { 82 | return context.WithValue(parent, contextKey, lc) 83 | } 84 | 85 | // FromContext returns the LambdaContext value stored in ctx, if any. 86 | func FromContext(ctx context.Context) (*LambdaContext, bool) { 87 | lc, ok := ctx.Value(contextKey).(*LambdaContext) 88 | return lc, ok 89 | } 90 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/README_DynamoDB.md: -------------------------------------------------------------------------------- 1 | # Sample Function 2 | 3 | The following is a sample Lambda function that receives DynamoDB event data as input and writes some of the record data to CloudWatch Logs. (Note that by default anything written to Console will be logged as CloudWatch Logs.) 4 | 5 | ```go 6 | import ( 7 | "context" 8 | "fmt" 9 | 10 | "github.com/aws/aws-lambda-go/events" 11 | ) 12 | 13 | func handleRequest(ctx context.Context, e events.DynamoDBEvent) { 14 | 15 | for _, record := range e.Records { 16 | fmt.Printf("Processing request data for event ID %s, type %s.\n", record.EventID, record.EventName) 17 | 18 | // Print new values for attributes of type String 19 | for name, value := range record.Change.NewImage { 20 | if value.DataType() == events.DataTypeString { 21 | fmt.Printf("Attribute name: %s, value: %s\n", name, value.String()) 22 | } 23 | } 24 | } 25 | } 26 | ``` 27 | 28 | # Reading attribute values 29 | 30 | Stream notifications are delivered to the Lambda handler whenever data in the DynamoDB table is modified. 31 | Depending on the Stream settings, a StreamRecord may contain the following data: 32 | 33 | * Keys: key attributes of the modified item. 34 | * NewImage: the entire item, as it appears after it was modified. 35 | * OldImage: the entire item, as it appeared before it was modified. 36 | 37 | The values for the attributes can be accessed using the AttributeValue type. For each type 38 | supported natively by DynamoDB, there is a corresponding accessor method: 39 | 40 | DynamoDB type | AttributeValue accessor method | Return type | DataType constant 41 | ---------------|--------------------------------|---------------------------|------------------ 42 | B (Binary) | Binary() | []byte | DataTypeBinary 43 | BOOL (Boolean) | Boolean() | bool | DataTypeBoolean 44 | BS (Binary Set)| BinarySet() | [][]byte | DataTypeBinarySet 45 | L (List) | List() | []AttributeValue | DataTypeList 46 | M (Map) | Map() | map[string]AttributeValue | DataTypeMap 47 | N (Number) | Number() / Integer() / Float() | string / int64 / float64 | DataTypeNumber 48 | NS (Number Set)| NumberSet() | []string | DataTypeNumberSet 49 | NULL (Null) | IsNull() | bool | DataTypeNull 50 | S (String) | String() | string | DataTypeString 51 | SS (String Set)| StringSet() | []string | DataTypeStringSet 52 | 53 | Calling the accessor method for the incorrect type will result in a panic. If the type needs to 54 | be discovered in runtime, the method DataType() can be used in order to determine the correct accessor. 55 | 56 | More information about DynamoDB data types can be seen [in this documentation](http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_AttributeValue.html). 57 | 58 | The following example reads values of attributes name and age, for which types are known to be String and Number: 59 | 60 | ```go 61 | import ( 62 | "context" 63 | "fmt" 64 | 65 | "github.com/aws/aws-lambda-go/events" 66 | ) 67 | 68 | func handleRequest(ctx context.Context, e events.DynamoDBEvent) { 69 | 70 | for _, record := range e.Records { 71 | fmt.Printf("Processing request data for event ID %s, type %s.\n", record.EventID, record.EventName) 72 | 73 | // Print new values for attributes name and age 74 | name := record.Change.NewImage["name"].String() 75 | age, _ := record.Change.NewImage["age"].Integer() 76 | 77 | fmt.Printf("Name: %s, age: %d\n", name, age) 78 | } 79 | } 80 | ``` 81 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/lex.go: -------------------------------------------------------------------------------- 1 | package events 2 | 3 | type LexEvent struct { 4 | MessageVersion string `json:"messageVersion,omitempty"` 5 | InvocationSource string `json:"invocationSource,omitempty"` 6 | UserID string `json:"userId,omitempty"` 7 | InputTranscript string `json:"inputTranscript,omitempty"` 8 | SessionAttributes SessionAttributes `json:"sessionAttributes,omitempty"` 9 | RequestAttributes map[string]string `json:"requestAttributes,omitempty"` 10 | Bot *LexBot `json:"bot,omitempty"` 11 | OutputDialogMode string `json:"outputDialogMode,omitempty"` 12 | CurrentIntent *LexCurrentIntent `json:"currentIntent,omitempty"` 13 | AlternativeIntents []LexAlternativeIntents `json:"alternativeIntents,omitempty"` 14 | DialogAction *LexDialogAction `json:"dialogAction,omitempty"` 15 | } 16 | 17 | type LexBot struct { 18 | Name string `json:"name,omitempty"` 19 | Alias string `json:"alias,omitempty"` 20 | Version string `json:"version,omitempty"` 21 | } 22 | 23 | type LexCurrentIntent struct { 24 | Name string `json:"name,omitempty"` 25 | NLUIntentConfidenceScore float64 `json:"nluIntentConfidenceScore,omitempty"` 26 | Slots Slots `json:"slots,omitempty"` 27 | SlotDetails map[string]SlotDetail `json:"slotDetails,omitempty"` 28 | ConfirmationStatus string `json:"confirmationStatus,omitempty"` 29 | } 30 | 31 | type LexAlternativeIntents struct { 32 | Name string `json:"name,omitempty"` 33 | NLUIntentConfidenceScore float64 `json:"nluIntentConfidenceScore,omitempty"` 34 | Slots Slots `json:"slots,omitempty"` 35 | SlotDetails map[string]SlotDetail `json:"slotDetails,omitempty"` 36 | ConfirmationStatus string `json:"confirmationStatus,omitempty"` 37 | } 38 | 39 | type SlotDetail struct { 40 | Resolutions []map[string]string `json:"resolutions,omitempty"` 41 | OriginalValue string `json:"originalValue,omitempty"` 42 | } 43 | 44 | type LexDialogAction struct { 45 | Type string `json:"type,omitempty"` 46 | FulfillmentState string `json:"fulfillmentState,omitempty"` 47 | Message map[string]string `json:"message,omitempty"` 48 | IntentName string `json:"intentName,omitempty"` 49 | Slots Slots `json:"slots,omitempty"` 50 | SlotToElicit string `json:"slotToElicit,omitempty"` 51 | ResponseCard *LexResponseCard `json:"responseCard,omitempty"` 52 | } 53 | 54 | type SessionAttributes map[string]string 55 | 56 | type Slots map[string]*string 57 | 58 | type LexResponse struct { 59 | SessionAttributes SessionAttributes `json:"sessionAttributes"` 60 | DialogAction LexDialogAction `json:"dialogAction,omitempty"` 61 | } 62 | 63 | type LexResponseCard struct { 64 | Version int64 `json:"version,omitempty"` 65 | ContentType string `json:"contentType,omitempty"` 66 | GenericAttachments []Attachment `json:"genericAttachments,omitempty"` 67 | } 68 | 69 | type Attachment struct { 70 | Title string `json:"title,omitempty"` 71 | SubTitle string `json:"subTitle,omitempty"` 72 | ImageURL string `json:"imageUrl,omitempty"` 73 | AttachmentLinkURL string `json:"attachmentLinkUrl,omitempty"` 74 | Buttons []map[string]string `json:"buttons,omitempty"` 75 | } 76 | 77 | func (h *LexEvent) Clear() { 78 | h.Bot = nil 79 | h.CurrentIntent = nil 80 | h.DialogAction = nil 81 | } 82 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/codepipeline_cloudwatch.go: -------------------------------------------------------------------------------- 1 | package events 2 | 3 | import ( 4 | "time" 5 | ) 6 | 7 | const ( 8 | CodePipelineEventSource = "aws.codepipeline" 9 | CodePipelineExecutionEventDetailType = "CodePipeline Pipeline Execution State Change" 10 | CodePipelineActionEventDetailType = "CodePipeline Action Execution State Change" 11 | CodePipelineStageEventDetailType = "CodePipeline Stage Execution State Change" 12 | ) 13 | 14 | type CodePipelineStageState string 15 | 16 | const ( 17 | CodePipelineStageStateStarted CodePipelineStageState = "STARTED" 18 | CodePipelineStageStateSucceeded CodePipelineStageState = "SUCCEEDED" 19 | CodePipelineStageStateResumed CodePipelineStageState = "RESUMED" 20 | CodePipelineStageStateFailed CodePipelineStageState = "FAILED" 21 | CodePipelineStageStateCanceled CodePipelineStageState = "CANCELED" 22 | ) 23 | 24 | type CodePipelineState string 25 | 26 | const ( 27 | CodePipelineStateStarted CodePipelineState = "STARTED" 28 | CodePipelineStateSucceeded CodePipelineState = "SUCCEEDED" 29 | CodePipelineStateResumed CodePipelineState = "RESUMED" 30 | CodePipelineStateFailed CodePipelineState = "FAILED" 31 | CodePipelineStateCanceled CodePipelineState = "CANCELED" 32 | CodePipelineStateSuperseded CodePipelineState = "SUPERSEDED" 33 | ) 34 | 35 | type CodePipelineActionState string 36 | 37 | const ( 38 | CodePipelineActionStateStarted CodePipelineActionState = "STARTED" 39 | CodePipelineActionStateSucceeded CodePipelineActionState = "SUCCEEDED" 40 | CodePipelineActionStateFailed CodePipelineActionState = "FAILED" 41 | CodePipelineActionStateCanceled CodePipelineActionState = "CANCELED" 42 | ) 43 | 44 | // CodePipelineEvent is documented at: 45 | // https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/EventTypes.html#codepipeline_event_type 46 | type CodePipelineCloudWatchEvent struct { 47 | // Version is the version of the event's schema. 48 | Version string `json:"version"` 49 | 50 | // ID is the GUID of this event. 51 | ID string `json:"id"` 52 | 53 | // DetailType informs the schema of the Detail field. For deployment state-change 54 | // events, the value should be equal to CodePipelineDeploymentEventDetailType. 55 | // For instance state-change events, the value should be equal to 56 | // CodePipelineInstanceEventDetailType. 57 | DetailType string `json:"detail-type"` 58 | 59 | // Source should be equal to CodePipelineEventSource. 60 | Source string `json:"source"` 61 | 62 | // AccountID is the id of the AWS account from which the event originated. 63 | AccountID string `json:"account"` 64 | 65 | // Time is the event's timestamp. 66 | Time time.Time `json:"time"` 67 | 68 | // Region is the AWS region from which the event originated. 69 | Region string `json:"region"` 70 | 71 | // Resources is a list of ARNs of CodePipeline applications and deployment 72 | // groups that this event pertains to. 73 | Resources []string `json:"resources"` 74 | 75 | // Detail contains information specific to a deployment event. 76 | Detail CodePipelineEventDetail `json:"detail"` 77 | } 78 | 79 | type CodePipelineEventDetail struct { 80 | Pipeline string `json:"pipeline"` 81 | 82 | // From live testing this is always int64 not string as documented 83 | Version int64 `json:"version"` 84 | 85 | ExecutionID string `json:"execution-id"` 86 | 87 | Stage string `json:"stage"` 88 | 89 | Action string `json:"action"` 90 | 91 | State CodePipelineState `json:"state"` 92 | 93 | Region string `json:"region"` 94 | 95 | Type CodePipelineEventDetailType `json:"type"` 96 | } 97 | 98 | type CodePipelineEventDetailType struct { 99 | Owner string `json:"owner"` 100 | 101 | Category string `json:"category"` 102 | 103 | Provider string `json:"provider"` 104 | 105 | // From published EventBridge schema registry this is always int64 not string as documented 106 | Version int64 `json:"version"` 107 | } 108 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/code_commit.go: -------------------------------------------------------------------------------- 1 | package events 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | "time" 7 | ) 8 | 9 | // CodeCommitEvent represents a CodeCommit event 10 | type CodeCommitEvent struct { 11 | Records []CodeCommitRecord `json:"Records"` 12 | } 13 | 14 | // String returns a string representation of this object. 15 | // Useful for testing and debugging. 16 | func (e CodeCommitEvent) String() string { 17 | return fmt.Sprintf("{Records: %v}", e.Records) 18 | } 19 | 20 | type CodeCommitEventTime time.Time 21 | 22 | // https://golang.org/pkg/time/#Parse 23 | const codeCommitEventTimeReference = "\"2006-01-2T15:04:05.000-0700\"" 24 | 25 | func (t *CodeCommitEventTime) MarshalJSON() ([]byte, error) { 26 | if t == nil { 27 | return nil, errors.New("CodeCommitEventTime cannot be nil") 28 | } 29 | 30 | gt := time.Time(*t) 31 | return []byte(gt.Format(codeCommitEventTimeReference)), nil 32 | } 33 | 34 | func (t *CodeCommitEventTime) UnmarshalJSON(data []byte) error { 35 | if t == nil { 36 | return errors.New("CodeCommitEventTime cannot be nil") 37 | } 38 | 39 | pt, err := time.Parse(codeCommitEventTimeReference, string(data)) 40 | if err == nil { 41 | *t = CodeCommitEventTime(pt) 42 | } 43 | return err 44 | } 45 | 46 | // CodeCommitRecord represents a CodeCommit record 47 | type CodeCommitRecord struct { 48 | EventID string `json:"eventId"` 49 | EventVersion string `json:"eventVersion"` 50 | EventTime CodeCommitEventTime `json:"eventTime"` 51 | EventTriggerName string `json:"eventTriggerName"` 52 | EventPartNumber uint64 `json:"eventPartNumber"` 53 | CodeCommit CodeCommitCodeCommit `json:"codecommit"` 54 | EventName string `json:"eventName"` 55 | EventTriggerConfigId string `json:"eventTriggerConfigId"` //nolint: stylecheck 56 | EventSourceARN string `json:"eventSourceARN"` 57 | UserIdentityARN string `json:"userIdentityARN"` 58 | EventSource string `json:"eventSource"` 59 | AWSRegion string `json:"awsRegion"` 60 | EventTotalParts uint64 `json:"eventTotalParts"` 61 | CustomData string `json:"customData,omitempty"` 62 | } 63 | 64 | // String returns a string representation of this object. 65 | // Useful for testing and debugging. 66 | func (r CodeCommitRecord) String() string { 67 | return fmt.Sprintf( 68 | "{eventId: %v, eventVersion: %v, eventTime: %v, eventTriggerName: %v, "+ 69 | "eventPartNumber: %v, codeCommit: %v, eventName: %v, "+ 70 | "eventTriggerConfigId: %v, eventSourceARN: %v, userIdentityARN: %v, "+ 71 | "eventSource: %v, awsRegion: %v, eventTotalParts: %v, customData: %v}", 72 | r.EventID, r.EventVersion, r.EventTime, r.EventTriggerName, 73 | r.EventPartNumber, r.CodeCommit, r.EventName, 74 | r.EventTriggerConfigId, r.EventSourceARN, r.UserIdentityARN, 75 | r.EventSource, r.AWSRegion, r.EventTotalParts, r.CustomData) 76 | } 77 | 78 | // CodeCommitCodeCommit represents a CodeCommit object in a record 79 | type CodeCommitCodeCommit struct { 80 | References []CodeCommitReference `json:"references"` 81 | } 82 | 83 | // String returns a string representation of this object. 84 | // Useful for testing and debugging. 85 | func (c CodeCommitCodeCommit) String() string { 86 | return fmt.Sprintf("{references: %v}", c.References) 87 | } 88 | 89 | // CodeCommitReference represents a Reference object in a CodeCommit object 90 | type CodeCommitReference struct { 91 | Commit string `json:"commit"` 92 | Ref string `json:"ref"` 93 | Created bool `json:"created,omitempty"` 94 | } 95 | 96 | // String returns a string representation of this object. 97 | // Useful for testing and debugging. 98 | func (r CodeCommitReference) String() string { 99 | return fmt.Sprintf( 100 | "{commit: %v, ref: %v, created: %v}", r.Commit, r.Ref, r.Created) 101 | } 102 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/lambda/entry.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | 3 | package lambda 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "log" 9 | "os" 10 | ) 11 | 12 | // Start takes a handler and talks to an internal Lambda endpoint to pass requests to the handler. If the 13 | // handler does not match one of the supported types an appropriate error message will be returned to the caller. 14 | // Start blocks, and does not return after being called. 15 | // 16 | // Rules: 17 | // 18 | // * handler must be a function 19 | // * handler may take between 0 and two arguments. 20 | // * if there are two arguments, the first argument must satisfy the "context.Context" interface. 21 | // * handler may return between 0 and two arguments. 22 | // * if there are two return values, the second argument must be an error. 23 | // * if there is one return value it must be an error. 24 | // 25 | // Valid function signatures: 26 | // 27 | // func () 28 | // func () error 29 | // func (TIn) error 30 | // func () (TOut, error) 31 | // func (TIn) (TOut, error) 32 | // func (context.Context) error 33 | // func (context.Context, TIn) error 34 | // func (context.Context) (TOut, error) 35 | // func (context.Context, TIn) (TOut, error) 36 | // 37 | // Where "TIn" and "TOut" are types compatible with the "encoding/json" standard library. 38 | // See https://golang.org/pkg/encoding/json/#Unmarshal for how deserialization behaves 39 | func Start(handler interface{}) { 40 | StartWithContext(context.Background(), handler) 41 | } 42 | 43 | // StartWithContext is the same as Start except sets the base context for the function. 44 | func StartWithContext(ctx context.Context, handler interface{}) { 45 | StartHandlerWithContext(ctx, NewHandler(handler)) 46 | } 47 | 48 | // StartHandler takes in a Handler wrapper interface which can be implemented either by a 49 | // custom function or a struct. 50 | // 51 | // Handler implementation requires a single "Invoke()" function: 52 | // 53 | // func Invoke(context.Context, []byte) ([]byte, error) 54 | func StartHandler(handler Handler) { 55 | StartHandlerWithContext(context.Background(), handler) 56 | } 57 | 58 | type startFunction struct { 59 | env string 60 | f func(ctx context.Context, envValue string, handler Handler) error 61 | } 62 | 63 | var ( 64 | // This allows users to save a little bit of coldstart time in the download, by the dependencies brought in for RPC support. 65 | // The tradeoff is dropping compatibility with the go1.x runtime, functions must be "Custom Runtime" instead. 66 | // To drop the rpc dependencies, compile with `-tags lambda.norpc` 67 | rpcStartFunction = &startFunction{ 68 | env: "_LAMBDA_SERVER_PORT", 69 | f: func(c context.Context, p string, h Handler) error { 70 | return errors.New("_LAMBDA_SERVER_PORT was present but the function was compiled without RPC support") 71 | }, 72 | } 73 | runtimeAPIStartFunction = &startFunction{ 74 | env: "AWS_LAMBDA_RUNTIME_API", 75 | f: startRuntimeAPILoop, 76 | } 77 | startFunctions = []*startFunction{rpcStartFunction, runtimeAPIStartFunction} 78 | 79 | // This allows end to end testing of the Start functions, by tests overwriting this function to keep the program alive 80 | logFatalf = log.Fatalf 81 | ) 82 | 83 | // StartHandlerWithContext is the same as StartHandler except sets the base context for the function. 84 | // 85 | // Handler implementation requires a single "Invoke()" function: 86 | // 87 | // func Invoke(context.Context, []byte) ([]byte, error) 88 | func StartHandlerWithContext(ctx context.Context, handler Handler) { 89 | var keys []string 90 | for _, start := range startFunctions { 91 | config := os.Getenv(start.env) 92 | if config != "" { 93 | // in normal operation, the start function never returns 94 | // if it does, exit!, this triggers a restart of the lambda function 95 | err := start.f(ctx, config, handler) 96 | logFatalf("%v", err) 97 | } 98 | keys = append(keys, start.env) 99 | } 100 | logFatalf("expected AWS Lambda environment variables %s are not defined", keys) 101 | } 102 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/lambda/invoke_loop.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved 2 | 3 | package lambda 4 | 5 | import ( 6 | "context" 7 | "encoding/json" 8 | "fmt" 9 | "log" 10 | "strconv" 11 | "time" 12 | 13 | "github.com/aws/aws-lambda-go/lambda/messages" 14 | ) 15 | 16 | const ( 17 | msPerS = int64(time.Second / time.Millisecond) 18 | nsPerMS = int64(time.Millisecond / time.Nanosecond) 19 | ) 20 | 21 | // startRuntimeAPILoop will return an error if handling a particular invoke resulted in a non-recoverable error 22 | func startRuntimeAPILoop(ctx context.Context, api string, handler Handler) error { 23 | client := newRuntimeAPIClient(api) 24 | function := NewFunction(handler).withContext(ctx) 25 | for { 26 | invoke, err := client.next() 27 | if err != nil { 28 | return err 29 | } 30 | 31 | err = handleInvoke(invoke, function) 32 | if err != nil { 33 | return err 34 | } 35 | } 36 | } 37 | 38 | // handleInvoke returns an error if the function panics, or some other non-recoverable error occurred 39 | func handleInvoke(invoke *invoke, function *Function) error { 40 | functionRequest, err := convertInvokeRequest(invoke) 41 | if err != nil { 42 | return fmt.Errorf("unexpected error occurred when parsing the invoke: %v", err) 43 | } 44 | 45 | functionResponse := &messages.InvokeResponse{} 46 | if err := function.Invoke(functionRequest, functionResponse); err != nil { 47 | return fmt.Errorf("unexpected error occurred when invoking the handler: %v", err) 48 | } 49 | 50 | if functionResponse.Error != nil { 51 | errorPayload := safeMarshal(functionResponse.Error) 52 | log.Printf("%s", errorPayload) 53 | if err := invoke.failure(errorPayload, contentTypeJSON); err != nil { 54 | return fmt.Errorf("unexpected error occurred when sending the function error to the API: %v", err) 55 | } 56 | if functionResponse.Error.ShouldExit { 57 | return fmt.Errorf("calling the handler function resulted in a panic, the process should exit") 58 | } 59 | return nil 60 | } 61 | 62 | if err := invoke.success(functionResponse.Payload, contentTypeJSON); err != nil { 63 | return fmt.Errorf("unexpected error occurred when sending the function functionResponse to the API: %v", err) 64 | } 65 | 66 | return nil 67 | } 68 | 69 | // convertInvokeRequest converts an invoke from the Runtime API, and unpacks it to be compatible with the shape of a `lambda.Function` InvokeRequest. 70 | func convertInvokeRequest(invoke *invoke) (*messages.InvokeRequest, error) { 71 | deadlineEpochMS, err := strconv.ParseInt(invoke.headers.Get(headerDeadlineMS), 10, 64) 72 | if err != nil { 73 | return nil, fmt.Errorf("failed to parse contents of header: %s", headerDeadlineMS) 74 | } 75 | deadlineS := deadlineEpochMS / msPerS 76 | deadlineNS := (deadlineEpochMS % msPerS) * nsPerMS 77 | 78 | res := &messages.InvokeRequest{ 79 | InvokedFunctionArn: invoke.headers.Get(headerInvokedFunctionARN), 80 | XAmznTraceId: invoke.headers.Get(headerTraceID), 81 | RequestId: invoke.id, 82 | Deadline: messages.InvokeRequest_Timestamp{ 83 | Seconds: deadlineS, 84 | Nanos: deadlineNS, 85 | }, 86 | Payload: invoke.payload, 87 | } 88 | 89 | clientContextJSON := invoke.headers.Get(headerClientContext) 90 | if clientContextJSON != "" { 91 | res.ClientContext = []byte(clientContextJSON) 92 | } 93 | 94 | cognitoIdentityJSON := invoke.headers.Get(headerCognitoIdentity) 95 | if cognitoIdentityJSON != "" { 96 | if err := json.Unmarshal([]byte(invoke.headers.Get(headerCognitoIdentity)), res); err != nil { 97 | return nil, fmt.Errorf("failed to unmarshal cognito identity json: %v", err) 98 | } 99 | } 100 | 101 | return res, nil 102 | } 103 | 104 | func safeMarshal(v interface{}) []byte { 105 | payload, err := json.Marshal(v) 106 | if err != nil { 107 | v := &messages.InvokeResponse_Error{ 108 | Type: "Runtime.SerializationError", 109 | Message: err.Error(), 110 | } 111 | payload, err := json.Marshal(v) 112 | if err != nil { 113 | panic(err) // never reach 114 | } 115 | return payload 116 | } 117 | return payload 118 | } 119 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/ses.go: -------------------------------------------------------------------------------- 1 | package events 2 | 3 | import "time" 4 | 5 | // SimpleEmailEvent is the outer structure of an event sent via SES. 6 | type SimpleEmailEvent struct { 7 | Records []SimpleEmailRecord `json:"Records"` 8 | } 9 | 10 | type SimpleEmailRecord struct { 11 | EventVersion string `json:"eventVersion"` 12 | EventSource string `json:"eventSource"` 13 | SES SimpleEmailService `json:"ses"` 14 | } 15 | 16 | type SimpleEmailService struct { 17 | Mail SimpleEmailMessage `json:"mail"` 18 | Receipt SimpleEmailReceipt `json:"receipt"` 19 | } 20 | 21 | type SimpleEmailMessage struct { 22 | CommonHeaders SimpleEmailCommonHeaders `json:"commonHeaders"` 23 | Source string `json:"source"` 24 | Timestamp time.Time `json:"timestamp"` 25 | Destination []string `json:"destination"` 26 | Headers []SimpleEmailHeader `json:"headers"` 27 | HeadersTruncated bool `json:"headersTruncated"` 28 | MessageID string `json:"messageId"` 29 | } 30 | 31 | type SimpleEmailReceipt struct { 32 | Recipients []string `json:"recipients"` 33 | Timestamp time.Time `json:"timestamp"` 34 | SpamVerdict SimpleEmailVerdict `json:"spamVerdict"` 35 | DKIMVerdict SimpleEmailVerdict `json:"dkimVerdict"` 36 | DMARCVerdict SimpleEmailVerdict `json:"dmarcVerdict"` 37 | DMARCPolicy string `json:"dmarcPolicy"` 38 | SPFVerdict SimpleEmailVerdict `json:"spfVerdict"` 39 | VirusVerdict SimpleEmailVerdict `json:"virusVerdict"` 40 | Action SimpleEmailReceiptAction `json:"action"` 41 | ProcessingTimeMillis int64 `json:"processingTimeMillis"` 42 | } 43 | 44 | type SimpleEmailHeader struct { 45 | Name string `json:"name"` 46 | Value string `json:"value"` 47 | } 48 | 49 | type SimpleEmailCommonHeaders struct { 50 | From []string `json:"from"` 51 | To []string `json:"to"` 52 | ReturnPath string `json:"returnPath"` 53 | MessageID string `json:"messageId"` 54 | Date string `json:"date"` 55 | Subject string `json:"subject"` 56 | } 57 | 58 | // SimpleEmailReceiptAction is a logical union of fields present in all action 59 | // Types. For example, the FunctionARN and InvocationType fields are only 60 | // present for the Lambda Type, and the BucketName and ObjectKey fields are only 61 | // present for the S3 Type. 62 | type SimpleEmailReceiptAction struct { 63 | Type string `json:"type"` 64 | TopicARN string `json:"topicArn,omitempty"` 65 | BucketName string `json:"bucketName,omitempty"` 66 | ObjectKey string `json:"objectKey,omitempty"` 67 | SMTPReplyCode string `json:"smtpReplyCode,omitempty"` 68 | StatusCode string `json:"statusCode,omitempty"` 69 | Message string `json:"message,omitempty"` 70 | Sender string `json:"sender,omitempty"` 71 | InvocationType string `json:"invocationType,omitempty"` 72 | FunctionARN string `json:"functionArn,omitempty"` 73 | OrganizationARN string `json:"organizationArn,omitempty"` 74 | } 75 | 76 | type SimpleEmailVerdict struct { 77 | Status string `json:"status"` 78 | } 79 | 80 | // SimpleEmailDispositionValue enumeration representing the dispostition value for SES 81 | type SimpleEmailDispositionValue string 82 | 83 | const ( 84 | // SimpleEmailContinue represents the CONTINUE disposition which tells the SES Rule Set to continue to the next rule 85 | SimpleEmailContinue SimpleEmailDispositionValue = "CONTINUE" 86 | // SimpleEmailStopRule represents the STOP_RULE disposition which tells the SES Rule Set to stop processing this rule and continue to the next 87 | SimpleEmailStopRule SimpleEmailDispositionValue = "STOP_RULE" 88 | // SimpleEmailStopRuleSet represents the STOP_RULE_SET disposition which tells the SES Rule SEt to stop processing all rules 89 | SimpleEmailStopRuleSet SimpleEmailDispositionValue = "STOP_RULE_SET" 90 | ) 91 | 92 | // SimpleEmailDisposition disposition return for SES to control rule functions 93 | type SimpleEmailDisposition struct { 94 | Disposition SimpleEmailDispositionValue `json:"disposition"` 95 | } 96 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/sns.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | 3 | package events 4 | 5 | import ( 6 | "time" 7 | ) 8 | 9 | type SNSEvent struct { 10 | Records []SNSEventRecord `json:"Records"` 11 | } 12 | 13 | type SNSEventRecord struct { 14 | EventVersion string `json:"EventVersion"` 15 | EventSubscriptionArn string `json:"EventSubscriptionArn"` //nolint: stylecheck 16 | EventSource string `json:"EventSource"` 17 | SNS SNSEntity `json:"Sns"` 18 | } 19 | 20 | type SNSEntity struct { 21 | Signature string `json:"Signature"` 22 | MessageID string `json:"MessageId"` 23 | Type string `json:"Type"` 24 | TopicArn string `json:"TopicArn"` //nolint: stylecheck 25 | MessageAttributes map[string]interface{} `json:"MessageAttributes"` 26 | SignatureVersion string `json:"SignatureVersion"` 27 | Timestamp time.Time `json:"Timestamp"` 28 | SigningCertURL string `json:"SigningCertUrl"` 29 | Message string `json:"Message"` 30 | UnsubscribeURL string `json:"UnsubscribeUrl"` 31 | Subject string `json:"Subject"` 32 | } 33 | 34 | type CloudWatchAlarmSNSPayload struct { 35 | AlarmName string `json:"AlarmName"` 36 | AlarmDescription string `json:"AlarmDescription"` 37 | AWSAccountID string `json:"AWSAccountId"` 38 | NewStateValue string `json:"NewStateValue"` 39 | NewStateReason string `json:"NewStateReason"` 40 | StateChangeTime string `json:"StateChangeTime"` 41 | Region string `json:"Region"` 42 | AlarmARN string `json:"AlarmArn"` 43 | OldStateValue string `json:"OldStateValue"` 44 | Trigger CloudWatchAlarmTrigger `json:"Trigger"` 45 | } 46 | 47 | type CloudWatchAlarmTrigger struct { 48 | Period int64 `json:"Period"` 49 | EvaluationPeriods int64 `json:"EvaluationPeriods"` 50 | ComparisonOperator string `json:"ComparisonOperator"` 51 | Threshold float64 `json:"Threshold"` 52 | TreatMissingData string `json:"TreatMissingData"` 53 | EvaluateLowSampleCountPercentile string `json:"EvaluateLowSampleCountPercentile"` 54 | Metrics []CloudWatchMetricDataQuery `json:"Metrics,omitempty"` 55 | MetricName string `json:"MetricName,omitempty"` 56 | Namespace string `json:"Namespace,omitempty"` 57 | StatisticType string `json:"StatisticType,omitempty"` 58 | Statistic string `json:"Statistic,omitempty"` 59 | Unit string `json:"Unit,omitempty"` 60 | Dimensions []CloudWatchDimension `json:"Dimensions,omitempty"` 61 | } 62 | 63 | type CloudWatchMetricDataQuery struct { 64 | Expression string `json:"Expression,omitempty"` 65 | ID string `json:"Id"` 66 | Label string `json:"Label,omitempty"` 67 | MetricStat CloudWatchMetricStat `json:"MetricStat,omitempty"` 68 | Period int64 `json:"Period,omitempty"` 69 | ReturnData bool `json:"ReturnData,omitempty"` 70 | } 71 | 72 | type CloudWatchMetricStat struct { 73 | Metric CloudWatchMetric `json:"Metric"` 74 | Period int64 `json:"Period"` 75 | Stat string `json:"Stat"` 76 | Unit string `json:"Unit,omitempty"` 77 | } 78 | 79 | type CloudWatchMetric struct { 80 | Dimensions []CloudWatchDimension `json:"Dimensions,omitempty"` 81 | MetricName string `json:"MetricName,omitempty"` 82 | Namespace string `json:"Namespace,omitempty"` 83 | } 84 | 85 | type CloudWatchDimension struct { 86 | Name string `json:"name"` 87 | Value string `json:"value"` 88 | } 89 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/lib/api-stack.ts: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: MIT-0 3 | import * as cdk from 'aws-cdk-lib'; 4 | import * as lambda from 'aws-cdk-lib/aws-lambda'; 5 | import * as apigatewayv2 from '@aws-cdk/aws-apigatewayv2-alpha'; 6 | import * as integrations from '@aws-cdk/aws-apigatewayv2-integrations-alpha'; 7 | import * as path from 'path'; 8 | import { Construct } from 'constructs'; 9 | import { spawnSync, SpawnSyncOptions } from 'child_process'; 10 | 11 | export class ApiStack extends cdk.Stack { 12 | constructor(scope: Construct, id: string, props?: cdk.StackProps) { 13 | super(scope, id, props); 14 | 15 | const entry = path.join(__dirname, '../functions/hello'); 16 | const environment = { 17 | CGO_ENABLED: '0', 18 | GOOS: 'linux', 19 | GOARCH: 'amd64', 20 | }; 21 | 22 | const handler = new lambda.Function(this, 'GolangFunction', { 23 | code: lambda.Code.fromAsset(entry, { 24 | bundling: { 25 | // try to bundle on the local machine 26 | local: { 27 | tryBundle(outputDir: string) { 28 | 29 | // make sure that we have all the required 30 | // dependencies to build the executable locally. 31 | // In this case we just check to make sure we have 32 | // go installed 33 | try { 34 | exec('go version', { 35 | stdio: [ // show output 36 | 'ignore', //ignore stdio 37 | process.stderr, // redirect stdout to stderr 38 | 'inherit' // inherit stderr 39 | ], 40 | }); 41 | } catch { 42 | // if we don't have go installed return false which 43 | // tells the CDK to try Docker bundling 44 | return false 45 | } 46 | 47 | exec( 48 | [ 49 | 'go test -v', // run tests first 50 | `go build -mod=vendor -o ${path.join(outputDir, 'bootstrap')}` 51 | ].join(' && '), 52 | { 53 | env: { ...process.env, ...environment }, // environment variables to use when running the build command 54 | stdio: [ // show output 55 | 'ignore', //ignore stdio 56 | process.stderr, // redirect stdout to stderr 57 | 'inherit' // inherit stderr 58 | ], 59 | cwd: entry, // where to run the build command from 60 | }, 61 | ); 62 | return true 63 | }, 64 | }, 65 | image: lambda.Runtime.GO_1_X.bundlingImage, // lambci/lambda:build-go1.x 66 | command: [ 67 | 'bash', '-c', [ 68 | 'go test -v', 69 | 'go build -mod=vendor -o /asset-output/bootstrap', 70 | ].join(' && ') 71 | ], 72 | environment: environment, 73 | }, 74 | }), 75 | handler: 'bootstrap', // if we name our handler 'bootstrap' we can also use the 'provided' runtime 76 | runtime: lambda.Runtime.GO_1_X, 77 | }); 78 | 79 | const api = new apigatewayv2.HttpApi(this, 'HelloApi', { 80 | createDefaultStage: true, 81 | corsPreflight: { 82 | allowMethods: [ apigatewayv2.CorsHttpMethod.GET ], 83 | allowOrigins: ['*'] 84 | } 85 | }); 86 | 87 | api.addRoutes({ 88 | path: '/hello', 89 | integration: new integrations.HttpLambdaIntegration('hello', handler), 90 | methods: [apigatewayv2.HttpMethod.GET] 91 | }); 92 | 93 | new cdk.CfnOutput(this, 'ApiUrlOutput', { value: api.url! }); 94 | } 95 | } 96 | 97 | 98 | function exec(command: string, options?: SpawnSyncOptions) { 99 | const proc = spawnSync('bash', ['-c', command], options); 100 | 101 | if (proc.error) { 102 | throw proc.error; 103 | } 104 | 105 | if (proc.status != 0) { 106 | if (proc.stdout || proc.stderr) { 107 | throw new Error(`[Status ${proc.status}] stdout: ${proc.stdout?.toString().trim()}\n\n\nstderr: ${proc.stderr?.toString().trim()}`); 108 | } 109 | throw new Error(`go exited with status ${proc.status}`); 110 | } 111 | 112 | return proc; 113 | } 114 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/lambda/handler.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | 3 | package lambda 4 | 5 | import ( 6 | "context" 7 | "encoding/json" 8 | "fmt" 9 | "reflect" 10 | 11 | "github.com/aws/aws-lambda-go/lambda/handlertrace" 12 | ) 13 | 14 | type Handler interface { 15 | Invoke(ctx context.Context, payload []byte) ([]byte, error) 16 | } 17 | 18 | // lambdaHandler is the generic function type 19 | type lambdaHandler func(context.Context, []byte) (interface{}, error) 20 | 21 | // Invoke calls the handler, and serializes the response. 22 | // If the underlying handler returned an error, or an error occurs during serialization, error is returned. 23 | func (handler lambdaHandler) Invoke(ctx context.Context, payload []byte) ([]byte, error) { 24 | response, err := handler(ctx, payload) 25 | if err != nil { 26 | return nil, err 27 | } 28 | 29 | responseBytes, err := json.Marshal(response) 30 | if err != nil { 31 | return nil, err 32 | } 33 | 34 | return responseBytes, nil 35 | } 36 | 37 | func errorHandler(e error) lambdaHandler { 38 | return func(ctx context.Context, event []byte) (interface{}, error) { 39 | return nil, e 40 | } 41 | } 42 | 43 | func validateArguments(handler reflect.Type) (bool, error) { 44 | handlerTakesContext := false 45 | if handler.NumIn() > 2 { 46 | return false, fmt.Errorf("handlers may not take more than two arguments, but handler takes %d", handler.NumIn()) 47 | } else if handler.NumIn() > 0 { 48 | contextType := reflect.TypeOf((*context.Context)(nil)).Elem() 49 | argumentType := handler.In(0) 50 | handlerTakesContext = argumentType.Implements(contextType) 51 | if handler.NumIn() > 1 && !handlerTakesContext { 52 | return false, fmt.Errorf("handler takes two arguments, but the first is not Context. got %s", argumentType.Kind()) 53 | } 54 | } 55 | 56 | return handlerTakesContext, nil 57 | } 58 | 59 | func validateReturns(handler reflect.Type) error { 60 | errorType := reflect.TypeOf((*error)(nil)).Elem() 61 | 62 | switch n := handler.NumOut(); { 63 | case n > 2: 64 | return fmt.Errorf("handler may not return more than two values") 65 | case n > 1: 66 | if !handler.Out(1).Implements(errorType) { 67 | return fmt.Errorf("handler returns two values, but the second does not implement error") 68 | } 69 | case n == 1: 70 | if !handler.Out(0).Implements(errorType) { 71 | return fmt.Errorf("handler returns a single value, but it does not implement error") 72 | } 73 | } 74 | 75 | return nil 76 | } 77 | 78 | // NewHandler creates a base lambda handler from the given handler function. The 79 | // returned Handler performs JSON serialization and deserialization, and 80 | // delegates to the input handler function. The handler function parameter must 81 | // satisfy the rules documented by Start. If handlerFunc is not a valid 82 | // handler, the returned Handler simply reports the validation error. 83 | func NewHandler(handlerFunc interface{}) Handler { 84 | if handlerFunc == nil { 85 | return errorHandler(fmt.Errorf("handler is nil")) 86 | } 87 | handler := reflect.ValueOf(handlerFunc) 88 | handlerType := reflect.TypeOf(handlerFunc) 89 | if handlerType.Kind() != reflect.Func { 90 | return errorHandler(fmt.Errorf("handler kind %s is not %s", handlerType.Kind(), reflect.Func)) 91 | } 92 | 93 | takesContext, err := validateArguments(handlerType) 94 | if err != nil { 95 | return errorHandler(err) 96 | } 97 | 98 | if err := validateReturns(handlerType); err != nil { 99 | return errorHandler(err) 100 | } 101 | 102 | return lambdaHandler(func(ctx context.Context, payload []byte) (interface{}, error) { 103 | 104 | trace := handlertrace.FromContext(ctx) 105 | 106 | // construct arguments 107 | var args []reflect.Value 108 | if takesContext { 109 | args = append(args, reflect.ValueOf(ctx)) 110 | } 111 | if (handlerType.NumIn() == 1 && !takesContext) || handlerType.NumIn() == 2 { 112 | eventType := handlerType.In(handlerType.NumIn() - 1) 113 | event := reflect.New(eventType) 114 | 115 | if err := json.Unmarshal(payload, event.Interface()); err != nil { 116 | return nil, err 117 | } 118 | if nil != trace.RequestEvent { 119 | trace.RequestEvent(ctx, event.Elem().Interface()) 120 | } 121 | args = append(args, event.Elem()) 122 | } 123 | 124 | response := handler.Call(args) 125 | 126 | // convert return values into (interface{}, error) 127 | var err error 128 | if len(response) > 0 { 129 | if errVal, ok := response[len(response)-1].Interface().(error); ok { 130 | err = errVal 131 | } 132 | } 133 | var val interface{} 134 | if len(response) > 1 { 135 | val = response[0].Interface() 136 | 137 | if nil != trace.ResponseEvent { 138 | trace.ResponseEvent(ctx, val) 139 | } 140 | } 141 | 142 | return val, err 143 | }) 144 | } 145 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/lambda/runtime_api_client.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved 2 | // 3 | // Runtime API documentation: https://docs.aws.amazon.com/lambda/latest/dg/runtimes-api.html 4 | 5 | package lambda 6 | 7 | import ( 8 | "bytes" 9 | "fmt" 10 | "io" 11 | "io/ioutil" 12 | "log" 13 | "net/http" 14 | "runtime" 15 | ) 16 | 17 | const ( 18 | headerAWSRequestID = "Lambda-Runtime-Aws-Request-Id" 19 | headerDeadlineMS = "Lambda-Runtime-Deadline-Ms" 20 | headerTraceID = "Lambda-Runtime-Trace-Id" 21 | headerCognitoIdentity = "Lambda-Runtime-Cognito-Identity" 22 | headerClientContext = "Lambda-Runtime-Client-Context" 23 | headerInvokedFunctionARN = "Lambda-Runtime-Invoked-Function-Arn" 24 | contentTypeJSON = "application/json" 25 | apiVersion = "2018-06-01" 26 | ) 27 | 28 | type runtimeAPIClient struct { 29 | baseURL string 30 | userAgent string 31 | httpClient *http.Client 32 | buffer *bytes.Buffer 33 | } 34 | 35 | func newRuntimeAPIClient(address string) *runtimeAPIClient { 36 | client := &http.Client{ 37 | Timeout: 0, // connections to the runtime API are never expected to time out 38 | } 39 | endpoint := "http://" + address + "/" + apiVersion + "/runtime/invocation/" 40 | userAgent := "aws-lambda-go/" + runtime.Version() 41 | return &runtimeAPIClient{endpoint, userAgent, client, bytes.NewBuffer(nil)} 42 | } 43 | 44 | type invoke struct { 45 | id string 46 | payload []byte 47 | headers http.Header 48 | client *runtimeAPIClient 49 | } 50 | 51 | // success sends the response payload for an in-progress invocation. 52 | // Notes: 53 | // * An invoke is not complete until next() is called again! 54 | func (i *invoke) success(payload []byte, contentType string) error { 55 | url := i.client.baseURL + i.id + "/response" 56 | return i.client.post(url, payload, contentType) 57 | } 58 | 59 | // failure sends the payload to the Runtime API. This marks the function's invoke as a failure. 60 | // Notes: 61 | // * The execution of the function process continues, and is billed, until next() is called again! 62 | // * A Lambda Function continues to be re-used for future invokes even after a failure. 63 | // If the error is fatal (panic, unrecoverable state), exit the process immediately after calling failure() 64 | func (i *invoke) failure(payload []byte, contentType string) error { 65 | url := i.client.baseURL + i.id + "/error" 66 | return i.client.post(url, payload, contentType) 67 | } 68 | 69 | // next connects to the Runtime API and waits for a new invoke Request to be available. 70 | // Note: After a call to Done() or Error() has been made, a call to next() will complete the in-flight invoke. 71 | func (c *runtimeAPIClient) next() (*invoke, error) { 72 | url := c.baseURL + "next" 73 | req, err := http.NewRequest(http.MethodGet, url, nil) 74 | if err != nil { 75 | return nil, fmt.Errorf("failed to construct GET request to %s: %v", url, err) 76 | } 77 | req.Header.Set("User-Agent", c.userAgent) 78 | 79 | resp, err := c.httpClient.Do(req) 80 | if err != nil { 81 | return nil, fmt.Errorf("failed to get the next invoke: %v", err) 82 | } 83 | defer func() { 84 | if err := resp.Body.Close(); err != nil { 85 | log.Printf("runtime API client failed to close %s response body: %v", url, err) 86 | } 87 | }() 88 | 89 | if resp.StatusCode != http.StatusOK { 90 | return nil, fmt.Errorf("failed to GET %s: got unexpected status code: %d", url, resp.StatusCode) 91 | } 92 | 93 | c.buffer.Reset() 94 | _, err = c.buffer.ReadFrom(resp.Body) 95 | if err != nil { 96 | return nil, fmt.Errorf("failed to read the invoke payload: %v", err) 97 | } 98 | 99 | return &invoke{ 100 | id: resp.Header.Get(headerAWSRequestID), 101 | payload: c.buffer.Bytes(), 102 | headers: resp.Header, 103 | client: c, 104 | }, nil 105 | } 106 | 107 | func (c *runtimeAPIClient) post(url string, payload []byte, contentType string) error { 108 | req, err := http.NewRequest(http.MethodPost, url, bytes.NewBuffer(payload)) 109 | if err != nil { 110 | return fmt.Errorf("failed to construct POST request to %s: %v", url, err) 111 | } 112 | req.Header.Set("User-Agent", c.userAgent) 113 | req.Header.Set("Content-Type", contentType) 114 | 115 | resp, err := c.httpClient.Do(req) 116 | if err != nil { 117 | return fmt.Errorf("failed to POST to %s: %v", url, err) 118 | } 119 | defer func() { 120 | if err := resp.Body.Close(); err != nil { 121 | log.Printf("runtime API client failed to close %s response body: %v", url, err) 122 | } 123 | }() 124 | 125 | if resp.StatusCode != http.StatusAccepted { 126 | return fmt.Errorf("failed to POST to %s: got unexpected status code: %d", url, resp.StatusCode) 127 | } 128 | 129 | _, err = io.Copy(ioutil.Discard, resp.Body) 130 | if err != nil { 131 | return fmt.Errorf("something went wrong reading the POST response from %s: %v", url, err) 132 | } 133 | 134 | return nil 135 | } 136 | -------------------------------------------------------------------------------- /cdk-bundle-static-site-example/lib/static-site-stack.ts: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: MIT-0 3 | import * as cdk from 'aws-cdk-lib'; 4 | import * as fs from 'fs-extra'; 5 | import * as s3 from 'aws-cdk-lib/aws-s3'; 6 | import * as cloudfront from 'aws-cdk-lib/aws-cloudfront'; 7 | import * as origins from 'aws-cdk-lib/aws-cloudfront-origins'; 8 | import * as s3_deployment from 'aws-cdk-lib/aws-s3-deployment'; 9 | import { Construct } from 'constructs'; 10 | import * as path from 'path'; 11 | import { spawnSync, SpawnSyncOptions } from 'child_process'; 12 | 13 | 14 | export interface StaticSiteStackProps extends cdk.StackProps { 15 | buildEnvironment?: { [key: string]: string }; 16 | } 17 | 18 | export class StaticSiteStack extends cdk.Stack { 19 | constructor(scope: Construct, id: string, props?: StaticSiteStackProps) { 20 | super(scope, id, props); 21 | 22 | const bucket = new s3.Bucket(this, 'HostingStorage', { 23 | bucketName: cdk.PhysicalName.GENERATE_IF_NEEDED, 24 | encryption: s3.BucketEncryption.S3_MANAGED, 25 | accessControl: s3.BucketAccessControl.PRIVATE, 26 | blockPublicAccess: s3.BlockPublicAccess.BLOCK_ALL, 27 | }); 28 | 29 | const distribution = new cloudfront.Distribution(this, 'Distribution', { 30 | defaultBehavior: { 31 | origin: new origins.S3Origin(bucket), 32 | allowedMethods: cloudfront.AllowedMethods.ALLOW_GET_HEAD_OPTIONS, 33 | viewerProtocolPolicy: cloudfront.ViewerProtocolPolicy.REDIRECT_TO_HTTPS, 34 | }, 35 | defaultRootObject: 'index.html', 36 | priceClass: cloudfront.PriceClass.PRICE_CLASS_100, 37 | }); 38 | 39 | new cdk.CfnOutput(this, 'CloudFrontUrlOutput', { value: distribution.distributionDomainName }); 40 | 41 | const entry = path.join(__dirname, '../frontend'); // path to the Nuxt.js app 42 | new s3_deployment.BucketDeployment(this, 'Deployment', { 43 | sources: [ 44 | s3_deployment.Source.asset(entry, { 45 | bundling: { 46 | // try to bundle on the local machine 47 | local: { 48 | tryBundle(outputDir: string) { 49 | // make sure we have all the required 50 | // dependencies to build the site locally. 51 | // In this case we just check to make sure 52 | // we have yarn installed 53 | try { 54 | exec('yarn --version', { 55 | stdio: [ // show output 56 | 'ignore', //ignore stdio 57 | process.stderr, // redirect stdout to stderr 58 | 'inherit' // inherit stderr 59 | ], 60 | }); 61 | } catch { 62 | // if we don't have yarn installed return false 63 | // which tells the CDK to try Docker bundling 64 | return false 65 | } 66 | 67 | try { 68 | exec( 69 | [ 70 | 'yarn install', 71 | 'yarn generate' 72 | ].join(' && '), 73 | { 74 | env: { ...process.env, ...props?.buildEnvironment ?? {} }, // environment variables to use when running the build command 75 | stdio: [ // show output 76 | 'ignore', //ignore stdio 77 | process.stderr, // redirect stdout to stderr 78 | 'inherit' // inherit stderr 79 | ], 80 | cwd: entry // where to run the build command from, i.e. the directory where our nuxt.js app is located 81 | } 82 | ) 83 | 84 | } catch { 85 | return false 86 | } 87 | 88 | try { 89 | // copy the dist directory that is created with 'yarn generate' 90 | // to the cdk outDir 91 | fs.copySync(path.join(entry, 'dist'), outputDir); 92 | } catch { 93 | return false 94 | } 95 | 96 | return true 97 | }, 98 | }, 99 | image: cdk.DockerImage.fromRegistry('node:lts'), 100 | command: [ 101 | 'bash', '-c', [ 102 | 'cd /asset-input', 103 | 'yarn install', 104 | 'yarn generate', 105 | 'cp -r /asset-input/dist/* /asset-output/', 106 | ].join(' && ') 107 | ], 108 | environment: props?.buildEnvironment 109 | } 110 | }) 111 | ], 112 | destinationBucket: bucket, 113 | distribution, 114 | memoryLimit: 256, 115 | }); 116 | } 117 | } 118 | 119 | function exec(command: string, options?: SpawnSyncOptions) { 120 | const proc = spawnSync('bash', ['-c', command], options); 121 | 122 | if (proc.error) { 123 | throw proc.error; 124 | } 125 | 126 | if (proc.status != 0) { 127 | if (proc.stdout || proc.stderr) { 128 | throw new Error(`[Status ${proc.status}] stdout: ${proc.stdout?.toString().trim()}\n\n\nstderr: ${proc.stderr?.toString().trim()}`); 129 | } 130 | throw new Error(`exited with status ${proc.status}`); 131 | } 132 | 133 | return proc; 134 | } 135 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/dynamodb.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | 3 | package events 4 | 5 | // The DynamoDBEvent stream event handled to Lambda 6 | // http://docs.aws.amazon.com/lambda/latest/dg/eventsources.html#eventsources-ddb-update 7 | type DynamoDBEvent struct { 8 | Records []DynamoDBEventRecord `json:"Records"` 9 | } 10 | 11 | // DynamoDbEventRecord stores information about each record of a DynamoDb stream event 12 | type DynamoDBEventRecord struct { 13 | // The region in which the GetRecords request was received. 14 | AWSRegion string `json:"awsRegion"` 15 | 16 | // The main body of the stream record, containing all of the DynamoDB-specific 17 | // fields. 18 | Change DynamoDBStreamRecord `json:"dynamodb"` 19 | 20 | // A globally unique identifier for the event that was recorded in this stream 21 | // record. 22 | EventID string `json:"eventID"` 23 | 24 | // The type of data modification that was performed on the DynamoDB table: 25 | // 26 | // * INSERT - a new item was added to the table. 27 | // 28 | // * MODIFY - one or more of an existing item's attributes were modified. 29 | // 30 | // * REMOVE - the item was deleted from the table 31 | EventName string `json:"eventName"` 32 | 33 | // The AWS service from which the stream record originated. For DynamoDB Streams, 34 | // this is aws:dynamodb. 35 | EventSource string `json:"eventSource"` 36 | 37 | // The version number of the stream record format. This number is updated whenever 38 | // the structure of Record is modified. 39 | // 40 | // Client applications must not assume that eventVersion will remain at a particular 41 | // value, as this number is subject to change at any time. In general, eventVersion 42 | // will only increase as the low-level DynamoDB Streams API evolves. 43 | EventVersion string `json:"eventVersion"` 44 | 45 | // The event source ARN of DynamoDB 46 | EventSourceArn string `json:"eventSourceARN"` //nolint: stylecheck 47 | 48 | // Items that are deleted by the Time to Live process after expiration have 49 | // the following fields: 50 | // 51 | // * Records[].userIdentity.type 52 | // 53 | // "Service" 54 | // 55 | // * Records[].userIdentity.principalId 56 | // 57 | // "dynamodb.amazonaws.com" 58 | UserIdentity *DynamoDBUserIdentity `json:"userIdentity,omitempty"` 59 | } 60 | 61 | type DynamoDBUserIdentity struct { 62 | Type string `json:"type"` 63 | PrincipalID string `json:"principalId"` 64 | } 65 | 66 | // DynamoDBStreamRecord represents a description of a single data modification that was performed on an item 67 | // in a DynamoDB table. 68 | type DynamoDBStreamRecord struct { 69 | 70 | // The approximate date and time when the stream record was created, in UNIX 71 | // epoch time (http://www.epochconverter.com/) format. 72 | ApproximateCreationDateTime SecondsEpochTime `json:"ApproximateCreationDateTime,omitempty"` 73 | 74 | // The primary key attribute(s) for the DynamoDB item that was modified. 75 | Keys map[string]DynamoDBAttributeValue `json:"Keys,omitempty"` 76 | 77 | // The item in the DynamoDB table as it appeared after it was modified. 78 | NewImage map[string]DynamoDBAttributeValue `json:"NewImage,omitempty"` 79 | 80 | // The item in the DynamoDB table as it appeared before it was modified. 81 | OldImage map[string]DynamoDBAttributeValue `json:"OldImage,omitempty"` 82 | 83 | // The sequence number of the stream record. 84 | SequenceNumber string `json:"SequenceNumber"` 85 | 86 | // The size of the stream record, in bytes. 87 | SizeBytes int64 `json:"SizeBytes"` 88 | 89 | // The type of data from the modified DynamoDB item that was captured in this 90 | // stream record. 91 | StreamViewType string `json:"StreamViewType"` 92 | } 93 | 94 | type DynamoDBKeyType string 95 | 96 | const ( 97 | DynamoDBKeyTypeHash DynamoDBKeyType = "HASH" 98 | DynamoDBKeyTypeRange DynamoDBKeyType = "RANGE" 99 | ) 100 | 101 | type DynamoDBOperationType string 102 | 103 | const ( 104 | DynamoDBOperationTypeInsert DynamoDBOperationType = "INSERT" 105 | DynamoDBOperationTypeModify DynamoDBOperationType = "MODIFY" 106 | DynamoDBOperationTypeRemove DynamoDBOperationType = "REMOVE" 107 | ) 108 | 109 | type DynamoDBSharedIteratorType string 110 | 111 | const ( 112 | DynamoDBShardIteratorTypeTrimHorizon DynamoDBSharedIteratorType = "TRIM_HORIZON" 113 | DynamoDBShardIteratorTypeLatest DynamoDBSharedIteratorType = "LATEST" 114 | DynamoDBShardIteratorTypeAtSequenceNumber DynamoDBSharedIteratorType = "AT_SEQUENCE_NUMBER" 115 | DynamoDBShardIteratorTypeAfterSequenceNumber DynamoDBSharedIteratorType = "AFTER_SEQUENCE_NUMBER" 116 | ) 117 | 118 | type DynamoDBStreamStatus string 119 | 120 | const ( 121 | DynamoDBStreamStatusEnabling DynamoDBStreamStatus = "ENABLING" 122 | DynamoDBStreamStatusEnabled DynamoDBStreamStatus = "ENABLED" 123 | DynamoDBStreamStatusDisabling DynamoDBStreamStatus = "DISABLING" 124 | DynamoDBStreamStatusDisabled DynamoDBStreamStatus = "DISABLED" 125 | ) 126 | 127 | type DynamoDBStreamViewType string 128 | 129 | const ( 130 | DynamoDBStreamViewTypeNewImage DynamoDBStreamViewType = "NEW_IMAGE" // the entire item, as it appeared after it was modified. 131 | DynamoDBStreamViewTypeOldImage DynamoDBStreamViewType = "OLD_IMAGE" // the entire item, as it appeared before it was modified. 132 | DynamoDBStreamViewTypeNewAndOldImages DynamoDBStreamViewType = "NEW_AND_OLD_IMAGES" // both the new and the old item images of the item. 133 | DynamoDBStreamViewTypeKeysOnly DynamoDBStreamViewType = "KEYS_ONLY" // only the key attributes of the modified item. 134 | ) 135 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/events/codebuild.go: -------------------------------------------------------------------------------- 1 | package events 2 | 3 | import ( 4 | "encoding/json" 5 | "time" 6 | ) 7 | 8 | const ( 9 | CodeBuildEventSource = "aws.codebuild" 10 | CodeBuildStateChangeDetailType = "CodeBuild Build State Change" 11 | CodeBuildPhaseChangeDetailType = "CodeBuild Build Phase Change" 12 | ) 13 | 14 | // CodeBuildPhaseStatus represents the status of code build phase (i.e. failed, in progress) 15 | type CodeBuildPhaseStatus string 16 | 17 | const ( 18 | CodeBuildPhaseStatusFailed CodeBuildPhaseStatus = "FAILED" 19 | CodeBuildPhaseStatusFault CodeBuildPhaseStatus = "FAULT" 20 | CodeBuildPhaseStatusInProgress CodeBuildPhaseStatus = "IN_PROGRESS" 21 | CodeBuildPhaseStatusQueued CodeBuildPhaseStatus = "QUEUED" 22 | CodeBuildPhaseStatusStopped CodeBuildPhaseStatus = "STOPPED" 23 | CodeBuildPhaseStatusSucceeded CodeBuildPhaseStatus = "SUCCEEDED" 24 | CodeBuildPhaseStatusTimedOut CodeBuildPhaseStatus = "TIMED_OUT" 25 | ) 26 | 27 | // CodeBuildPhaseType represents the type of the code build phase (i.e. submitted, install) 28 | type CodeBuildPhaseType string 29 | 30 | const ( 31 | CodeBuildPhaseTypeSubmitted CodeBuildPhaseType = "SUBMITTED" 32 | CodeBuildPhaseTypeQueued CodeBuildPhaseType = "QUEUED" 33 | CodeBuildPhaseTypeProvisioning CodeBuildPhaseType = "PROVISIONING" 34 | CodeBuildPhaseTypeDownloadSource CodeBuildPhaseType = "DOWNLOAD_SOURCE" 35 | CodeBuildPhaseTypeInstall CodeBuildPhaseType = "INSTALL" 36 | CodeBuildPhaseTypePreBuild CodeBuildPhaseType = "PRE_BUILD" 37 | CodeBuildPhaseTypeBuild CodeBuildPhaseType = "BUILD" 38 | CodeBuildPhaseTypePostBuild CodeBuildPhaseType = "POST_BUILD" 39 | CodeBuildPhaseTypeUploadArtifacts CodeBuildPhaseType = "UPLOAD_ARTIFACTS" 40 | CodeBuildPhaseTypeFinalizing CodeBuildPhaseType = "FINALIZING" 41 | CodeBuildPhaseTypeCompleted CodeBuildPhaseType = "COMPLETED" 42 | ) 43 | 44 | // CodeBuildEvent is documented at: 45 | // https://docs.aws.amazon.com/codebuild/latest/userguide/sample-build-notifications.html#sample-build-notifications-ref 46 | type CodeBuildEvent struct { 47 | // AccountID is the id of the AWS account from which the event originated. 48 | AccountID string `json:"account"` 49 | 50 | // Region is the AWS region from which the event originated. 51 | Region string `json:"region"` 52 | 53 | // DetailType informs the schema of the Detail field. For build state-change 54 | // events, the value will be CodeBuildStateChangeDetailType. For phase-change 55 | // events, it will be CodeBuildPhaseChangeDetailType. 56 | DetailType string `json:"detail-type"` 57 | 58 | // Source should be equal to CodeBuildEventSource. 59 | Source string `json:"source"` 60 | 61 | // Version is the version of the event's schema. 62 | Version string `json:"version"` 63 | 64 | // Time is the event's timestamp. 65 | Time time.Time `json:"time"` 66 | 67 | // ID is the GUID of this event. 68 | ID string `json:"id"` 69 | 70 | // Resources is a list of ARNs of CodeBuild builds that this event pertains to. 71 | Resources []string `json:"resources"` 72 | 73 | // Detail contains information specific to a build state-change or 74 | // build phase-change event. 75 | Detail CodeBuildEventDetail `json:"detail"` 76 | } 77 | 78 | // CodeBuildEventDetail represents the all details related to the code build event 79 | type CodeBuildEventDetail struct { 80 | BuildStatus CodeBuildPhaseStatus `json:"build-status"` 81 | ProjectName string `json:"project-name"` 82 | BuildID string `json:"build-id"` 83 | AdditionalInformation CodeBuildEventAdditionalInformation `json:"additional-information"` 84 | CurrentPhase CodeBuildPhaseType `json:"current-phase"` 85 | CurrentPhaseContext string `json:"current-phase-context"` 86 | Version string `json:"version"` 87 | 88 | CompletedPhaseStatus CodeBuildPhaseStatus `json:"completed-phase-status"` 89 | CompletedPhase CodeBuildPhaseType `json:"completed-phase"` 90 | CompletedPhaseContext string `json:"completed-phase-context"` 91 | CompletedPhaseDuration DurationSeconds `json:"completed-phase-duration-seconds"` 92 | CompletedPhaseStart CodeBuildTime `json:"completed-phase-start"` 93 | CompletedPhaseEnd CodeBuildTime `json:"completed-phase-end"` 94 | } 95 | 96 | //CodeBuildEventAdditionalInformation represents additional information to the code build event 97 | type CodeBuildEventAdditionalInformation struct { 98 | Artifact CodeBuildArtifact `json:"artifact"` 99 | 100 | Environment CodeBuildEnvironment `json:"environment"` 101 | 102 | Timeout DurationMinutes `json:"timeout-in-minutes"` 103 | 104 | BuildComplete bool `json:"build-complete"` 105 | 106 | Initiator string `json:"initiator"` 107 | 108 | BuildStartTime CodeBuildTime `json:"build-start-time"` 109 | 110 | Source CodeBuildSource `json:"source"` 111 | 112 | Logs CodeBuildLogs `json:"logs"` 113 | 114 | Phases []CodeBuildPhase `json:"phases"` 115 | } 116 | 117 | // CodeBuildArtifact represents the artifact provided to build 118 | type CodeBuildArtifact struct { 119 | MD5Sum string `json:"md5sum"` 120 | SHA256Sum string `json:"sha256sum"` 121 | Location string `json:"location"` 122 | } 123 | 124 | // CodeBuildEnvironment represents the environment for a build 125 | type CodeBuildEnvironment struct { 126 | Image string `json:"image"` 127 | PrivilegedMode bool `json:"privileged-mode"` 128 | ComputeType string `json:"compute-type"` 129 | Type string `json:"type"` 130 | EnvironmentVariables []CodeBuildEnvironmentVariable `json:"environment-variables"` 131 | } 132 | 133 | // CodeBuildEnvironmentVariable encapsulate environment variables for the code build 134 | type CodeBuildEnvironmentVariable struct { 135 | // Name is the name of the environment variable. 136 | Name string `json:"name"` 137 | 138 | // Type is PLAINTEXT or PARAMETER_STORE. 139 | Type string `json:"type"` 140 | 141 | // Value is the value of the environment variable. 142 | Value string `json:"value"` 143 | } 144 | 145 | // CodeBuildSource represent the code source will be build 146 | type CodeBuildSource struct { 147 | Location string `json:"location"` 148 | Type string `json:"type"` 149 | } 150 | 151 | // CodeBuildLogs gives the log details of a code build 152 | type CodeBuildLogs struct { 153 | GroupName string `json:"group-name"` 154 | StreamName string `json:"stream-name"` 155 | DeepLink string `json:"deep-link"` 156 | } 157 | 158 | // CodeBuildPhase represents the phase of a build and its details 159 | type CodeBuildPhase struct { 160 | PhaseContext []interface{} `json:"phase-context"` 161 | 162 | StartTime CodeBuildTime `json:"start-time"` 163 | 164 | EndTime CodeBuildTime `json:"end-time"` 165 | 166 | Duration DurationSeconds `json:"duration-in-seconds"` 167 | 168 | PhaseType CodeBuildPhaseType `json:"phase-type"` 169 | 170 | PhaseStatus CodeBuildPhaseStatus `json:"phase-status"` 171 | } 172 | 173 | // CodeBuildTime represents the time of the build 174 | type CodeBuildTime time.Time 175 | 176 | const codeBuildTimeFormat = "Jan 2, 2006 3:04:05 PM" 177 | 178 | // MarshalJSON converts a given CodeBuildTime to json 179 | func (t CodeBuildTime) MarshalJSON() ([]byte, error) { 180 | return json.Marshal(time.Time(t).Format(codeBuildTimeFormat)) 181 | } 182 | 183 | // UnmarshalJSON converts a given json to a CodeBuildTime 184 | func (t *CodeBuildTime) UnmarshalJSON(data []byte) error { 185 | var s string 186 | if err := json.Unmarshal(data, &s); err != nil { 187 | return err 188 | } 189 | 190 | ts, err := time.Parse(codeBuildTimeFormat, s) 191 | if err != nil { 192 | return err 193 | } 194 | 195 | *t = CodeBuildTime(ts) 196 | return nil 197 | } 198 | -------------------------------------------------------------------------------- /cdk-bundle-go-lambda-example/functions/hello/vendor/github.com/aws/aws-lambda-go/LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | 204 | --------------------------------------------------------------------------------