Modifying a Stack Template
If you want to modify resources and properties that are declared in a stack template, you must modify the stack's template. To ensure that you update only the resources that you intend to update, use the template for the existing stack as a starting point and then make your updates to that template. If you are managing your template in a source control system, use a copy of that template as a starting point. Otherwise, you can get a copy of a stack template from AWS CloudFormation.
If you want to modify just the parameters or settings of a stack (like a stack's Amazon SNS topic), you can reuse the existing stack template. You don't need to get a copy of the stack template or make any modification to the stack template.
If your template includes an unsupported change, AWS CloudFormation returns a message saying that the change is not permitted. This message might occur asynchronously, however, because resources are created and updated by AWS CloudFormation in a non-deterministic order by default.
To update a stack's template by using the console
In the AWS CloudFormation console, select the stack that you want to update and then choose the Actions and then View in Designer.
AWS CloudFormation opens a copy of the stack's template in AWS CloudFormation Designer.
Modify the template.
You can use the AWS CloudFormation Designer drag-and-drop interface or the integrated JSON editor to modify the template. For more information about using AWS CloudFormation Designer, see What Is AWS CloudFormation Designer?.
Modify only the resources that you want to update. Use the same values as the current stack configuration for resources and properties that you aren't updating. You can modify the template by completing any of the following actions:
Add new resources, or remove existing resources.
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 trigger an update.
Add, modify, or delete properties of existing resources.
Consult the AWS Resource Types Reference for information about the effects of updating particular resource properties. For each property, the effects of an update will be one of the following:
Add, modify, or delete attributes for resources (
You cannot update the
UpdatePolicyattribute by itself. You can update them only when you include changes that add, modify, or delete resources. For example, you can add or modify a metadata attribute of a resource.
Add, modify, or delete parameter declarations. However, you cannot add, modify, or delete a parameter that is used by a resource that does not support updates.
Add, modify, or delete mapping declarations.
You cannot update a mapping by itself if the values in the mapping are not being used by your stack. You need to include changes that add, modify, or delete resources. For example, you can add or modify a metadata attribute of a resource. If you update a mapping value that your stack is using, you don't need to make any other changes to trigger an update.
Add, modify, or delete condition declarations.
You cannot update conditions by themselves. You can update conditions only when you include changes that add, modify, or delete resources. For example, you can add or modify a metadata attribute of a resource.
Add, modify, or delete output value declarations.
Some resources or properties may have constraints on property values or changes to those values. For example, changes to the AllocatedStorage property of an AWS::RDS::DBInstance resource must be greater than the current setting, If the value specified for the update does not meet those constraints, the update for that resource will fail. For the specific constraints on AllocatedStorage changes, see ModifyDBInstance.
Updates to a resource can affect the properties of other resources. If you used the Ref function or the Fn::GetAtt function to specify an attribute from an updated resource as part of a property value in another resource in the template, AWS CloudFormation will also update the resource that contains the reference to the property that has changed. For example, if you updated the MasterUsername property of an AWS::RDS::DBInstance resource and you had an AWS::AutoScaling::LaunchConfiguration resource that had a UserData property that contained a reference to the DB instance name using the Ref function, AWS CloudFormation would recreate the DB instance with a new name and also update the LaunchConfiguration resource.
From the AWS CloudFormation Designer toolbar, choose the Validate template () to check for any syntax errors in your template.
View and fix any errors in the Errors pane, and then validate the template again. If you don't see any errors, your template is syntactically valid.
From the AWS CloudFormation Designer toolbar, choose the File menu () and then Save to save the template in an S3 bucket or locally.
To get and modify a template for a stack from AWS CloudFormation by using the command line
Use the command
aws cloudformation get-templateto get the template for the stack you want to update.
Copy the template, paste it into a text file, modify it, and save it. Make sure that you copy only the template. The command encloses the template in quotation marks, but do not 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.