Course contentsShow
← Cloud and Infrastructure
Lesson 890 of 2,98916. AWS CloudFormationFree lesson

Stack Rollback Configuration

Configure rollback triggers and CloudWatch alarms to automatically roll back stacks when issues are detected.

Stack Rollback Configuration

What you'll learn: How to automatically detect and revert CloudFormation stack failures before they cause production issues.

What Is Stack Rollback Configuration?

When you deploy infrastructure changes, things can go wrong—a misconfigured security group, an unreachable endpoint, or a failing health check. Stack Rollback Configuration lets you define triggers that monitor your stack during creation or update. If something breaks, CloudFormation automatically rolls back to the last known good state.

Think of it like a safety net: you're walking a tightrope (deploying infrastructure), and sensors detect if you're losing balance (CloudWatch alarms trip). Instead of falling (production outage), the net catches you (automatic rollback).

How It Works

You configure rollback triggers that reference CloudWatch alarms. During stack operations, CloudFormation monitors these alarms for a specified period (the monitoring time). If any alarm enters the ALARM state, the stack automatically rolls back.

Example scenario:

  • You update an Auto Scaling group configuration
  • A CloudWatch alarm monitors HTTP 5xx errors
  • If errors spike above threshold during the monitoring window, the alarm triggers
  • CloudFormation automatically reverts the stack to its previous configuration

Key Components

  • MonitoringTimeInMinutes: How long to watch alarms after stack operation begins (0-180 minutes)
  • RollbackTriggers: List of CloudWatch alarm ARNs to monitor
  • AlarmARN: The specific CloudWatch alarm that can trigger rollback

This configuration is set when you create or update a stack, typically through the AWS CLI or CloudFormation console's advanced options.

Key Takeaway: Stack Rollback Configuration uses CloudWatch alarms as safety sensors to automatically revert failed deployments, protecting your infrastructure from problematic changes before they impact users.