Deploying a SAM Application
Get ready to deploy the SAM application in this lesson!
We'll cover the following
Step 3: Deploy
You now have a single CloudFormation template (output.yaml
) which describes the entire infrastructure and links to a packaged version of the function code. To create a running instance of your application, you’ll need to create a new CloudFormation stack based on this template. To do that, run the following command in the directory that contains the packaged template (output.yaml
):
sam deploy --template-file output.yaml --stack-name sam-test-1 --capabilities CAPABILITY_IAM
This command has three arguments:
--template-file
is the template to deploy. You want to use the result of thepackage
command here, henceoutput.yaml
.--stack-name
is a name for the target stack. If a stack with the specified name does not yet exist in your AWS account, CloudFormation will create it. If you use the same name the next time you deploy, CloudFormation will update the existing resources instead of creating new ones.--capabilities CAPABILITY_IAM
allows CloudFormation to create IAM policies. SAM needs this to let the API Gateway call Lambda functions. Note that these are not security capabilities of the Lambda function, but instead the privileges required by the deployment process.
Note that you will use
sam-test-1
as the stack name to run all the commands in this course.
Create a free account to view this lesson.
By signing up, you agree to Educative's Terms of Service and Privacy Policy