A team wants Terraform to assert after every plan and apply that its public health endpoint returns HTTP 200. A failure must be reported but must never block a deployment, and HCP Terraform health assessments should keep evaluating it between runs. Which construct fits?
Select an answer to reveal the explanation.
Short Explanation
A check block is a smoke detector that beeps but never locks the doors. You get the warning, the deploy carries on, and HCP Terraform keeps sniffing the air between runs. The trap is any option with condition, validation or precondition in it, because those stop the run cold.
Full Explanation
Check blocks are designed for functional validation of infrastructure outside the usual resource lifecycle. A check block can contain a scoped data source, such as an http data source pointed at the endpoint, plus one or more assert blocks, for example asserting that the status_code equals 200. When an assertion fails, Terraform reports a warning and continues, and check blocks run as the last step of plan and apply. When health assessments are enabled on an HCP Terraform workspace, continuous validation re-evaluates check blocks between runs and alerts on failures, meeting the monitoring part of the requirement. A postcondition is an error condition: if it fails, Terraform stops work that depends on that resource, which contradicts the requirement never to block. Variable validation can reference only values available in configuration and raises errors; it cannot perform an HTTP request, and it would block the run. An output precondition is also an error that halts the operation when false. Exam caveat: a scoped data source inside a check block that fails to read produces a warning too, rather than an error. Operational check: point the assertion at an endpoint returning a different code and confirm plan finishes with a warning, then confirm the workspace's health page shows the failed check.