How does the sam build and sam deploy workflow package and deploy a serverless application to AWS?
Short answer
The sam build command compiles your application code and its dependencies into a deployment ready format, resolving anything needed for the target Lambda runtime, and sam deploy then packages those build artifacts, uploads them to S3, and executes a CloudFormation deployment…
Advertisement
AModel answer
The sam build command compiles your application code and its dependencies into a deployment ready format, resolving anything needed for the target Lambda runtime, and sam deploy then packages those build artifacts, uploads them to S3, and executes a CloudFormation deployment using the transformed SAM template, handling the entire process of getting your local application code running as a live set of AWS resources with just these two straightforward commands.
Example
sam build sam deploy --guided
Real-world example
A team automates their deployment process using sam build followed by sam deploy within their CI/CD pipeline, ensuring every code change that passes tests is automatically packaged and deployed to their AWS environment consistently.
Likely follow-ups
- What does the --guided flag do during the first sam deploy?
- How do build dependencies get resolved differently for different Lambda runtimes?
Related topics