How do you pass a complex value through an environment variable?
IntermediateConceptVariables, Locals, Outputs and Types
Answer
TF_VAR_name takes HCL or JSON syntax for lists, maps and objects.
export TF_VAR_subnets='["10.0.1.0/24","10.0.2.0/24"]'
export TF_VAR_tags='{"team":"platform","env":"prod"}'
Handy in CI, though for large structures a .tfvars.json file is easier to review.
More on Variables, Locals, Outputs and Types
How do you declare an input variable?BeginnerIn what order does Terraform load variable values?BeginnerHow do you define an output and what is it for?BeginnerWhat is the difference between locals and variables?BeginnerWhat are the primitive types in Terraform?BeginnerHow do list, set and map differ?Intermediate