Local development with SAM
This method allows you to iterate very quickly against Lambda code without having to run AWS resources locally.
Requirements
Step 1: Create and deploy a simple SAM Template (see template.yaml)
- must include the environment varibales on the Lambda to pass the SAMPLE_TABLE in (see line 17)
- use
sam deploy --guided
for the first time deploy
Ths will create the table in the AWS dev account and will be accessible to the locally invoked Lambda function via the AWS CLI credentials
Step 2: Create a local environments file (See locals.json)
- Ensure it contains the name of the actual table created in the deploy
- I also have an "experimental" python script that will build this for you. (see build-params.py)
Step 3: Test locally
- requires an AWS CLI profile to be configured with CRUD access to dynamodb
A single invoke
sam local invoke getAllItemsFunction -n locals.json
As a listening API Gateway emulator
sam local start-api -n locals.js