AWS CloudFormation
User Guide (API Version 2010-05-15)
Did this page help you?  Yes | No |  Tell us about it...
« PreviousNext »
View the PDF for this guide.Go to the AWS Discussion Forum for this product.Go to the Kindle Store to download this guide in Kindle format.

AWS CloudFormation Stacks Updates

You can update a stack that has been successfully created to update resources in the stack, such as an Amazon EC2 instance, or to update the stack's settings, such as the stack's Amazon SNS notification topic. For example, if your stack included an Amazon EC2 instance, you can update that instance by updating the stack. You don't need to create a new stack. You can use the AWS CloudFormation console, the aws cloudformation update-stack CLI command, or the UpdateStack API to update a stack.

Updates to stack resources

You modify stack resources by submitting an updated template or by submitting updated input parameters. When you submit an update, AWS CloudFormation updates resources based on differences between what you submit and the stack's current template. Resources that have not changed run without disruption during the update process. Resources that are updated could be interrupted or replaced, depending on the resources and properties that are being updated. AWS CloudFormation uses one of the following techniques to update resources:

Update with No Interruption

AWS CloudFormation updates the resource without disrupting operation of that resource and without changing the resource's physical name. For example, if you update any properties on an AWS::CloudWatch::Alarm resource, AWS CloudFormation updates the alarm's configuration and, during the update, the alarm's operation continues without disruption.

Updates with Some Interruption

AWS CloudFormation updates the resource with some interruption but the physical name is retained. For example, if you update certain properties on an AWS::EC2::Instance resource, the instance might have some interruption while AWS CloudFormation and Amazon EC2 reconfigure the instance.

Replacement

AWS CloudFormation recreates the resource during an update, which also generates a new physical ID. AWS CloudFormation creates the replacement resource first, changes references from other dependent resources to point to the replacement resource, and then deletes the old resource. For example, if you update the Engine property of an AWS::RDS::DBInstance resource, AWS CloudFormation creates a new resource and replaces the current DBInstance resource with the new one.

To learn more about updating a particular resource, see the documentation that is associated with that resource. For example, the Amazon EC2 documentation provides details about what changes interrupt an instance. See also the AWS Resource Types Reference, where the effects of updating a resource are listed for each property.

Depending on the technique AWS CloudFormation uses to modify each updated resource in your stack, you can make decisions about when it's best to modify resources to reduce the impact of these changes on your application. In particular, you can plan when resources must be replaced during an update. For example, if you update the Port property of an AWS::RDS::DBInstance resource, AWS CloudFormation creates a new DB instance with the updated port setting and a new physical name. To plan for this, you should do the following:

  1. Take a snapshot of the current databases.

  2. Prepare a strategy for how applications that use that DB instance will handle an interruption while the DB instance is being replaced.

  3. Ensure that the applications that use that DB instance take into account the updated port setting and any other updates you have made.

  4. Use the DB snapshot to restore the databases on the new DB instance.

This example is not exhaustive; it's meant to give you an idea of the things to plan for when a resource is replaced during an update.

Note

If the template includes one or more nested stacks, AWS CloudFormation also initiates an update for every nested stack. This is necessary to determine whether the nested stacks have been modified. AWS CloudFormation updates only those resources in the nested stacks that have changes specified in corresponding templates.