This repo should help you get started authoring, testing, and deploying your own serverless web API using AWS Lambda, SAM, and DynamoDB, whether locally or in your own AWS account.
- 3 AWS Lambda functions:
- Hello World
- POST Your Vote
- Vote Results
- An AWS SAM Template, which wires them up to:
- DynamoDB
- IAM
- API Gateway
- A Makefile to stand it all up:
- Setup your local dev environment
- Package and deploy to your AWS account
- Ensure that
make
is installed. - Ensure that Docker is installed.
- Install the AWS CLI:
pip install awscli
, etc. - Install the AWS SAM CLI:
npm install -g aws-sam-local
, etc. - Copy the provided
config.example
file into your own file namedconfig
to overrideSTACK_NAME
and other relevant values.
$ make dev-setup # creates local dynamodb table
$ make # starts local dynamodb and local api gateway in the foreground
In another terminal, run:
$ make local-test # curls local endpoints to trigger your lambdas
Test your code, edit your functions, hit save, and test them again.
$ make deploy-setup # creates your s3 bucket to store SAM packages
When you're ready to deploy your code to AWS:
$ make package # creates and pushes your SAM package
$ make deploy # deploys your SAM package to your AWS account
$ make remote-test # curls your newly-created remote API endpoints
$ make clean-all # destroys all resources, local and remote