Options for deploying your application with Amazon SAM - Amazon Serverless Application Model
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Options for deploying your application with Amazon SAM

With Amazon SAM, you can deploy your application manually and you can also automate deployments. Use the Amazon SAM CLI to manually deploy your application. To automate deployment, use pipelines and a continuous integration and continuous deployment (CI/CD) system. The topics in this section provide information on both approaches.

How to use the Amazon SAM CLI to manually deploy

After you develop and test your serverless application locally, you can deploy your application using the sam deploy command.

To have Amazon SAM guide you through the deployment with prompts, specify the --guided flag. When you specify this flag, the sam deploy command zips your application artifacts, uploads them either to Amazon Simple Storage Service (Amazon S3) (for .zip file archives) or to Amazon Elastic Container Registry (Amazon ECR) (for container images). The command then deploys your application to the Amazon Cloud.

Example:

# Deploy an application using prompts: sam deploy --guided

Deploy with CI/CD systems and pipelines

Amazon SAM helps you automate deployment using pipelines and a continuous integration and continuous deployment (CI/CD) system. Amazon SAM can be used to create pipelines and simplify CI/CD tasks for serverless applications. Multiple CI/CD systems support Amazon SAM build container images, and Amazon SAM also provides a set of default pipeline templates for multiple CI/CD systems that encapsulate Amazon's deployment best practices.

For more information, see Using CI/CD systems and pipelines to deploy with Amazon SAM.

Gradual deployments

If you want to deploy your Amazon SAM application gradually rather than all at once, you can specify deployment configurations that Amazon CodeDeploy provides. For more information, see Working with deployment configurations in CodeDeploy in the Amazon CodeDeploy User Guide.

For information about configuring your Amazon SAM application to deploy gradually, see Deploying serverless applications gradually.

Troubleshooting deployments using the Amazon SAM CLI

Amazon SAM CLI error: "Security Constraints Not Satisfied"

When running sam deploy --guided, you're prompted with the question HelloWorldFunction may not have authorization defined, Is this okay? [y/N]. If you respond to this prompt with N (the default response), you see the following error:

 
Error: Security Constraints Not Satisfied
            

The prompt is informing you that the application you're about to deploy might have an Amazon API Gateway API configured without authorization. By responding N to this prompt, you're saying that this is not OK.

To fix this, you have the following options:

  • Configure your application with authorization. For information about configuring authorization, see Control API access with your Amazon SAM template.

  • Respond to this question with Y to indicate that you're OK with deploying an application that has an API Gateway API configured without authorization.

Learn more

For hands-on examples of deploying serverless applications, see the following from The Complete Amazon SAM Workshop:

  • Module 3 - Deploy manually – Learn how to build, package, and deploy a serverless application using the Amazon SAM CLI.

  • Module 4 - CI/CD – Learn how to automate the build, package, and deployment phases by creating a continuous integration and delivery (CI/CD) pipeline.