Steps to Deploy SAM Applications
The complicated deployment process is the reason why there are so many packaging tools for Lambda functions, including the AWS SAM command-line tools. SAM understands the typical project layouts for various programming languages and knows how to interact with platform package managers.
In the example project, the
CodeUri parameter for a Lambda function points to a local directory with source code files. This is quite usual for teamwork and storing in a version control system, and you will use this approach in almost all projects. But you cannot send that template directly to AWS. In general, turning a SAM application on your disk into resources running in AWS requires three steps:
- Build: create a clean copy of all Lambda functions, remove test and development resources, and download third-party dependencies.
- Package: bundle each function into a self-contained ZIP archive, upload it to S3, and produce a copy of the source application template that points to remote resources instead of local directories.
- Deploy: upload the packaged template to CloudFormation, and execute the changes to create a running infrastructure.