chrismitchellonline

Using AWS CLI to Manage CloudFormation Tips & Tricks

2020-11-12

Learn a few tips and tricks for working with the AWS CLI to manage a CloudFormation stack.

Errors in Stack

A CloudFormation stack can be created without errors but a stack can still fail to create or update its AWS resources. To check the status of your stack, run the following AWS CLI command. If StackStatus is something other than CREATE_COMPLETE you will need to investigate before you can run any update commands:

aws cloudformation describe-stacks --stack-name <stack-name>
Recreating the Stack

If you have errors creating your stack and need to run the create command, you will need to delete the stack first. Caution! Ensure you are deleting the right stack with this command there are no warnings or undo actions with command! Not only does the CloudFormation stack get deleted, but everything created by the stack as well (depending on policy). For more information about protecting a stack from deletion, see Protecting a stack from being deleted from AWS Documentation.

aws cloudformation delete-stack --stack-name <stack-name>
Updating CloudFormation Stack

To update a CloudFormation stack we update our template and then call the update-stack CLI command:

aws cloudformation update-stack --stack-name <stack-name> --template-body file://<updated-template-file>
comments powered by Disqus
Social Media