AWS SAM
Make sure you have followed prerequisites steps and installed Docker.
Hello World
- Run
sam init
and initialize the project as it is written in the book - Run build by issuing
sam build --use-container
- Run function locally
sam local invoke
- Start API
sam local start-api
- In a separate terminal window make a call to local API
curl localhost:3000/hello
- Create a bucket for packages application (
aws s3 mb ...
) - Package your application
sam package --s3-bucekt BUCKET_NAME --output-template-file template-out.yaml
- Deploy the stack
sam deploy --template-file template-out.yaml --stack-name hello-world --capabilities CAPABILITY_IAM
- Invoke remote API
curl API_URL/Prod/hello
Party planner
Steps are similar to Hello, World
sam build --use-container
sam package --s3-bucket mastering-cfn-sam-bucket --output-template-file template-out.yaml
sam deploy --template-file template-out.yaml --stack-name party --capabilities CAPABILITY_IAM
- Invoke remote API
curl -X POST -d @events/event.json -H "Content-Type: application/json" https://API_URL/Prod/register
- Examine the DynamoDB table
- Invoke Lambda function for reporting
aws lambda invoke --function-name REPORTING_FUNCTION --payload '{}' out.txt
- Check S3
aws s3 ls s3://REPORTING_BUCKET aws s3 cp s3://REPORTING_BUCKET/Birthday.txt . cat Birthday.txt