Posted On: Jun 20, 2023

AWS CloudFormation launches a new parameter OnStackFailure for the CreateChangeSet API that allows customers to control the rollback behavior of ChangeSets. Customers use ChangeSets to preview the impact of a stack operation on active resources. Customers can deploy ChangeSets with an ExecuteChangeSet operation. With this launch, customers can modify the actions that CloudFormation will take when ChangeSet execution is unsuccessful. This allows customers to reduce manual intervention during retries of ChangeSet executions.

Customers can set OnStackFailure to ROLLBACK, DELETE, or DO_NOTHING. ROLLBACK is the default option for OnStackFailure. When customers set OnStackFailure to ROLLBACK, CloudFormation reverts the stack to its last stable state if ChangeSet execution fails. This matches the current behavior of ChangeSets and allows customers to prevent service interruptions during stack updates in production environments. Customers can set OnStackFailure to DELETE only for ChangeSets that create new stacks. When customers set OnStackFailure to DELETE, CloudFormation deletes the new stack if ChangeSet execution fails. This eliminates the need for manual clean-up of stacks and allows customers to retry stack creation with CI/CD actions. This speeds up development in test environments and prevents human error in production environments. When customers set OnStackFailure to DO_NOTHING, CloudFormation preserves the state of the stack if ChangeSet execution fails. This makes it easier to investigate provisioning failures, such as breaches of AWS account limits, in test environments.

OnStackFailure parameter is available in AWS Regions where CloudFormation is available. Refer to the AWS Region table to see AWS Regions where CloudFormation is available.

To learn more about OnStackFailure, refer to the CreateChangeSet API documentation.