Search⌘ K
AI Features

Rollbacks and User Data Practical

Explore how AWS CloudFormation manages rollbacks when stack creations or updates fail, including scenarios involving EC2 instances and wait conditions. Understand rollback states, reasons for rollback failures, and best practices to troubleshoot and recover stacks. Gain practical knowledge of using user data and wait conditions to control stack behavior and resource signals.

Rollbacks

When a CloudFormation stack fails, it enters a rollback state by default. This means all changes made by the failed stack revert. All resources are deleted if the failed stack is being created (run for the first time). For example, let’s take a CloudFormation stack that creates an EC2 instance and an RDS database. If the stack created an EC2 instance and then failed while creating an RDS database, the rollback operation will delete the EC2 instance and any other RDS resources created in the stack.

If the stack fails during an update, a rollback will delete or revert all changes ...