concept

Terraform native test syntax

Write native plan and apply tests with explicit assertions.

Formal Syntax & Structure

terraform syntaxterraform
Terraform native test syntax

Working Example

Example Snippetterraform
variables {  replicas = 2}run "two_slots" {  command = plan  assert {    condition     = length(output.slot_names) == 2 && output.slot_names[0] == "slot-1"    error_message = "Expected two slots starting with slot-1."  }}run "one_slot" {  command = plan  variables {    replicas = 1  }  assert {    condition     = length(output.slot_names) == 1    error_message = "Expected exactly one slot."  }}
Terraform Reference