An HCP Terraform workspace variable allowed_cidrs holds ["10.0.0.0/16", "10.1.0.0/16"]. The configuration declares the variable as list(string), but runs fail because the value arrives as a single string. How should the workspace variable be fixed?
Select an answer to reveal the explanation.
Short Explanation
HCP Terraform treats every variable value as text unless you tell it otherwise. Tick the HCL checkbox on that Terraform variable and the brackets become a real list, written in the same syntax you'd put in a .tf file. Sensitive, jsonencode or a variable set won't change how the text is read.
Full Explanation
Terraform variables defined in an HCP Terraform workspace are strings by default. To supply a list, map or other complex value, the variable's HCL option is enabled and the value is entered in normal HCL syntax; the workspace's Terraform version interprets it, so ["10.0.0.0/16", "10.1.0.0/16"] then arrives as a list that satisfies list(string). The HCL option is available for Terraform variables, not environment variables. Marking a variable sensitive only makes it write-only in the UI and hides it in logs; the value is still treated as a string. Wrapping the value in jsonencode() without the HCL option simply stores that text as a literal string, and jsonencode would produce a string in any case, not a list. Variable sets follow the same rules as workspace variables: a set's Terraform variable is also a string unless its HCL option is enabled, and priority affects precedence, not type. Exam caveat: once the HCL option is on, the value must be valid HCL; a missing quote or bracket fails the run. Operational check: edit the variable, enable HCL, save, queue a plan, and confirm the resources receive two CIDR entries rather than a type error.