This repository contains a sample AWS Lambda application defined with the AWS Serverless Application Model (SAM).
The sample application provides a REST API (with API Gateway) with a single endpoint. When this endpoint is requested, a Lambda function is triggered, which sends an email to you via the Simple Notification Service (SNS).
This repository contains three AWS Lambda applications, where each application is a stage of the final application:
The third stage in sam-hello-world-3 is the final application, and the others are intermediate stages that you would go through when developing the final application. These intermediate stages are included here for learning purposes.
You can deploy each stage as an independent Lambda application to AWS, as described in the following.
You can deploy the application to AWS with the SAM CLI:
sam package \
--template-file template.yml \
--output-template-file package.yml \
--s3-bucket <MY_BUCKET>
sam deploy \
--template-file package.yml \
--stack-name <MY_STACK> \
--capabilities CAPABILITY_IAM
You have to provide the name of an existing AWS S3 bucket in your account to the sam package
command. The sam package
command uploads the application artefacts (in this case the Lambda function code) to this bucket. When you later trigger a deployment with the sam deploy
command, AWS gets the artefacts from this bucket.
For installing he SAM CLI, use the following:
pip install aws-sam-cli
This is an accompanying code repository of the following article: