Skip to content

aws-lambda-template-generator/ts-simple-api-proxy-template-sam-cli

Repository files navigation

TypeScript Simple API Proxy Template with SAM CLI

Get started

Make sure that SAM CLI is installed.

  1. Build
sam build
  1. Testing lambda locally
# We first build and copy dist files into .aws-sam
yarn pre-deploy

# With an example event data - this works
sam local invoke

# Startup API Gateway and Lambda in a container
sam local start-api

# Test with curl
curl http://127.0.0.1:3000/get-users
  1. Deploy the function

We first need to build the template, compile TypeScript and copy the dist folder, then deploy. We can override any default config in samconfig.toml file.

yarn pre-deploy
sam deploy --s3-bucket test.lambdafunction.bucket --s3-prefix simpleapiproxy
  1. Clean up the function
aws cloudformation delete-stack --stack-name ts-simple-api-proxy-with-sam

Sam Configuration

There are two configuration files for SAM in this example

  • template.yaml

  • samconfig.toml

    • This file is a project-level configuration file that stores default parameters.

.aws-sam folder

By default SAM CLI pushes the function from build/TsSimpleApiProxyFunction. Therefore, the dist folder has to be copied into it.

About

Simple Rest API TypeScript Lambda with SAM CLI

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published