├── nodejs18.x ├── file-processing │ ├── cdk │ │ ├── .gitignore │ │ ├── cdk │ │ │ ├── cdk.json │ │ │ ├── jest.config.js │ │ │ ├── README.md │ │ │ ├── bin │ │ │ │ └── cdk.ts │ │ │ ├── lib │ │ │ │ └── permissions-boundary-aspect.ts │ │ │ ├── package.json │ │ │ └── tsconfig.json │ │ ├── __tests__ │ │ │ └── s3-example │ │ │ │ └── log.json │ │ ├── package.json │ │ ├── LICENSE │ │ ├── src │ │ │ └── handlers │ │ │ │ └── s3-json-logger.js │ │ ├── buildspec.yml │ │ └── events │ │ │ └── event-s3.json │ └── sam │ │ ├── .gitignore │ │ ├── __tests__ │ │ └── s3-example │ │ │ └── log.json │ │ ├── package.json │ │ ├── buildspec.yml │ │ ├── LICENSE │ │ ├── src │ │ └── handlers │ │ │ └── s3-json-logger.js │ │ └── events │ │ └── event-s3.json ├── scheduled-job │ ├── cdk │ │ ├── .gitignore │ │ ├── cdk │ │ │ ├── cdk.json │ │ │ ├── jest.config.js │ │ │ ├── README.md │ │ │ ├── bin │ │ │ │ └── cdk.ts │ │ │ ├── lib │ │ │ │ └── permissions-boundary-aspect.ts │ │ │ ├── package.json │ │ │ └── tsconfig.json │ │ ├── package.json │ │ ├── events │ │ │ └── event-cloudwatch-event.json │ │ ├── src │ │ │ └── handlers │ │ │ │ └── scheduled-event-logger.js │ │ ├── LICENSE │ │ ├── buildspec.yml │ │ └── __tests__ │ │ │ └── unit │ │ │ └── handlers │ │ │ └── scheduled-event-logger.test.js │ └── sam │ │ ├── .gitignore │ │ ├── package.json │ │ ├── events │ │ └── event-cloudwatch-event.json │ │ ├── src │ │ └── handlers │ │ │ └── scheduled-event-logger.js │ │ ├── buildspec.yml │ │ ├── LICENSE │ │ └── __tests__ │ │ └── unit │ │ └── handlers │ │ └── scheduled-event-logger.test.js ├── author-from-scratch │ ├── cdk │ │ ├── .gitignore │ │ ├── cdk │ │ │ ├── cdk.json │ │ │ ├── jest.config.js │ │ │ ├── README.md │ │ │ ├── bin │ │ │ │ └── cdk.ts │ │ │ ├── lib │ │ │ │ ├── permissions-boundary-aspect.ts │ │ │ │ └── cdk-stack.ts │ │ │ ├── package.json │ │ │ └── tsconfig.json │ │ ├── package.json │ │ ├── src │ │ │ └── handlers │ │ │ │ └── hello-from-lambda.js │ │ ├── LICENSE │ │ ├── __tests__ │ │ │ └── unit │ │ │ │ └── handlers │ │ │ │ └── hello-from-lambda.test.js │ │ └── buildspec.yml │ └── sam │ │ ├── .gitignore │ │ ├── package.json │ │ ├── src │ │ └── handlers │ │ │ └── hello-from-lambda.js │ │ ├── buildspec.yml │ │ ├── LICENSE │ │ └── __tests__ │ │ └── unit │ │ └── handlers │ │ └── hello-from-lambda.test.js ├── queue-processing │ ├── cdk │ │ ├── .gitignore │ │ ├── cdk │ │ │ ├── cdk.json │ │ │ ├── jest.config.js │ │ │ ├── README.md │ │ │ ├── bin │ │ │ │ └── cdk.ts │ │ │ ├── lib │ │ │ │ └── permissions-boundary-aspect.ts │ │ │ ├── package.json │ │ │ └── tsconfig.json │ │ ├── package.json │ │ ├── src │ │ │ └── handlers │ │ │ │ └── sqs-payload-logger.js │ │ ├── events │ │ │ └── event-sqs.json │ │ ├── LICENSE │ │ └── buildspec.yml │ └── sam │ │ ├── .gitignore │ │ ├── package.json │ │ ├── src │ │ └── handlers │ │ │ └── sqs-payload-logger.js │ │ ├── events │ │ └── event-sqs.json │ │ ├── buildspec.yml │ │ └── LICENSE ├── notifications-processing │ ├── cdk │ │ ├── .gitignore │ │ ├── cdk │ │ │ ├── cdk.json │ │ │ ├── jest.config.js │ │ │ ├── README.md │ │ │ ├── bin │ │ │ │ └── cdk.ts │ │ │ ├── lib │ │ │ │ └── permissions-boundary-aspect.ts │ │ │ ├── package.json │ │ │ └── tsconfig.json │ │ ├── events │ │ │ └── event-sns.json │ │ ├── package.json │ │ ├── src │ │ │ └── handlers │ │ │ │ └── sns-payload-logger.js │ │ ├── LICENSE │ │ ├── buildspec.yml │ │ └── __tests__ │ │ │ └── unit │ │ │ └── handlers │ │ │ └── sns-payload-logger.test.js │ └── sam │ │ ├── .gitignore │ │ ├── events │ │ └── event-sns.json │ │ ├── package.json │ │ ├── src │ │ └── handlers │ │ │ └── sns-payload-logger.js │ │ ├── buildspec.yml │ │ ├── LICENSE │ │ └── __tests__ │ │ └── unit │ │ └── handlers │ │ └── sns-payload-logger.test.js └── serverless-api-backend │ ├── cdk │ ├── .gitignore │ ├── cdk │ │ ├── cdk.json │ │ ├── jest.config.js │ │ ├── README.md │ │ ├── bin │ │ │ └── cdk.ts │ │ ├── lib │ │ │ └── permissions-boundary-aspect.ts │ │ ├── package.json │ │ └── tsconfig.json │ ├── events │ │ ├── event-get-all-items.json │ │ ├── event-post-item.json │ │ └── event-get-by-id.json │ ├── env.json │ ├── package.json │ ├── LICENSE │ ├── buildspec.yml │ ├── __tests__ │ │ └── unit │ │ │ └── handlers │ │ │ ├── put-item.test.js │ │ │ ├── get-all-items.test.js │ │ │ └── get-by-id.test.js │ └── src │ │ └── handlers │ │ ├── put-item.js │ │ ├── get-all-items.js │ │ └── get-by-id.js │ └── sam │ ├── .gitignore │ ├── events │ ├── event-get-all-items.json │ ├── event-post-item.json │ └── event-get-by-id.json │ ├── env.json │ ├── package.json │ ├── buildspec.yml │ ├── LICENSE │ ├── __tests__ │ └── unit │ │ └── handlers │ │ ├── put-item.test.js │ │ ├── get-all-items.test.js │ │ └── get-by-id.test.js │ └── src │ └── handlers │ ├── put-item.js │ ├── get-all-items.js │ └── get-by-id.js ├── nodejs22.x ├── file-processing │ ├── cdk │ │ ├── .gitignore │ │ ├── cdk │ │ │ ├── cdk.json │ │ │ ├── jest.config.js │ │ │ ├── README.md │ │ │ ├── bin │ │ │ │ └── cdk.ts │ │ │ ├── lib │ │ │ │ └── permissions-boundary-aspect.ts │ │ │ ├── package.json │ │ │ └── tsconfig.json │ │ ├── __tests__ │ │ │ └── s3-example │ │ │ │ └── log.json │ │ ├── package.json │ │ ├── LICENSE │ │ ├── src │ │ │ └── handlers │ │ │ │ └── s3-json-logger.js │ │ ├── buildspec.yml │ │ └── events │ │ │ └── event-s3.json │ └── sam │ │ ├── .gitignore │ │ ├── __tests__ │ │ └── s3-example │ │ │ └── log.json │ │ ├── package.json │ │ ├── buildspec.yml │ │ ├── LICENSE │ │ ├── src │ │ └── handlers │ │ │ └── s3-json-logger.js │ │ └── events │ │ └── event-s3.json ├── scheduled-job │ ├── cdk │ │ ├── .gitignore │ │ ├── cdk │ │ │ ├── cdk.json │ │ │ ├── jest.config.js │ │ │ ├── README.md │ │ │ ├── bin │ │ │ │ └── cdk.ts │ │ │ ├── lib │ │ │ │ └── permissions-boundary-aspect.ts │ │ │ ├── package.json │ │ │ └── tsconfig.json │ │ ├── package.json │ │ ├── events │ │ │ └── event-cloudwatch-event.json │ │ ├── src │ │ │ └── handlers │ │ │ │ └── scheduled-event-logger.js │ │ ├── LICENSE │ │ ├── buildspec.yml │ │ └── __tests__ │ │ │ └── unit │ │ │ └── handlers │ │ │ └── scheduled-event-logger.test.js │ └── sam │ │ ├── .gitignore │ │ ├── package.json │ │ ├── events │ │ └── event-cloudwatch-event.json │ │ ├── src │ │ └── handlers │ │ │ └── scheduled-event-logger.js │ │ ├── buildspec.yml │ │ ├── LICENSE │ │ └── __tests__ │ │ └── unit │ │ └── handlers │ │ └── scheduled-event-logger.test.js ├── author-from-scratch │ ├── cdk │ │ ├── .gitignore │ │ ├── cdk │ │ │ ├── cdk.json │ │ │ ├── jest.config.js │ │ │ ├── README.md │ │ │ ├── bin │ │ │ │ └── cdk.ts │ │ │ ├── lib │ │ │ │ ├── permissions-boundary-aspect.ts │ │ │ │ └── cdk-stack.ts │ │ │ ├── package.json │ │ │ └── tsconfig.json │ │ ├── package.json │ │ ├── src │ │ │ └── handlers │ │ │ │ └── hello-from-lambda.js │ │ ├── LICENSE │ │ ├── __tests__ │ │ │ └── unit │ │ │ │ └── handlers │ │ │ │ └── hello-from-lambda.test.js │ │ └── buildspec.yml │ └── sam │ │ ├── .gitignore │ │ ├── package.json │ │ ├── src │ │ └── handlers │ │ │ └── hello-from-lambda.js │ │ ├── buildspec.yml │ │ ├── LICENSE │ │ └── __tests__ │ │ └── unit │ │ └── handlers │ │ └── hello-from-lambda.test.js ├── queue-processing │ ├── cdk │ │ ├── .gitignore │ │ ├── cdk │ │ │ ├── cdk.json │ │ │ ├── jest.config.js │ │ │ ├── README.md │ │ │ ├── bin │ │ │ │ └── cdk.ts │ │ │ ├── lib │ │ │ │ └── permissions-boundary-aspect.ts │ │ │ ├── package.json │ │ │ └── tsconfig.json │ │ ├── package.json │ │ ├── src │ │ │ └── handlers │ │ │ │ └── sqs-payload-logger.js │ │ ├── events │ │ │ └── event-sqs.json │ │ ├── LICENSE │ │ └── buildspec.yml │ └── sam │ │ ├── .gitignore │ │ ├── package.json │ │ ├── src │ │ └── handlers │ │ │ └── sqs-payload-logger.js │ │ ├── events │ │ └── event-sqs.json │ │ ├── buildspec.yml │ │ └── LICENSE ├── notifications-processing │ ├── cdk │ │ ├── .gitignore │ │ ├── cdk │ │ │ ├── cdk.json │ │ │ ├── jest.config.js │ │ │ ├── README.md │ │ │ ├── bin │ │ │ │ └── cdk.ts │ │ │ ├── lib │ │ │ │ └── permissions-boundary-aspect.ts │ │ │ ├── package.json │ │ │ └── tsconfig.json │ │ ├── events │ │ │ └── event-sns.json │ │ ├── package.json │ │ ├── src │ │ │ └── handlers │ │ │ │ └── sns-payload-logger.js │ │ ├── LICENSE │ │ ├── buildspec.yml │ │ └── __tests__ │ │ │ └── unit │ │ │ └── handlers │ │ │ └── sns-payload-logger.test.js │ └── sam │ │ ├── .gitignore │ │ ├── events │ │ └── event-sns.json │ │ ├── package.json │ │ ├── src │ │ └── handlers │ │ │ └── sns-payload-logger.js │ │ ├── buildspec.yml │ │ ├── LICENSE │ │ └── __tests__ │ │ └── unit │ │ └── handlers │ │ └── sns-payload-logger.test.js └── serverless-api-backend │ ├── cdk │ ├── .gitignore │ ├── cdk │ │ ├── cdk.json │ │ ├── jest.config.js │ │ ├── README.md │ │ ├── bin │ │ │ └── cdk.ts │ │ ├── lib │ │ │ └── permissions-boundary-aspect.ts │ │ ├── package.json │ │ └── tsconfig.json │ ├── events │ │ ├── event-get-all-items.json │ │ ├── event-post-item.json │ │ └── event-get-by-id.json │ ├── env.json │ ├── package.json │ ├── LICENSE │ ├── buildspec.yml │ ├── __tests__ │ │ └── unit │ │ │ └── handlers │ │ │ ├── put-item.test.js │ │ │ ├── get-all-items.test.js │ │ │ └── get-by-id.test.js │ └── src │ │ └── handlers │ │ ├── put-item.js │ │ ├── get-all-items.js │ │ └── get-by-id.js │ └── sam │ ├── .gitignore │ ├── events │ ├── event-get-all-items.json │ ├── event-post-item.json │ └── event-get-by-id.json │ ├── env.json │ ├── package.json │ ├── buildspec.yml │ ├── LICENSE │ ├── __tests__ │ └── unit │ │ └── handlers │ │ ├── put-item.test.js │ │ ├── get-all-items.test.js │ │ └── get-by-id.test.js │ └── src │ └── handlers │ ├── put-item.js │ ├── get-all-items.js │ └── get-by-id.js ├── .github └── PULL_REQUEST_TEMPLATE.md ├── README.md ├── CODE_OF_CONDUCT.md ├── CICD-toolchain-for-serverless-applications └── README.md └── LICENSE /nodejs18.x/file-processing/cdk/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /nodejs18.x/file-processing/sam/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /nodejs18.x/scheduled-job/cdk/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /nodejs18.x/scheduled-job/sam/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /nodejs22.x/file-processing/cdk/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /nodejs22.x/file-processing/sam/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /nodejs22.x/scheduled-job/cdk/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /nodejs22.x/scheduled-job/sam/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /nodejs18.x/author-from-scratch/cdk/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /nodejs18.x/author-from-scratch/sam/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /nodejs18.x/queue-processing/cdk/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /nodejs18.x/queue-processing/sam/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /nodejs22.x/author-from-scratch/cdk/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /nodejs22.x/author-from-scratch/sam/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /nodejs22.x/queue-processing/cdk/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /nodejs22.x/queue-processing/sam/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /nodejs18.x/notifications-processing/cdk/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /nodejs18.x/notifications-processing/sam/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /nodejs18.x/serverless-api-backend/cdk/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /nodejs18.x/serverless-api-backend/sam/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /nodejs22.x/notifications-processing/cdk/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /nodejs22.x/notifications-processing/sam/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /nodejs22.x/serverless-api-backend/cdk/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /nodejs22.x/serverless-api-backend/sam/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /nodejs18.x/scheduled-job/cdk/cdk/cdk.json: -------------------------------------------------------------------------------- 1 | { 2 | "app": "npx ts-node bin/cdk.ts" 3 | } 4 | -------------------------------------------------------------------------------- /nodejs22.x/scheduled-job/cdk/cdk/cdk.json: -------------------------------------------------------------------------------- 1 | { 2 | "app": "npx ts-node bin/cdk.ts" 3 | } 4 | -------------------------------------------------------------------------------- /nodejs18.x/file-processing/cdk/cdk/cdk.json: -------------------------------------------------------------------------------- 1 | { 2 | "app": "npx ts-node bin/cdk.ts" 3 | } 4 | -------------------------------------------------------------------------------- /nodejs18.x/queue-processing/cdk/cdk/cdk.json: -------------------------------------------------------------------------------- 1 | { 2 | "app": "npx ts-node bin/cdk.ts" 3 | } 4 | -------------------------------------------------------------------------------- /nodejs22.x/file-processing/cdk/cdk/cdk.json: -------------------------------------------------------------------------------- 1 | { 2 | "app": "npx ts-node bin/cdk.ts" 3 | } 4 | -------------------------------------------------------------------------------- /nodejs22.x/queue-processing/cdk/cdk/cdk.json: -------------------------------------------------------------------------------- 1 | { 2 | "app": "npx ts-node bin/cdk.ts" 3 | } 4 | -------------------------------------------------------------------------------- /nodejs18.x/author-from-scratch/cdk/cdk/cdk.json: -------------------------------------------------------------------------------- 1 | { 2 | "app": "npx ts-node bin/cdk.ts" 3 | } 4 | -------------------------------------------------------------------------------- /nodejs18.x/serverless-api-backend/cdk/cdk/cdk.json: -------------------------------------------------------------------------------- 1 | { 2 | "app": "npx ts-node bin/cdk.ts" 3 | } 4 | -------------------------------------------------------------------------------- /nodejs22.x/author-from-scratch/cdk/cdk/cdk.json: -------------------------------------------------------------------------------- 1 | { 2 | "app": "npx ts-node bin/cdk.ts" 3 | } 4 | -------------------------------------------------------------------------------- /nodejs22.x/serverless-api-backend/cdk/cdk/cdk.json: -------------------------------------------------------------------------------- 1 | { 2 | "app": "npx ts-node bin/cdk.ts" 3 | } 4 | -------------------------------------------------------------------------------- /nodejs18.x/notifications-processing/cdk/cdk/cdk.json: -------------------------------------------------------------------------------- 1 | { 2 | "app": "npx ts-node bin/cdk.ts" 3 | } 4 | -------------------------------------------------------------------------------- /nodejs18.x/serverless-api-backend/cdk/events/event-get-all-items.json: -------------------------------------------------------------------------------- 1 | { 2 | "httpMethod": "GET" 3 | } -------------------------------------------------------------------------------- /nodejs18.x/serverless-api-backend/sam/events/event-get-all-items.json: -------------------------------------------------------------------------------- 1 | { 2 | "httpMethod": "GET" 3 | } -------------------------------------------------------------------------------- /nodejs22.x/notifications-processing/cdk/cdk/cdk.json: -------------------------------------------------------------------------------- 1 | { 2 | "app": "npx ts-node bin/cdk.ts" 3 | } 4 | -------------------------------------------------------------------------------- /nodejs22.x/serverless-api-backend/cdk/events/event-get-all-items.json: -------------------------------------------------------------------------------- 1 | { 2 | "httpMethod": "GET" 3 | } -------------------------------------------------------------------------------- /nodejs22.x/serverless-api-backend/sam/events/event-get-all-items.json: -------------------------------------------------------------------------------- 1 | { 2 | "httpMethod": "GET" 3 | } -------------------------------------------------------------------------------- /nodejs18.x/serverless-api-backend/cdk/events/event-post-item.json: -------------------------------------------------------------------------------- 1 | { 2 | "httpMethod": "POST", 3 | "body": "{\"id\": \"id1\",\"name\": \"name1\"}" 4 | } -------------------------------------------------------------------------------- /nodejs18.x/serverless-api-backend/sam/events/event-post-item.json: -------------------------------------------------------------------------------- 1 | { 2 | "httpMethod": "POST", 3 | "body": "{\"id\": \"id1\",\"name\": \"name1\"}" 4 | } -------------------------------------------------------------------------------- /nodejs22.x/serverless-api-backend/cdk/events/event-post-item.json: -------------------------------------------------------------------------------- 1 | { 2 | "httpMethod": "POST", 3 | "body": "{\"id\": \"id1\",\"name\": \"name1\"}" 4 | } -------------------------------------------------------------------------------- /nodejs22.x/serverless-api-backend/sam/events/event-post-item.json: -------------------------------------------------------------------------------- 1 | { 2 | "httpMethod": "POST", 3 | "body": "{\"id\": \"id1\",\"name\": \"name1\"}" 4 | } -------------------------------------------------------------------------------- /nodejs18.x/serverless-api-backend/cdk/events/event-get-by-id.json: -------------------------------------------------------------------------------- 1 | { 2 | "httpMethod": "GET", 3 | "pathParameters": { 4 | "id": "id1" 5 | } 6 | } -------------------------------------------------------------------------------- /nodejs18.x/serverless-api-backend/sam/events/event-get-by-id.json: -------------------------------------------------------------------------------- 1 | { 2 | "httpMethod": "GET", 3 | "pathParameters": { 4 | "id": "id1" 5 | } 6 | } -------------------------------------------------------------------------------- /nodejs22.x/serverless-api-backend/cdk/events/event-get-by-id.json: -------------------------------------------------------------------------------- 1 | { 2 | "httpMethod": "GET", 3 | "pathParameters": { 4 | "id": "id1" 5 | } 6 | } -------------------------------------------------------------------------------- /nodejs22.x/serverless-api-backend/sam/events/event-get-by-id.json: -------------------------------------------------------------------------------- 1 | { 2 | "httpMethod": "GET", 3 | "pathParameters": { 4 | "id": "id1" 5 | } 6 | } -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | *Issue #, if available:* 2 | 3 | *Description of changes:* 4 | 5 | 6 | By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice. 7 | -------------------------------------------------------------------------------- /nodejs18.x/file-processing/cdk/cdk/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | 'roots': [ 3 | '/test' 4 | ], 5 | testMatch: ['**/*.test.ts'], 6 | 'transform': { 7 | '^.+\\.tsx?$': 'ts-jest' 8 | }, 9 | }; 10 | -------------------------------------------------------------------------------- /nodejs18.x/queue-processing/cdk/cdk/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | 'roots': [ 3 | '/test' 4 | ], 5 | testMatch: ['**/*.test.ts'], 6 | 'transform': { 7 | '^.+\\.tsx?$': 'ts-jest' 8 | }, 9 | }; 10 | -------------------------------------------------------------------------------- /nodejs18.x/scheduled-job/cdk/cdk/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | 'roots': [ 3 | '/test' 4 | ], 5 | testMatch: ['**/*.test.ts'], 6 | 'transform': { 7 | '^.+\\.tsx?$': 'ts-jest' 8 | }, 9 | }; 10 | -------------------------------------------------------------------------------- /nodejs22.x/file-processing/cdk/cdk/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | 'roots': [ 3 | '/test' 4 | ], 5 | testMatch: ['**/*.test.ts'], 6 | 'transform': { 7 | '^.+\\.tsx?$': 'ts-jest' 8 | }, 9 | }; 10 | -------------------------------------------------------------------------------- /nodejs22.x/queue-processing/cdk/cdk/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | 'roots': [ 3 | '/test' 4 | ], 5 | testMatch: ['**/*.test.ts'], 6 | 'transform': { 7 | '^.+\\.tsx?$': 'ts-jest' 8 | }, 9 | }; 10 | -------------------------------------------------------------------------------- /nodejs22.x/scheduled-job/cdk/cdk/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | 'roots': [ 3 | '/test' 4 | ], 5 | testMatch: ['**/*.test.ts'], 6 | 'transform': { 7 | '^.+\\.tsx?$': 'ts-jest' 8 | }, 9 | }; 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## AWS Lambda Sample Applications 2 | 3 | Sample code used to create serverless applications with AWS SAM in the Lambda console. 4 | 5 | ## License Summary 6 | 7 | This sample code is made available under the MIT-0 license. See the LICENSE file. 8 | -------------------------------------------------------------------------------- /nodejs18.x/author-from-scratch/cdk/cdk/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | 'roots': [ 3 | '/test' 4 | ], 5 | testMatch: ['**/*.test.ts'], 6 | 'transform': { 7 | '^.+\\.tsx?$': 'ts-jest' 8 | }, 9 | }; 10 | -------------------------------------------------------------------------------- /nodejs18.x/serverless-api-backend/cdk/cdk/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | 'roots': [ 3 | '/test' 4 | ], 5 | testMatch: ['**/*.test.ts'], 6 | 'transform': { 7 | '^.+\\.tsx?$': 'ts-jest' 8 | }, 9 | }; 10 | -------------------------------------------------------------------------------- /nodejs22.x/author-from-scratch/cdk/cdk/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | 'roots': [ 3 | '/test' 4 | ], 5 | testMatch: ['**/*.test.ts'], 6 | 'transform': { 7 | '^.+\\.tsx?$': 'ts-jest' 8 | }, 9 | }; 10 | -------------------------------------------------------------------------------- /nodejs22.x/serverless-api-backend/cdk/cdk/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | 'roots': [ 3 | '/test' 4 | ], 5 | testMatch: ['**/*.test.ts'], 6 | 'transform': { 7 | '^.+\\.tsx?$': 'ts-jest' 8 | }, 9 | }; 10 | -------------------------------------------------------------------------------- /nodejs18.x/notifications-processing/cdk/cdk/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | 'roots': [ 3 | '/test' 4 | ], 5 | testMatch: ['**/*.test.ts'], 6 | 'transform': { 7 | '^.+\\.tsx?$': 'ts-jest' 8 | }, 9 | }; 10 | -------------------------------------------------------------------------------- /nodejs22.x/notifications-processing/cdk/cdk/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | 'roots': [ 3 | '/test' 4 | ], 5 | testMatch: ['**/*.test.ts'], 6 | 'transform': { 7 | '^.+\\.tsx?$': 'ts-jest' 8 | }, 9 | }; 10 | -------------------------------------------------------------------------------- /nodejs18.x/serverless-api-backend/cdk/env.json: -------------------------------------------------------------------------------- 1 | { 2 | "getAllItems": { 3 | "SAMPLE_TABLE": "" 4 | }, 5 | "getById": { 6 | "SAMPLE_TABLE": "" 7 | }, 8 | "putItem": { 9 | "SAMPLE_TABLE": "" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /nodejs18.x/serverless-api-backend/sam/env.json: -------------------------------------------------------------------------------- 1 | { 2 | "getAllItems": { 3 | "SAMPLE_TABLE": "" 4 | }, 5 | "getById": { 6 | "SAMPLE_TABLE": "" 7 | }, 8 | "putItem": { 9 | "SAMPLE_TABLE": "" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /nodejs22.x/serverless-api-backend/cdk/env.json: -------------------------------------------------------------------------------- 1 | { 2 | "getAllItems": { 3 | "SAMPLE_TABLE": "" 4 | }, 5 | "getById": { 6 | "SAMPLE_TABLE": "" 7 | }, 8 | "putItem": { 9 | "SAMPLE_TABLE": "" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /nodejs22.x/serverless-api-backend/sam/env.json: -------------------------------------------------------------------------------- 1 | { 2 | "getAllItems": { 3 | "SAMPLE_TABLE": "" 4 | }, 5 | "getById": { 6 | "SAMPLE_TABLE": "" 7 | }, 8 | "putItem": { 9 | "SAMPLE_TABLE": "" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /nodejs18.x/file-processing/cdk/__tests__/s3-example/log.json: -------------------------------------------------------------------------------- 1 | [{ 2 | "namespace": "session", 3 | "createTime": "2019-01-01T12:00:00.000Z", 4 | "data": [{ 5 | "name": "end", 6 | "value": 50, 7 | "unit": "Milliseconds", 8 | "metadata": {} 9 | }] 10 | }] 11 | 12 | -------------------------------------------------------------------------------- /nodejs18.x/file-processing/sam/__tests__/s3-example/log.json: -------------------------------------------------------------------------------- 1 | [{ 2 | "namespace": "session", 3 | "createTime": "2019-01-01T12:00:00.000Z", 4 | "data": [{ 5 | "name": "end", 6 | "value": 50, 7 | "unit": "Milliseconds", 8 | "metadata": {} 9 | }] 10 | }] 11 | 12 | -------------------------------------------------------------------------------- /nodejs22.x/file-processing/cdk/__tests__/s3-example/log.json: -------------------------------------------------------------------------------- 1 | [{ 2 | "namespace": "session", 3 | "createTime": "2019-01-01T12:00:00.000Z", 4 | "data": [{ 5 | "name": "end", 6 | "value": 50, 7 | "unit": "Milliseconds", 8 | "metadata": {} 9 | }] 10 | }] 11 | 12 | -------------------------------------------------------------------------------- /nodejs22.x/file-processing/sam/__tests__/s3-example/log.json: -------------------------------------------------------------------------------- 1 | [{ 2 | "namespace": "session", 3 | "createTime": "2019-01-01T12:00:00.000Z", 4 | "data": [{ 5 | "name": "end", 6 | "value": 50, 7 | "unit": "Milliseconds", 8 | "metadata": {} 9 | }] 10 | }] 11 | 12 | -------------------------------------------------------------------------------- /nodejs18.x/notifications-processing/cdk/events/event-sns.json: -------------------------------------------------------------------------------- 1 | { 2 | "Records": [ 3 | { 4 | "Sns": { 5 | "Message": "This is a notification from SNS", 6 | "Subject": "SNS Notification", 7 | "TopicArn": "arn:aws:sns:us-west-2:123456789012:SimpleTopic" 8 | } 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /nodejs18.x/notifications-processing/sam/events/event-sns.json: -------------------------------------------------------------------------------- 1 | { 2 | "Records": [ 3 | { 4 | "Sns": { 5 | "Message": "This is a notification from SNS", 6 | "Subject": "SNS Notification", 7 | "TopicArn": "arn:aws:sns:us-west-2:123456789012:SimpleTopic" 8 | } 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /nodejs22.x/notifications-processing/cdk/events/event-sns.json: -------------------------------------------------------------------------------- 1 | { 2 | "Records": [ 3 | { 4 | "Sns": { 5 | "Message": "This is a notification from SNS", 6 | "Subject": "SNS Notification", 7 | "TopicArn": "arn:aws:sns:us-west-2:123456789012:SimpleTopic" 8 | } 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /nodejs22.x/notifications-processing/sam/events/event-sns.json: -------------------------------------------------------------------------------- 1 | { 2 | "Records": [ 3 | { 4 | "Sns": { 5 | "Message": "This is a notification from SNS", 6 | "Subject": "SNS Notification", 7 | "TopicArn": "arn:aws:sns:us-west-2:123456789012:SimpleTopic" 8 | } 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /nodejs18.x/queue-processing/cdk/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lambda-sqs", 3 | "description": "Lambda-SQS starter application", 4 | "version": "0.0.1", 5 | "private": true, 6 | "dependencies": { 7 | }, 8 | "devDependencies": { 9 | "jest": "^29.5.0" 10 | }, 11 | "scripts": { 12 | "test": "jest" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /nodejs18.x/queue-processing/sam/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lambda-sqs", 3 | "description": "Lambda-SQS starter application", 4 | "version": "0.0.1", 5 | "private": true, 6 | "dependencies": { 7 | }, 8 | "devDependencies": { 9 | "jest": "^29.5.0" 10 | }, 11 | "scripts": { 12 | "test": "jest" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /nodejs22.x/queue-processing/cdk/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lambda-sqs", 3 | "description": "Lambda-SQS starter application", 4 | "version": "0.0.1", 5 | "private": true, 6 | "dependencies": { 7 | }, 8 | "devDependencies": { 9 | "jest": "^29.5.0" 10 | }, 11 | "scripts": { 12 | "test": "jest" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /nodejs22.x/queue-processing/sam/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lambda-sqs", 3 | "description": "Lambda-SQS starter application", 4 | "version": "0.0.1", 5 | "private": true, 6 | "dependencies": { 7 | }, 8 | "devDependencies": { 9 | "jest": "^29.5.0" 10 | }, 11 | "scripts": { 12 | "test": "jest" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /nodejs18.x/notifications-processing/cdk/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lambda-sns", 3 | "description": "Lambda-SNS starter project", 4 | "version": "0.0.1", 5 | "private": true, 6 | "dependencies": { 7 | }, 8 | "devDependencies": { 9 | "jest": "^29.5.0" 10 | }, 11 | "scripts": { 12 | "test": "jest" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /nodejs18.x/notifications-processing/sam/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lambda-sns", 3 | "description": "Lambda-SNS starter project", 4 | "version": "0.0.1", 5 | "private": true, 6 | "dependencies": { 7 | }, 8 | "devDependencies": { 9 | "jest": "^29.5.0" 10 | }, 11 | "scripts": { 12 | "test": "jest" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /nodejs22.x/notifications-processing/cdk/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lambda-sns", 3 | "description": "Lambda-SNS starter project", 4 | "version": "0.0.1", 5 | "private": true, 6 | "dependencies": { 7 | }, 8 | "devDependencies": { 9 | "jest": "^29.5.0" 10 | }, 11 | "scripts": { 12 | "test": "jest" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /nodejs22.x/notifications-processing/sam/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lambda-sns", 3 | "description": "Lambda-SNS starter project", 4 | "version": "0.0.1", 5 | "private": true, 6 | "dependencies": { 7 | }, 8 | "devDependencies": { 9 | "jest": "^29.5.0" 10 | }, 11 | "scripts": { 12 | "test": "jest" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /nodejs18.x/scheduled-job/cdk/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lambda-scheduled", 3 | "description": "Lambda-Scheduled Event starter project", 4 | "version": "0.0.1", 5 | "private": true, 6 | "dependencies": { 7 | }, 8 | "devDependencies": { 9 | "jest": "^29.5.0" 10 | }, 11 | "scripts": { 12 | "test": "jest" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /nodejs18.x/scheduled-job/sam/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lambda-scheduled", 3 | "description": "Lambda-Scheduled Event starter project", 4 | "version": "0.0.1", 5 | "private": true, 6 | "dependencies": { 7 | }, 8 | "devDependencies": { 9 | "jest": "^29.5.0" 10 | }, 11 | "scripts": { 12 | "test": "jest" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /nodejs22.x/scheduled-job/cdk/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lambda-scheduled", 3 | "description": "Lambda-Scheduled Event starter project", 4 | "version": "0.0.1", 5 | "private": true, 6 | "dependencies": { 7 | }, 8 | "devDependencies": { 9 | "jest": "^29.5.0" 10 | }, 11 | "scripts": { 12 | "test": "jest" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /nodejs22.x/scheduled-job/sam/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lambda-scheduled", 3 | "description": "Lambda-Scheduled Event starter project", 4 | "version": "0.0.1", 5 | "private": true, 6 | "dependencies": { 7 | }, 8 | "devDependencies": { 9 | "jest": "^29.5.0" 10 | }, 11 | "scripts": { 12 | "test": "jest" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /nodejs18.x/author-from-scratch/cdk/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lambda-from-scratch", 3 | "description": "Start from scratch starter project", 4 | "version": "0.0.1", 5 | "private": true, 6 | "dependencies": { 7 | }, 8 | "devDependencies": { 9 | "jest": "^29.5.0" 10 | }, 11 | "scripts": { 12 | "test": "jest" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /nodejs18.x/author-from-scratch/sam/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lambda-from-scratch", 3 | "description": "Start from scratch starter project", 4 | "version": "0.0.1", 5 | "private": true, 6 | "dependencies": { 7 | }, 8 | "devDependencies": { 9 | "jest": "^29.5.0" 10 | }, 11 | "scripts": { 12 | "test": "jest" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /nodejs22.x/author-from-scratch/cdk/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lambda-from-scratch", 3 | "description": "Start from scratch starter project", 4 | "version": "0.0.1", 5 | "private": true, 6 | "dependencies": { 7 | }, 8 | "devDependencies": { 9 | "jest": "^29.5.0" 10 | }, 11 | "scripts": { 12 | "test": "jest" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /nodejs22.x/author-from-scratch/sam/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lambda-from-scratch", 3 | "description": "Start from scratch starter project", 4 | "version": "0.0.1", 5 | "private": true, 6 | "dependencies": { 7 | }, 8 | "devDependencies": { 9 | "jest": "^29.5.0" 10 | }, 11 | "scripts": { 12 | "test": "jest" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /nodejs18.x/scheduled-job/cdk/events/event-cloudwatch-event.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "cdc73f9d-aea9-11e3-9d5a-835b769c0d9c", 3 | "detail-type": "Scheduled Event", 4 | "source": "aws.events", 5 | "account": "123456789012", 6 | "time": "1970-01-01T00:00:00Z", 7 | "region": "us-west-2", 8 | "resources": [ 9 | "arn:aws:events:us-west-2:123456789012:rule/ExampleRule" 10 | ], 11 | "detail": {} 12 | } 13 | -------------------------------------------------------------------------------- /nodejs18.x/scheduled-job/sam/events/event-cloudwatch-event.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "cdc73f9d-aea9-11e3-9d5a-835b769c0d9c", 3 | "detail-type": "Scheduled Event", 4 | "source": "aws.events", 5 | "account": "123456789012", 6 | "time": "1970-01-01T00:00:00Z", 7 | "region": "us-west-2", 8 | "resources": [ 9 | "arn:aws:events:us-west-2:123456789012:rule/ExampleRule" 10 | ], 11 | "detail": {} 12 | } 13 | -------------------------------------------------------------------------------- /nodejs18.x/serverless-api-backend/cdk/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lambda-api-backend", 3 | "description": "Website & Mobile starter project", 4 | "version": "0.0.1", 5 | "private": true, 6 | "dependencies": { 7 | "aws-sdk": "^2.660.0" 8 | }, 9 | "devDependencies": { 10 | "jest": "^29.5.0" 11 | }, 12 | "scripts": { 13 | "test": "jest" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /nodejs18.x/serverless-api-backend/sam/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lambda-api-backend", 3 | "description": "Website & Mobile starter project", 4 | "version": "0.0.1", 5 | "private": true, 6 | "dependencies": { 7 | "aws-sdk": "^2.660.0" 8 | }, 9 | "devDependencies": { 10 | "jest": "^29.5.0" 11 | }, 12 | "scripts": { 13 | "test": "jest" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /nodejs22.x/scheduled-job/cdk/events/event-cloudwatch-event.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "cdc73f9d-aea9-11e3-9d5a-835b769c0d9c", 3 | "detail-type": "Scheduled Event", 4 | "source": "aws.events", 5 | "account": "123456789012", 6 | "time": "1970-01-01T00:00:00Z", 7 | "region": "us-west-2", 8 | "resources": [ 9 | "arn:aws:events:us-west-2:123456789012:rule/ExampleRule" 10 | ], 11 | "detail": {} 12 | } 13 | -------------------------------------------------------------------------------- /nodejs22.x/scheduled-job/sam/events/event-cloudwatch-event.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "cdc73f9d-aea9-11e3-9d5a-835b769c0d9c", 3 | "detail-type": "Scheduled Event", 4 | "source": "aws.events", 5 | "account": "123456789012", 6 | "time": "1970-01-01T00:00:00Z", 7 | "region": "us-west-2", 8 | "resources": [ 9 | "arn:aws:events:us-west-2:123456789012:rule/ExampleRule" 10 | ], 11 | "detail": {} 12 | } 13 | -------------------------------------------------------------------------------- /nodejs22.x/serverless-api-backend/cdk/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lambda-api-backend", 3 | "description": "Website & Mobile starter project", 4 | "version": "0.0.1", 5 | "private": true, 6 | "dependencies": { 7 | "aws-sdk": "^2.660.0" 8 | }, 9 | "devDependencies": { 10 | "jest": "^29.5.0" 11 | }, 12 | "scripts": { 13 | "test": "jest" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /nodejs22.x/serverless-api-backend/sam/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lambda-api-backend", 3 | "description": "Website & Mobile starter project", 4 | "version": "0.0.1", 5 | "private": true, 6 | "dependencies": { 7 | "aws-sdk": "^2.660.0" 8 | }, 9 | "devDependencies": { 10 | "jest": "^29.5.0" 11 | }, 12 | "scripts": { 13 | "test": "jest" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /nodejs18.x/file-processing/cdk/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lambda-s3", 3 | "description": "Lambda-S3 starter project", 4 | "version": "0.0.1", 5 | "private": true, 6 | "dependencies": { 7 | "aws-sdk": "^2.660.0" 8 | }, 9 | "devDependencies": { 10 | "aws-sdk-mock": "^5.7.0", 11 | "jest": "^29.5.0" 12 | }, 13 | "scripts": { 14 | "test": "jest" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /nodejs18.x/file-processing/sam/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lambda-s3", 3 | "description": "Lambda-S3 starter project", 4 | "version": "0.0.1", 5 | "private": true, 6 | "dependencies": { 7 | "aws-sdk": "^2.660.0" 8 | }, 9 | "devDependencies": { 10 | "aws-sdk-mock": "^5.7.0", 11 | "jest": "^29.5.0" 12 | }, 13 | "scripts": { 14 | "test": "jest" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /nodejs18.x/scheduled-job/cdk/cdk/README.md: -------------------------------------------------------------------------------- 1 | # Useful commands 2 | 3 | * `npm run build` compile typescript to js 4 | * `npm run watch` watch for changes and compile 5 | * `npm run test` perform the jest unit tests 6 | * `cdk deploy` deploy this stack to your default AWS account/region 7 | * `cdk diff` compare deployed stack with current state 8 | * `cdk synth` emits the synthesized CloudFormation template 9 | -------------------------------------------------------------------------------- /nodejs22.x/file-processing/cdk/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lambda-s3", 3 | "description": "Lambda-S3 starter project", 4 | "version": "0.0.1", 5 | "private": true, 6 | "dependencies": { 7 | "aws-sdk": "^2.660.0" 8 | }, 9 | "devDependencies": { 10 | "aws-sdk-mock": "^5.7.0", 11 | "jest": "^29.5.0" 12 | }, 13 | "scripts": { 14 | "test": "jest" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /nodejs22.x/file-processing/sam/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lambda-s3", 3 | "description": "Lambda-S3 starter project", 4 | "version": "0.0.1", 5 | "private": true, 6 | "dependencies": { 7 | "aws-sdk": "^2.660.0" 8 | }, 9 | "devDependencies": { 10 | "aws-sdk-mock": "^5.7.0", 11 | "jest": "^29.5.0" 12 | }, 13 | "scripts": { 14 | "test": "jest" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /nodejs22.x/scheduled-job/cdk/cdk/README.md: -------------------------------------------------------------------------------- 1 | # Useful commands 2 | 3 | * `npm run build` compile typescript to js 4 | * `npm run watch` watch for changes and compile 5 | * `npm run test` perform the jest unit tests 6 | * `cdk deploy` deploy this stack to your default AWS account/region 7 | * `cdk diff` compare deployed stack with current state 8 | * `cdk synth` emits the synthesized CloudFormation template 9 | -------------------------------------------------------------------------------- /nodejs18.x/file-processing/cdk/cdk/README.md: -------------------------------------------------------------------------------- 1 | # Useful commands 2 | 3 | * `npm run build` compile typescript to js 4 | * `npm run watch` watch for changes and compile 5 | * `npm run test` perform the jest unit tests 6 | * `cdk deploy` deploy this stack to your default AWS account/region 7 | * `cdk diff` compare deployed stack with current state 8 | * `cdk synth` emits the synthesized CloudFormation template 9 | -------------------------------------------------------------------------------- /nodejs18.x/queue-processing/cdk/cdk/README.md: -------------------------------------------------------------------------------- 1 | # Useful commands 2 | 3 | * `npm run build` compile typescript to js 4 | * `npm run watch` watch for changes and compile 5 | * `npm run test` perform the jest unit tests 6 | * `cdk deploy` deploy this stack to your default AWS account/region 7 | * `cdk diff` compare deployed stack with current state 8 | * `cdk synth` emits the synthesized CloudFormation template 9 | -------------------------------------------------------------------------------- /nodejs22.x/file-processing/cdk/cdk/README.md: -------------------------------------------------------------------------------- 1 | # Useful commands 2 | 3 | * `npm run build` compile typescript to js 4 | * `npm run watch` watch for changes and compile 5 | * `npm run test` perform the jest unit tests 6 | * `cdk deploy` deploy this stack to your default AWS account/region 7 | * `cdk diff` compare deployed stack with current state 8 | * `cdk synth` emits the synthesized CloudFormation template 9 | -------------------------------------------------------------------------------- /nodejs22.x/queue-processing/cdk/cdk/README.md: -------------------------------------------------------------------------------- 1 | # Useful commands 2 | 3 | * `npm run build` compile typescript to js 4 | * `npm run watch` watch for changes and compile 5 | * `npm run test` perform the jest unit tests 6 | * `cdk deploy` deploy this stack to your default AWS account/region 7 | * `cdk diff` compare deployed stack with current state 8 | * `cdk synth` emits the synthesized CloudFormation template 9 | -------------------------------------------------------------------------------- /nodejs18.x/author-from-scratch/cdk/cdk/README.md: -------------------------------------------------------------------------------- 1 | # Useful commands 2 | 3 | * `npm run build` compile typescript to js 4 | * `npm run watch` watch for changes and compile 5 | * `npm run test` perform the jest unit tests 6 | * `cdk deploy` deploy this stack to your default AWS account/region 7 | * `cdk diff` compare deployed stack with current state 8 | * `cdk synth` emits the synthesized CloudFormation template 9 | -------------------------------------------------------------------------------- /nodejs18.x/serverless-api-backend/cdk/cdk/README.md: -------------------------------------------------------------------------------- 1 | # Useful commands 2 | 3 | * `npm run build` compile typescript to js 4 | * `npm run watch` watch for changes and compile 5 | * `npm run test` perform the jest unit tests 6 | * `cdk deploy` deploy this stack to your default AWS account/region 7 | * `cdk diff` compare deployed stack with current state 8 | * `cdk synth` emits the synthesized CloudFormation template 9 | -------------------------------------------------------------------------------- /nodejs22.x/author-from-scratch/cdk/cdk/README.md: -------------------------------------------------------------------------------- 1 | # Useful commands 2 | 3 | * `npm run build` compile typescript to js 4 | * `npm run watch` watch for changes and compile 5 | * `npm run test` perform the jest unit tests 6 | * `cdk deploy` deploy this stack to your default AWS account/region 7 | * `cdk diff` compare deployed stack with current state 8 | * `cdk synth` emits the synthesized CloudFormation template 9 | -------------------------------------------------------------------------------- /nodejs22.x/serverless-api-backend/cdk/cdk/README.md: -------------------------------------------------------------------------------- 1 | # Useful commands 2 | 3 | * `npm run build` compile typescript to js 4 | * `npm run watch` watch for changes and compile 5 | * `npm run test` perform the jest unit tests 6 | * `cdk deploy` deploy this stack to your default AWS account/region 7 | * `cdk diff` compare deployed stack with current state 8 | * `cdk synth` emits the synthesized CloudFormation template 9 | -------------------------------------------------------------------------------- /nodejs18.x/notifications-processing/cdk/cdk/README.md: -------------------------------------------------------------------------------- 1 | # Useful commands 2 | 3 | * `npm run build` compile typescript to js 4 | * `npm run watch` watch for changes and compile 5 | * `npm run test` perform the jest unit tests 6 | * `cdk deploy` deploy this stack to your default AWS account/region 7 | * `cdk diff` compare deployed stack with current state 8 | * `cdk synth` emits the synthesized CloudFormation template 9 | -------------------------------------------------------------------------------- /nodejs22.x/notifications-processing/cdk/cdk/README.md: -------------------------------------------------------------------------------- 1 | # Useful commands 2 | 3 | * `npm run build` compile typescript to js 4 | * `npm run watch` watch for changes and compile 5 | * `npm run test` perform the jest unit tests 6 | * `cdk deploy` deploy this stack to your default AWS account/region 7 | * `cdk diff` compare deployed stack with current state 8 | * `cdk synth` emits the synthesized CloudFormation template 9 | -------------------------------------------------------------------------------- /nodejs18.x/scheduled-job/cdk/src/handlers/scheduled-event-logger.js: -------------------------------------------------------------------------------- 1 | /** 2 | * A Lambda function that logs the payload received from a CloudWatch scheduled event. 3 | */ 4 | exports.scheduledEventLoggerHandler = async (event, context) => { 5 | // All log statements are written to CloudWatch by default. For more information, see 6 | // https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-logging.html 7 | console.log(JSON.stringify(event)); 8 | }; 9 | -------------------------------------------------------------------------------- /nodejs18.x/scheduled-job/sam/src/handlers/scheduled-event-logger.js: -------------------------------------------------------------------------------- 1 | /** 2 | * A Lambda function that logs the payload received from a CloudWatch scheduled event. 3 | */ 4 | exports.scheduledEventLoggerHandler = async (event, context) => { 5 | // All log statements are written to CloudWatch by default. For more information, see 6 | // https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-logging.html 7 | console.log(JSON.stringify(event)); 8 | }; 9 | -------------------------------------------------------------------------------- /nodejs22.x/scheduled-job/cdk/src/handlers/scheduled-event-logger.js: -------------------------------------------------------------------------------- 1 | /** 2 | * A Lambda function that logs the payload received from a CloudWatch scheduled event. 3 | */ 4 | exports.scheduledEventLoggerHandler = async (event, context) => { 5 | // All log statements are written to CloudWatch by default. For more information, see 6 | // https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-logging.html 7 | console.log(JSON.stringify(event)); 8 | }; 9 | -------------------------------------------------------------------------------- /nodejs22.x/scheduled-job/sam/src/handlers/scheduled-event-logger.js: -------------------------------------------------------------------------------- 1 | /** 2 | * A Lambda function that logs the payload received from a CloudWatch scheduled event. 3 | */ 4 | exports.scheduledEventLoggerHandler = async (event, context) => { 5 | // All log statements are written to CloudWatch by default. For more information, see 6 | // https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-logging.html 7 | console.log(JSON.stringify(event)); 8 | }; 9 | -------------------------------------------------------------------------------- /nodejs18.x/queue-processing/cdk/src/handlers/sqs-payload-logger.js: -------------------------------------------------------------------------------- 1 | /** 2 | * A Lambda function that logs the payload received from SQS. 3 | */ 4 | exports.sqsPayloadLoggerHandler = async (event, context) => { 5 | // All log statements are written to CloudWatch by default. For more information, see 6 | // https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-logging.html 7 | event.Records.forEach((record) => { 8 | console.log(JSON.stringify(record)); 9 | }); 10 | }; 11 | -------------------------------------------------------------------------------- /nodejs18.x/queue-processing/sam/src/handlers/sqs-payload-logger.js: -------------------------------------------------------------------------------- 1 | /** 2 | * A Lambda function that logs the payload received from SQS. 3 | */ 4 | exports.sqsPayloadLoggerHandler = async (event, context) => { 5 | // All log statements are written to CloudWatch by default. For more information, see 6 | // https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-logging.html 7 | event.Records.forEach((record) => { 8 | console.log(JSON.stringify(record)); 9 | }); 10 | }; 11 | -------------------------------------------------------------------------------- /nodejs22.x/queue-processing/cdk/src/handlers/sqs-payload-logger.js: -------------------------------------------------------------------------------- 1 | /** 2 | * A Lambda function that logs the payload received from SQS. 3 | */ 4 | exports.sqsPayloadLoggerHandler = async (event, context) => { 5 | // All log statements are written to CloudWatch by default. For more information, see 6 | // https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-logging.html 7 | event.Records.forEach((record) => { 8 | console.log(JSON.stringify(record)); 9 | }); 10 | }; 11 | -------------------------------------------------------------------------------- /nodejs22.x/queue-processing/sam/src/handlers/sqs-payload-logger.js: -------------------------------------------------------------------------------- 1 | /** 2 | * A Lambda function that logs the payload received from SQS. 3 | */ 4 | exports.sqsPayloadLoggerHandler = async (event, context) => { 5 | // All log statements are written to CloudWatch by default. For more information, see 6 | // https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-logging.html 7 | event.Records.forEach((record) => { 8 | console.log(JSON.stringify(record)); 9 | }); 10 | }; 11 | -------------------------------------------------------------------------------- /nodejs18.x/notifications-processing/cdk/src/handlers/sns-payload-logger.js: -------------------------------------------------------------------------------- 1 | /** 2 | * A Lambda function that logs the payload received from SNS. 3 | */ 4 | exports.snsPayloadLoggerHandler = async (event, context) => { 5 | // All log statements are written to CloudWatch by default. For more information, see 6 | // https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-logging.html 7 | event.Records.forEach(({ Sns }) => { 8 | console.log(JSON.stringify(Sns)); 9 | }); 10 | }; 11 | -------------------------------------------------------------------------------- /nodejs18.x/notifications-processing/sam/src/handlers/sns-payload-logger.js: -------------------------------------------------------------------------------- 1 | /** 2 | * A Lambda function that logs the payload received from SNS. 3 | */ 4 | exports.snsPayloadLoggerHandler = async (event, context) => { 5 | // All log statements are written to CloudWatch by default. For more information, see 6 | // https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-logging.html 7 | event.Records.forEach(({ Sns }) => { 8 | console.log(JSON.stringify(Sns)); 9 | }); 10 | }; 11 | -------------------------------------------------------------------------------- /nodejs22.x/notifications-processing/cdk/src/handlers/sns-payload-logger.js: -------------------------------------------------------------------------------- 1 | /** 2 | * A Lambda function that logs the payload received from SNS. 3 | */ 4 | exports.snsPayloadLoggerHandler = async (event, context) => { 5 | // All log statements are written to CloudWatch by default. For more information, see 6 | // https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-logging.html 7 | event.Records.forEach(({ Sns }) => { 8 | console.log(JSON.stringify(Sns)); 9 | }); 10 | }; 11 | -------------------------------------------------------------------------------- /nodejs22.x/notifications-processing/sam/src/handlers/sns-payload-logger.js: -------------------------------------------------------------------------------- 1 | /** 2 | * A Lambda function that logs the payload received from SNS. 3 | */ 4 | exports.snsPayloadLoggerHandler = async (event, context) => { 5 | // All log statements are written to CloudWatch by default. For more information, see 6 | // https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-logging.html 7 | event.Records.forEach(({ Sns }) => { 8 | console.log(JSON.stringify(Sns)); 9 | }); 10 | }; 11 | -------------------------------------------------------------------------------- /nodejs18.x/author-from-scratch/cdk/src/handlers/hello-from-lambda.js: -------------------------------------------------------------------------------- 1 | /** 2 | * A Lambda function that returns a string. 3 | */ 4 | exports.helloFromLambdaHandler = async () => { 5 | // If you change this message, you will need to adjust tests in hello-from-lambda.test.js 6 | const message = 'Hello from Lambda!'; 7 | 8 | // All log statements are written to CloudWatch by default. For more information, see 9 | // https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-logging.html 10 | console.log(message); 11 | 12 | return message; 13 | }; 14 | -------------------------------------------------------------------------------- /nodejs18.x/author-from-scratch/sam/src/handlers/hello-from-lambda.js: -------------------------------------------------------------------------------- 1 | /** 2 | * A Lambda function that returns a string. 3 | */ 4 | exports.helloFromLambdaHandler = async () => { 5 | // If you change this message, you will need to adjust tests in hello-from-lambda.test.js 6 | const message = 'Hello from Lambda!'; 7 | 8 | // All log statements are written to CloudWatch by default. For more information, see 9 | // https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-logging.html 10 | console.log(message); 11 | 12 | return message; 13 | }; 14 | -------------------------------------------------------------------------------- /nodejs22.x/author-from-scratch/cdk/src/handlers/hello-from-lambda.js: -------------------------------------------------------------------------------- 1 | /** 2 | * A Lambda function that returns a string. 3 | */ 4 | exports.helloFromLambdaHandler = async () => { 5 | // If you change this message, you will need to adjust tests in hello-from-lambda.test.js 6 | const message = 'Hello from Lambda!'; 7 | 8 | // All log statements are written to CloudWatch by default. For more information, see 9 | // https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-logging.html 10 | console.log(message); 11 | 12 | return message; 13 | }; 14 | -------------------------------------------------------------------------------- /nodejs22.x/author-from-scratch/sam/src/handlers/hello-from-lambda.js: -------------------------------------------------------------------------------- 1 | /** 2 | * A Lambda function that returns a string. 3 | */ 4 | exports.helloFromLambdaHandler = async () => { 5 | // If you change this message, you will need to adjust tests in hello-from-lambda.test.js 6 | const message = 'Hello from Lambda!'; 7 | 8 | // All log statements are written to CloudWatch by default. For more information, see 9 | // https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-logging.html 10 | console.log(message); 11 | 12 | return message; 13 | }; 14 | -------------------------------------------------------------------------------- /nodejs18.x/file-processing/cdk/cdk/bin/cdk.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | import { App, Aspects, Aws } from 'aws-cdk-lib'; 3 | 4 | import { CdkStack } from '../lib/cdk-stack'; 5 | import { PermissionsBoundaryAspect } from '../lib/permissions-boundary-aspect'; 6 | 7 | 8 | const stack = new CdkStack(new App(), 'CdkStack', { description: 'Lambda-S3 starter project' }); 9 | const { ACCOUNT_ID, PARTITION, REGION, STACK_NAME } = Aws; 10 | const permissionBoundaryArn = `arn:${PARTITION}:iam::${ACCOUNT_ID}:policy/${STACK_NAME}-${REGION}-PermissionsBoundary`; 11 | 12 | // Apply permissions boundary to the stack 13 | Aspects.of(stack).add(new PermissionsBoundaryAspect(permissionBoundaryArn)); 14 | -------------------------------------------------------------------------------- /nodejs22.x/file-processing/cdk/cdk/bin/cdk.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | import { App, Aspects, Aws } from 'aws-cdk-lib'; 3 | 4 | import { CdkStack } from '../lib/cdk-stack'; 5 | import { PermissionsBoundaryAspect } from '../lib/permissions-boundary-aspect'; 6 | 7 | 8 | const stack = new CdkStack(new App(), 'CdkStack', { description: 'Lambda-S3 starter project' }); 9 | const { ACCOUNT_ID, PARTITION, REGION, STACK_NAME } = Aws; 10 | const permissionBoundaryArn = `arn:${PARTITION}:iam::${ACCOUNT_ID}:policy/${STACK_NAME}-${REGION}-PermissionsBoundary`; 11 | 12 | // Apply permissions boundary to the stack 13 | Aspects.of(stack).add(new PermissionsBoundaryAspect(permissionBoundaryArn)); 14 | -------------------------------------------------------------------------------- /nodejs18.x/queue-processing/cdk/cdk/bin/cdk.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | import { App, Aspects, Aws } from 'aws-cdk-lib'; 3 | 4 | import { CdkStack } from '../lib/cdk-stack'; 5 | import { PermissionsBoundaryAspect } from '../lib/permissions-boundary-aspect'; 6 | 7 | 8 | const stack = new CdkStack(new App(), 'CdkStack', { description: 'Lambda-SQS starter application' }); 9 | const { ACCOUNT_ID, PARTITION, REGION, STACK_NAME } = Aws; 10 | const permissionBoundaryArn = `arn:${PARTITION}:iam::${ACCOUNT_ID}:policy/${STACK_NAME}-${REGION}-PermissionsBoundary`; 11 | 12 | // Apply permissions boundary to the stack 13 | Aspects.of(stack).add(new PermissionsBoundaryAspect(permissionBoundaryArn)); 14 | -------------------------------------------------------------------------------- /nodejs22.x/queue-processing/cdk/cdk/bin/cdk.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | import { App, Aspects, Aws } from 'aws-cdk-lib'; 3 | 4 | import { CdkStack } from '../lib/cdk-stack'; 5 | import { PermissionsBoundaryAspect } from '../lib/permissions-boundary-aspect'; 6 | 7 | 8 | const stack = new CdkStack(new App(), 'CdkStack', { description: 'Lambda-SQS starter application' }); 9 | const { ACCOUNT_ID, PARTITION, REGION, STACK_NAME } = Aws; 10 | const permissionBoundaryArn = `arn:${PARTITION}:iam::${ACCOUNT_ID}:policy/${STACK_NAME}-${REGION}-PermissionsBoundary`; 11 | 12 | // Apply permissions boundary to the stack 13 | Aspects.of(stack).add(new PermissionsBoundaryAspect(permissionBoundaryArn)); 14 | -------------------------------------------------------------------------------- /nodejs18.x/author-from-scratch/cdk/cdk/bin/cdk.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | import { App, Aspects, Aws } from 'aws-cdk-lib'; 3 | 4 | import { CdkStack } from '../lib/cdk-stack'; 5 | import { PermissionsBoundaryAspect } from '../lib/permissions-boundary-aspect'; 6 | 7 | 8 | const stack = new CdkStack(new App(), 'CdkStack', { description: 'Start from scratch starter project' }); 9 | const { ACCOUNT_ID, PARTITION, REGION, STACK_NAME } = Aws; 10 | const permissionBoundaryArn = `arn:${PARTITION}:iam::${ACCOUNT_ID}:policy/${STACK_NAME}-${REGION}-PermissionsBoundary`; 11 | 12 | // Apply permissions boundary to the stack 13 | Aspects.of(stack).add(new PermissionsBoundaryAspect(permissionBoundaryArn)); 14 | -------------------------------------------------------------------------------- /nodejs18.x/notifications-processing/cdk/cdk/bin/cdk.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | import { App, Aspects, Aws } from 'aws-cdk-lib'; 3 | 4 | import { CdkStack } from '../lib/cdk-stack'; 5 | import { PermissionsBoundaryAspect } from '../lib/permissions-boundary-aspect'; 6 | 7 | 8 | const stack = new CdkStack(new App(), 'CdkStack', { description: 'Lambda-SNS starter project' }); 9 | const { ACCOUNT_ID, PARTITION, REGION, STACK_NAME } = Aws; 10 | const permissionBoundaryArn = `arn:${PARTITION}:iam::${ACCOUNT_ID}:policy/${STACK_NAME}-${REGION}-PermissionsBoundary`; 11 | 12 | // Apply permissions boundary to the stack 13 | Aspects.of(stack).add(new PermissionsBoundaryAspect(permissionBoundaryArn)); 14 | -------------------------------------------------------------------------------- /nodejs18.x/scheduled-job/cdk/cdk/bin/cdk.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | import { App, Aspects, Aws } from 'aws-cdk-lib'; 3 | 4 | import { CdkStack } from '../lib/cdk-stack'; 5 | import { PermissionsBoundaryAspect } from '../lib/permissions-boundary-aspect'; 6 | 7 | 8 | const stack = new CdkStack(new App(), 'CdkStack', { description: 'Lambda-Scheduled Event starter project' }); 9 | const { ACCOUNT_ID, PARTITION, REGION, STACK_NAME } = Aws; 10 | const permissionBoundaryArn = `arn:${PARTITION}:iam::${ACCOUNT_ID}:policy/${STACK_NAME}-${REGION}-PermissionsBoundary`; 11 | 12 | // Apply permissions boundary to the stack 13 | Aspects.of(stack).add(new PermissionsBoundaryAspect(permissionBoundaryArn)); 14 | -------------------------------------------------------------------------------- /nodejs22.x/author-from-scratch/cdk/cdk/bin/cdk.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | import { App, Aspects, Aws } from 'aws-cdk-lib'; 3 | 4 | import { CdkStack } from '../lib/cdk-stack'; 5 | import { PermissionsBoundaryAspect } from '../lib/permissions-boundary-aspect'; 6 | 7 | 8 | const stack = new CdkStack(new App(), 'CdkStack', { description: 'Start from scratch starter project' }); 9 | const { ACCOUNT_ID, PARTITION, REGION, STACK_NAME } = Aws; 10 | const permissionBoundaryArn = `arn:${PARTITION}:iam::${ACCOUNT_ID}:policy/${STACK_NAME}-${REGION}-PermissionsBoundary`; 11 | 12 | // Apply permissions boundary to the stack 13 | Aspects.of(stack).add(new PermissionsBoundaryAspect(permissionBoundaryArn)); 14 | -------------------------------------------------------------------------------- /nodejs22.x/notifications-processing/cdk/cdk/bin/cdk.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | import { App, Aspects, Aws } from 'aws-cdk-lib'; 3 | 4 | import { CdkStack } from '../lib/cdk-stack'; 5 | import { PermissionsBoundaryAspect } from '../lib/permissions-boundary-aspect'; 6 | 7 | 8 | const stack = new CdkStack(new App(), 'CdkStack', { description: 'Lambda-SNS starter project' }); 9 | const { ACCOUNT_ID, PARTITION, REGION, STACK_NAME } = Aws; 10 | const permissionBoundaryArn = `arn:${PARTITION}:iam::${ACCOUNT_ID}:policy/${STACK_NAME}-${REGION}-PermissionsBoundary`; 11 | 12 | // Apply permissions boundary to the stack 13 | Aspects.of(stack).add(new PermissionsBoundaryAspect(permissionBoundaryArn)); 14 | -------------------------------------------------------------------------------- /nodejs22.x/scheduled-job/cdk/cdk/bin/cdk.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | import { App, Aspects, Aws } from 'aws-cdk-lib'; 3 | 4 | import { CdkStack } from '../lib/cdk-stack'; 5 | import { PermissionsBoundaryAspect } from '../lib/permissions-boundary-aspect'; 6 | 7 | 8 | const stack = new CdkStack(new App(), 'CdkStack', { description: 'Lambda-Scheduled Event starter project' }); 9 | const { ACCOUNT_ID, PARTITION, REGION, STACK_NAME } = Aws; 10 | const permissionBoundaryArn = `arn:${PARTITION}:iam::${ACCOUNT_ID}:policy/${STACK_NAME}-${REGION}-PermissionsBoundary`; 11 | 12 | // Apply permissions boundary to the stack 13 | Aspects.of(stack).add(new PermissionsBoundaryAspect(permissionBoundaryArn)); 14 | -------------------------------------------------------------------------------- /nodejs18.x/serverless-api-backend/cdk/cdk/bin/cdk.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | import { App, Aspects, Aws } from 'aws-cdk-lib'; 3 | 4 | import { CdkStack } from '../lib/cdk-stack'; 5 | import { PermissionsBoundaryAspect } from '../lib/permissions-boundary-aspect'; 6 | 7 | 8 | const stack = new CdkStack(new App(), 'CdkStack', { description: 'Website & Mobile starter project' }); 9 | const { ACCOUNT_ID, PARTITION, REGION, STACK_NAME } = Aws; 10 | const permissionBoundaryArn = `arn:${PARTITION}:iam::${ACCOUNT_ID}:policy/${STACK_NAME}-${REGION}-PermissionsBoundary`; 11 | 12 | // Apply permissions boundary to the stack 13 | Aspects.of(stack).add(new PermissionsBoundaryAspect(permissionBoundaryArn)); 14 | -------------------------------------------------------------------------------- /nodejs22.x/serverless-api-backend/cdk/cdk/bin/cdk.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | import { App, Aspects, Aws } from 'aws-cdk-lib'; 3 | 4 | import { CdkStack } from '../lib/cdk-stack'; 5 | import { PermissionsBoundaryAspect } from '../lib/permissions-boundary-aspect'; 6 | 7 | 8 | const stack = new CdkStack(new App(), 'CdkStack', { description: 'Website & Mobile starter project' }); 9 | const { ACCOUNT_ID, PARTITION, REGION, STACK_NAME } = Aws; 10 | const permissionBoundaryArn = `arn:${PARTITION}:iam::${ACCOUNT_ID}:policy/${STACK_NAME}-${REGION}-PermissionsBoundary`; 11 | 12 | // Apply permissions boundary to the stack 13 | Aspects.of(stack).add(new PermissionsBoundaryAspect(permissionBoundaryArn)); 14 | -------------------------------------------------------------------------------- /nodejs18.x/scheduled-job/cdk/cdk/lib/permissions-boundary-aspect.ts: -------------------------------------------------------------------------------- 1 | import { IAspect } from 'aws-cdk-lib'; 2 | import * as iam from 'aws-cdk-lib/aws-iam'; 3 | import { IConstruct } from 'constructs'; 4 | 5 | 6 | export class PermissionsBoundaryAspect implements IAspect { 7 | private readonly arn: string; 8 | 9 | constructor(permissionBoundaryArn: string) { 10 | this.arn = permissionBoundaryArn; 11 | } 12 | 13 | public visit(node: IConstruct): void { 14 | if (node instanceof iam.Role) { 15 | const roleResource = node.node.findChild('Resource') as iam.CfnRole; 16 | roleResource.addPropertyOverride('PermissionsBoundary', this.arn); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /nodejs22.x/scheduled-job/cdk/cdk/lib/permissions-boundary-aspect.ts: -------------------------------------------------------------------------------- 1 | import { IAspect } from 'aws-cdk-lib'; 2 | import * as iam from 'aws-cdk-lib/aws-iam'; 3 | import { IConstruct } from 'constructs'; 4 | 5 | 6 | export class PermissionsBoundaryAspect implements IAspect { 7 | private readonly arn: string; 8 | 9 | constructor(permissionBoundaryArn: string) { 10 | this.arn = permissionBoundaryArn; 11 | } 12 | 13 | public visit(node: IConstruct): void { 14 | if (node instanceof iam.Role) { 15 | const roleResource = node.node.findChild('Resource') as iam.CfnRole; 16 | roleResource.addPropertyOverride('PermissionsBoundary', this.arn); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /nodejs18.x/file-processing/cdk/cdk/lib/permissions-boundary-aspect.ts: -------------------------------------------------------------------------------- 1 | import { IAspect } from 'aws-cdk-lib'; 2 | import * as iam from 'aws-cdk-lib/aws-iam'; 3 | import { IConstruct } from 'constructs'; 4 | 5 | 6 | export class PermissionsBoundaryAspect implements IAspect { 7 | private readonly arn: string; 8 | 9 | constructor(permissionBoundaryArn: string) { 10 | this.arn = permissionBoundaryArn; 11 | } 12 | 13 | public visit(node: IConstruct): void { 14 | if (node instanceof iam.Role) { 15 | const roleResource = node.node.findChild('Resource') as iam.CfnRole; 16 | roleResource.addPropertyOverride('PermissionsBoundary', this.arn); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /nodejs18.x/queue-processing/cdk/cdk/lib/permissions-boundary-aspect.ts: -------------------------------------------------------------------------------- 1 | import { IAspect } from 'aws-cdk-lib'; 2 | import * as iam from 'aws-cdk-lib/aws-iam'; 3 | import { IConstruct } from 'constructs'; 4 | 5 | 6 | export class PermissionsBoundaryAspect implements IAspect { 7 | private readonly arn: string; 8 | 9 | constructor(permissionBoundaryArn: string) { 10 | this.arn = permissionBoundaryArn; 11 | } 12 | 13 | public visit(node: IConstruct): void { 14 | if (node instanceof iam.Role) { 15 | const roleResource = node.node.findChild('Resource') as iam.CfnRole; 16 | roleResource.addPropertyOverride('PermissionsBoundary', this.arn); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /nodejs22.x/file-processing/cdk/cdk/lib/permissions-boundary-aspect.ts: -------------------------------------------------------------------------------- 1 | import { IAspect } from 'aws-cdk-lib'; 2 | import * as iam from 'aws-cdk-lib/aws-iam'; 3 | import { IConstruct } from 'constructs'; 4 | 5 | 6 | export class PermissionsBoundaryAspect implements IAspect { 7 | private readonly arn: string; 8 | 9 | constructor(permissionBoundaryArn: string) { 10 | this.arn = permissionBoundaryArn; 11 | } 12 | 13 | public visit(node: IConstruct): void { 14 | if (node instanceof iam.Role) { 15 | const roleResource = node.node.findChild('Resource') as iam.CfnRole; 16 | roleResource.addPropertyOverride('PermissionsBoundary', this.arn); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /nodejs22.x/file-processing/cdk/cdk/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lambda-s3-cdk", 3 | "version": "0.0.1", 4 | "bin": { 5 | "cdk": "bin/cdk.js" 6 | }, 7 | "scripts": { 8 | "build": "tsc", 9 | "watch": "tsc -w", 10 | "test": "jest", 11 | "cdk": "cdk" 12 | }, 13 | "devDependencies": { 14 | "@types/node": "^22.0.0", 15 | "@types/jest": "^29.5.0", 16 | "aws-cdk": "^2.70.0", 17 | "aws-cdk-lib": "^2.70.0", 18 | "constructs": "^10.1.290", 19 | "jest": "^29.5.0", 20 | "ts-jest": "^29.1.0", 21 | "ts-node": "^10.9.0", 22 | "typescript": "^5.0.0" 23 | }, 24 | "dependencies": { 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /nodejs22.x/queue-processing/cdk/cdk/lib/permissions-boundary-aspect.ts: -------------------------------------------------------------------------------- 1 | import { IAspect } from 'aws-cdk-lib'; 2 | import * as iam from 'aws-cdk-lib/aws-iam'; 3 | import { IConstruct } from 'constructs'; 4 | 5 | 6 | export class PermissionsBoundaryAspect implements IAspect { 7 | private readonly arn: string; 8 | 9 | constructor(permissionBoundaryArn: string) { 10 | this.arn = permissionBoundaryArn; 11 | } 12 | 13 | public visit(node: IConstruct): void { 14 | if (node instanceof iam.Role) { 15 | const roleResource = node.node.findChild('Resource') as iam.CfnRole; 16 | roleResource.addPropertyOverride('PermissionsBoundary', this.arn); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /nodejs18.x/author-from-scratch/cdk/cdk/lib/permissions-boundary-aspect.ts: -------------------------------------------------------------------------------- 1 | import { IAspect } from 'aws-cdk-lib'; 2 | import * as iam from 'aws-cdk-lib/aws-iam'; 3 | import { IConstruct } from 'constructs'; 4 | 5 | 6 | export class PermissionsBoundaryAspect implements IAspect { 7 | private readonly arn: string; 8 | 9 | constructor(permissionBoundaryArn: string) { 10 | this.arn = permissionBoundaryArn; 11 | } 12 | 13 | public visit(node: IConstruct): void { 14 | if (node instanceof iam.Role) { 15 | const roleResource = node.node.findChild('Resource') as iam.CfnRole; 16 | roleResource.addPropertyOverride('PermissionsBoundary', this.arn); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /nodejs18.x/file-processing/cdk/cdk/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lambda-s3-cdk", 3 | "version": "0.0.1", 4 | "bin": { 5 | "cdk": "bin/cdk.js" 6 | }, 7 | "scripts": { 8 | "build": "tsc", 9 | "watch": "tsc -w", 10 | "test": "jest", 11 | "cdk": "cdk" 12 | }, 13 | "devDependencies": { 14 | "@types/node": "^18.15.0", 15 | "@types/jest": "^29.5.0", 16 | "aws-cdk": "^2.70.0", 17 | "aws-cdk-lib": "^2.70.0", 18 | "constructs": "^10.1.290", 19 | "jest": "^29.5.0", 20 | "ts-jest": "^29.1.0", 21 | "ts-node": "^10.9.0", 22 | "typescript": "^5.0.0" 23 | }, 24 | "dependencies": { 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /nodejs18.x/queue-processing/cdk/cdk/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lambda-sqs-cdk", 3 | "version": "0.0.1", 4 | "bin": { 5 | "cdk": "bin/cdk.js" 6 | }, 7 | "scripts": { 8 | "build": "tsc", 9 | "watch": "tsc -w", 10 | "test": "jest", 11 | "cdk": "cdk" 12 | }, 13 | "devDependencies": { 14 | "@types/node": "^18.15.0", 15 | "@types/jest": "^29.5.0", 16 | "aws-cdk": "^2.70.0", 17 | "aws-cdk-lib": "^2.70.0", 18 | "constructs": "^10.1.290", 19 | "jest": "^29.5.0", 20 | "ts-jest": "^29.1.0", 21 | "ts-node": "^10.9.0", 22 | "typescript": "^5.0.0" 23 | }, 24 | "dependencies": { 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /nodejs18.x/serverless-api-backend/cdk/cdk/lib/permissions-boundary-aspect.ts: -------------------------------------------------------------------------------- 1 | import { IAspect } from 'aws-cdk-lib'; 2 | import * as iam from 'aws-cdk-lib/aws-iam'; 3 | import { IConstruct } from 'constructs'; 4 | 5 | 6 | export class PermissionsBoundaryAspect implements IAspect { 7 | private readonly arn: string; 8 | 9 | constructor(permissionBoundaryArn: string) { 10 | this.arn = permissionBoundaryArn; 11 | } 12 | 13 | public visit(node: IConstruct): void { 14 | if (node instanceof iam.Role) { 15 | const roleResource = node.node.findChild('Resource') as iam.CfnRole; 16 | roleResource.addPropertyOverride('PermissionsBoundary', this.arn); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /nodejs22.x/author-from-scratch/cdk/cdk/lib/permissions-boundary-aspect.ts: -------------------------------------------------------------------------------- 1 | import { IAspect } from 'aws-cdk-lib'; 2 | import * as iam from 'aws-cdk-lib/aws-iam'; 3 | import { IConstruct } from 'constructs'; 4 | 5 | 6 | export class PermissionsBoundaryAspect implements IAspect { 7 | private readonly arn: string; 8 | 9 | constructor(permissionBoundaryArn: string) { 10 | this.arn = permissionBoundaryArn; 11 | } 12 | 13 | public visit(node: IConstruct): void { 14 | if (node instanceof iam.Role) { 15 | const roleResource = node.node.findChild('Resource') as iam.CfnRole; 16 | roleResource.addPropertyOverride('PermissionsBoundary', this.arn); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /nodejs22.x/queue-processing/cdk/cdk/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lambda-sqs-cdk", 3 | "version": "0.0.1", 4 | "bin": { 5 | "cdk": "bin/cdk.js" 6 | }, 7 | "scripts": { 8 | "build": "tsc", 9 | "watch": "tsc -w", 10 | "test": "jest", 11 | "cdk": "cdk" 12 | }, 13 | "devDependencies": { 14 | "@types/node": "^22.0.0", 15 | "@types/jest": "^29.5.0", 16 | "aws-cdk": "^2.70.0", 17 | "aws-cdk-lib": "^2.70.0", 18 | "constructs": "^10.1.290", 19 | "jest": "^29.5.0", 20 | "ts-jest": "^29.1.0", 21 | "ts-node": "^10.9.0", 22 | "typescript": "^5.0.0" 23 | }, 24 | "dependencies": { 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /nodejs22.x/scheduled-job/cdk/cdk/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lambda-scheduled-cdk", 3 | "version": "0.0.1", 4 | "bin": { 5 | "cdk": "bin/cdk.js" 6 | }, 7 | "scripts": { 8 | "build": "tsc", 9 | "watch": "tsc -w", 10 | "test": "jest", 11 | "cdk": "cdk" 12 | }, 13 | "devDependencies": { 14 | "@types/node": "^22.0.0", 15 | "@types/jest": "^29.5.0", 16 | "aws-cdk": "^2.70.0", 17 | "aws-cdk-lib": "^2.70.0", 18 | "constructs": "^10.1.290", 19 | "jest": "^29.5.0", 20 | "ts-jest": "^29.1.0", 21 | "ts-node": "^10.9.0", 22 | "typescript": "^5.0.0" 23 | }, 24 | "dependencies": { 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /nodejs22.x/serverless-api-backend/cdk/cdk/lib/permissions-boundary-aspect.ts: -------------------------------------------------------------------------------- 1 | import { IAspect } from 'aws-cdk-lib'; 2 | import * as iam from 'aws-cdk-lib/aws-iam'; 3 | import { IConstruct } from 'constructs'; 4 | 5 | 6 | export class PermissionsBoundaryAspect implements IAspect { 7 | private readonly arn: string; 8 | 9 | constructor(permissionBoundaryArn: string) { 10 | this.arn = permissionBoundaryArn; 11 | } 12 | 13 | public visit(node: IConstruct): void { 14 | if (node instanceof iam.Role) { 15 | const roleResource = node.node.findChild('Resource') as iam.CfnRole; 16 | roleResource.addPropertyOverride('PermissionsBoundary', this.arn); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /nodejs18.x/notifications-processing/cdk/cdk/lib/permissions-boundary-aspect.ts: -------------------------------------------------------------------------------- 1 | import { IAspect } from 'aws-cdk-lib'; 2 | import * as iam from 'aws-cdk-lib/aws-iam'; 3 | import { IConstruct } from 'constructs'; 4 | 5 | 6 | export class PermissionsBoundaryAspect implements IAspect { 7 | private readonly arn: string; 8 | 9 | constructor(permissionBoundaryArn: string) { 10 | this.arn = permissionBoundaryArn; 11 | } 12 | 13 | public visit(node: IConstruct): void { 14 | if (node instanceof iam.Role) { 15 | const roleResource = node.node.findChild('Resource') as iam.CfnRole; 16 | roleResource.addPropertyOverride('PermissionsBoundary', this.arn); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /nodejs18.x/scheduled-job/cdk/cdk/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lambda-scheduled-cdk", 3 | "version": "0.0.1", 4 | "bin": { 5 | "cdk": "bin/cdk.js" 6 | }, 7 | "scripts": { 8 | "build": "tsc", 9 | "watch": "tsc -w", 10 | "test": "jest", 11 | "cdk": "cdk" 12 | }, 13 | "devDependencies": { 14 | "@types/node": "^18.15.0", 15 | "@types/jest": "^29.5.0", 16 | "aws-cdk": "^2.70.0", 17 | "aws-cdk-lib": "^2.70.0", 18 | "constructs": "^10.1.290", 19 | "jest": "^29.5.0", 20 | "ts-jest": "^29.1.0", 21 | "ts-node": "^10.9.0", 22 | "typescript": "^5.0.0" 23 | }, 24 | "dependencies": { 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /nodejs22.x/notifications-processing/cdk/cdk/lib/permissions-boundary-aspect.ts: -------------------------------------------------------------------------------- 1 | import { IAspect } from 'aws-cdk-lib'; 2 | import * as iam from 'aws-cdk-lib/aws-iam'; 3 | import { IConstruct } from 'constructs'; 4 | 5 | 6 | export class PermissionsBoundaryAspect implements IAspect { 7 | private readonly arn: string; 8 | 9 | constructor(permissionBoundaryArn: string) { 10 | this.arn = permissionBoundaryArn; 11 | } 12 | 13 | public visit(node: IConstruct): void { 14 | if (node instanceof iam.Role) { 15 | const roleResource = node.node.findChild('Resource') as iam.CfnRole; 16 | roleResource.addPropertyOverride('PermissionsBoundary', this.arn); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /nodejs22.x/notifications-processing/cdk/cdk/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lambda-sns-cdk", 3 | "version": "0.0.1", 4 | "bin": { 5 | "cdk": "bin/cdk.js" 6 | }, 7 | "scripts": { 8 | "build": "tsc", 9 | "watch": "tsc -w", 10 | "test": "jest", 11 | "cdk": "cdk" 12 | }, 13 | "devDependencies": { 14 | "@types/node": "^22.0.0", 15 | "@types/jest": "^29.5.0", 16 | "aws-cdk": "^2.70.0", 17 | "aws-cdk-lib": "^2.70.0", 18 | "constructs": "^10.1.290", 19 | "jest": "^29.5.0", 20 | "ts-jest": "^29.1.0", 21 | "ts-node": "^10.9.0", 22 | "typescript": "^5.0.0" 23 | }, 24 | "dependencies": { 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /nodejs18.x/author-from-scratch/cdk/cdk/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lambda-from-scratch-cdk", 3 | "version": "0.0.1", 4 | "bin": { 5 | "cdk": "bin/cdk.js" 6 | }, 7 | "scripts": { 8 | "build": "tsc", 9 | "watch": "tsc -w", 10 | "test": "jest", 11 | "cdk": "cdk" 12 | }, 13 | "devDependencies": { 14 | "@types/node": "^18.15.0", 15 | "@types/jest": "^29.5.0", 16 | "aws-cdk": "^2.70.0", 17 | "aws-cdk-lib": "^2.70.0", 18 | "constructs": "^10.1.290", 19 | "jest": "^29.5.0", 20 | "ts-jest": "^29.1.0", 21 | "ts-node": "^10.9.0", 22 | "typescript": "^5.0.0" 23 | }, 24 | "dependencies": { 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /nodejs18.x/notifications-processing/cdk/cdk/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lambda-sns-cdk", 3 | "version": "0.0.1", 4 | "bin": { 5 | "cdk": "bin/cdk.js" 6 | }, 7 | "scripts": { 8 | "build": "tsc", 9 | "watch": "tsc -w", 10 | "test": "jest", 11 | "cdk": "cdk" 12 | }, 13 | "devDependencies": { 14 | "@types/node": "^18.15.0", 15 | "@types/jest": "^29.5.0", 16 | "aws-cdk": "^2.70.0", 17 | "aws-cdk-lib": "^2.70.0", 18 | "constructs": "^10.1.290", 19 | "jest": "^29.5.0", 20 | "ts-jest": "^29.1.0", 21 | "ts-node": "^10.9.0", 22 | "typescript": "^5.0.0" 23 | }, 24 | "dependencies": { 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /nodejs18.x/queue-processing/cdk/events/event-sqs.json: -------------------------------------------------------------------------------- 1 | { 2 | "Records": [ 3 | { 4 | "messageId": "19dd0b57-b21e-4ac1-bd88-01bbb068cb78", 5 | "receiptHandle": "MessageReceiptHandle", 6 | "body": "Hello from SQS!", 7 | "attributes": { 8 | "ApproximateReceiveCount": "1", 9 | "SentTimestamp": "1523232000000", 10 | "SenderId": "012345678910", 11 | "ApproximateFirstReceiveTimestamp": "1523232000001" 12 | }, 13 | "messageAttributes": {}, 14 | "md5OfBody": "7b270e59b47ff90a553787216d55d91d", 15 | "eventSource": "aws:sqs", 16 | "eventSourceARN": "arn:aws:sqs:us-west-2:012345678910:SimpleQueue", 17 | "awsRegion": "us-west-2" 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /nodejs18.x/queue-processing/sam/events/event-sqs.json: -------------------------------------------------------------------------------- 1 | { 2 | "Records": [ 3 | { 4 | "messageId": "19dd0b57-b21e-4ac1-bd88-01bbb068cb78", 5 | "receiptHandle": "MessageReceiptHandle", 6 | "body": "Hello from SQS!", 7 | "attributes": { 8 | "ApproximateReceiveCount": "1", 9 | "SentTimestamp": "1523232000000", 10 | "SenderId": "012345678910", 11 | "ApproximateFirstReceiveTimestamp": "1523232000001" 12 | }, 13 | "messageAttributes": {}, 14 | "md5OfBody": "7b270e59b47ff90a553787216d55d91d", 15 | "eventSource": "aws:sqs", 16 | "eventSourceARN": "arn:aws:sqs:us-west-2:012345678910:SimpleQueue", 17 | "awsRegion": "us-west-2" 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /nodejs22.x/author-from-scratch/cdk/cdk/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lambda-from-scratch-cdk", 3 | "version": "0.0.1", 4 | "bin": { 5 | "cdk": "bin/cdk.js" 6 | }, 7 | "scripts": { 8 | "build": "tsc", 9 | "watch": "tsc -w", 10 | "test": "jest", 11 | "cdk": "cdk" 12 | }, 13 | "devDependencies": { 14 | "@types/node": "^22.0.0", 15 | "@types/jest": "^29.5.0", 16 | "aws-cdk": "^2.70.0", 17 | "aws-cdk-lib": "^2.70.0", 18 | "constructs": "^10.1.290", 19 | "jest": "^29.5.0", 20 | "ts-jest": "^29.1.0", 21 | "ts-node": "^10.9.0", 22 | "typescript": "^5.0.0" 23 | }, 24 | "dependencies": { 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /nodejs22.x/queue-processing/cdk/events/event-sqs.json: -------------------------------------------------------------------------------- 1 | { 2 | "Records": [ 3 | { 4 | "messageId": "19dd0b57-b21e-4ac1-bd88-01bbb068cb78", 5 | "receiptHandle": "MessageReceiptHandle", 6 | "body": "Hello from SQS!", 7 | "attributes": { 8 | "ApproximateReceiveCount": "1", 9 | "SentTimestamp": "1523232000000", 10 | "SenderId": "012345678910", 11 | "ApproximateFirstReceiveTimestamp": "1523232000001" 12 | }, 13 | "messageAttributes": {}, 14 | "md5OfBody": "7b270e59b47ff90a553787216d55d91d", 15 | "eventSource": "aws:sqs", 16 | "eventSourceARN": "arn:aws:sqs:us-west-2:012345678910:SimpleQueue", 17 | "awsRegion": "us-west-2" 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /nodejs22.x/queue-processing/sam/events/event-sqs.json: -------------------------------------------------------------------------------- 1 | { 2 | "Records": [ 3 | { 4 | "messageId": "19dd0b57-b21e-4ac1-bd88-01bbb068cb78", 5 | "receiptHandle": "MessageReceiptHandle", 6 | "body": "Hello from SQS!", 7 | "attributes": { 8 | "ApproximateReceiveCount": "1", 9 | "SentTimestamp": "1523232000000", 10 | "SenderId": "012345678910", 11 | "ApproximateFirstReceiveTimestamp": "1523232000001" 12 | }, 13 | "messageAttributes": {}, 14 | "md5OfBody": "7b270e59b47ff90a553787216d55d91d", 15 | "eventSource": "aws:sqs", 16 | "eventSourceARN": "arn:aws:sqs:us-west-2:012345678910:SimpleQueue", 17 | "awsRegion": "us-west-2" 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /nodejs18.x/serverless-api-backend/cdk/cdk/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lambda-api-backend-cdk", 3 | "version": "0.0.1", 4 | "bin": { 5 | "cdk": "bin/cdk.js" 6 | }, 7 | "scripts": { 8 | "build": "tsc", 9 | "watch": "tsc -w", 10 | "test": "jest", 11 | "cdk": "cdk" 12 | }, 13 | "devDependencies": { 14 | "@types/node": "^18.15.0", 15 | "@types/jest": "^29.5.0", 16 | "aws-cdk": "^2.70.0", 17 | "aws-cdk-lib": "^2.70.0", 18 | "constructs": "^10.1.290", 19 | "jest": "^29.5.0", 20 | "ts-jest": "^29.1.0", 21 | "ts-node": "^10.9.0", 22 | "typescript": "^5.0.0" 23 | }, 24 | "dependencies": { 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /nodejs22.x/serverless-api-backend/cdk/cdk/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lambda-api-backend-cdk", 3 | "version": "0.0.1", 4 | "bin": { 5 | "cdk": "bin/cdk.js" 6 | }, 7 | "scripts": { 8 | "build": "tsc", 9 | "watch": "tsc -w", 10 | "test": "jest", 11 | "cdk": "cdk" 12 | }, 13 | "devDependencies": { 14 | "@types/node": "^22.0.0", 15 | "@types/jest": "^29.5.0", 16 | "aws-cdk": "^2.70.0", 17 | "aws-cdk-lib": "^2.70.0", 18 | "constructs": "^10.1.290", 19 | "jest": "^29.5.0", 20 | "ts-jest": "^29.1.0", 21 | "ts-node": "^10.9.0", 22 | "typescript": "^5.0.0" 23 | }, 24 | "dependencies": { 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /CICD-toolchain-for-serverless-applications/README.md: -------------------------------------------------------------------------------- 1 | ## CI/CD toolchain for Serverless Applications 2 | 3 | A continuous delivery pipeline to deploy serverless applications created in the AWS Lambda console. With continuous delivery, every change that you push to your source control repository triggers a pipeline that builds and deploys your application automatically. The Lambda console provides examples for common application types with sample code and templates that create supporting resources. 4 | 5 | To get started, go to the [AWS Lambda console](https://us-east-1.console.aws.amazon.com/lambda/home?region=us-east-1#/create/application). For more information, see [the documentation](https://docs.aws.amazon.com/lambda/latest/dg/applications-tutorial.html). 6 | -------------------------------------------------------------------------------- /nodejs18.x/scheduled-job/sam/buildspec.yml: -------------------------------------------------------------------------------- 1 | version: 0.2 2 | phases: 3 | install: 4 | commands: 5 | # Install all dependencies (including dependencies for running tests) 6 | - npm install 7 | pre_build: 8 | commands: 9 | # Discover and run unit tests in the '__tests__' directory 10 | - npm run test 11 | # Remove all dependencies not needed for the Lambda deployment package (the packages from devDependencies in package.json) 12 | - npm prune --production 13 | build: 14 | commands: 15 | # Use AWS SAM to package the application by using AWS CloudFormation 16 | - aws cloudformation package --template template.yml --s3-bucket $S3_BUCKET --output-template-file template-export.yml 17 | artifacts: 18 | files: 19 | - template-export.yml 20 | -------------------------------------------------------------------------------- /nodejs22.x/scheduled-job/sam/buildspec.yml: -------------------------------------------------------------------------------- 1 | version: 0.2 2 | phases: 3 | install: 4 | commands: 5 | # Install all dependencies (including dependencies for running tests) 6 | - npm install 7 | pre_build: 8 | commands: 9 | # Discover and run unit tests in the '__tests__' directory 10 | - npm run test 11 | # Remove all dependencies not needed for the Lambda deployment package (the packages from devDependencies in package.json) 12 | - npm prune --production 13 | build: 14 | commands: 15 | # Use AWS SAM to package the application by using AWS CloudFormation 16 | - aws cloudformation package --template template.yml --s3-bucket $S3_BUCKET --output-template-file template-export.yml 17 | artifacts: 18 | files: 19 | - template-export.yml 20 | -------------------------------------------------------------------------------- /nodejs18.x/author-from-scratch/sam/buildspec.yml: -------------------------------------------------------------------------------- 1 | version: 0.2 2 | phases: 3 | install: 4 | commands: 5 | # Install all dependencies (including dependencies for running tests) 6 | - npm install 7 | pre_build: 8 | commands: 9 | # Discover and run unit tests in the '__tests__' directory 10 | - npm run test 11 | # Remove all dependencies not needed for the Lambda deployment package (the packages from devDependencies in package.json) 12 | - npm prune --production 13 | build: 14 | commands: 15 | # Use AWS SAM to package the application by using AWS CloudFormation 16 | - aws cloudformation package --template template.yml --s3-bucket $S3_BUCKET --output-template-file template-export.yml 17 | artifacts: 18 | files: 19 | - template-export.yml 20 | -------------------------------------------------------------------------------- /nodejs18.x/file-processing/sam/buildspec.yml: -------------------------------------------------------------------------------- 1 | version: 0.2 2 | phases: 3 | install: 4 | commands: 5 | # Install all dependencies (including dependencies for running tests) 6 | - npm install 7 | pre_build: 8 | commands: 9 | # Discover and run unit tests in the '__tests__' directory 10 | - npm run test 11 | # Remove all dependencies not needed for the Lambda deployment package (the packages from devDependencies in package.json) 12 | - npm prune --production 13 | build: 14 | commands: 15 | # Use AWS SAM to package the application by using AWS CloudFormation 16 | - aws cloudformation package --template template.yml --s3-bucket $S3_BUCKET --output-template-file template-export.yml 17 | artifacts: 18 | files: 19 | - template-export.yml 20 | -------------------------------------------------------------------------------- /nodejs18.x/queue-processing/sam/buildspec.yml: -------------------------------------------------------------------------------- 1 | version: 0.2 2 | phases: 3 | install: 4 | commands: 5 | # Install all dependencies (including dependencies for running tests) 6 | - npm install 7 | pre_build: 8 | commands: 9 | # Discover and run unit tests in the '__tests__' directory 10 | - npm run test 11 | # Remove all dependencies not needed for the Lambda deployment package (the packages from devDependencies in package.json) 12 | - npm prune --production 13 | build: 14 | commands: 15 | # Use AWS SAM to package the application by using AWS CloudFormation 16 | - aws cloudformation package --template template.yml --s3-bucket $S3_BUCKET --output-template-file template-export.yml 17 | artifacts: 18 | files: 19 | - template-export.yml 20 | -------------------------------------------------------------------------------- /nodejs22.x/author-from-scratch/sam/buildspec.yml: -------------------------------------------------------------------------------- 1 | version: 0.2 2 | phases: 3 | install: 4 | commands: 5 | # Install all dependencies (including dependencies for running tests) 6 | - npm install 7 | pre_build: 8 | commands: 9 | # Discover and run unit tests in the '__tests__' directory 10 | - npm run test 11 | # Remove all dependencies not needed for the Lambda deployment package (the packages from devDependencies in package.json) 12 | - npm prune --production 13 | build: 14 | commands: 15 | # Use AWS SAM to package the application by using AWS CloudFormation 16 | - aws cloudformation package --template template.yml --s3-bucket $S3_BUCKET --output-template-file template-export.yml 17 | artifacts: 18 | files: 19 | - template-export.yml 20 | -------------------------------------------------------------------------------- /nodejs22.x/file-processing/sam/buildspec.yml: -------------------------------------------------------------------------------- 1 | version: 0.2 2 | phases: 3 | install: 4 | commands: 5 | # Install all dependencies (including dependencies for running tests) 6 | - npm install 7 | pre_build: 8 | commands: 9 | # Discover and run unit tests in the '__tests__' directory 10 | - npm run test 11 | # Remove all dependencies not needed for the Lambda deployment package (the packages from devDependencies in package.json) 12 | - npm prune --production 13 | build: 14 | commands: 15 | # Use AWS SAM to package the application by using AWS CloudFormation 16 | - aws cloudformation package --template template.yml --s3-bucket $S3_BUCKET --output-template-file template-export.yml 17 | artifacts: 18 | files: 19 | - template-export.yml 20 | -------------------------------------------------------------------------------- /nodejs22.x/queue-processing/sam/buildspec.yml: -------------------------------------------------------------------------------- 1 | version: 0.2 2 | phases: 3 | install: 4 | commands: 5 | # Install all dependencies (including dependencies for running tests) 6 | - npm install 7 | pre_build: 8 | commands: 9 | # Discover and run unit tests in the '__tests__' directory 10 | - npm run test 11 | # Remove all dependencies not needed for the Lambda deployment package (the packages from devDependencies in package.json) 12 | - npm prune --production 13 | build: 14 | commands: 15 | # Use AWS SAM to package the application by using AWS CloudFormation 16 | - aws cloudformation package --template template.yml --s3-bucket $S3_BUCKET --output-template-file template-export.yml 17 | artifacts: 18 | files: 19 | - template-export.yml 20 | -------------------------------------------------------------------------------- /nodejs18.x/notifications-processing/sam/buildspec.yml: -------------------------------------------------------------------------------- 1 | version: 0.2 2 | phases: 3 | install: 4 | commands: 5 | # Install all dependencies (including dependencies for running tests) 6 | - npm install 7 | pre_build: 8 | commands: 9 | # Discover and run unit tests in the '__tests__' directory 10 | - npm run test 11 | # Remove all dependencies not needed for the Lambda deployment package (the packages from devDependencies in package.json) 12 | - npm prune --production 13 | build: 14 | commands: 15 | # Use AWS SAM to package the application by using AWS CloudFormation 16 | - aws cloudformation package --template template.yml --s3-bucket $S3_BUCKET --output-template-file template-export.yml 17 | artifacts: 18 | files: 19 | - template-export.yml 20 | -------------------------------------------------------------------------------- /nodejs18.x/serverless-api-backend/sam/buildspec.yml: -------------------------------------------------------------------------------- 1 | version: 0.2 2 | phases: 3 | install: 4 | commands: 5 | # Install all dependencies (including dependencies for running tests) 6 | - npm install 7 | pre_build: 8 | commands: 9 | # Discover and run unit tests in the '__tests__' directory 10 | - npm run test 11 | # Remove all dependencies not needed for the Lambda deployment package (the packages from devDependencies in package.json) 12 | - npm prune --production 13 | build: 14 | commands: 15 | # Use AWS SAM to package the application by using AWS CloudFormation 16 | - aws cloudformation package --template template.yml --s3-bucket $S3_BUCKET --output-template-file template-export.yml 17 | artifacts: 18 | files: 19 | - template-export.yml 20 | -------------------------------------------------------------------------------- /nodejs22.x/notifications-processing/sam/buildspec.yml: -------------------------------------------------------------------------------- 1 | version: 0.2 2 | phases: 3 | install: 4 | commands: 5 | # Install all dependencies (including dependencies for running tests) 6 | - npm install 7 | pre_build: 8 | commands: 9 | # Discover and run unit tests in the '__tests__' directory 10 | - npm run test 11 | # Remove all dependencies not needed for the Lambda deployment package (the packages from devDependencies in package.json) 12 | - npm prune --production 13 | build: 14 | commands: 15 | # Use AWS SAM to package the application by using AWS CloudFormation 16 | - aws cloudformation package --template template.yml --s3-bucket $S3_BUCKET --output-template-file template-export.yml 17 | artifacts: 18 | files: 19 | - template-export.yml 20 | -------------------------------------------------------------------------------- /nodejs22.x/serverless-api-backend/sam/buildspec.yml: -------------------------------------------------------------------------------- 1 | version: 0.2 2 | phases: 3 | install: 4 | commands: 5 | # Install all dependencies (including dependencies for running tests) 6 | - npm install 7 | pre_build: 8 | commands: 9 | # Discover and run unit tests in the '__tests__' directory 10 | - npm run test 11 | # Remove all dependencies not needed for the Lambda deployment package (the packages from devDependencies in package.json) 12 | - npm prune --production 13 | build: 14 | commands: 15 | # Use AWS SAM to package the application by using AWS CloudFormation 16 | - aws cloudformation package --template template.yml --s3-bucket $S3_BUCKET --output-template-file template-export.yml 17 | artifacts: 18 | files: 19 | - template-export.yml 20 | -------------------------------------------------------------------------------- /nodejs18.x/file-processing/cdk/cdk/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2018", 4 | "module": "commonjs", 5 | "lib": [ 6 | "es2016", 7 | "es2017.object", 8 | "es2017.string" 9 | ], 10 | "declaration": true, 11 | "strict": true, 12 | "noImplicitAny": true, 13 | "strictNullChecks": true, 14 | "noImplicitThis": true, 15 | "alwaysStrict": true, 16 | "noUnusedLocals": false, 17 | "noUnusedParameters": false, 18 | "noImplicitReturns": true, 19 | "noFallthroughCasesInSwitch": false, 20 | "inlineSourceMap": true, 21 | "inlineSources": true, 22 | "experimentalDecorators": true, 23 | "strictPropertyInitialization": false, 24 | "typeRoots": [ 25 | "./node_modules/@types" 26 | ] 27 | }, 28 | "exclude": [ 29 | "cdk.out" 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /nodejs18.x/queue-processing/cdk/cdk/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2018", 4 | "module": "commonjs", 5 | "lib": [ 6 | "es2016", 7 | "es2017.object", 8 | "es2017.string" 9 | ], 10 | "declaration": true, 11 | "strict": true, 12 | "noImplicitAny": true, 13 | "strictNullChecks": true, 14 | "noImplicitThis": true, 15 | "alwaysStrict": true, 16 | "noUnusedLocals": false, 17 | "noUnusedParameters": false, 18 | "noImplicitReturns": true, 19 | "noFallthroughCasesInSwitch": false, 20 | "inlineSourceMap": true, 21 | "inlineSources": true, 22 | "experimentalDecorators": true, 23 | "strictPropertyInitialization": false, 24 | "typeRoots": [ 25 | "./node_modules/@types" 26 | ] 27 | }, 28 | "exclude": [ 29 | "cdk.out" 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /nodejs18.x/scheduled-job/cdk/cdk/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2018", 4 | "module": "commonjs", 5 | "lib": [ 6 | "es2016", 7 | "es2017.object", 8 | "es2017.string" 9 | ], 10 | "declaration": true, 11 | "strict": true, 12 | "noImplicitAny": true, 13 | "strictNullChecks": true, 14 | "noImplicitThis": true, 15 | "alwaysStrict": true, 16 | "noUnusedLocals": false, 17 | "noUnusedParameters": false, 18 | "noImplicitReturns": true, 19 | "noFallthroughCasesInSwitch": false, 20 | "inlineSourceMap": true, 21 | "inlineSources": true, 22 | "experimentalDecorators": true, 23 | "strictPropertyInitialization": false, 24 | "typeRoots": [ 25 | "./node_modules/@types" 26 | ] 27 | }, 28 | "exclude": [ 29 | "cdk.out" 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /nodejs22.x/file-processing/cdk/cdk/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2018", 4 | "module": "commonjs", 5 | "lib": [ 6 | "es2016", 7 | "es2017.object", 8 | "es2017.string" 9 | ], 10 | "declaration": true, 11 | "strict": true, 12 | "noImplicitAny": true, 13 | "strictNullChecks": true, 14 | "noImplicitThis": true, 15 | "alwaysStrict": true, 16 | "noUnusedLocals": false, 17 | "noUnusedParameters": false, 18 | "noImplicitReturns": true, 19 | "noFallthroughCasesInSwitch": false, 20 | "inlineSourceMap": true, 21 | "inlineSources": true, 22 | "experimentalDecorators": true, 23 | "strictPropertyInitialization": false, 24 | "typeRoots": [ 25 | "./node_modules/@types" 26 | ] 27 | }, 28 | "exclude": [ 29 | "cdk.out" 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /nodejs22.x/queue-processing/cdk/cdk/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2018", 4 | "module": "commonjs", 5 | "lib": [ 6 | "es2016", 7 | "es2017.object", 8 | "es2017.string" 9 | ], 10 | "declaration": true, 11 | "strict": true, 12 | "noImplicitAny": true, 13 | "strictNullChecks": true, 14 | "noImplicitThis": true, 15 | "alwaysStrict": true, 16 | "noUnusedLocals": false, 17 | "noUnusedParameters": false, 18 | "noImplicitReturns": true, 19 | "noFallthroughCasesInSwitch": false, 20 | "inlineSourceMap": true, 21 | "inlineSources": true, 22 | "experimentalDecorators": true, 23 | "strictPropertyInitialization": false, 24 | "typeRoots": [ 25 | "./node_modules/@types" 26 | ] 27 | }, 28 | "exclude": [ 29 | "cdk.out" 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /nodejs22.x/scheduled-job/cdk/cdk/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2018", 4 | "module": "commonjs", 5 | "lib": [ 6 | "es2016", 7 | "es2017.object", 8 | "es2017.string" 9 | ], 10 | "declaration": true, 11 | "strict": true, 12 | "noImplicitAny": true, 13 | "strictNullChecks": true, 14 | "noImplicitThis": true, 15 | "alwaysStrict": true, 16 | "noUnusedLocals": false, 17 | "noUnusedParameters": false, 18 | "noImplicitReturns": true, 19 | "noFallthroughCasesInSwitch": false, 20 | "inlineSourceMap": true, 21 | "inlineSources": true, 22 | "experimentalDecorators": true, 23 | "strictPropertyInitialization": false, 24 | "typeRoots": [ 25 | "./node_modules/@types" 26 | ] 27 | }, 28 | "exclude": [ 29 | "cdk.out" 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /nodejs18.x/author-from-scratch/cdk/cdk/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2018", 4 | "module": "commonjs", 5 | "lib": [ 6 | "es2016", 7 | "es2017.object", 8 | "es2017.string" 9 | ], 10 | "declaration": true, 11 | "strict": true, 12 | "noImplicitAny": true, 13 | "strictNullChecks": true, 14 | "noImplicitThis": true, 15 | "alwaysStrict": true, 16 | "noUnusedLocals": false, 17 | "noUnusedParameters": false, 18 | "noImplicitReturns": true, 19 | "noFallthroughCasesInSwitch": false, 20 | "inlineSourceMap": true, 21 | "inlineSources": true, 22 | "experimentalDecorators": true, 23 | "strictPropertyInitialization": false, 24 | "typeRoots": [ 25 | "./node_modules/@types" 26 | ] 27 | }, 28 | "exclude": [ 29 | "cdk.out" 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /nodejs18.x/serverless-api-backend/cdk/cdk/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2018", 4 | "module": "commonjs", 5 | "lib": [ 6 | "es2016", 7 | "es2017.object", 8 | "es2017.string" 9 | ], 10 | "declaration": true, 11 | "strict": true, 12 | "noImplicitAny": true, 13 | "strictNullChecks": true, 14 | "noImplicitThis": true, 15 | "alwaysStrict": true, 16 | "noUnusedLocals": false, 17 | "noUnusedParameters": false, 18 | "noImplicitReturns": true, 19 | "noFallthroughCasesInSwitch": false, 20 | "inlineSourceMap": true, 21 | "inlineSources": true, 22 | "experimentalDecorators": true, 23 | "strictPropertyInitialization": false, 24 | "typeRoots": [ 25 | "./node_modules/@types" 26 | ] 27 | }, 28 | "exclude": [ 29 | "cdk.out" 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /nodejs22.x/author-from-scratch/cdk/cdk/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2018", 4 | "module": "commonjs", 5 | "lib": [ 6 | "es2016", 7 | "es2017.object", 8 | "es2017.string" 9 | ], 10 | "declaration": true, 11 | "strict": true, 12 | "noImplicitAny": true, 13 | "strictNullChecks": true, 14 | "noImplicitThis": true, 15 | "alwaysStrict": true, 16 | "noUnusedLocals": false, 17 | "noUnusedParameters": false, 18 | "noImplicitReturns": true, 19 | "noFallthroughCasesInSwitch": false, 20 | "inlineSourceMap": true, 21 | "inlineSources": true, 22 | "experimentalDecorators": true, 23 | "strictPropertyInitialization": false, 24 | "typeRoots": [ 25 | "./node_modules/@types" 26 | ] 27 | }, 28 | "exclude": [ 29 | "cdk.out" 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /nodejs22.x/serverless-api-backend/cdk/cdk/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2018", 4 | "module": "commonjs", 5 | "lib": [ 6 | "es2016", 7 | "es2017.object", 8 | "es2017.string" 9 | ], 10 | "declaration": true, 11 | "strict": true, 12 | "noImplicitAny": true, 13 | "strictNullChecks": true, 14 | "noImplicitThis": true, 15 | "alwaysStrict": true, 16 | "noUnusedLocals": false, 17 | "noUnusedParameters": false, 18 | "noImplicitReturns": true, 19 | "noFallthroughCasesInSwitch": false, 20 | "inlineSourceMap": true, 21 | "inlineSources": true, 22 | "experimentalDecorators": true, 23 | "strictPropertyInitialization": false, 24 | "typeRoots": [ 25 | "./node_modules/@types" 26 | ] 27 | }, 28 | "exclude": [ 29 | "cdk.out" 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /nodejs18.x/notifications-processing/cdk/cdk/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2018", 4 | "module": "commonjs", 5 | "lib": [ 6 | "es2016", 7 | "es2017.object", 8 | "es2017.string" 9 | ], 10 | "declaration": true, 11 | "strict": true, 12 | "noImplicitAny": true, 13 | "strictNullChecks": true, 14 | "noImplicitThis": true, 15 | "alwaysStrict": true, 16 | "noUnusedLocals": false, 17 | "noUnusedParameters": false, 18 | "noImplicitReturns": true, 19 | "noFallthroughCasesInSwitch": false, 20 | "inlineSourceMap": true, 21 | "inlineSources": true, 22 | "experimentalDecorators": true, 23 | "strictPropertyInitialization": false, 24 | "typeRoots": [ 25 | "./node_modules/@types" 26 | ] 27 | }, 28 | "exclude": [ 29 | "cdk.out" 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /nodejs22.x/notifications-processing/cdk/cdk/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2018", 4 | "module": "commonjs", 5 | "lib": [ 6 | "es2016", 7 | "es2017.object", 8 | "es2017.string" 9 | ], 10 | "declaration": true, 11 | "strict": true, 12 | "noImplicitAny": true, 13 | "strictNullChecks": true, 14 | "noImplicitThis": true, 15 | "alwaysStrict": true, 16 | "noUnusedLocals": false, 17 | "noUnusedParameters": false, 18 | "noImplicitReturns": true, 19 | "noFallthroughCasesInSwitch": false, 20 | "inlineSourceMap": true, 21 | "inlineSources": true, 22 | "experimentalDecorators": true, 23 | "strictPropertyInitialization": false, 24 | "typeRoots": [ 25 | "./node_modules/@types" 26 | ] 27 | }, 28 | "exclude": [ 29 | "cdk.out" 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2019 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 | -------------------------------------------------------------------------------- /nodejs18.x/scheduled-job/cdk/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2019 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 | -------------------------------------------------------------------------------- /nodejs18.x/scheduled-job/sam/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2019 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 | -------------------------------------------------------------------------------- /nodejs22.x/scheduled-job/cdk/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2019 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 | -------------------------------------------------------------------------------- /nodejs22.x/scheduled-job/sam/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2019 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 | -------------------------------------------------------------------------------- /nodejs18.x/file-processing/cdk/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2019 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 | -------------------------------------------------------------------------------- /nodejs18.x/file-processing/sam/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2019 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 | -------------------------------------------------------------------------------- /nodejs18.x/queue-processing/cdk/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2019 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 | -------------------------------------------------------------------------------- /nodejs18.x/queue-processing/sam/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2019 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 | -------------------------------------------------------------------------------- /nodejs22.x/file-processing/cdk/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2019 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 | -------------------------------------------------------------------------------- /nodejs22.x/file-processing/sam/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2019 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 | -------------------------------------------------------------------------------- /nodejs22.x/queue-processing/cdk/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2019 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 | -------------------------------------------------------------------------------- /nodejs22.x/queue-processing/sam/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2019 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 | -------------------------------------------------------------------------------- /nodejs18.x/author-from-scratch/cdk/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2019 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 | -------------------------------------------------------------------------------- /nodejs18.x/author-from-scratch/sam/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2019 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 | -------------------------------------------------------------------------------- /nodejs18.x/serverless-api-backend/cdk/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2019 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 | -------------------------------------------------------------------------------- /nodejs18.x/serverless-api-backend/sam/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2019 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 | -------------------------------------------------------------------------------- /nodejs22.x/author-from-scratch/cdk/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2019 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 | -------------------------------------------------------------------------------- /nodejs22.x/author-from-scratch/sam/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2019 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 | -------------------------------------------------------------------------------- /nodejs22.x/serverless-api-backend/cdk/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2019 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 | -------------------------------------------------------------------------------- /nodejs22.x/serverless-api-backend/sam/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2019 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 | -------------------------------------------------------------------------------- /nodejs18.x/notifications-processing/cdk/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2019 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 | -------------------------------------------------------------------------------- /nodejs18.x/notifications-processing/sam/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2019 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 | -------------------------------------------------------------------------------- /nodejs22.x/notifications-processing/cdk/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2019 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 | -------------------------------------------------------------------------------- /nodejs22.x/notifications-processing/sam/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2019 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 | -------------------------------------------------------------------------------- /nodejs18.x/author-from-scratch/cdk/__tests__/unit/handlers/hello-from-lambda.test.js: -------------------------------------------------------------------------------- 1 | // Import all functions from hello-from-lambda.js 2 | const lambda = require('../../../src/handlers/hello-from-lambda.js'); 3 | 4 | describe('Test for hello-from-lambda', () => { 5 | // This test invokes the hello-from-lambda Lambda function and compares the result 6 | it('Verifies successful response', async () => { 7 | // Invoke helloFromLambdaHandler 8 | const result = await lambda.helloFromLambdaHandler(); 9 | 10 | /* 11 | The expected result should match the return from your Lambda function. 12 | e.g. 13 | If you change from `const message = 'Hello from Lambda!';` to `const message = 'Hello World!';` in hello-from-lambda.js, 14 | you should change the following line to `const expectedResult = 'Hello World!';` 15 | */ 16 | const expectedResult = 'Hello from Lambda!'; 17 | 18 | // Compare the result with the expected result 19 | expect(result).toEqual(expectedResult); 20 | }); 21 | }); 22 | -------------------------------------------------------------------------------- /nodejs18.x/author-from-scratch/sam/__tests__/unit/handlers/hello-from-lambda.test.js: -------------------------------------------------------------------------------- 1 | // Import all functions from hello-from-lambda.js 2 | const lambda = require('../../../src/handlers/hello-from-lambda.js'); 3 | 4 | describe('Test for hello-from-lambda', () => { 5 | // This test invokes the hello-from-lambda Lambda function and compares the result 6 | it('Verifies successful response', async () => { 7 | // Invoke helloFromLambdaHandler 8 | const result = await lambda.helloFromLambdaHandler(); 9 | 10 | /* 11 | The expected result should match the return from your Lambda function. 12 | e.g. 13 | If you change from `const message = 'Hello from Lambda!';` to `const message = 'Hello World!';` in hello-from-lambda.js, 14 | you should change the following line to `const expectedResult = 'Hello World!';` 15 | */ 16 | const expectedResult = 'Hello from Lambda!'; 17 | 18 | // Compare the result with the expected result 19 | expect(result).toEqual(expectedResult); 20 | }); 21 | }); 22 | -------------------------------------------------------------------------------- /nodejs22.x/author-from-scratch/cdk/__tests__/unit/handlers/hello-from-lambda.test.js: -------------------------------------------------------------------------------- 1 | // Import all functions from hello-from-lambda.js 2 | const lambda = require('../../../src/handlers/hello-from-lambda.js'); 3 | 4 | describe('Test for hello-from-lambda', () => { 5 | // This test invokes the hello-from-lambda Lambda function and compares the result 6 | it('Verifies successful response', async () => { 7 | // Invoke helloFromLambdaHandler 8 | const result = await lambda.helloFromLambdaHandler(); 9 | 10 | /* 11 | The expected result should match the return from your Lambda function. 12 | e.g. 13 | If you change from `const message = 'Hello from Lambda!';` to `const message = 'Hello World!';` in hello-from-lambda.js, 14 | you should change the following line to `const expectedResult = 'Hello World!';` 15 | */ 16 | const expectedResult = 'Hello from Lambda!'; 17 | 18 | // Compare the result with the expected result 19 | expect(result).toEqual(expectedResult); 20 | }); 21 | }); 22 | -------------------------------------------------------------------------------- /nodejs22.x/author-from-scratch/sam/__tests__/unit/handlers/hello-from-lambda.test.js: -------------------------------------------------------------------------------- 1 | // Import all functions from hello-from-lambda.js 2 | const lambda = require('../../../src/handlers/hello-from-lambda.js'); 3 | 4 | describe('Test for hello-from-lambda', () => { 5 | // This test invokes the hello-from-lambda Lambda function and compares the result 6 | it('Verifies successful response', async () => { 7 | // Invoke helloFromLambdaHandler 8 | const result = await lambda.helloFromLambdaHandler(); 9 | 10 | /* 11 | The expected result should match the return from your Lambda function. 12 | e.g. 13 | If you change from `const message = 'Hello from Lambda!';` to `const message = 'Hello World!';` in hello-from-lambda.js, 14 | you should change the following line to `const expectedResult = 'Hello World!';` 15 | */ 16 | const expectedResult = 'Hello from Lambda!'; 17 | 18 | // Compare the result with the expected result 19 | expect(result).toEqual(expectedResult); 20 | }); 21 | }); 22 | -------------------------------------------------------------------------------- /nodejs18.x/file-processing/cdk/src/handlers/s3-json-logger.js: -------------------------------------------------------------------------------- 1 | // Create clients outside of the handler 2 | 3 | // Create a client to read objects from S3 4 | const AWS = require('aws-sdk'); 5 | 6 | const s3 = new AWS.S3(); 7 | 8 | /** 9 | * A Lambda function that logs the payload received from S3. 10 | */ 11 | exports.s3JsonLoggerHandler = async (event, context) => { 12 | const getObjectRequests = event.Records.map(async (record) => { 13 | const params = { 14 | Bucket: record.s3.bucket.name, 15 | Key: record.s3.object.key, 16 | }; 17 | try { 18 | const { Body } = await s3.getObject(params).promise(); 19 | // All log statements are written to CloudWatch by default. For more information, see 20 | // https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-logging.html 21 | console.log(Body.toString()); 22 | } catch (error) { 23 | console.error('Error calling S3 getObject:', error); 24 | throw error; 25 | } 26 | }); 27 | 28 | await Promise.all(getObjectRequests); 29 | }; 30 | -------------------------------------------------------------------------------- /nodejs18.x/file-processing/sam/src/handlers/s3-json-logger.js: -------------------------------------------------------------------------------- 1 | // Create clients outside of the handler 2 | 3 | // Create a client to read objects from S3 4 | const AWS = require('aws-sdk'); 5 | 6 | const s3 = new AWS.S3(); 7 | 8 | /** 9 | * A Lambda function that logs the payload received from S3. 10 | */ 11 | exports.s3JsonLoggerHandler = async (event, context) => { 12 | const getObjectRequests = event.Records.map(async (record) => { 13 | const params = { 14 | Bucket: record.s3.bucket.name, 15 | Key: record.s3.object.key, 16 | }; 17 | try { 18 | const { Body } = await s3.getObject(params).promise(); 19 | // All log statements are written to CloudWatch by default. For more information, see 20 | // https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-logging.html 21 | console.log(Body.toString()); 22 | } catch (error) { 23 | console.error('Error calling S3 getObject:', error); 24 | throw error; 25 | } 26 | }); 27 | 28 | await Promise.all(getObjectRequests); 29 | }; 30 | -------------------------------------------------------------------------------- /nodejs22.x/file-processing/cdk/src/handlers/s3-json-logger.js: -------------------------------------------------------------------------------- 1 | // Create clients outside of the handler 2 | 3 | // Create a client to read objects from S3 4 | const AWS = require('aws-sdk'); 5 | 6 | const s3 = new AWS.S3(); 7 | 8 | /** 9 | * A Lambda function that logs the payload received from S3. 10 | */ 11 | exports.s3JsonLoggerHandler = async (event, context) => { 12 | const getObjectRequests = event.Records.map(async (record) => { 13 | const params = { 14 | Bucket: record.s3.bucket.name, 15 | Key: record.s3.object.key, 16 | }; 17 | try { 18 | const { Body } = await s3.getObject(params).promise(); 19 | // All log statements are written to CloudWatch by default. For more information, see 20 | // https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-logging.html 21 | console.log(Body.toString()); 22 | } catch (error) { 23 | console.error('Error calling S3 getObject:', error); 24 | throw error; 25 | } 26 | }); 27 | 28 | await Promise.all(getObjectRequests); 29 | }; 30 | -------------------------------------------------------------------------------- /nodejs22.x/file-processing/sam/src/handlers/s3-json-logger.js: -------------------------------------------------------------------------------- 1 | // Create clients outside of the handler 2 | 3 | // Create a client to read objects from S3 4 | const AWS = require('aws-sdk'); 5 | 6 | const s3 = new AWS.S3(); 7 | 8 | /** 9 | * A Lambda function that logs the payload received from S3. 10 | */ 11 | exports.s3JsonLoggerHandler = async (event, context) => { 12 | const getObjectRequests = event.Records.map(async (record) => { 13 | const params = { 14 | Bucket: record.s3.bucket.name, 15 | Key: record.s3.object.key, 16 | }; 17 | try { 18 | const { Body } = await s3.getObject(params).promise(); 19 | // All log statements are written to CloudWatch by default. For more information, see 20 | // https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-logging.html 21 | console.log(Body.toString()); 22 | } catch (error) { 23 | console.error('Error calling S3 getObject:', error); 24 | throw error; 25 | } 26 | }); 27 | 28 | await Promise.all(getObjectRequests); 29 | }; 30 | -------------------------------------------------------------------------------- /nodejs18.x/scheduled-job/cdk/buildspec.yml: -------------------------------------------------------------------------------- 1 | version: 0.2 2 | phases: 3 | install: 4 | commands: 5 | # Install all dependencies (including dependencies for running tests) 6 | - npm install 7 | # Install CDK dependencies 8 | - cd cdk 9 | - npm install 10 | - cd .. 11 | pre_build: 12 | commands: 13 | # Discover and run unit tests in the '__tests__' directory 14 | - npm run test 15 | # Remove all dependencies not needed for the Lambda deployment package (the packages from devDependencies in package.json) 16 | - npm prune --production 17 | # Copy artifacts to a separate folder 18 | - mkdir function-code 19 | - cp -r src node_modules function-code 20 | build: 21 | commands: 22 | # Archive Lambda function code and upload it to S3 23 | - cd function-code 24 | - zip -r function-code.zip . 25 | - aws s3 cp function-code.zip s3://$S3_BUCKET/$CODEBUILD_BUILD_ID/ 26 | # Use AWS CDK to synthesize the application 27 | - cd ../cdk 28 | - ./node_modules/.bin/cdk synth > ../template-export.yml 29 | artifacts: 30 | files: 31 | - template-export.yml 32 | -------------------------------------------------------------------------------- /nodejs22.x/scheduled-job/cdk/buildspec.yml: -------------------------------------------------------------------------------- 1 | version: 0.2 2 | phases: 3 | install: 4 | commands: 5 | # Install all dependencies (including dependencies for running tests) 6 | - npm install 7 | # Install CDK dependencies 8 | - cd cdk 9 | - npm install 10 | - cd .. 11 | pre_build: 12 | commands: 13 | # Discover and run unit tests in the '__tests__' directory 14 | - npm run test 15 | # Remove all dependencies not needed for the Lambda deployment package (the packages from devDependencies in package.json) 16 | - npm prune --production 17 | # Copy artifacts to a separate folder 18 | - mkdir function-code 19 | - cp -r src node_modules function-code 20 | build: 21 | commands: 22 | # Archive Lambda function code and upload it to S3 23 | - cd function-code 24 | - zip -r function-code.zip . 25 | - aws s3 cp function-code.zip s3://$S3_BUCKET/$CODEBUILD_BUILD_ID/ 26 | # Use AWS CDK to synthesize the application 27 | - cd ../cdk 28 | - ./node_modules/.bin/cdk synth > ../template-export.yml 29 | artifacts: 30 | files: 31 | - template-export.yml 32 | -------------------------------------------------------------------------------- /nodejs18.x/author-from-scratch/cdk/buildspec.yml: -------------------------------------------------------------------------------- 1 | version: 0.2 2 | phases: 3 | install: 4 | commands: 5 | # Install all dependencies (including dependencies for running tests) 6 | - npm install 7 | # Install CDK dependencies 8 | - cd cdk 9 | - npm install 10 | - cd .. 11 | pre_build: 12 | commands: 13 | # Discover and run unit tests in the '__tests__' directory 14 | - npm run test 15 | # Remove all dependencies not needed for the Lambda deployment package (the packages from devDependencies in package.json) 16 | - npm prune --production 17 | # Copy artifacts to a separate folder 18 | - mkdir function-code 19 | - cp -r src node_modules function-code 20 | build: 21 | commands: 22 | # Archive Lambda function code and upload it to S3 23 | - cd function-code 24 | - zip -r function-code.zip . 25 | - aws s3 cp function-code.zip s3://$S3_BUCKET/$CODEBUILD_BUILD_ID/ 26 | # Use AWS CDK to synthesize the application 27 | - cd ../cdk 28 | - ./node_modules/.bin/cdk synth > ../template-export.yml 29 | artifacts: 30 | files: 31 | - template-export.yml 32 | -------------------------------------------------------------------------------- /nodejs18.x/file-processing/cdk/buildspec.yml: -------------------------------------------------------------------------------- 1 | version: 0.2 2 | phases: 3 | install: 4 | commands: 5 | # Install all dependencies (including dependencies for running tests) 6 | - npm install 7 | # Install CDK dependencies 8 | - cd cdk 9 | - npm install 10 | - cd .. 11 | pre_build: 12 | commands: 13 | # Discover and run unit tests in the '__tests__' directory 14 | - npm run test 15 | # Remove all dependencies not needed for the Lambda deployment package (the packages from devDependencies in package.json) 16 | - npm prune --production 17 | # Copy artifacts to a separate folder 18 | - mkdir function-code 19 | - cp -r src node_modules function-code 20 | build: 21 | commands: 22 | # Archive Lambda function code and upload it to S3 23 | - cd function-code 24 | - zip -r function-code.zip . 25 | - aws s3 cp function-code.zip s3://$S3_BUCKET/$CODEBUILD_BUILD_ID/ 26 | # Use AWS CDK to synthesize the application 27 | - cd ../cdk 28 | - ./node_modules/.bin/cdk synth > ../template-export.yml 29 | artifacts: 30 | files: 31 | - template-export.yml 32 | -------------------------------------------------------------------------------- /nodejs18.x/queue-processing/cdk/buildspec.yml: -------------------------------------------------------------------------------- 1 | version: 0.2 2 | phases: 3 | install: 4 | commands: 5 | # Install all dependencies (including dependencies for running tests) 6 | - npm install 7 | # Install CDK dependencies 8 | - cd cdk 9 | - npm install 10 | - cd .. 11 | pre_build: 12 | commands: 13 | # Discover and run unit tests in the '__tests__' directory 14 | - npm run test 15 | # Remove all dependencies not needed for the Lambda deployment package (the packages from devDependencies in package.json) 16 | - npm prune --production 17 | # Copy artifacts to a separate folder 18 | - mkdir function-code 19 | - cp -r src node_modules function-code 20 | build: 21 | commands: 22 | # Archive Lambda function code and upload it to S3 23 | - cd function-code 24 | - zip -r function-code.zip . 25 | - aws s3 cp function-code.zip s3://$S3_BUCKET/$CODEBUILD_BUILD_ID/ 26 | # Use AWS CDK to synthesize the application 27 | - cd ../cdk 28 | - ./node_modules/.bin/cdk synth > ../template-export.yml 29 | artifacts: 30 | files: 31 | - template-export.yml 32 | -------------------------------------------------------------------------------- /nodejs22.x/author-from-scratch/cdk/buildspec.yml: -------------------------------------------------------------------------------- 1 | version: 0.2 2 | phases: 3 | install: 4 | commands: 5 | # Install all dependencies (including dependencies for running tests) 6 | - npm install 7 | # Install CDK dependencies 8 | - cd cdk 9 | - npm install 10 | - cd .. 11 | pre_build: 12 | commands: 13 | # Discover and run unit tests in the '__tests__' directory 14 | - npm run test 15 | # Remove all dependencies not needed for the Lambda deployment package (the packages from devDependencies in package.json) 16 | - npm prune --production 17 | # Copy artifacts to a separate folder 18 | - mkdir function-code 19 | - cp -r src node_modules function-code 20 | build: 21 | commands: 22 | # Archive Lambda function code and upload it to S3 23 | - cd function-code 24 | - zip -r function-code.zip . 25 | - aws s3 cp function-code.zip s3://$S3_BUCKET/$CODEBUILD_BUILD_ID/ 26 | # Use AWS CDK to synthesize the application 27 | - cd ../cdk 28 | - ./node_modules/.bin/cdk synth > ../template-export.yml 29 | artifacts: 30 | files: 31 | - template-export.yml 32 | -------------------------------------------------------------------------------- /nodejs22.x/file-processing/cdk/buildspec.yml: -------------------------------------------------------------------------------- 1 | version: 0.2 2 | phases: 3 | install: 4 | commands: 5 | # Install all dependencies (including dependencies for running tests) 6 | - npm install 7 | # Install CDK dependencies 8 | - cd cdk 9 | - npm install 10 | - cd .. 11 | pre_build: 12 | commands: 13 | # Discover and run unit tests in the '__tests__' directory 14 | - npm run test 15 | # Remove all dependencies not needed for the Lambda deployment package (the packages from devDependencies in package.json) 16 | - npm prune --production 17 | # Copy artifacts to a separate folder 18 | - mkdir function-code 19 | - cp -r src node_modules function-code 20 | build: 21 | commands: 22 | # Archive Lambda function code and upload it to S3 23 | - cd function-code 24 | - zip -r function-code.zip . 25 | - aws s3 cp function-code.zip s3://$S3_BUCKET/$CODEBUILD_BUILD_ID/ 26 | # Use AWS CDK to synthesize the application 27 | - cd ../cdk 28 | - ./node_modules/.bin/cdk synth > ../template-export.yml 29 | artifacts: 30 | files: 31 | - template-export.yml 32 | -------------------------------------------------------------------------------- /nodejs22.x/queue-processing/cdk/buildspec.yml: -------------------------------------------------------------------------------- 1 | version: 0.2 2 | phases: 3 | install: 4 | commands: 5 | # Install all dependencies (including dependencies for running tests) 6 | - npm install 7 | # Install CDK dependencies 8 | - cd cdk 9 | - npm install 10 | - cd .. 11 | pre_build: 12 | commands: 13 | # Discover and run unit tests in the '__tests__' directory 14 | - npm run test 15 | # Remove all dependencies not needed for the Lambda deployment package (the packages from devDependencies in package.json) 16 | - npm prune --production 17 | # Copy artifacts to a separate folder 18 | - mkdir function-code 19 | - cp -r src node_modules function-code 20 | build: 21 | commands: 22 | # Archive Lambda function code and upload it to S3 23 | - cd function-code 24 | - zip -r function-code.zip . 25 | - aws s3 cp function-code.zip s3://$S3_BUCKET/$CODEBUILD_BUILD_ID/ 26 | # Use AWS CDK to synthesize the application 27 | - cd ../cdk 28 | - ./node_modules/.bin/cdk synth > ../template-export.yml 29 | artifacts: 30 | files: 31 | - template-export.yml 32 | -------------------------------------------------------------------------------- /nodejs18.x/notifications-processing/cdk/buildspec.yml: -------------------------------------------------------------------------------- 1 | version: 0.2 2 | phases: 3 | install: 4 | commands: 5 | # Install all dependencies (including dependencies for running tests) 6 | - npm install 7 | # Install CDK dependencies 8 | - cd cdk 9 | - npm install 10 | - cd .. 11 | pre_build: 12 | commands: 13 | # Discover and run unit tests in the '__tests__' directory 14 | - npm run test 15 | # Remove all dependencies not needed for the Lambda deployment package (the packages from devDependencies in package.json) 16 | - npm prune --production 17 | # Copy artifacts to a separate folder 18 | - mkdir function-code 19 | - cp -r src node_modules function-code 20 | build: 21 | commands: 22 | # Archive Lambda function code and upload it to S3 23 | - cd function-code 24 | - zip -r function-code.zip . 25 | - aws s3 cp function-code.zip s3://$S3_BUCKET/$CODEBUILD_BUILD_ID/ 26 | # Use AWS CDK to synthesize the application 27 | - cd ../cdk 28 | - ./node_modules/.bin/cdk synth > ../template-export.yml 29 | artifacts: 30 | files: 31 | - template-export.yml 32 | -------------------------------------------------------------------------------- /nodejs18.x/serverless-api-backend/cdk/buildspec.yml: -------------------------------------------------------------------------------- 1 | version: 0.2 2 | phases: 3 | install: 4 | commands: 5 | # Install all dependencies (including dependencies for running tests) 6 | - npm install 7 | # Install CDK dependencies 8 | - cd cdk 9 | - npm install 10 | - cd .. 11 | pre_build: 12 | commands: 13 | # Discover and run unit tests in the '__tests__' directory 14 | - npm run test 15 | # Remove all dependencies not needed for the Lambda deployment package (the packages from devDependencies in package.json) 16 | - npm prune --production 17 | # Copy artifacts to a separate folder 18 | - mkdir function-code 19 | - cp -r src node_modules function-code 20 | build: 21 | commands: 22 | # Archive Lambda function code and upload it to S3 23 | - cd function-code 24 | - zip -r function-code.zip . 25 | - aws s3 cp function-code.zip s3://$S3_BUCKET/$CODEBUILD_BUILD_ID/ 26 | # Use AWS CDK to synthesize the application 27 | - cd ../cdk 28 | - ./node_modules/.bin/cdk synth > ../template-export.yml 29 | artifacts: 30 | files: 31 | - template-export.yml 32 | -------------------------------------------------------------------------------- /nodejs22.x/notifications-processing/cdk/buildspec.yml: -------------------------------------------------------------------------------- 1 | version: 0.2 2 | phases: 3 | install: 4 | commands: 5 | # Install all dependencies (including dependencies for running tests) 6 | - npm install 7 | # Install CDK dependencies 8 | - cd cdk 9 | - npm install 10 | - cd .. 11 | pre_build: 12 | commands: 13 | # Discover and run unit tests in the '__tests__' directory 14 | - npm run test 15 | # Remove all dependencies not needed for the Lambda deployment package (the packages from devDependencies in package.json) 16 | - npm prune --production 17 | # Copy artifacts to a separate folder 18 | - mkdir function-code 19 | - cp -r src node_modules function-code 20 | build: 21 | commands: 22 | # Archive Lambda function code and upload it to S3 23 | - cd function-code 24 | - zip -r function-code.zip . 25 | - aws s3 cp function-code.zip s3://$S3_BUCKET/$CODEBUILD_BUILD_ID/ 26 | # Use AWS CDK to synthesize the application 27 | - cd ../cdk 28 | - ./node_modules/.bin/cdk synth > ../template-export.yml 29 | artifacts: 30 | files: 31 | - template-export.yml 32 | -------------------------------------------------------------------------------- /nodejs22.x/serverless-api-backend/cdk/buildspec.yml: -------------------------------------------------------------------------------- 1 | version: 0.2 2 | phases: 3 | install: 4 | commands: 5 | # Install all dependencies (including dependencies for running tests) 6 | - npm install 7 | # Install CDK dependencies 8 | - cd cdk 9 | - npm install 10 | - cd .. 11 | pre_build: 12 | commands: 13 | # Discover and run unit tests in the '__tests__' directory 14 | - npm run test 15 | # Remove all dependencies not needed for the Lambda deployment package (the packages from devDependencies in package.json) 16 | - npm prune --production 17 | # Copy artifacts to a separate folder 18 | - mkdir function-code 19 | - cp -r src node_modules function-code 20 | build: 21 | commands: 22 | # Archive Lambda function code and upload it to S3 23 | - cd function-code 24 | - zip -r function-code.zip . 25 | - aws s3 cp function-code.zip s3://$S3_BUCKET/$CODEBUILD_BUILD_ID/ 26 | # Use AWS CDK to synthesize the application 27 | - cd ../cdk 28 | - ./node_modules/.bin/cdk synth > ../template-export.yml 29 | artifacts: 30 | files: 31 | - template-export.yml 32 | -------------------------------------------------------------------------------- /nodejs18.x/file-processing/cdk/events/event-s3.json: -------------------------------------------------------------------------------- 1 | { 2 | "Records": [ 3 | { 4 | "eventVersion": "2.0", 5 | "eventSource": "aws:s3", 6 | "awsRegion": "us-east-1", 7 | "eventTime": "1970-01-01T00:00:00.000Z", 8 | "eventName": "ObjectCreated:Put", 9 | "userIdentity": { 10 | "principalId": "EXAMPLE" 11 | }, 12 | "requestParameters": { 13 | "sourceIPAddress": "127.0.0.1" 14 | }, 15 | "responseElements": { 16 | "x-amz-request-id": "EXAMPLE123456789", 17 | "x-amz-id-2": "EXAMPLE123/5678abcdefghijklambdaisawesome/mnopqrstuvwxyzABCDEFGH" 18 | }, 19 | "s3": { 20 | "s3SchemaVersion": "1.0", 21 | "configurationId": "testConfigRule", 22 | "bucket": { 23 | "name": "example-bucket", 24 | "ownerIdentity": { 25 | "principalId": "EXAMPLE" 26 | }, 27 | "arn": "arn:aws:s3:::example-bucket" 28 | }, 29 | "object": { 30 | "key": "test/key", 31 | "size": 1024, 32 | "eTag": "0123456789abcdef0123456789abcdef", 33 | "sequencer": "0A1B2C3D4E5F678901" 34 | } 35 | } 36 | } 37 | ] 38 | } -------------------------------------------------------------------------------- /nodejs18.x/file-processing/sam/events/event-s3.json: -------------------------------------------------------------------------------- 1 | { 2 | "Records": [ 3 | { 4 | "eventVersion": "2.0", 5 | "eventSource": "aws:s3", 6 | "awsRegion": "us-east-1", 7 | "eventTime": "1970-01-01T00:00:00.000Z", 8 | "eventName": "ObjectCreated:Put", 9 | "userIdentity": { 10 | "principalId": "EXAMPLE" 11 | }, 12 | "requestParameters": { 13 | "sourceIPAddress": "127.0.0.1" 14 | }, 15 | "responseElements": { 16 | "x-amz-request-id": "EXAMPLE123456789", 17 | "x-amz-id-2": "EXAMPLE123/5678abcdefghijklambdaisawesome/mnopqrstuvwxyzABCDEFGH" 18 | }, 19 | "s3": { 20 | "s3SchemaVersion": "1.0", 21 | "configurationId": "testConfigRule", 22 | "bucket": { 23 | "name": "example-bucket", 24 | "ownerIdentity": { 25 | "principalId": "EXAMPLE" 26 | }, 27 | "arn": "arn:aws:s3:::example-bucket" 28 | }, 29 | "object": { 30 | "key": "test/key", 31 | "size": 1024, 32 | "eTag": "0123456789abcdef0123456789abcdef", 33 | "sequencer": "0A1B2C3D4E5F678901" 34 | } 35 | } 36 | } 37 | ] 38 | } -------------------------------------------------------------------------------- /nodejs22.x/file-processing/cdk/events/event-s3.json: -------------------------------------------------------------------------------- 1 | { 2 | "Records": [ 3 | { 4 | "eventVersion": "2.0", 5 | "eventSource": "aws:s3", 6 | "awsRegion": "us-east-1", 7 | "eventTime": "1970-01-01T00:00:00.000Z", 8 | "eventName": "ObjectCreated:Put", 9 | "userIdentity": { 10 | "principalId": "EXAMPLE" 11 | }, 12 | "requestParameters": { 13 | "sourceIPAddress": "127.0.0.1" 14 | }, 15 | "responseElements": { 16 | "x-amz-request-id": "EXAMPLE123456789", 17 | "x-amz-id-2": "EXAMPLE123/5678abcdefghijklambdaisawesome/mnopqrstuvwxyzABCDEFGH" 18 | }, 19 | "s3": { 20 | "s3SchemaVersion": "1.0", 21 | "configurationId": "testConfigRule", 22 | "bucket": { 23 | "name": "example-bucket", 24 | "ownerIdentity": { 25 | "principalId": "EXAMPLE" 26 | }, 27 | "arn": "arn:aws:s3:::example-bucket" 28 | }, 29 | "object": { 30 | "key": "test/key", 31 | "size": 1024, 32 | "eTag": "0123456789abcdef0123456789abcdef", 33 | "sequencer": "0A1B2C3D4E5F678901" 34 | } 35 | } 36 | } 37 | ] 38 | } -------------------------------------------------------------------------------- /nodejs22.x/file-processing/sam/events/event-s3.json: -------------------------------------------------------------------------------- 1 | { 2 | "Records": [ 3 | { 4 | "eventVersion": "2.0", 5 | "eventSource": "aws:s3", 6 | "awsRegion": "us-east-1", 7 | "eventTime": "1970-01-01T00:00:00.000Z", 8 | "eventName": "ObjectCreated:Put", 9 | "userIdentity": { 10 | "principalId": "EXAMPLE" 11 | }, 12 | "requestParameters": { 13 | "sourceIPAddress": "127.0.0.1" 14 | }, 15 | "responseElements": { 16 | "x-amz-request-id": "EXAMPLE123456789", 17 | "x-amz-id-2": "EXAMPLE123/5678abcdefghijklambdaisawesome/mnopqrstuvwxyzABCDEFGH" 18 | }, 19 | "s3": { 20 | "s3SchemaVersion": "1.0", 21 | "configurationId": "testConfigRule", 22 | "bucket": { 23 | "name": "example-bucket", 24 | "ownerIdentity": { 25 | "principalId": "EXAMPLE" 26 | }, 27 | "arn": "arn:aws:s3:::example-bucket" 28 | }, 29 | "object": { 30 | "key": "test/key", 31 | "size": 1024, 32 | "eTag": "0123456789abcdef0123456789abcdef", 33 | "sequencer": "0A1B2C3D4E5F678901" 34 | } 35 | } 36 | } 37 | ] 38 | } -------------------------------------------------------------------------------- /nodejs18.x/author-from-scratch/cdk/cdk/lib/cdk-stack.ts: -------------------------------------------------------------------------------- 1 | import { App, CfnParameter, Stack, StackProps } from 'aws-cdk-lib'; 2 | import * as lambda from 'aws-cdk-lib/aws-lambda'; 3 | import * as s3 from 'aws-cdk-lib/aws-s3'; 4 | 5 | 6 | export class CdkStack extends Stack { 7 | constructor(scope: App, id: string, props: StackProps) { 8 | super(scope, id, props); 9 | 10 | new CfnParameter(this, 'AppId'); 11 | 12 | // The code will be uploaded to this location during the pipeline's build step 13 | const artifactBucket = process.env.S3_BUCKET!; 14 | const artifactKey = `${process.env.CODEBUILD_BUILD_ID}/function-code.zip`; 15 | 16 | // This is a Lambda function config associated with the source code: hello-from-lambda.js 17 | new lambda.Function(this, 'helloFromLambda', { 18 | description: 'A Lambda function that returns a string.', 19 | handler: 'src/handlers/hello-from-lambda.helloFromLambdaHandler', 20 | runtime: lambda.Runtime.NODEJS_18_X, 21 | code: lambda.Code.fromBucket( 22 | s3.Bucket.fromBucketName(this, 'ArtifactBucket', artifactBucket), 23 | artifactKey, 24 | ), 25 | }); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /nodejs22.x/author-from-scratch/cdk/cdk/lib/cdk-stack.ts: -------------------------------------------------------------------------------- 1 | import { App, CfnParameter, Stack, StackProps } from 'aws-cdk-lib'; 2 | import * as lambda from 'aws-cdk-lib/aws-lambda'; 3 | import * as s3 from 'aws-cdk-lib/aws-s3'; 4 | 5 | 6 | export class CdkStack extends Stack { 7 | constructor(scope: App, id: string, props: StackProps) { 8 | super(scope, id, props); 9 | 10 | new CfnParameter(this, 'AppId'); 11 | 12 | // The code will be uploaded to this location during the pipeline's build step 13 | const artifactBucket = process.env.S3_BUCKET!; 14 | const artifactKey = `${process.env.CODEBUILD_BUILD_ID}/function-code.zip`; 15 | 16 | // This is a Lambda function config associated with the source code: hello-from-lambda.js 17 | new lambda.Function(this, 'helloFromLambda', { 18 | description: 'A Lambda function that returns a string.', 19 | handler: 'src/handlers/hello-from-lambda.helloFromLambdaHandler', 20 | runtime: lambda.Runtime.NODEJS_22_X, 21 | code: lambda.Code.fromBucket( 22 | s3.Bucket.fromBucketName(this, 'ArtifactBucket', artifactBucket), 23 | artifactKey, 24 | ), 25 | }); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /nodejs18.x/notifications-processing/cdk/__tests__/unit/handlers/sns-payload-logger.test.js: -------------------------------------------------------------------------------- 1 | // Import all functions from sns-payload-logger.js 2 | const snsPayloadLogger = require('../../../src/handlers/sns-payload-logger.js'); 3 | 4 | describe('Test for sns-payload-logger', () => { 5 | // This test invokes the sns-payload-logger Lambda function and verifies that the received payload is logged 6 | it('Verifies the payload is logged', async () => { 7 | // Mock console.log statements so we can verify them. For more information, see 8 | // https://jestjs.io/docs/en/mock-functions.html 9 | console.log = jest.fn(); 10 | 11 | // Create a sample payload with SNS message format 12 | const payload = { 13 | Records: [{ 14 | Sns: { 15 | Message: 'This is a notification from SNS', 16 | Subject: 'SNS Notification', 17 | TopicArn: 'arn:aws:sns:us-west-2:123456789012:SimpleTopic', 18 | }, 19 | }], 20 | }; 21 | 22 | await snsPayloadLogger.snsPayloadLoggerHandler(payload, null); 23 | 24 | // Verify that console.log has been called with the expected payload 25 | payload.Records.forEach(({ Sns }, i) => { 26 | expect(console.log).toHaveBeenNthCalledWith(i + 1, JSON.stringify(Sns)); 27 | }); 28 | }); 29 | }); 30 | -------------------------------------------------------------------------------- /nodejs18.x/notifications-processing/sam/__tests__/unit/handlers/sns-payload-logger.test.js: -------------------------------------------------------------------------------- 1 | // Import all functions from sns-payload-logger.js 2 | const snsPayloadLogger = require('../../../src/handlers/sns-payload-logger.js'); 3 | 4 | describe('Test for sns-payload-logger', () => { 5 | // This test invokes the sns-payload-logger Lambda function and verifies that the received payload is logged 6 | it('Verifies the payload is logged', async () => { 7 | // Mock console.log statements so we can verify them. For more information, see 8 | // https://jestjs.io/docs/en/mock-functions.html 9 | console.log = jest.fn(); 10 | 11 | // Create a sample payload with SNS message format 12 | const payload = { 13 | Records: [{ 14 | Sns: { 15 | Message: 'This is a notification from SNS', 16 | Subject: 'SNS Notification', 17 | TopicArn: 'arn:aws:sns:us-west-2:123456789012:SimpleTopic', 18 | }, 19 | }], 20 | }; 21 | 22 | await snsPayloadLogger.snsPayloadLoggerHandler(payload, null); 23 | 24 | // Verify that console.log has been called with the expected payload 25 | payload.Records.forEach(({ Sns }, i) => { 26 | expect(console.log).toHaveBeenNthCalledWith(i + 1, JSON.stringify(Sns)); 27 | }); 28 | }); 29 | }); 30 | -------------------------------------------------------------------------------- /nodejs22.x/notifications-processing/cdk/__tests__/unit/handlers/sns-payload-logger.test.js: -------------------------------------------------------------------------------- 1 | // Import all functions from sns-payload-logger.js 2 | const snsPayloadLogger = require('../../../src/handlers/sns-payload-logger.js'); 3 | 4 | describe('Test for sns-payload-logger', () => { 5 | // This test invokes the sns-payload-logger Lambda function and verifies that the received payload is logged 6 | it('Verifies the payload is logged', async () => { 7 | // Mock console.log statements so we can verify them. For more information, see 8 | // https://jestjs.io/docs/en/mock-functions.html 9 | console.log = jest.fn(); 10 | 11 | // Create a sample payload with SNS message format 12 | const payload = { 13 | Records: [{ 14 | Sns: { 15 | Message: 'This is a notification from SNS', 16 | Subject: 'SNS Notification', 17 | TopicArn: 'arn:aws:sns:us-west-2:123456789012:SimpleTopic', 18 | }, 19 | }], 20 | }; 21 | 22 | await snsPayloadLogger.snsPayloadLoggerHandler(payload, null); 23 | 24 | // Verify that console.log has been called with the expected payload 25 | payload.Records.forEach(({ Sns }, i) => { 26 | expect(console.log).toHaveBeenNthCalledWith(i + 1, JSON.stringify(Sns)); 27 | }); 28 | }); 29 | }); 30 | -------------------------------------------------------------------------------- /nodejs22.x/notifications-processing/sam/__tests__/unit/handlers/sns-payload-logger.test.js: -------------------------------------------------------------------------------- 1 | // Import all functions from sns-payload-logger.js 2 | const snsPayloadLogger = require('../../../src/handlers/sns-payload-logger.js'); 3 | 4 | describe('Test for sns-payload-logger', () => { 5 | // This test invokes the sns-payload-logger Lambda function and verifies that the received payload is logged 6 | it('Verifies the payload is logged', async () => { 7 | // Mock console.log statements so we can verify them. For more information, see 8 | // https://jestjs.io/docs/en/mock-functions.html 9 | console.log = jest.fn(); 10 | 11 | // Create a sample payload with SNS message format 12 | const payload = { 13 | Records: [{ 14 | Sns: { 15 | Message: 'This is a notification from SNS', 16 | Subject: 'SNS Notification', 17 | TopicArn: 'arn:aws:sns:us-west-2:123456789012:SimpleTopic', 18 | }, 19 | }], 20 | }; 21 | 22 | await snsPayloadLogger.snsPayloadLoggerHandler(payload, null); 23 | 24 | // Verify that console.log has been called with the expected payload 25 | payload.Records.forEach(({ Sns }, i) => { 26 | expect(console.log).toHaveBeenNthCalledWith(i + 1, JSON.stringify(Sns)); 27 | }); 28 | }); 29 | }); 30 | -------------------------------------------------------------------------------- /nodejs18.x/scheduled-job/cdk/__tests__/unit/handlers/scheduled-event-logger.test.js: -------------------------------------------------------------------------------- 1 | // Import all functions from scheduled-event-logger.js 2 | const scheduledEventLogger = require('../../../src/handlers/scheduled-event-logger.js'); 3 | 4 | describe('Test for scheduled-event-logger', () => { 5 | // This test invokes the scheduled-event-logger Lambda function and verifies that the received payload is logged 6 | it('Verifies the payload is logged', async () => { 7 | // Mock console.log statements so we can verify them. For more information, see 8 | // https://jestjs.io/docs/en/mock-functions.html 9 | console.log = jest.fn(); 10 | 11 | // Create a sample payload with CloudWatch scheduled event message format 12 | const payload = { 13 | id: 'cdc73f9d-aea9-11e3-9d5a-835b769c0d9c', 14 | 'detail-type': 'Scheduled Event', 15 | source: 'aws.events', 16 | account: '', 17 | time: '1970-01-01T00:00:00Z', 18 | region: 'us-west-2', 19 | resources: [ 20 | 'arn:aws:events:us-west-2:123456789012:rule/ExampleRule', 21 | ], 22 | detail: {}, 23 | }; 24 | 25 | await scheduledEventLogger.scheduledEventLoggerHandler(payload, null); 26 | 27 | // Verify that console.log has been called with the expected payload 28 | expect(console.log).toHaveBeenCalledWith(JSON.stringify(payload)); 29 | }); 30 | }); 31 | -------------------------------------------------------------------------------- /nodejs18.x/scheduled-job/sam/__tests__/unit/handlers/scheduled-event-logger.test.js: -------------------------------------------------------------------------------- 1 | // Import all functions from scheduled-event-logger.js 2 | const scheduledEventLogger = require('../../../src/handlers/scheduled-event-logger.js'); 3 | 4 | describe('Test for scheduled-event-logger', () => { 5 | // This test invokes the scheduled-event-logger Lambda function and verifies that the received payload is logged 6 | it('Verifies the payload is logged', async () => { 7 | // Mock console.log statements so we can verify them. For more information, see 8 | // https://jestjs.io/docs/en/mock-functions.html 9 | console.log = jest.fn(); 10 | 11 | // Create a sample payload with CloudWatch scheduled event message format 12 | const payload = { 13 | id: 'cdc73f9d-aea9-11e3-9d5a-835b769c0d9c', 14 | 'detail-type': 'Scheduled Event', 15 | source: 'aws.events', 16 | account: '', 17 | time: '1970-01-01T00:00:00Z', 18 | region: 'us-west-2', 19 | resources: [ 20 | 'arn:aws:events:us-west-2:123456789012:rule/ExampleRule', 21 | ], 22 | detail: {}, 23 | }; 24 | 25 | await scheduledEventLogger.scheduledEventLoggerHandler(payload, null); 26 | 27 | // Verify that console.log has been called with the expected payload 28 | expect(console.log).toHaveBeenCalledWith(JSON.stringify(payload)); 29 | }); 30 | }); 31 | -------------------------------------------------------------------------------- /nodejs22.x/scheduled-job/cdk/__tests__/unit/handlers/scheduled-event-logger.test.js: -------------------------------------------------------------------------------- 1 | // Import all functions from scheduled-event-logger.js 2 | const scheduledEventLogger = require('../../../src/handlers/scheduled-event-logger.js'); 3 | 4 | describe('Test for scheduled-event-logger', () => { 5 | // This test invokes the scheduled-event-logger Lambda function and verifies that the received payload is logged 6 | it('Verifies the payload is logged', async () => { 7 | // Mock console.log statements so we can verify them. For more information, see 8 | // https://jestjs.io/docs/en/mock-functions.html 9 | console.log = jest.fn(); 10 | 11 | // Create a sample payload with CloudWatch scheduled event message format 12 | const payload = { 13 | id: 'cdc73f9d-aea9-11e3-9d5a-835b769c0d9c', 14 | 'detail-type': 'Scheduled Event', 15 | source: 'aws.events', 16 | account: '', 17 | time: '1970-01-01T00:00:00Z', 18 | region: 'us-west-2', 19 | resources: [ 20 | 'arn:aws:events:us-west-2:123456789012:rule/ExampleRule', 21 | ], 22 | detail: {}, 23 | }; 24 | 25 | await scheduledEventLogger.scheduledEventLoggerHandler(payload, null); 26 | 27 | // Verify that console.log has been called with the expected payload 28 | expect(console.log).toHaveBeenCalledWith(JSON.stringify(payload)); 29 | }); 30 | }); 31 | -------------------------------------------------------------------------------- /nodejs22.x/scheduled-job/sam/__tests__/unit/handlers/scheduled-event-logger.test.js: -------------------------------------------------------------------------------- 1 | // Import all functions from scheduled-event-logger.js 2 | const scheduledEventLogger = require('../../../src/handlers/scheduled-event-logger.js'); 3 | 4 | describe('Test for scheduled-event-logger', () => { 5 | // This test invokes the scheduled-event-logger Lambda function and verifies that the received payload is logged 6 | it('Verifies the payload is logged', async () => { 7 | // Mock console.log statements so we can verify them. For more information, see 8 | // https://jestjs.io/docs/en/mock-functions.html 9 | console.log = jest.fn(); 10 | 11 | // Create a sample payload with CloudWatch scheduled event message format 12 | const payload = { 13 | id: 'cdc73f9d-aea9-11e3-9d5a-835b769c0d9c', 14 | 'detail-type': 'Scheduled Event', 15 | source: 'aws.events', 16 | account: '', 17 | time: '1970-01-01T00:00:00Z', 18 | region: 'us-west-2', 19 | resources: [ 20 | 'arn:aws:events:us-west-2:123456789012:rule/ExampleRule', 21 | ], 22 | detail: {}, 23 | }; 24 | 25 | await scheduledEventLogger.scheduledEventLoggerHandler(payload, null); 26 | 27 | // Verify that console.log has been called with the expected payload 28 | expect(console.log).toHaveBeenCalledWith(JSON.stringify(payload)); 29 | }); 30 | }); 31 | -------------------------------------------------------------------------------- /nodejs18.x/serverless-api-backend/cdk/__tests__/unit/handlers/put-item.test.js: -------------------------------------------------------------------------------- 1 | // Import dynamodb from aws-sdk 2 | const dynamodb = require('aws-sdk/clients/dynamodb'); 3 | 4 | // Import all functions from put-item.js 5 | const lambda = require('../../../src/handlers/put-item.js'); 6 | 7 | // This includes all tests for putItemHandler 8 | describe('Test putItemHandler', () => { 9 | let putSpy; 10 | 11 | // One-time setup and teardown, see more in https://jestjs.io/docs/en/setup-teardown 12 | beforeAll(() => { 13 | // Mock DynamoDB put method 14 | // https://jestjs.io/docs/en/jest-object.html#jestspyonobject-methodname 15 | putSpy = jest.spyOn(dynamodb.DocumentClient.prototype, 'put'); 16 | }); 17 | 18 | // Clean up mocks 19 | afterAll(() => { 20 | putSpy.mockRestore(); 21 | }); 22 | 23 | // This test invokes putItemHandler and compares the result 24 | it('should add id to the table', async () => { 25 | // Return the specified value whenever the spied put function is called 26 | putSpy.mockReturnValue({ 27 | promise: () => Promise.resolve('data'), 28 | }); 29 | 30 | const event = { 31 | httpMethod: 'POST', 32 | body: '{"id":"id1","name":"name1"}', 33 | }; 34 | 35 | // Invoke putItemHandler() 36 | const result = await lambda.putItemHandler(event); 37 | const expectedResult = { 38 | statusCode: 200, 39 | body: event.body, 40 | }; 41 | 42 | // Compare the result with the expected result 43 | expect(result).toEqual(expectedResult); 44 | }); 45 | }); 46 | -------------------------------------------------------------------------------- /nodejs18.x/serverless-api-backend/sam/__tests__/unit/handlers/put-item.test.js: -------------------------------------------------------------------------------- 1 | // Import dynamodb from aws-sdk 2 | const dynamodb = require('aws-sdk/clients/dynamodb'); 3 | 4 | // Import all functions from put-item.js 5 | const lambda = require('../../../src/handlers/put-item.js'); 6 | 7 | // This includes all tests for putItemHandler 8 | describe('Test putItemHandler', () => { 9 | let putSpy; 10 | 11 | // One-time setup and teardown, see more in https://jestjs.io/docs/en/setup-teardown 12 | beforeAll(() => { 13 | // Mock DynamoDB put method 14 | // https://jestjs.io/docs/en/jest-object.html#jestspyonobject-methodname 15 | putSpy = jest.spyOn(dynamodb.DocumentClient.prototype, 'put'); 16 | }); 17 | 18 | // Clean up mocks 19 | afterAll(() => { 20 | putSpy.mockRestore(); 21 | }); 22 | 23 | // This test invokes putItemHandler and compares the result 24 | it('should add id to the table', async () => { 25 | // Return the specified value whenever the spied put function is called 26 | putSpy.mockReturnValue({ 27 | promise: () => Promise.resolve('data'), 28 | }); 29 | 30 | const event = { 31 | httpMethod: 'POST', 32 | body: '{"id":"id1","name":"name1"}', 33 | }; 34 | 35 | // Invoke putItemHandler() 36 | const result = await lambda.putItemHandler(event); 37 | const expectedResult = { 38 | statusCode: 200, 39 | body: event.body, 40 | }; 41 | 42 | // Compare the result with the expected result 43 | expect(result).toEqual(expectedResult); 44 | }); 45 | }); 46 | -------------------------------------------------------------------------------- /nodejs22.x/serverless-api-backend/cdk/__tests__/unit/handlers/put-item.test.js: -------------------------------------------------------------------------------- 1 | // Import dynamodb from aws-sdk 2 | const dynamodb = require('aws-sdk/clients/dynamodb'); 3 | 4 | // Import all functions from put-item.js 5 | const lambda = require('../../../src/handlers/put-item.js'); 6 | 7 | // This includes all tests for putItemHandler 8 | describe('Test putItemHandler', () => { 9 | let putSpy; 10 | 11 | // One-time setup and teardown, see more in https://jestjs.io/docs/en/setup-teardown 12 | beforeAll(() => { 13 | // Mock DynamoDB put method 14 | // https://jestjs.io/docs/en/jest-object.html#jestspyonobject-methodname 15 | putSpy = jest.spyOn(dynamodb.DocumentClient.prototype, 'put'); 16 | }); 17 | 18 | // Clean up mocks 19 | afterAll(() => { 20 | putSpy.mockRestore(); 21 | }); 22 | 23 | // This test invokes putItemHandler and compares the result 24 | it('should add id to the table', async () => { 25 | // Return the specified value whenever the spied put function is called 26 | putSpy.mockReturnValue({ 27 | promise: () => Promise.resolve('data'), 28 | }); 29 | 30 | const event = { 31 | httpMethod: 'POST', 32 | body: '{"id":"id1","name":"name1"}', 33 | }; 34 | 35 | // Invoke putItemHandler() 36 | const result = await lambda.putItemHandler(event); 37 | const expectedResult = { 38 | statusCode: 200, 39 | body: event.body, 40 | }; 41 | 42 | // Compare the result with the expected result 43 | expect(result).toEqual(expectedResult); 44 | }); 45 | }); 46 | -------------------------------------------------------------------------------- /nodejs22.x/serverless-api-backend/sam/__tests__/unit/handlers/put-item.test.js: -------------------------------------------------------------------------------- 1 | // Import dynamodb from aws-sdk 2 | const dynamodb = require('aws-sdk/clients/dynamodb'); 3 | 4 | // Import all functions from put-item.js 5 | const lambda = require('../../../src/handlers/put-item.js'); 6 | 7 | // This includes all tests for putItemHandler 8 | describe('Test putItemHandler', () => { 9 | let putSpy; 10 | 11 | // One-time setup and teardown, see more in https://jestjs.io/docs/en/setup-teardown 12 | beforeAll(() => { 13 | // Mock DynamoDB put method 14 | // https://jestjs.io/docs/en/jest-object.html#jestspyonobject-methodname 15 | putSpy = jest.spyOn(dynamodb.DocumentClient.prototype, 'put'); 16 | }); 17 | 18 | // Clean up mocks 19 | afterAll(() => { 20 | putSpy.mockRestore(); 21 | }); 22 | 23 | // This test invokes putItemHandler and compares the result 24 | it('should add id to the table', async () => { 25 | // Return the specified value whenever the spied put function is called 26 | putSpy.mockReturnValue({ 27 | promise: () => Promise.resolve('data'), 28 | }); 29 | 30 | const event = { 31 | httpMethod: 'POST', 32 | body: '{"id":"id1","name":"name1"}', 33 | }; 34 | 35 | // Invoke putItemHandler() 36 | const result = await lambda.putItemHandler(event); 37 | const expectedResult = { 38 | statusCode: 200, 39 | body: event.body, 40 | }; 41 | 42 | // Compare the result with the expected result 43 | expect(result).toEqual(expectedResult); 44 | }); 45 | }); 46 | -------------------------------------------------------------------------------- /nodejs18.x/serverless-api-backend/cdk/src/handlers/put-item.js: -------------------------------------------------------------------------------- 1 | // Create clients and set shared const values outside of the handler 2 | 3 | // Create a DocumentClient that represents the query to add an item 4 | const dynamodb = require('aws-sdk/clients/dynamodb'); 5 | 6 | const docClient = new dynamodb.DocumentClient(); 7 | 8 | // Get the DynamoDB table name from environment variables 9 | const tableName = process.env.SAMPLE_TABLE; 10 | 11 | /** 12 | * A simple example includes a HTTP post method to add one item to a DynamoDB table. 13 | */ 14 | exports.putItemHandler = async (event) => { 15 | const { body, httpMethod, path } = event; 16 | if (httpMethod !== 'POST') { 17 | throw new Error(`postMethod only accepts POST method, you tried: ${httpMethod} method.`); 18 | } 19 | // All log statements are written to CloudWatch by default. For more information, see 20 | // https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-logging.html 21 | console.log('received:', JSON.stringify(event)); 22 | 23 | // Get id and name from the body of the request 24 | const { id, name } = JSON.parse(body); 25 | 26 | // Creates a new item, or replaces an old item with a new item 27 | // https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB/DocumentClient.html#put-property 28 | const params = { 29 | TableName: tableName, 30 | Item: { id, name }, 31 | }; 32 | await docClient.put(params).promise(); 33 | 34 | const response = { 35 | statusCode: 200, 36 | body, 37 | }; 38 | 39 | console.log(`response from: ${path} statusCode: ${response.statusCode} body: ${response.body}`); 40 | return response; 41 | }; 42 | -------------------------------------------------------------------------------- /nodejs18.x/serverless-api-backend/sam/src/handlers/put-item.js: -------------------------------------------------------------------------------- 1 | // Create clients and set shared const values outside of the handler 2 | 3 | // Create a DocumentClient that represents the query to add an item 4 | const dynamodb = require('aws-sdk/clients/dynamodb'); 5 | 6 | const docClient = new dynamodb.DocumentClient(); 7 | 8 | // Get the DynamoDB table name from environment variables 9 | const tableName = process.env.SAMPLE_TABLE; 10 | 11 | /** 12 | * A simple example includes a HTTP post method to add one item to a DynamoDB table. 13 | */ 14 | exports.putItemHandler = async (event) => { 15 | const { body, httpMethod, path } = event; 16 | if (httpMethod !== 'POST') { 17 | throw new Error(`postMethod only accepts POST method, you tried: ${httpMethod} method.`); 18 | } 19 | // All log statements are written to CloudWatch by default. For more information, see 20 | // https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-logging.html 21 | console.log('received:', JSON.stringify(event)); 22 | 23 | // Get id and name from the body of the request 24 | const { id, name } = JSON.parse(body); 25 | 26 | // Creates a new item, or replaces an old item with a new item 27 | // https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB/DocumentClient.html#put-property 28 | const params = { 29 | TableName: tableName, 30 | Item: { id, name }, 31 | }; 32 | await docClient.put(params).promise(); 33 | 34 | const response = { 35 | statusCode: 200, 36 | body, 37 | }; 38 | 39 | console.log(`response from: ${path} statusCode: ${response.statusCode} body: ${response.body}`); 40 | return response; 41 | }; 42 | -------------------------------------------------------------------------------- /nodejs22.x/serverless-api-backend/cdk/src/handlers/put-item.js: -------------------------------------------------------------------------------- 1 | // Create clients and set shared const values outside of the handler 2 | 3 | // Create a DocumentClient that represents the query to add an item 4 | const dynamodb = require('aws-sdk/clients/dynamodb'); 5 | 6 | const docClient = new dynamodb.DocumentClient(); 7 | 8 | // Get the DynamoDB table name from environment variables 9 | const tableName = process.env.SAMPLE_TABLE; 10 | 11 | /** 12 | * A simple example includes a HTTP post method to add one item to a DynamoDB table. 13 | */ 14 | exports.putItemHandler = async (event) => { 15 | const { body, httpMethod, path } = event; 16 | if (httpMethod !== 'POST') { 17 | throw new Error(`postMethod only accepts POST method, you tried: ${httpMethod} method.`); 18 | } 19 | // All log statements are written to CloudWatch by default. For more information, see 20 | // https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-logging.html 21 | console.log('received:', JSON.stringify(event)); 22 | 23 | // Get id and name from the body of the request 24 | const { id, name } = JSON.parse(body); 25 | 26 | // Creates a new item, or replaces an old item with a new item 27 | // https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB/DocumentClient.html#put-property 28 | const params = { 29 | TableName: tableName, 30 | Item: { id, name }, 31 | }; 32 | await docClient.put(params).promise(); 33 | 34 | const response = { 35 | statusCode: 200, 36 | body, 37 | }; 38 | 39 | console.log(`response from: ${path} statusCode: ${response.statusCode} body: ${response.body}`); 40 | return response; 41 | }; 42 | -------------------------------------------------------------------------------- /nodejs22.x/serverless-api-backend/sam/src/handlers/put-item.js: -------------------------------------------------------------------------------- 1 | // Create clients and set shared const values outside of the handler 2 | 3 | // Create a DocumentClient that represents the query to add an item 4 | const dynamodb = require('aws-sdk/clients/dynamodb'); 5 | 6 | const docClient = new dynamodb.DocumentClient(); 7 | 8 | // Get the DynamoDB table name from environment variables 9 | const tableName = process.env.SAMPLE_TABLE; 10 | 11 | /** 12 | * A simple example includes a HTTP post method to add one item to a DynamoDB table. 13 | */ 14 | exports.putItemHandler = async (event) => { 15 | const { body, httpMethod, path } = event; 16 | if (httpMethod !== 'POST') { 17 | throw new Error(`postMethod only accepts POST method, you tried: ${httpMethod} method.`); 18 | } 19 | // All log statements are written to CloudWatch by default. For more information, see 20 | // https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-logging.html 21 | console.log('received:', JSON.stringify(event)); 22 | 23 | // Get id and name from the body of the request 24 | const { id, name } = JSON.parse(body); 25 | 26 | // Creates a new item, or replaces an old item with a new item 27 | // https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB/DocumentClient.html#put-property 28 | const params = { 29 | TableName: tableName, 30 | Item: { id, name }, 31 | }; 32 | await docClient.put(params).promise(); 33 | 34 | const response = { 35 | statusCode: 200, 36 | body, 37 | }; 38 | 39 | console.log(`response from: ${path} statusCode: ${response.statusCode} body: ${response.body}`); 40 | return response; 41 | }; 42 | -------------------------------------------------------------------------------- /nodejs18.x/serverless-api-backend/cdk/src/handlers/get-all-items.js: -------------------------------------------------------------------------------- 1 | // Create clients and set shared const values outside of the handler 2 | 3 | // Create a DocumentClient that represents the query to get all items 4 | const dynamodb = require('aws-sdk/clients/dynamodb'); 5 | 6 | const docClient = new dynamodb.DocumentClient(); 7 | 8 | // Get the DynamoDB table name from environment variables 9 | const tableName = process.env.SAMPLE_TABLE; 10 | 11 | /** 12 | * A simple example includes a HTTP get method to get all items from a DynamoDB table. 13 | */ 14 | exports.getAllItemsHandler = async (event) => { 15 | const { httpMethod, path } = event; 16 | if (httpMethod !== 'GET') { 17 | throw new Error(`getAllItems only accept GET method, you tried: ${httpMethod}`); 18 | } 19 | // All log statements are written to CloudWatch by default. For more information, see 20 | // https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-logging.html 21 | console.log('received:', JSON.stringify(event)); 22 | 23 | // get all items from the table (only first 1MB data, you can use `LastEvaluatedKey` to get the rest of data) 24 | // https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB/DocumentClient.html#scan-property 25 | // https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_Scan.html 26 | const params = { TableName: tableName }; 27 | const { Items } = await docClient.scan(params).promise(); 28 | 29 | const response = { 30 | statusCode: 200, 31 | body: JSON.stringify(Items), 32 | }; 33 | 34 | console.log(`response from: ${path} statusCode: ${response.statusCode} body: ${response.body}`); 35 | return response; 36 | }; 37 | -------------------------------------------------------------------------------- /nodejs18.x/serverless-api-backend/sam/src/handlers/get-all-items.js: -------------------------------------------------------------------------------- 1 | // Create clients and set shared const values outside of the handler 2 | 3 | // Create a DocumentClient that represents the query to get all items 4 | const dynamodb = require('aws-sdk/clients/dynamodb'); 5 | 6 | const docClient = new dynamodb.DocumentClient(); 7 | 8 | // Get the DynamoDB table name from environment variables 9 | const tableName = process.env.SAMPLE_TABLE; 10 | 11 | /** 12 | * A simple example includes a HTTP get method to get all items from a DynamoDB table. 13 | */ 14 | exports.getAllItemsHandler = async (event) => { 15 | const { httpMethod, path } = event; 16 | if (httpMethod !== 'GET') { 17 | throw new Error(`getAllItems only accept GET method, you tried: ${httpMethod}`); 18 | } 19 | // All log statements are written to CloudWatch by default. For more information, see 20 | // https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-logging.html 21 | console.log('received:', JSON.stringify(event)); 22 | 23 | // get all items from the table (only first 1MB data, you can use `LastEvaluatedKey` to get the rest of data) 24 | // https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB/DocumentClient.html#scan-property 25 | // https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_Scan.html 26 | const params = { TableName: tableName }; 27 | const { Items } = await docClient.scan(params).promise(); 28 | 29 | const response = { 30 | statusCode: 200, 31 | body: JSON.stringify(Items), 32 | }; 33 | 34 | console.log(`response from: ${path} statusCode: ${response.statusCode} body: ${response.body}`); 35 | return response; 36 | }; 37 | -------------------------------------------------------------------------------- /nodejs22.x/serverless-api-backend/cdk/src/handlers/get-all-items.js: -------------------------------------------------------------------------------- 1 | // Create clients and set shared const values outside of the handler 2 | 3 | // Create a DocumentClient that represents the query to get all items 4 | const dynamodb = require('aws-sdk/clients/dynamodb'); 5 | 6 | const docClient = new dynamodb.DocumentClient(); 7 | 8 | // Get the DynamoDB table name from environment variables 9 | const tableName = process.env.SAMPLE_TABLE; 10 | 11 | /** 12 | * A simple example includes a HTTP get method to get all items from a DynamoDB table. 13 | */ 14 | exports.getAllItemsHandler = async (event) => { 15 | const { httpMethod, path } = event; 16 | if (httpMethod !== 'GET') { 17 | throw new Error(`getAllItems only accept GET method, you tried: ${httpMethod}`); 18 | } 19 | // All log statements are written to CloudWatch by default. For more information, see 20 | // https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-logging.html 21 | console.log('received:', JSON.stringify(event)); 22 | 23 | // get all items from the table (only first 1MB data, you can use `LastEvaluatedKey` to get the rest of data) 24 | // https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB/DocumentClient.html#scan-property 25 | // https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_Scan.html 26 | const params = { TableName: tableName }; 27 | const { Items } = await docClient.scan(params).promise(); 28 | 29 | const response = { 30 | statusCode: 200, 31 | body: JSON.stringify(Items), 32 | }; 33 | 34 | console.log(`response from: ${path} statusCode: ${response.statusCode} body: ${response.body}`); 35 | return response; 36 | }; 37 | -------------------------------------------------------------------------------- /nodejs22.x/serverless-api-backend/sam/src/handlers/get-all-items.js: -------------------------------------------------------------------------------- 1 | // Create clients and set shared const values outside of the handler 2 | 3 | // Create a DocumentClient that represents the query to get all items 4 | const dynamodb = require('aws-sdk/clients/dynamodb'); 5 | 6 | const docClient = new dynamodb.DocumentClient(); 7 | 8 | // Get the DynamoDB table name from environment variables 9 | const tableName = process.env.SAMPLE_TABLE; 10 | 11 | /** 12 | * A simple example includes a HTTP get method to get all items from a DynamoDB table. 13 | */ 14 | exports.getAllItemsHandler = async (event) => { 15 | const { httpMethod, path } = event; 16 | if (httpMethod !== 'GET') { 17 | throw new Error(`getAllItems only accept GET method, you tried: ${httpMethod}`); 18 | } 19 | // All log statements are written to CloudWatch by default. For more information, see 20 | // https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-logging.html 21 | console.log('received:', JSON.stringify(event)); 22 | 23 | // get all items from the table (only first 1MB data, you can use `LastEvaluatedKey` to get the rest of data) 24 | // https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB/DocumentClient.html#scan-property 25 | // https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_Scan.html 26 | const params = { TableName: tableName }; 27 | const { Items } = await docClient.scan(params).promise(); 28 | 29 | const response = { 30 | statusCode: 200, 31 | body: JSON.stringify(Items), 32 | }; 33 | 34 | console.log(`response from: ${path} statusCode: ${response.statusCode} body: ${response.body}`); 35 | return response; 36 | }; 37 | -------------------------------------------------------------------------------- /nodejs18.x/serverless-api-backend/cdk/__tests__/unit/handlers/get-all-items.test.js: -------------------------------------------------------------------------------- 1 | // Import dynamodb from aws-sdk 2 | const dynamodb = require('aws-sdk/clients/dynamodb'); 3 | 4 | // Import all functions from get-all-items.js 5 | const lambda = require('../../../src/handlers/get-all-items.js'); 6 | 7 | // This includes all tests for getAllItemsHandler 8 | describe('Test getAllItemsHandler', () => { 9 | let scanSpy; 10 | 11 | // One-time setup and teardown, see more in https://jestjs.io/docs/en/setup-teardown 12 | beforeAll(() => { 13 | // Mock DynamoDB scan method 14 | // https://jestjs.io/docs/en/jest-object.html#jestspyonobject-methodname 15 | scanSpy = jest.spyOn(dynamodb.DocumentClient.prototype, 'scan'); 16 | }); 17 | 18 | // Clean up mocks 19 | afterAll(() => { 20 | scanSpy.mockRestore(); 21 | }); 22 | 23 | // This test invokes getAllItemsHandler and compares the result 24 | it('should return ids', async () => { 25 | const items = [{ id: 'id1' }, { id: 'id2' }]; 26 | 27 | // Return the specified value whenever the spied scan function is called 28 | scanSpy.mockReturnValue({ 29 | promise: () => Promise.resolve({ Items: items }), 30 | }); 31 | 32 | const event = { 33 | httpMethod: 'GET', 34 | }; 35 | 36 | // Invoke getAllItemsHandler 37 | const result = await lambda.getAllItemsHandler(event); 38 | 39 | const expectedResult = { 40 | statusCode: 200, 41 | body: JSON.stringify(items), 42 | }; 43 | 44 | // Compare the result with the expected result 45 | expect(result).toEqual(expectedResult); 46 | }); 47 | }); 48 | -------------------------------------------------------------------------------- /nodejs18.x/serverless-api-backend/sam/__tests__/unit/handlers/get-all-items.test.js: -------------------------------------------------------------------------------- 1 | // Import dynamodb from aws-sdk 2 | const dynamodb = require('aws-sdk/clients/dynamodb'); 3 | 4 | // Import all functions from get-all-items.js 5 | const lambda = require('../../../src/handlers/get-all-items.js'); 6 | 7 | // This includes all tests for getAllItemsHandler 8 | describe('Test getAllItemsHandler', () => { 9 | let scanSpy; 10 | 11 | // One-time setup and teardown, see more in https://jestjs.io/docs/en/setup-teardown 12 | beforeAll(() => { 13 | // Mock DynamoDB scan method 14 | // https://jestjs.io/docs/en/jest-object.html#jestspyonobject-methodname 15 | scanSpy = jest.spyOn(dynamodb.DocumentClient.prototype, 'scan'); 16 | }); 17 | 18 | // Clean up mocks 19 | afterAll(() => { 20 | scanSpy.mockRestore(); 21 | }); 22 | 23 | // This test invokes getAllItemsHandler and compares the result 24 | it('should return ids', async () => { 25 | const items = [{ id: 'id1' }, { id: 'id2' }]; 26 | 27 | // Return the specified value whenever the spied scan function is called 28 | scanSpy.mockReturnValue({ 29 | promise: () => Promise.resolve({ Items: items }), 30 | }); 31 | 32 | const event = { 33 | httpMethod: 'GET', 34 | }; 35 | 36 | // Invoke getAllItemsHandler 37 | const result = await lambda.getAllItemsHandler(event); 38 | 39 | const expectedResult = { 40 | statusCode: 200, 41 | body: JSON.stringify(items), 42 | }; 43 | 44 | // Compare the result with the expected result 45 | expect(result).toEqual(expectedResult); 46 | }); 47 | }); 48 | -------------------------------------------------------------------------------- /nodejs22.x/serverless-api-backend/cdk/__tests__/unit/handlers/get-all-items.test.js: -------------------------------------------------------------------------------- 1 | // Import dynamodb from aws-sdk 2 | const dynamodb = require('aws-sdk/clients/dynamodb'); 3 | 4 | // Import all functions from get-all-items.js 5 | const lambda = require('../../../src/handlers/get-all-items.js'); 6 | 7 | // This includes all tests for getAllItemsHandler 8 | describe('Test getAllItemsHandler', () => { 9 | let scanSpy; 10 | 11 | // One-time setup and teardown, see more in https://jestjs.io/docs/en/setup-teardown 12 | beforeAll(() => { 13 | // Mock DynamoDB scan method 14 | // https://jestjs.io/docs/en/jest-object.html#jestspyonobject-methodname 15 | scanSpy = jest.spyOn(dynamodb.DocumentClient.prototype, 'scan'); 16 | }); 17 | 18 | // Clean up mocks 19 | afterAll(() => { 20 | scanSpy.mockRestore(); 21 | }); 22 | 23 | // This test invokes getAllItemsHandler and compares the result 24 | it('should return ids', async () => { 25 | const items = [{ id: 'id1' }, { id: 'id2' }]; 26 | 27 | // Return the specified value whenever the spied scan function is called 28 | scanSpy.mockReturnValue({ 29 | promise: () => Promise.resolve({ Items: items }), 30 | }); 31 | 32 | const event = { 33 | httpMethod: 'GET', 34 | }; 35 | 36 | // Invoke getAllItemsHandler 37 | const result = await lambda.getAllItemsHandler(event); 38 | 39 | const expectedResult = { 40 | statusCode: 200, 41 | body: JSON.stringify(items), 42 | }; 43 | 44 | // Compare the result with the expected result 45 | expect(result).toEqual(expectedResult); 46 | }); 47 | }); 48 | -------------------------------------------------------------------------------- /nodejs22.x/serverless-api-backend/sam/__tests__/unit/handlers/get-all-items.test.js: -------------------------------------------------------------------------------- 1 | // Import dynamodb from aws-sdk 2 | const dynamodb = require('aws-sdk/clients/dynamodb'); 3 | 4 | // Import all functions from get-all-items.js 5 | const lambda = require('../../../src/handlers/get-all-items.js'); 6 | 7 | // This includes all tests for getAllItemsHandler 8 | describe('Test getAllItemsHandler', () => { 9 | let scanSpy; 10 | 11 | // One-time setup and teardown, see more in https://jestjs.io/docs/en/setup-teardown 12 | beforeAll(() => { 13 | // Mock DynamoDB scan method 14 | // https://jestjs.io/docs/en/jest-object.html#jestspyonobject-methodname 15 | scanSpy = jest.spyOn(dynamodb.DocumentClient.prototype, 'scan'); 16 | }); 17 | 18 | // Clean up mocks 19 | afterAll(() => { 20 | scanSpy.mockRestore(); 21 | }); 22 | 23 | // This test invokes getAllItemsHandler and compares the result 24 | it('should return ids', async () => { 25 | const items = [{ id: 'id1' }, { id: 'id2' }]; 26 | 27 | // Return the specified value whenever the spied scan function is called 28 | scanSpy.mockReturnValue({ 29 | promise: () => Promise.resolve({ Items: items }), 30 | }); 31 | 32 | const event = { 33 | httpMethod: 'GET', 34 | }; 35 | 36 | // Invoke getAllItemsHandler 37 | const result = await lambda.getAllItemsHandler(event); 38 | 39 | const expectedResult = { 40 | statusCode: 200, 41 | body: JSON.stringify(items), 42 | }; 43 | 44 | // Compare the result with the expected result 45 | expect(result).toEqual(expectedResult); 46 | }); 47 | }); 48 | -------------------------------------------------------------------------------- /nodejs18.x/serverless-api-backend/cdk/src/handlers/get-by-id.js: -------------------------------------------------------------------------------- 1 | // Create clients and set shared const values outside of the handler 2 | 3 | // Create a DocumentClient that represents the query to get an item 4 | const dynamodb = require('aws-sdk/clients/dynamodb'); 5 | 6 | const docClient = new dynamodb.DocumentClient(); 7 | 8 | // Get the DynamoDB table name from environment variables 9 | const tableName = process.env.SAMPLE_TABLE; 10 | 11 | /** 12 | * A simple example includes a HTTP get method to get one item by id from a DynamoDB table. 13 | */ 14 | exports.getByIdHandler = async (event) => { 15 | const { httpMethod, path, pathParameters } = event; 16 | if (httpMethod !== 'GET') { 17 | throw new Error(`getMethod only accept GET method, you tried: ${httpMethod}`); 18 | } 19 | // All log statements are written to CloudWatch by default. For more information, see 20 | // https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-logging.html 21 | console.log('received:', JSON.stringify(event)); 22 | 23 | // Get id from pathParameters from APIGateway because of `/{id}` at template.yml 24 | const { id } = pathParameters; 25 | 26 | // Get the item from the table 27 | // https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB/DocumentClient.html#get-property 28 | const params = { 29 | TableName: tableName, 30 | Key: { id }, 31 | }; 32 | const { Item } = await docClient.get(params).promise(); 33 | 34 | const response = { 35 | statusCode: 200, 36 | body: JSON.stringify(Item), 37 | }; 38 | 39 | console.log(`response from: ${path} statusCode: ${response.statusCode} body: ${response.body}`); 40 | return response; 41 | }; 42 | -------------------------------------------------------------------------------- /nodejs18.x/serverless-api-backend/sam/src/handlers/get-by-id.js: -------------------------------------------------------------------------------- 1 | // Create clients and set shared const values outside of the handler 2 | 3 | // Create a DocumentClient that represents the query to get an item 4 | const dynamodb = require('aws-sdk/clients/dynamodb'); 5 | 6 | const docClient = new dynamodb.DocumentClient(); 7 | 8 | // Get the DynamoDB table name from environment variables 9 | const tableName = process.env.SAMPLE_TABLE; 10 | 11 | /** 12 | * A simple example includes a HTTP get method to get one item by id from a DynamoDB table. 13 | */ 14 | exports.getByIdHandler = async (event) => { 15 | const { httpMethod, path, pathParameters } = event; 16 | if (httpMethod !== 'GET') { 17 | throw new Error(`getMethod only accept GET method, you tried: ${httpMethod}`); 18 | } 19 | // All log statements are written to CloudWatch by default. For more information, see 20 | // https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-logging.html 21 | console.log('received:', JSON.stringify(event)); 22 | 23 | // Get id from pathParameters from APIGateway because of `/{id}` at template.yml 24 | const { id } = pathParameters; 25 | 26 | // Get the item from the table 27 | // https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB/DocumentClient.html#get-property 28 | const params = { 29 | TableName: tableName, 30 | Key: { id }, 31 | }; 32 | const { Item } = await docClient.get(params).promise(); 33 | 34 | const response = { 35 | statusCode: 200, 36 | body: JSON.stringify(Item), 37 | }; 38 | 39 | console.log(`response from: ${path} statusCode: ${response.statusCode} body: ${response.body}`); 40 | return response; 41 | }; 42 | -------------------------------------------------------------------------------- /nodejs22.x/serverless-api-backend/cdk/src/handlers/get-by-id.js: -------------------------------------------------------------------------------- 1 | // Create clients and set shared const values outside of the handler 2 | 3 | // Create a DocumentClient that represents the query to get an item 4 | const dynamodb = require('aws-sdk/clients/dynamodb'); 5 | 6 | const docClient = new dynamodb.DocumentClient(); 7 | 8 | // Get the DynamoDB table name from environment variables 9 | const tableName = process.env.SAMPLE_TABLE; 10 | 11 | /** 12 | * A simple example includes a HTTP get method to get one item by id from a DynamoDB table. 13 | */ 14 | exports.getByIdHandler = async (event) => { 15 | const { httpMethod, path, pathParameters } = event; 16 | if (httpMethod !== 'GET') { 17 | throw new Error(`getMethod only accept GET method, you tried: ${httpMethod}`); 18 | } 19 | // All log statements are written to CloudWatch by default. For more information, see 20 | // https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-logging.html 21 | console.log('received:', JSON.stringify(event)); 22 | 23 | // Get id from pathParameters from APIGateway because of `/{id}` at template.yml 24 | const { id } = pathParameters; 25 | 26 | // Get the item from the table 27 | // https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB/DocumentClient.html#get-property 28 | const params = { 29 | TableName: tableName, 30 | Key: { id }, 31 | }; 32 | const { Item } = await docClient.get(params).promise(); 33 | 34 | const response = { 35 | statusCode: 200, 36 | body: JSON.stringify(Item), 37 | }; 38 | 39 | console.log(`response from: ${path} statusCode: ${response.statusCode} body: ${response.body}`); 40 | return response; 41 | }; 42 | -------------------------------------------------------------------------------- /nodejs22.x/serverless-api-backend/sam/src/handlers/get-by-id.js: -------------------------------------------------------------------------------- 1 | // Create clients and set shared const values outside of the handler 2 | 3 | // Create a DocumentClient that represents the query to get an item 4 | const dynamodb = require('aws-sdk/clients/dynamodb'); 5 | 6 | const docClient = new dynamodb.DocumentClient(); 7 | 8 | // Get the DynamoDB table name from environment variables 9 | const tableName = process.env.SAMPLE_TABLE; 10 | 11 | /** 12 | * A simple example includes a HTTP get method to get one item by id from a DynamoDB table. 13 | */ 14 | exports.getByIdHandler = async (event) => { 15 | const { httpMethod, path, pathParameters } = event; 16 | if (httpMethod !== 'GET') { 17 | throw new Error(`getMethod only accept GET method, you tried: ${httpMethod}`); 18 | } 19 | // All log statements are written to CloudWatch by default. For more information, see 20 | // https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-logging.html 21 | console.log('received:', JSON.stringify(event)); 22 | 23 | // Get id from pathParameters from APIGateway because of `/{id}` at template.yml 24 | const { id } = pathParameters; 25 | 26 | // Get the item from the table 27 | // https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB/DocumentClient.html#get-property 28 | const params = { 29 | TableName: tableName, 30 | Key: { id }, 31 | }; 32 | const { Item } = await docClient.get(params).promise(); 33 | 34 | const response = { 35 | statusCode: 200, 36 | body: JSON.stringify(Item), 37 | }; 38 | 39 | console.log(`response from: ${path} statusCode: ${response.statusCode} body: ${response.body}`); 40 | return response; 41 | }; 42 | -------------------------------------------------------------------------------- /nodejs18.x/serverless-api-backend/cdk/__tests__/unit/handlers/get-by-id.test.js: -------------------------------------------------------------------------------- 1 | // Import dynamodb from aws-sdk 2 | const dynamodb = require('aws-sdk/clients/dynamodb'); 3 | 4 | // Import all functions from get-by-id.js 5 | const lambda = require('../../../src/handlers/get-by-id.js'); 6 | 7 | // This includes all tests for getByIdHandler 8 | describe('Test getByIdHandler', () => { 9 | let getSpy; 10 | 11 | // One-time setup and teardown, see more in https://jestjs.io/docs/en/setup-teardown 12 | beforeAll(() => { 13 | // Mock DynamoDB get method 14 | // https://jestjs.io/docs/en/jest-object.html#jestspyonobject-methodname 15 | getSpy = jest.spyOn(dynamodb.DocumentClient.prototype, 'get'); 16 | }); 17 | 18 | // Clean up mocks 19 | afterAll(() => { 20 | getSpy.mockRestore(); 21 | }); 22 | 23 | // This test invokes getByIdHandler and compares the result 24 | it('should get item by id', async () => { 25 | const item = { id: 'id1' }; 26 | 27 | // Return the specified value whenever the spied get function is called 28 | getSpy.mockReturnValue({ 29 | promise: () => Promise.resolve({ Item: item }), 30 | }); 31 | 32 | const event = { 33 | httpMethod: 'GET', 34 | pathParameters: { 35 | id: 'id1', 36 | }, 37 | }; 38 | 39 | // Invoke getByIdHandler 40 | const result = await lambda.getByIdHandler(event); 41 | 42 | const expectedResult = { 43 | statusCode: 200, 44 | body: JSON.stringify(item), 45 | }; 46 | 47 | // Compare the result with the expected result 48 | expect(result).toEqual(expectedResult); 49 | }); 50 | }); 51 | -------------------------------------------------------------------------------- /nodejs18.x/serverless-api-backend/sam/__tests__/unit/handlers/get-by-id.test.js: -------------------------------------------------------------------------------- 1 | // Import dynamodb from aws-sdk 2 | const dynamodb = require('aws-sdk/clients/dynamodb'); 3 | 4 | // Import all functions from get-by-id.js 5 | const lambda = require('../../../src/handlers/get-by-id.js'); 6 | 7 | // This includes all tests for getByIdHandler 8 | describe('Test getByIdHandler', () => { 9 | let getSpy; 10 | 11 | // One-time setup and teardown, see more in https://jestjs.io/docs/en/setup-teardown 12 | beforeAll(() => { 13 | // Mock DynamoDB get method 14 | // https://jestjs.io/docs/en/jest-object.html#jestspyonobject-methodname 15 | getSpy = jest.spyOn(dynamodb.DocumentClient.prototype, 'get'); 16 | }); 17 | 18 | // Clean up mocks 19 | afterAll(() => { 20 | getSpy.mockRestore(); 21 | }); 22 | 23 | // This test invokes getByIdHandler and compares the result 24 | it('should get item by id', async () => { 25 | const item = { id: 'id1' }; 26 | 27 | // Return the specified value whenever the spied get function is called 28 | getSpy.mockReturnValue({ 29 | promise: () => Promise.resolve({ Item: item }), 30 | }); 31 | 32 | const event = { 33 | httpMethod: 'GET', 34 | pathParameters: { 35 | id: 'id1', 36 | }, 37 | }; 38 | 39 | // Invoke getByIdHandler 40 | const result = await lambda.getByIdHandler(event); 41 | 42 | const expectedResult = { 43 | statusCode: 200, 44 | body: JSON.stringify(item), 45 | }; 46 | 47 | // Compare the result with the expected result 48 | expect(result).toEqual(expectedResult); 49 | }); 50 | }); 51 | -------------------------------------------------------------------------------- /nodejs22.x/serverless-api-backend/cdk/__tests__/unit/handlers/get-by-id.test.js: -------------------------------------------------------------------------------- 1 | // Import dynamodb from aws-sdk 2 | const dynamodb = require('aws-sdk/clients/dynamodb'); 3 | 4 | // Import all functions from get-by-id.js 5 | const lambda = require('../../../src/handlers/get-by-id.js'); 6 | 7 | // This includes all tests for getByIdHandler 8 | describe('Test getByIdHandler', () => { 9 | let getSpy; 10 | 11 | // One-time setup and teardown, see more in https://jestjs.io/docs/en/setup-teardown 12 | beforeAll(() => { 13 | // Mock DynamoDB get method 14 | // https://jestjs.io/docs/en/jest-object.html#jestspyonobject-methodname 15 | getSpy = jest.spyOn(dynamodb.DocumentClient.prototype, 'get'); 16 | }); 17 | 18 | // Clean up mocks 19 | afterAll(() => { 20 | getSpy.mockRestore(); 21 | }); 22 | 23 | // This test invokes getByIdHandler and compares the result 24 | it('should get item by id', async () => { 25 | const item = { id: 'id1' }; 26 | 27 | // Return the specified value whenever the spied get function is called 28 | getSpy.mockReturnValue({ 29 | promise: () => Promise.resolve({ Item: item }), 30 | }); 31 | 32 | const event = { 33 | httpMethod: 'GET', 34 | pathParameters: { 35 | id: 'id1', 36 | }, 37 | }; 38 | 39 | // Invoke getByIdHandler 40 | const result = await lambda.getByIdHandler(event); 41 | 42 | const expectedResult = { 43 | statusCode: 200, 44 | body: JSON.stringify(item), 45 | }; 46 | 47 | // Compare the result with the expected result 48 | expect(result).toEqual(expectedResult); 49 | }); 50 | }); 51 | -------------------------------------------------------------------------------- /nodejs22.x/serverless-api-backend/sam/__tests__/unit/handlers/get-by-id.test.js: -------------------------------------------------------------------------------- 1 | // Import dynamodb from aws-sdk 2 | const dynamodb = require('aws-sdk/clients/dynamodb'); 3 | 4 | // Import all functions from get-by-id.js 5 | const lambda = require('../../../src/handlers/get-by-id.js'); 6 | 7 | // This includes all tests for getByIdHandler 8 | describe('Test getByIdHandler', () => { 9 | let getSpy; 10 | 11 | // One-time setup and teardown, see more in https://jestjs.io/docs/en/setup-teardown 12 | beforeAll(() => { 13 | // Mock DynamoDB get method 14 | // https://jestjs.io/docs/en/jest-object.html#jestspyonobject-methodname 15 | getSpy = jest.spyOn(dynamodb.DocumentClient.prototype, 'get'); 16 | }); 17 | 18 | // Clean up mocks 19 | afterAll(() => { 20 | getSpy.mockRestore(); 21 | }); 22 | 23 | // This test invokes getByIdHandler and compares the result 24 | it('should get item by id', async () => { 25 | const item = { id: 'id1' }; 26 | 27 | // Return the specified value whenever the spied get function is called 28 | getSpy.mockReturnValue({ 29 | promise: () => Promise.resolve({ Item: item }), 30 | }); 31 | 32 | const event = { 33 | httpMethod: 'GET', 34 | pathParameters: { 35 | id: 'id1', 36 | }, 37 | }; 38 | 39 | // Invoke getByIdHandler 40 | const result = await lambda.getByIdHandler(event); 41 | 42 | const expectedResult = { 43 | statusCode: 200, 44 | body: JSON.stringify(item), 45 | }; 46 | 47 | // Compare the result with the expected result 48 | expect(result).toEqual(expectedResult); 49 | }); 50 | }); 51 | --------------------------------------------------------------------------------