Forrest logo
back to the sam tool

sam:tldr:29251

sam: Package a SAM application.
$ sam package
try on your machine

The command "sam package" is a command used in the AWS Serverless Application Model (SAM) to package your AWS Lambda functions and other artifacts into a deployment package for deployment to AWS.

When you run the "sam package" command, it will take your AWS SAM template (usually named "template.yaml" or "template.yml") and any local artifacts referenced in the template, such as Lambda function code, and package them into a zip file. This package is then uploaded and stored in an Amazon S3 bucket.

The command has the following syntax:

sam package --template-file <path/to/template> --output-template-file <path/to/output/template> --s3-bucket <bucket-name>
  • --template-file parameter specifies the path to your AWS SAM template file.
  • --output-template-file parameter specifies the path and name of the output template file to be created after packaging.
  • --s3-bucket parameter specifies the name of the Amazon S3 bucket where the packaged artifacts will be uploaded.

After running the command, SAM will create the output template file and replace the local artifact references with the S3 URL of the packaged artifact. This packaged template can then be used for deployment using the "sam deploy" command.

Overall, the "sam package" command is used to package your AWS SAM application's resources for efficient and easier deployment to AWS.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the sam tool