TFFR2 - Additional Terraform Outputs
ID: TFFR2 - Category: Outputs - Additional Terraform Outputs
The prohibition on outputting an entire provider resource is enforced by no_entire_resource_output_tffr2.
Authors SHOULD NOT output entire resource objects as these may contain sensitive outputs and the schema can change with API or provider versions.
Instead, authors SHOULD output the computed attributes of the resource as discreet outputs.
This kind of pattern protects against provider schema changes and is known as an anti-corruption layer.
Remember, you SHOULD NOT output values that are already inputs (other than name).
E.g.,
# Resource output, computed attribute.
output "foo" {
description = "MyResource foo attribute"
value = azapi_resource.myresource.output.properties.foo
}
# Resource output for resources that are deployed using `for_each`. Again only computed attributes.
output "childresource_foos" {
description = "MyResource children's foo attributes"
value = {
for key, value in azapi_resource.mychildresource : key => value.output.properties.foo
}
}
# Output of a sensitive attribute
output "bar" {
description = "MyResource bar attribute"
value = azapi_resource.myresource.output.properties.bar
sensitive = true
}