💾 Archived View for cfdocs.wetterberg.nu › using-cfn-updating-stacks-get-template.gemini captured on 2024-05-12 at 15:11:04. Gemini links have been rewritten to link to archived content
View Raw
More Information
⬅️ Previous capture (2021-12-03)
-=-=-=-=-=-=-
Modifying a stack template
Search
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)
- Get and update a template for a stack (CLI)
Update a stack's template \(console\)
- On the Stacks page of the AWS CloudFormation console, click the name of the stack that you want to update.
- In the stack details pane for the selected stack, select the Template pane, and then click 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:Update requires: No interruptionUpdate requires: Some interruptionsUpdate requires: ReplacementAdd, modify, or delete attributes for resources (Metadata, DependsOn, CreationPolicy, UpdatePolicy, and DeletionPolicy).ImportantYou cannot update the CreationPolicy, DeletionPolicy. or UpdatePolicy attribute 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.ImportantIf 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.ImportantYou 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 fails. 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 also updates 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.
- To check for syntax errors in your template, from the AWS CloudFormation Designer toolbar, choose Validate template ([Image NOT FOUND]).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 ([Image NOT FOUND]) and then Save to save the template in an S3 bucket or locally.
AWS CloudFormation console
What is AWS CloudFormation Designer?
AWS Resource Types Reference
No interruption
Some interruptions
Replacement
AWS::RDS::DBInstance
ModifyDBInstance
Ref function
Fn::GetAtt function
Get and update a template for a stack \(CLI\)
- To get the template for the stack you want to update, use the command https://docs.aws.amazon.com/cli/latest/reference/cloudformation/get-template.html.
- 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.
https://docs.aws.amazon.com/cli/latest/reference/cloudformation/get-template.html