├── {{cookiecutter.project_slug}} ├── .gitignore ├── events │ └── event-example.json ├── env.json.sample ├── Procfile ├── jest.config.js ├── tsconfig.json ├── .vscode │ └── launch.json ├── src │ └── handlers │ │ └── example.ts ├── package.json ├── __tests__ │ ├── unit │ │ └── handlers │ │ │ └── example.test.ts │ └── utils │ │ └── helpers.ts ├── Makefile ├── template.yml └── README.md ├── cookiecutter.json ├── LICENSE └── README.md /{{cookiecutter.project_slug}}/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .aws-sam 3 | env.json 4 | dist/ 5 | -------------------------------------------------------------------------------- /{{cookiecutter.project_slug}}/events/event-example.json: -------------------------------------------------------------------------------- 1 | { 2 | "httpMethod": "GET" 3 | } 4 | -------------------------------------------------------------------------------- /{{cookiecutter.project_slug}}/env.json.sample: -------------------------------------------------------------------------------- 1 | { 2 | "exampleFunction": { 3 | "SAMPLE_ENV_VAR": "SAMPLE_VALUE" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /cookiecutter.json: -------------------------------------------------------------------------------- 1 | { 2 | "project_name": "Human readable name of the project", 3 | "project_slug": "Directory/package name (no whitespaces)" 4 | } -------------------------------------------------------------------------------- /{{cookiecutter.project_slug}}/Procfile: -------------------------------------------------------------------------------- 1 | sam: sam local start-api --env-vars=env.json 2>&1 | tr "\r" "\n" # workaround for stdout corruption https://github.com/aws/aws-lambda-runtime-interface-emulator/issues/15#issuecomment-792448261 2 | tsc: npm run watch 3 | -------------------------------------------------------------------------------- /{{cookiecutter.project_slug}}/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | preset: 'ts-jest', 3 | testEnvironment: 'node', 4 | modulePathIgnorePatterns: [ 5 | "/.aws-sam", 6 | "/__tests__/fixtures", 7 | "/__tests__/utils", 8 | "/__tests__/global-setup.js", 9 | ], 10 | clearMocks: true, 11 | }; 12 | -------------------------------------------------------------------------------- /{{cookiecutter.project_slug}}/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@tsconfig/node14/tsconfig.json", 3 | "compilerOptions": { 4 | "sourceMap": true, 5 | "allowJs": true, 6 | "checkJs": true, 7 | "moduleResolution": "node", 8 | "outDir": "./dist", 9 | "rootDir": "./src" 10 | }, 11 | "include": ["src/**/*.ts", "src/**/*.js"] 12 | } 13 | -------------------------------------------------------------------------------- /{{cookiecutter.project_slug}}/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "Attach to SAM CLI", 6 | "type": "node", 7 | "request": "attach", 8 | "address": "localhost", 9 | "port": 5858, 10 | "localRoot": "${workspaceRoot}/", 11 | "remoteRoot": "/var/task", 12 | "protocol": "inspector", 13 | "stopOnEntry": false 14 | } 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /{{cookiecutter.project_slug}}/src/handlers/example.ts: -------------------------------------------------------------------------------- 1 | import 'source-map-support/register'; 2 | import { 3 | APIGatewayProxyEvent, 4 | APIGatewayProxyResult 5 | } from 'aws-lambda'; 6 | 7 | /** 8 | * A simple example includes a HTTP get method. 9 | */ 10 | export const exampleHandler = async ( 11 | event: APIGatewayProxyEvent, 12 | ): Promise => { 13 | // All log statements are written to CloudWatch 14 | console.debug('Received event:', event); 15 | 16 | return { 17 | statusCode: 200, 18 | body: JSON.stringify({ 19 | message: 'Hello world!', 20 | }) 21 | }; 22 | } 23 | -------------------------------------------------------------------------------- /{{cookiecutter.project_slug}}/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "{{cookiecutter.project_slug}}", 3 | "version": "1.0.0", 4 | "description": "{{cookiecutter.project_name}}", 5 | "private": true, 6 | "dependencies": { 7 | "source-map-support": "^0.5.19" 8 | }, 9 | "devDependencies": { 10 | "@tsconfig/node14": "^1.0.0", 11 | "@types/aws-lambda": "^8.10.72", 12 | "@types/jest": "^26.0.20", 13 | "@types/node": "^14.14.26", 14 | "jest": "^26.6.3", 15 | "ts-jest": "^26.5.1", 16 | "ts-node": "^9.0.0", 17 | "typescript": "^4.1.5" 18 | }, 19 | "scripts": { 20 | "build": "node_modules/typescript/bin/tsc", 21 | "watch": "node_modules/typescript/bin/tsc -w --preserveWatchOutput", 22 | "test": "jest" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /{{cookiecutter.project_slug}}/__tests__/unit/handlers/example.test.ts: -------------------------------------------------------------------------------- 1 | import { constructAPIGwEvent } from '../../utils/helpers'; 2 | 3 | import { exampleHandler } from '../../../src/handlers/example'; 4 | 5 | // This includes all tests for exampleHandler() 6 | describe('Test exampleHandler', () => { 7 | it('should return ids', async () => { 8 | const event = constructAPIGwEvent({}, { method: 'GET', path: '/' }); 9 | 10 | // Invoke exampleHandler() 11 | const result = await exampleHandler(event); 12 | 13 | const expectedResult = { 14 | statusCode: 200, 15 | body: JSON.stringify({ message: 'Hello world!' }) 16 | }; 17 | 18 | // Compare the result with the expected result 19 | expect(result).toEqual(expectedResult); 20 | }); 21 | }); 22 | -------------------------------------------------------------------------------- /{{cookiecutter.project_slug}}/__tests__/utils/helpers.ts: -------------------------------------------------------------------------------- 1 | import { APIGatewayProxyEvent } from 'aws-lambda'; 2 | 3 | export function constructAPIGwEvent(message: any, options: Record = {}): APIGatewayProxyEvent { 4 | return { 5 | httpMethod: options.method || 'GET', 6 | path: options.path || '/', 7 | queryStringParameters: options.query || {}, 8 | headers: options.headers || {}, 9 | body: options.rawBody || JSON.stringify(message), 10 | multiValueHeaders: {}, 11 | multiValueQueryStringParameters: {}, 12 | isBase64Encoded: false, 13 | pathParameters: options.pathParameters || {}, 14 | stageVariables: options.stageVariables || {}, 15 | requestContext: options.requestContext || {}, 16 | resource: options.resource || '', 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /{{cookiecutter.project_slug}}/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: build-RuntimeDependenciesLayer build-lambda-common 2 | .PHONY: build-ExampleFunction 3 | 4 | build-ExampleFunction: 5 | $(MAKE) HANDLER=src/handlers/example.ts build-lambda-common 6 | 7 | build-lambda-common: 8 | npm install 9 | rm -rf dist 10 | echo "{\"extends\": \"./tsconfig.json\", \"include\": [\"${HANDLER}\"] }" > tsconfig-only-handler.json 11 | npm run build -- --build tsconfig-only-handler.json 12 | cp -r dist "$(ARTIFACTS_DIR)/" 13 | 14 | build-RuntimeDependenciesLayer: 15 | mkdir -p "$(ARTIFACTS_DIR)/nodejs" 16 | cp package.json package-lock.json "$(ARTIFACTS_DIR)/nodejs/" 17 | npm install --production --prefix "$(ARTIFACTS_DIR)/nodejs/" 18 | rm "$(ARTIFACTS_DIR)/nodejs/package.json" # to avoid rebuilding when changes aren't related to dependencies 19 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2021 Andrey Novikov 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # Template for AWS SAM using TypeScript and shared layers 3 | 4 | This is a [Cookiecutter](https://github.com/audreyr/cookiecutter) template to create a Serverless application based on [Serverless Application Model (SAM)](https://aws.amazon.com/serverless/sam/) on Node.js 14 runtime using TypeScript for Lambda functions source code and shared layers for runtime dependencies. 5 | 6 | Resulted application will be close to this example app: [aws-sam-typescript-layers-example](https://github.com/Envek/aws-sam-typescript-layers-example/) 7 | 8 | ## Usage 9 | 10 | [Install AWS SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html) and run following command: 11 | 12 | ```sh 13 | sam init --location gh:Envek/cookiecutter-aws-sam-typescript-layers 14 | ``` 15 | 16 | You'll be prompted a few questions to help this template to scaffold this project and after its completion you should see a new folder at your current path with the name of the project you gave as input. 17 | 18 | ## License 19 | 20 | This project is licensed under the terms of the [MIT license](https://opensource.org/licenses/MIT). 21 | -------------------------------------------------------------------------------- /{{cookiecutter.project_slug}}/template.yml: -------------------------------------------------------------------------------- 1 | # This is the SAM template that represents the architecture of your serverless application 2 | # https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-template-basics.html 3 | 4 | # The AWSTemplateFormatVersion identifies the capabilities of the template 5 | # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/format-version-structure.html 6 | AWSTemplateFormatVersion: 2010-09-09 7 | Description: >- 8 | {{cookiecutter.project_name}} 9 | 10 | # Transform section specifies one or more macros that AWS CloudFormation uses to process your template 11 | # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/transform-section-structure.html 12 | Transform: 13 | - AWS::Serverless-2016-10-31 14 | 15 | Globals: 16 | Function: 17 | Layers: 18 | - !Ref RuntimeDependenciesLayer 19 | Environment: 20 | # # Environment variables used by every function 21 | # Variables: 22 | # SAMPLE_TABLE: !Ref SampleTable 23 | Runtime: nodejs14.x 24 | MemorySize: 128 25 | Timeout: 100 26 | 27 | # Resources declares the AWS resources that you want to include in the stack 28 | # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/resources-section-structure.html 29 | Resources: 30 | # Each Lambda function is defined by properties: 31 | # https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction 32 | 33 | # This is a Lambda function config associated with the source code: in src/handlers/example.ts 34 | ExampleFunction: 35 | Type: AWS::Serverless::Function 36 | Metadata: 37 | BuildMethod: makefile 38 | Properties: 39 | Handler: dist/handlers/example.exampleHandler 40 | Description: A simple example includes a HTTP get method to get all items from a DynamoDB table. 41 | Events: 42 | Api: 43 | Type: Api 44 | Properties: 45 | Path: / 46 | Method: GET 47 | 48 | # Shared layer with Lambda runtime dependencies 49 | RuntimeDependenciesLayer: 50 | Type: AWS::Serverless::LayerVersion 51 | Metadata: 52 | BuildMethod: makefile 53 | Properties: 54 | LayerName: "{{cookiecutter.project_slug}}-dependencies" 55 | Description: Runtime dependencies for Lambdas 56 | ContentUri: ./ 57 | CompatibleRuntimes: 58 | - nodejs14.x 59 | RetentionPolicy: Retain 60 | 61 | Outputs: 62 | WebEndpoint: 63 | Description: "API Gateway endpoint URL for Prod stage" 64 | Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/" 65 | -------------------------------------------------------------------------------- /{{cookiecutter.project_slug}}/README.md: -------------------------------------------------------------------------------- 1 | # {{cookiecutter.project_name}} 2 | 3 | This project contains source code and supporting files for a serverless application that you can deploy with the AWS Serverless Application Model (AWS SAM) command line interface (CLI). It includes the following files and folders: 4 | 5 | - `src` - Code for the application's Lambda function written in TypeScript. 6 | - `events` - Invocation events that you can use to invoke the function. 7 | - `__tests__` - Unit tests for the application code. 8 | - `template.yml` - A template that defines the application's AWS resources. 9 | 10 | The application uses several AWS resources, including Lambda functions and API Gateway API. These resources are defined in the `template.yml` file in this project. You can update the template to add AWS resources through the same deployment process that updates your application code. 11 | 12 | If you prefer to use an integrated development environment (IDE) to build and test your application, you can use the AWS Toolkit. 13 | The AWS Toolkit is an open-source plugin for popular IDEs that uses the AWS SAM CLI to build and deploy serverless applications on AWS. The AWS Toolkit also adds step-through debugging for Lambda function code. 14 | 15 | To get started, see the following: 16 | 17 | * [PyCharm](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html) 18 | * [IntelliJ](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html) 19 | * [VS Code](https://docs.aws.amazon.com/toolkit-for-vscode/latest/userguide/welcome.html) 20 | * [Visual Studio](https://docs.aws.amazon.com/toolkit-for-visual-studio/latest/user-guide/welcome.html) 21 | 22 | ## Deploy the application 23 | 24 | The AWS SAM CLI is an extension of the AWS CLI that adds functionality for building and testing Lambda applications. It uses Docker to run your functions in an Amazon Linux environment that matches Lambda. It can also emulate your application's build environment and API. 25 | 26 | To use the AWS SAM CLI, you need the following tools: 27 | 28 | * AWS SAM CLI - [Install the AWS SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html). 29 | * Node.js - [Install Node.js 14](https://nodejs.org/en/), including the npm package management tool. 30 | * Docker - [Install Docker community edition](https://hub.docker.com/search/?type=edition&offering=community). 31 | 32 | To build and deploy your application for the first time, run the following in your shell: 33 | 34 | ```bash 35 | sam build 36 | sam deploy --guided 37 | ``` 38 | 39 | The first command will build the source of your application: installs dependencies that are defined in `package.json`, creates a deployment package, and saves it in the `.aws-sam/build` folder. 40 | 41 | The second command will package and deploy your application to AWS, with a series of prompts: 42 | 43 | * **Stack Name**: The name of the stack to deploy to CloudFormation. This should be unique to your account and region, and a good starting point would be something matching your project name. 44 | * **AWS Region**: The AWS region you want to deploy your app to. 45 | * **Confirm changes before deploy**: If set to yes, any change sets will be shown to you before execution for manual review. If set to no, the AWS SAM CLI will automatically deploy application changes. 46 | * **Allow SAM CLI IAM role creation**: Many AWS SAM templates, including this example, create AWS IAM roles required for the AWS Lambda function(s) included to access AWS services. By default, these are scoped down to minimum required permissions. To deploy an AWS CloudFormation stack which creates or modified IAM roles, the `CAPABILITY_IAM` value for `capabilities` must be provided. If permission isn't provided through this prompt, to deploy this example you must explicitly pass `--capabilities CAPABILITY_IAM` to the `sam deploy` command. 47 | * **Save arguments to samconfig.toml**: If set to yes, your choices will be saved to a configuration file inside the project, so that in the future you can just re-run `sam deploy` without parameters to deploy changes to your application. 48 | 49 | The API Gateway endpoint API will be displayed in the outputs when the deployment is complete. 50 | 51 | ### Building of additional layers and Lambda itself 52 | 53 | To decrease size of Lambda functions, runtime dependencies are extracted into Lambda Layer. 54 | 55 | However, many guides (including Amazon ones) like [1](https://aws.amazon.com/blogs/compute/working-with-aws-lambda-and-lambda-layers-in-aws-sam/) or [2](https://medium.com/@anjanava.biswas/nodejs-runtime-environment-with-aws-lambda-layers-f3914613e20e) propose to move `package.json` to another folder which breaks local development and testing. 56 | 57 | To keep local workflow, building of Lambda itself and its layers was changed from default “automagic” of SAM (`sam build` automatically copies code, installs packages, and cleans up, but this process can't be customized) to explicit steps defined in `Makefile` as per [Building layers](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/building-layers.html) doc. 58 | 59 | So, now on `sam build` command: 60 | 1. Only `src` folder is copied into function itself (however it is renamed into `dist` and contains TypeScript transpiled to JavaScript). 61 | 2. packages are installed into separate layer (`package-lock.json` is also copied for reference) 62 | 3. Local project layout isn't changed at all. 63 | 64 | `sam deploy` will update layer with dependencies only if number or versions of packages were changed. 65 | 66 | ## Use the AWS SAM CLI to build and test locally 67 | 68 | Copy `env.json.sample` to `env.json`: 69 | 70 | ```sh 71 | cp -n env.json{.sample,} 72 | ``` 73 | 74 | **Warning:** Make sure you don't have `.aws-sam` directory (built SAM template), because if you do, `sam local invoke` will use code from it and won't see your code changes. 75 | 76 | If you have some kind of Procfile launcher like [Overmind](https://github.com/DarthSim/overmind) (highly recommended!) you can use it to start both TypeScript compiler in watch mode and local API gateway simultaneously: 77 | 78 | ```bash 79 | $ overmind start 80 | ``` 81 | 82 | And that's it: now you can head over to http://localhost:3000/ to hit `ExampleFunction`! 83 | 84 | But, sure, you still can start components independently: 85 | 86 | Start Typescript compiler in watch mode to recompile your code on change (_instead_ of running `sam build` command). 87 | 88 | ```bash 89 | $ npm run watch 90 | ``` 91 | 92 | Test a single function by invoking it directly with a test event. An event is a JSON document that represents the input that the function receives from the event source. Test events are included in the `events` folder in this project. 93 | 94 | Run functions locally and invoke them with the `sam local invoke` command. 95 | 96 | ```bash 97 | $ sam local invoke ExampleFunction --env-vars env.json --event events/event-example.json 98 | ``` 99 | 100 | The AWS SAM CLI can also emulate your application's API. Use the `sam local start-api` command to run the API locally on port 3000. 101 | 102 | ```bash 103 | $ sam local start-api --env-vars=env.json 104 | $ curl http://localhost:3000/ 105 | ``` 106 | 107 | The AWS SAM CLI reads the application template to determine the API's routes and the functions that they invoke. The `Events` property on each function's definition includes the route and method for each path. 108 | 109 | ```yaml 110 | Events: 111 | Api: 112 | Type: Api 113 | Properties: 114 | Path: / 115 | Method: GET 116 | ``` 117 | 118 | ### Debugging 119 | 120 | You can debug with external debugger by this manual: [Step-through debugging Node.js functions locally ](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-using-debugging-nodejs.html) 121 | 122 | 1. Run `sam local invoke` with `--debug-port` option. 123 | 124 | ```sh 125 | $ sam local invoke ExampleFunction --env-vars=env.json --event events/event-example.json --debug-port 5858 126 | ``` 127 | 128 | It will wait for debugger to attach before starting execution of the function. 129 | 130 | 2. Place a breakpoint where needed (yes, right in TypeScript code). 131 | 132 | 3. Start external debugger. In Visual Studio Code you can just press F5. 133 | 134 | ## Add a resource to your application 135 | The application template uses AWS SAM to define application resources. AWS SAM is an extension of AWS CloudFormation with a simpler syntax for configuring common serverless application resources, such as functions, triggers, and APIs. For resources that aren't included in the [AWS SAM specification](https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md), you can use the standard [AWS CloudFormation resource types](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.html). 136 | 137 | Update `template.yml` to add a dead-letter queue to your application. In the **Resources** section, add a resource named **MyQueue** with the type **AWS::SQS::Queue**. Then add a property to the **AWS::Serverless::Function** resource named **DeadLetterQueue** that targets the queue's Amazon Resource Name (ARN), and a policy that grants the function permission to access the queue. 138 | 139 | ```yaml 140 | Resources: 141 | MyQueue: 142 | Type: AWS::SQS::Queue 143 | 144 | ExampleFunction: 145 | Type: AWS::Serverless::Function 146 | Properties: 147 | Handler: src/handlers/example.exampleHandler 148 | Runtime: nodejs14.x 149 | DeadLetterQueue: 150 | Type: SQS 151 | TargetArn: !GetAtt MyQueue.Arn 152 | Policies: 153 | - SQSSendMessagePolicy: 154 | QueueName: !GetAtt MyQueue.QueueName 155 | ``` 156 | 157 | The dead-letter queue is a location for Lambda to send events that could not be processed. It's only used if you invoke your function asynchronously, but it's useful here to show how you can modify your application's resources and function configuration. 158 | 159 | Deploy the updated application. 160 | 161 | ```bash 162 | $ sam deploy 163 | ``` 164 | 165 | Open the [**Applications**](https://console.aws.amazon.com/lambda/home#/applications) page of the Lambda console, and choose your application. When the deployment completes, view the application resources on the **Overview** tab to see the new resource. Then, choose the function to see the updated configuration that specifies the dead-letter queue. 166 | 167 | ## Fetch, tail, and filter Lambda function logs 168 | 169 | To simplify troubleshooting, the AWS SAM CLI has a command called `sam logs`. `sam logs` lets you fetch logs that are generated by your Lambda function from the command line. In addition to printing the logs on the terminal, this command has several nifty features to help you quickly find the bug. 170 | 171 | **NOTE:** This command works for all Lambda functions, not just the ones you deploy using AWS SAM. 172 | 173 | ```bash 174 | $ sam logs -n ExampleFunction --stack-name sam-app --tail 175 | ``` 176 | 177 | **NOTE:** This uses the logical name of the function within the stack. This is the correct name to use when searching logs inside an AWS Lambda function within a CloudFormation stack, even if the deployed function name varies due to CloudFormation's unique resource name generation. 178 | 179 | You can find more information and examples about filtering Lambda function logs in the [AWS SAM CLI documentation](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-logging.html). 180 | 181 | ## Unit tests 182 | 183 | Tests are defined in the `__tests__` folder in this project. Use `npm` to install the [Jest test framework](https://jestjs.io/) and run unit tests. 184 | 185 | ```bash 186 | $ npm install 187 | $ npm test 188 | ``` 189 | 190 | ## Cleanup 191 | 192 | To delete the sample application that you created, use the AWS CLI. Assuming you used your project name for the stack name, you can run the following: 193 | 194 | ```bash 195 | $ aws cloudformation delete-stack --stack-name aws-sam-typescript-layers-example 196 | ``` 197 | 198 | ## Resources 199 | 200 | For an introduction to the AWS SAM specification, the AWS SAM CLI, and serverless application concepts, see the [AWS SAM Developer Guide](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/what-is-sam.html). 201 | 202 | Next, you can use the AWS Serverless Application Repository to deploy ready-to-use apps that go beyond Hello World samples and learn how authors developed their applications. For more information, see the [AWS Serverless Application Repository main page](https://aws.amazon.com/serverless/serverlessrepo/) and the [AWS Serverless Application Repository Developer Guide](https://docs.aws.amazon.com/serverlessrepo/latest/devguide/what-is-serverlessrepo.html). 203 | --------------------------------------------------------------------------------