Interview Prep/Terraform/Import Refactoring Drift and Lifecycle

A load balancer's TLS certificate must be rotated with no outage.

IntermediateScenarioImport Refactoring Drift and Lifecycle
Answer

Situation read → The default order is destroy then create, which would break the listener.

What I'd do → Use create_before_destroy.

resource "aws_acm_certificate" "app" {
  domain_name       = "app.example.com"
  validation_method = "DNS"
  lifecycle { create_before_destroy = true }
}

Why → The new cert exists and is attached before the old one is removed, so the listener always has a valid certificate.

Interview tip → create_before_destroy propagates to dependencies, and names must not collide.

All Terraform questions Roadmap: Terraform in production

More on Import Refactoring Drift and Lifecycle