Course contentsShow
← Cloud and Infrastructure
Lesson 720 of 2,98913. Infrastructure as Code FoundationsFree lesson

Rollback Strategies

Explore approaches for safely reverting infrastructure changes when deployments fail or cause issues.

Rollback Strategies

What you'll learn: How to safely revert infrastructure changes when deployments fail or cause unexpected issues.


Even with careful planning and testing, infrastructure changes can sometimes go wrong in production. A rollback strategy is your safety net—a predefined plan for undoing changes and returning to a known-good state when things break.

Why Rollbacks Matter

Think of infrastructure rollback like the "undo" button in a word processor, except the stakes are much higher. A failed database migration or misconfigured load balancer can bring down your entire application. Having a clear rollback path means you can recover quickly rather than troubleshooting under pressure.

Common Rollback Approaches

Version-controlled rollback is the simplest: since your infrastructure code is in version control (remember lesson 710?), you can revert your code to the previous commit and re-apply. This works because IaC tools will detect the differences and make the necessary changes.

State file backups provide another safety layer. Before major changes, backup your state file (from lesson 700-704). If something breaks, you can restore the backup and re-apply the old configuration.

Blue-green deployments maintain two identical environments. Deploy changes to the inactive "green" environment, test it, then switch traffic over. If issues arise, switch back to "blue" instantly—no actual rollback needed.

Immutable infrastructure (lesson 691) makes rollbacks cleaner: instead of modifying existing resources, you provision entirely new ones. Rolling back means pointing traffic to the old resources and destroying the new ones.

Rollback Considerations

Not all changes can be safely rolled back. Database schema changes, deleted resources, or modifications with dependencies require careful planning. Always test rollback procedures in non-production environments first.

Key Takeaway: A rollback strategy is your insurance policy for infrastructure changes—plan how you'll undo deployments before you need to, using version control, state backups, or deployment patterns that minimize rollback complexity.