Hi all,
I’m currently playing around with the HCL to dynamically evaluate attribute values in various TF blocks such as resources. For the most the PartialContent
function on the Body
type provides back a BodyContent
which can be used to parse out Attributes
and their values as long as they are set within the block e.g.
block_name {
attribute_name = "attribute_value"
}
In this example, we’re after “attribute_value” and this works. However, if the value for this attribute is set as variable or local, it doesn’t quite resolve to the actual value e.g.:
block_name {
attribute_name = var.attribute
}
variable "attribute" {
type = string
default = ""
}
I understand that the actual variable value can’t be evaluated until we do a terraform plan
since that is evaluated at runtime but my question is, what is the best way to evaluate the eventual value of an attribute before the config is applied. Is there a way to inject a callback between plan
& apply
? Or something else?