Sub topic 2
Recreating Infrastructure with Infrastructure as Code
Assume you know AWS Regions, Availability Zones, VPCs, EC2, managed databases, DNS, and load balancers. This chapter focuses on recovering an application in a second Region.
Recreating infrastructure with infrastructure as code
Infrastructure as code (IaC) defines infrastructure in version-controlled files. Use IaC for VPCs, subnets, security groups, load balancers, compute groups, IAM roles, alarms, and database settings. Deploy the same modules in the primary and recovery Regions, changing only Region-specific values.
A recovery runbook should apply the known version of the configuration, not depend on manually rebuilding resources during an outage. Store templates in a repository and test them regularly. Keep secrets in AWS Secrets Manager or another secret store, rather than in the template.
# Example recovery commands for a warm-standby environment
aws autoscaling update-auto-scaling-group \
--region us-west-2 \
--auto-scaling-group-name app-dr \
--min-size 4 \
--desired-capacity 4 \
--max-size 12
aws rds failover-global-cluster \
--region us-west-2 \
--global-cluster-identifier app-global \
--target-db-cluster-identifier arn:aws:rds:us-west-2:111122223333:cluster:app-dr-clusterPilot light: a minimal always-on core
A pilot light keeps the essential data layer and recovery configuration running. For example, a replicated database, an S3 bucket, container images, and IaC templates may remain available while application servers stay stopped or at zero capacity.
During recovery, apply the templates, start compute capacity, run migrations if required, and validate the application. Pilot light costs less than a full standby, but recovery takes longer and has more steps.
Redirecting traffic with Route 53 and Global Accelerator
Route 53 failover records use health checks to return the primary endpoint while it is healthy and the secondary endpoint after failure. Use a short TTL, but remember that DNS resolvers may cache answers until the TTL expires.
Global Accelerator provides static anycast IP addresses and directs users to healthy regional endpoints. It can detect endpoint health without requiring clients to discover a new DNS name. It is useful when stable IP addresses or faster traffic movement matter.
Warm standby: a scaled-down running copy
Warm standby keeps a smaller application fleet running in the recovery Region. Data replication is already active, so recovery mainly requires scaling out, promoting or switching the database, and redirecting traffic.
| Strategy | Running recovery resources | Typical recovery |
|---|---|---|
| Pilot light | Core data and configuration | More setup steps |
| Warm standby | Scaled-down application and data layers | Faster, higher cost |
Exercise
Why does warm standby usually recover faster than pilot light?
Show answer
Warm standby already runs a scaled-down application fleet, so recovery needs scaling and traffic redirection instead of creating the entire fleet.