Today, we have better solutions like AWS Toolkit extension that provides both debugging, build, and local invoke.
We need to bootstrap our environment quickly in order to have both SAM Local and DynamoDB Local to play together nicely:
- Create a docker network
docker network create sam-demo
- Run and Bootstrap DynamoDB Local
You need to install boto3 and faker library to bootstrap dynamo (pip install faker boto3), or simply use AWS CLI
docker run -d -v "$PWD":/dynamodb_local_db -p 8000:8000 --network sam-demo --name dynamodb cnadiminti/dynamodb-local
python bootstrap_dynamodb.py -t "users" --hash-key "id"
- Create local development environment and run
make build-dev SERVICE="users"
sam local start-api --docker-network sam-demo
- Test API locally
curl localhost:3000/getUsers