Interview Prep/Terraform/Refactoring, Migration and Drift

How do you replace an Auto Scaling group's launch template without downtime?

AdvancedProductionRefactoring, Migration and Drift
Answer

Use create_before_destroy with a name that changes per version (or name_prefix), and an instance_refresh block on the ASG so instances roll gradually with min_healthy_percentage.

instance_refresh {
  strategy = "Rolling"
  preferences { min_healthy_percentage = 90 }
}

Pair with health checks on the load balancer, and test in staging with realistic traffic.

All Terraform questions Roadmap: Terraform in production

More on Refactoring, Migration and Drift