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 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 modifications 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.
Update a Stack's Template (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 and YAML 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.
If the values in a mapping are not being used by your stack, you can't update the mapping by itself. 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
AllocatedStorageproperty 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 fails. For the specific constraints on
AllocatedStoragechanges, 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 also updates the resource that contains the reference to the property that has changed. For example, if you updated the
MasterUsernameproperty of an
AWS::RDS::DBInstanceresource and you had an
AWS::AutoScaling::LaunchConfigurationresource that had a
UserDataproperty that contained a reference to the DB instance name using the
Reffunction, AWS CloudFormation would recreate the DB instance with a new name and also update the
To check for syntax errors in your template, from the AWS CloudFormation Designer toolbar, choose Validate template ().
View and fix any errors in the Messages 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.
Get and Update a Template for a Stack (CLI)
To get the template for the stack you want to update, use the command
aws cloudformation get-template.
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 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.