Output Plan Checks
The terraform-plugin-testing
module provides a package plancheck
with built-in output value plan checks for common use-cases:
Check | Description |
---|---|
ExpectKnownOutputValue | Asserts the output at the specified address has the specified type, and value. |
ExpectKnownOutputValueAtPath | Asserts the output at the specified address, and path has the specified type, and value. |
ExpectNullOutputValue | Asserts the output at the specified address has a null value. |
ExpectNullOutputValueAtPath | Asserts the output at the specified address, and path has a null value. |
ExpectUnknownOutputValue | Asserts the output at the specified address has an unknown value. |
ExpectUnknownOutputValueAtPath | Asserts the output at the specified address, and path has an unknown value. |
ExpectKnownOutputValue
Plan Check
The plancheck.ExpectKnownOutputValue(address, value)
plan check verifies that a specific output value has a known type, and value.
Refer to Known Value Checks for details, and examples of the available knownvalue.Check types that can be used with the ExpectKnownOutputValue
plan check.
ExpectKnownOutputValueAtPath
Plan Check
The plancheck.ExpectKnownOutputValueAtPath(address, path, value)
plan check verifies that a specific output value at a defined path has a known type, and value.
Note: Prior to Terraform v1.3.0 a planned output is marked as fully unknown if any attribute is unknown.
Refer to Known Value Checks for details, and examples of the available knownvalue.Check types that can be used with the ExpectKnownOutputValueAtPath
plan check.
ExpectNullOutputValue
Plan Check
Note: ExpectNullOutputValue
is deprecated. Use ExpectKnownOutputValue
with knownvalue.Null()
instead.
The built-in plancheck.ExpectNullOutputValue(address)
plan check determines whether an output at the specified address has a null value.
ExpectNullOutputValueAtPath
Plan Check
Note: ExpectNullOutputValueAtPath
is deprecated. Use ExpectKnownOutputValueAtPath
with knownvalue.Null()
instead.
The built-in plancheck.ExpectNullOutputValueAtPath(address, path)
plan check determines whether an output at the specified address, and path has a null value. |
ExpectUnknownOutputValue
Plan Check
One of the built-in plan checks, plancheck.ExpectUnknownOutputValue
, determines whether an output value is unknown, for example, prior to the terraform apply
phase.
The following uses the time_offset resource from the time provider, to illustrate usage of the plancheck.ExpectUnknownOutputValue
, and verifies that day
is unknown.
ExpectUnknownOutputValueAtPath
Plan Check
Output values can contain objects or collections as well as primitive (e.g., string) values. Output value plan checks provide two forms for the plan checks, for example ExpectUnknownOutputValue()
, and ExpectUnknownOutputValueAtPath()
. The Expect<...>OutputValueAtPath()
form is used to access a value contained within an object or collection, as illustrated in the following example.