sam build
- Fetch dependencies & build the application. If the application code does not require building, skip this command and run sam package
directly.aws cloudformation package
or sam package
- Convert the SAM template to CloudFormation template, package the application code and the CloudFormation template and upload to an S3 bucket (must be created beforehand).aws cloudformation deploy
or sam deploy
- Deploy the application package from S3 (creates and executes Change Set in CloudFormation)sam publish
- publish serverless app to SAR (only needs the CF template, the code is referenced from S3)Transform: "AWS::Serverless-2016-10-31'
- indicates that the YAML file is a SAM template (required)Resources
- resources to be created (required)
AWS::Serverless::Function
- define a Lambda functionAWS::Serverless::Api
- define an API gatewayAWS::Serverless::SimpleTable
- define a DynamoDB tableAWS::Serverless::Application
- use an application from SARS3ReadPolicy
- read-only permission to objects in an S3 bucketSQSPollerPolicy
- allow the function to poll an SQS queueDynamoDBCrudPolicy
- allow CRUD operations on a DynamoDB tableDynamoDBReadPolicy
- allow read operations on a DynamoDB tableSAM uses CodeDeploy under the hood to update Lambda functions every time we update the code and deploy.
Gradually shifts traffic to the new Lambda version using Aliases
Optional Pre & Post Traffic Hooks (run on separate Lambda functions) to validate the deployment before the traffic shift starts and after it ends
Optional Automated Rollback using CloudWatch Alarms
Configure the deployment strategy in the Properties
section of the Lambda function.