Interview Prep/Terraform/Testing Upgrades and Large-Scale Operations

Add a runtime health assertion to infrastructure without blocking applies.

IntermediateScenarioTesting Upgrades and Large-Scale Operations
Answer

Situation read → You want post-apply validation that warns instead of failing.

What I'd do → Use a check block (Terraform 1.5+).

check "app_is_healthy" {
  data "http" "health" {
    url = "https://${aws_lb.app.dns_name}/health"
  }
  assert {
    condition     = data.http.health.status_code == 200
    error_message = "Health endpoint did not return 200."
  }
}

Why → Check failures show as warnings on every plan/apply, which is useful for continuous validation.

Interview tip → Contrast with precondition/postcondition, which block.

All Terraform questions Roadmap: Terraform in production

More on Testing Upgrades and Large-Scale Operations