You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The tfe_variable object only supports strings as a valid input today. This means that we can't output complex objects (for example, a map of objects) as a variable without going through an intermediary like jsonencode() to convert it to a string. This means that you can't do input type validation on the consuming workspace.
Use-cases
Our workspace factory generates a set of standard variables on creation of workspace. This includes some nested maps. Today, we must convert these to json, then accept them as strings on the incoming variable definition.
│ Error: Incorrect attribute value type
│
│ on ptfe.tf line 8, in resource "tfe_variable" "fff":
│ 8: value = { key1 = "value1", key2 = "value2" }
│
│ Inappropriate value for attribute "value": string required.
Proposal
Some options I thought about:
Update the SDK to allow a dynamic type?
I am not familiar enough with the SDK for development, but it seems that it might require a more flexible .any type in the SDK to be able to encode the input type of the variable properly?
** tfvars encode/decode?**
Another option might require changes on the core side to allow a tfvarsdecode/tfvarsencode like function to enable output of hcl compatible variables? In that case, it'd be a documentation side in the provider to give an example on how to handle that use case.
** Enable parsing of .tfvars.json style in TFE **
Enable a flag on the TFE side to allow parsing of JSON natively as an input, rather than needing to convert to HCL or Strings for complex types
Any other ideas of how this could be done would be well appreciated.
The text was updated successfully, but these errors were encountered:
Just noticed there is a duplicate Here and workaround here: https://github.com/hashicorp/terraform-provider-tfe/issues/40. There has been no movement on that issue for > 12 months so closing.
The tfe_variable object only supports strings as a valid input today. This means that we can't output complex objects (for example, a map of objects) as a variable without going through an intermediary like
jsonencode()
to convert it to a string. This means that you can't do input type validation on the consuming workspace.Use-cases
Our workspace factory generates a set of standard variables on creation of workspace. This includes some nested maps. Today, we must convert these to json, then accept them as strings on the incoming variable definition.
Attempted Solutions
output:
Proposal
Some options I thought about:
Update the SDK to allow a dynamic type?
I am not familiar enough with the SDK for development, but it seems that it might require a more flexible .any type in the SDK to be able to encode the input type of the variable properly?
** tfvars encode/decode?**
Another option might require changes on the core side to allow a
tfvarsdecode/tfvarsencode
like function to enable output of hcl compatible variables? In that case, it'd be a documentation side in the provider to give an example on how to handle that use case.** Enable parsing of
.tfvars.json
style in TFE **Enable a flag on the TFE side to allow parsing of JSON natively as an input, rather than needing to convert to HCL or Strings for complex types
Any other ideas of how this could be done would be well appreciated.
The text was updated successfully, but these errors were encountered: