Skip to main content
The check block defines post-deploy, runtime assertions that validate the state of deployed resources. Checks run after resources are provisioned and can depend on specific resources being in place.

Syntax

check name {
  depends_on = [resource_a, resource_b]

  assert {
    condition     = <boolean expression>
    error_message = <string expression>
  }
}
The label is a bare identifier, quotes optional. A quoted label may contain spaces.

Fields

FieldDescription
depends_onOptional. A list of resource references the check depends on. The check runs after these resources are available.
assert { }One or more assertion blocks. See assert.

Assert blocks

Each assert block has exactly two required fields:
FieldDescription
conditionA boolean expression that must evaluate to true for the check to pass.
error_messageA string expression reported when the condition is false.
for, count, and for_each are not allowed inside check blocks.

Example

check api_health {
  depends_on = [api_gateway, backend]

  assert {
    condition     = api_gateway.stage == "prod"
    error_message = "API gateway must be on the prod stage"
  }
}

How checks are used

Checks run as post-deploy assertions. Use depends_on to ensure the referenced resources exist before the assert conditions are evaluated against their live state.