Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between AWS sam build and sam package when using SAM?

I'm building some serverless apps and trying to use SAM. I've been going through some tutorials and some use sam build, while others use sam package.

What are the differences between these commands? It seems like sam package is more difficult to use.

like image 816
Ordep81 Avatar asked Jul 23 '20 18:07

Ordep81


People also ask

What does AWS Sam build do?

AWS SAM CLI lets you locally build, test, and debug serverless applications defined by SAM templates. Using the sam build command, you can easily create deployment artifacts that target AWS Lambda's execution environment. This enables the functions you build locally to run in a similar environment in the cloud.

What is a SAM package?

Packages an AWS SAM application. This command creates a . zip file of your code and dependencies, and uploads the file to Amazon Simple Storage Service (Amazon S3). AWS SAM enables encryption for all files stored in Amazon S3.

Does Sam deploy build?

Builds a serverless application and prepares it for subsequent steps in your workflow, like locally testing the application or deploying it to the AWS Cloud.

What is the difference between Sam template and Cloudformation template?

SAM templates are a superset of Cloudformation. Any Cloudformation template can be run through SAM unchanged, and it will work. SAM supports all the types available in Cloudformation templates, so you can think of SAM as "CloudFormation++".


1 Answers

You may see some older tutorials where they were using sam package but the task that this command is/was performing is now built into sam deploy command so you don't need to perform it manually anymore.

The common order of calls today is init -> build -> deploy.

As for the differences between those 2, build preprocesses your project files locally while package used to zip your project, push it to S3 bucket and returned a processed template (replacing code references) that you would subsequently deploy (this zipping, pushing to s3 and deploying is now handled by deploy command).

like image 127
Matus Dubrava Avatar answered Sep 19 '22 18:09

Matus Dubrava