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
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:
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.
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.
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:
Take a snapshot of the current databases.
Prepare a strategy for how applications that use that DB instance will handle an interruption while the DB instance is being replaced.
Ensure that the applications that use that DB instance take into account the updated port setting and any other updates you have made.
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.
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.