How do you roll out a new launch template to an ASG without downtime?
IntermediateScenarioImport Refactoring Drift and Lifecycle
Answer
Situation read → A launch template change doesn't touch running instances by default.
What I'd do → Enable instance refresh and reference the latest template version.
resource "aws_autoscaling_group" "web" {
launch_template {
id = aws_launch_template.web.id
version = aws_launch_template.web.latest_version
}
instance_refresh {
strategy = "Rolling"
preferences {
min_healthy_percentage = 90
instance_warmup = 120
}
}
}
Why → Terraform detects the new version and the ASG replaces instances in batches while keeping capacity.
Interview tip → Combine with health checks and a target group so bad AMIs are caught and the refresh stops.
More on Import Refactoring Drift and Lifecycle
An S3 bucket was created by hand in the console and now must be managed by Terraform. How do you bring it in?BeginnerYou must adopt 200 existing resources and don't want to write all the HCL by hand.IntermediateHow do you find out that someone changed infrastructure outside Terraform?BeginnerSomeone opened port 22 on a security group in the console. Terraform wants to remove it. What's your process?IntermediateAn Auto Scaling group's desired capacity is changed by autoscaling, and Terraform keeps resetting it.IntermediateHow do you protect a production database from an accidental `terraform destroy`?Beginner