- Lab
-
Libraries: If you want this lab, consider one of these libraries.
Disaster Recovery and State Reconstruction
In this hands-on lab, you will build disaster recovery capabilities for your Terraform state infrastructure. Starting with a working remote backend, you will configure S3 Cross-Region Replication to maintain a geo-redundant copy of your state, simulate a regional outage, and perform a manual failover to the DR replica, and recover from a corrupted state file using S3 versioning history. By the end of the lab, you will have practiced the three core DR scenarios every infrastructure architect must be prepared for: regional failure, accidental corruption, and data loss recovery.
Lab Info
Table of Contents
-
Challenge
Implement cross-region replication for state storage to maintain a geo-redundant copy of the infrastructure source of truth
- Create a secondary S3 bucket in the DR region with encryption, versioning, and public access blocking.
- Create an IAM replication role and configure Cross-Region Replication on the primary bucket.
- Trigger a state update and verify that the state file appears in the DR bucket.
- Create a DynamoDB lock table in the DR region for failover operations.
-
Challenge
Simulate a regional outage and perform a manual failover to the secondary state replica to maintain operational continuity
- Confirm that the primary backend is healthy, then simulate an outage by denying access to the primary bucket.
- Reconfigure the backend to point to the DR bucket and verify a zero-drift plan. Restore primary access by removing the deny policy and reconfiguring the backend to point back to the primary bucket.
-
Challenge
Restore a corrupted state file using backend versioning history to recover from accidental or malicious data loss
- Pull the current state, save a backup, then deliberately corrupt it by removing a resource entry.
- Push the corrupted state and observe the resulting drift in
terraform plan. - Identify the last known good version using S3 version history, restore it with
terraform state push -force, and confirm zero drift.
About the author
Real skill practice before real-world application
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Learn by doing
Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.
Follow your guide
All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.
Turn time into mastery
On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.