Update your stack template
To modify the resources or properties in a CloudFormation stack, you must update the stack's template. Start with the existing template for that stack and make your changes to it. If you have the template stored in a source control system, use a copy of that as your starting point. Otherwise, you can get a copy of the template from CloudFormation.
If you only want to change the parameters or settings of the stack (like a stack's Amazon SNS topic), you can reuse the existing template without getting a copy.
You can update a CloudFormation stack template by using Infrastructure Composer or a text editor.
To update an existing stack template by using Infrastructure Composer
-
On the Stacks page of the CloudFormation console
, choose the name of the stack that you want to update. -
In the stack details pane for the selected stack, select the Template tab, and then choose View in Infrastructure Composer.
-
CloudFormation opens the template in Infrastructure Composer. Here, you can drag, drop, configure, and connect resources (cards) from the Resources pallete. For more information, see How to compose in AWS Infrastructure Composer.
To update an existing stack template by using the AWS CLI
-
To get the template for the stack you want to update, use the get-template CLI command.
-
Copy the template, paste it into a text file, modify it, and save it. Copy only the template. The command encloses the template in quotation marks, but don't copy the quotation marks surrounding the template. The template itself starts with an open brace and ends with the final close brace. Specify changes to the stack's resources in this file.
Keep in mind the following points as you make changes to your template:
-
You can't add, modify, or delete a parameter that's used by a resource that doesn't support updates.
-
For most resources, changing the logical name of a resource is equivalent to deleting that resource and replacing it with a new one. Any other resources that depend on the renamed resource also need to be updated and might cause them to be replaced. Other resources require you to update a property (not just the logical name) in order to initiate an update.
-
Some resources may have constraints about what values you can set for certain properties. For example, changes to the
AllocatedStorage
property for an RDS database instance must be greater than the current value. If your update violates these rules, that part will fail. -
Updating one resource can also affect others that reference it. If you use functions like
Ref
orGetAtt
to set a property based on another resource, CloudFormation will update the referencing resource too when the referenced one changes. -
For information about the effects of updating particular resource properties, see the AWS Resource Types Reference. For each property, the effects of an update will be one of the following:
-
Update requires: No interruption
-
Update requires: Some interruptions
-
Update requires: Replacement
-
-
You can verify the JSON or YAML syntax of your template by using the validate-template CLI command or by specifying your template on the console. The console performs validation automatically. However, these methods only verify the syntax of your template and don't validate the property values that you specified for a resource are valid for that resource. For more complex validations or to check for best practices, you might also use additional tools like CloudFormation Linter (cfn-lint)
and CloudFormation Rain (rain fmt) .
Note
Sometimes CloudFormation won't allow certain changes you try to make, and it will tell you the change isn't permitted. This message might occur asynchronously, however, because resources are created and updated by CloudFormation in a non-deterministic order by default.