terraform:map
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
terraform:map [18/02/2025 10:37] – created andrew | terraform:map [18/02/2025 15:30] (current) – [Map object] andrew | ||
---|---|---|---|
Line 23: | Line 23: | ||
} | } | ||
output " | output " | ||
- | value = " | + | value = " |
} | } | ||
+ | output " | ||
+ | value = var.var_map[var.owner] | ||
+ | } | ||
+ | |||
</ | </ | ||
Line 58: | Line 62: | ||
$ | $ | ||
</ | </ | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | ====== Map object ====== | ||
+ | |||
+ | |||
+ | < | ||
+ | variable " | ||
+ | type = map(object({ | ||
+ | var1 = string | ||
+ | var2 = string | ||
+ | var3 = bool | ||
+ | })) | ||
+ | |||
+ | default = { | ||
+ | " | ||
+ | var1 = " | ||
+ | var2 = " | ||
+ | var3 = true | ||
+ | } | ||
+ | " | ||
+ | var1 = " | ||
+ | var2 = " | ||
+ | var3 = true | ||
+ | } | ||
+ | |||
+ | } | ||
+ | } | ||
+ | |||
+ | |||
+ | output " | ||
+ | value = var.map_object[" | ||
+ | } | ||
+ | |||
+ | output " | ||
+ | value = var.map_object[" | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | |||
+ | <code bash> | ||
+ | $ terraform apply | ||
+ | |||
+ | Changes to Outputs: | ||
+ | + Choice_var1 = " | ||
+ | + choice_obj | ||
+ | + var1 = " | ||
+ | + var2 = " | ||
+ | + var3 = true | ||
+ | } | ||
+ | |||
+ | You can apply this plan to save these new output values to the Terraform state, without changing any real infrastructure. | ||
+ | |||
+ | Do you want to perform these actions? | ||
+ | Terraform will perform the actions described above. | ||
+ | Only ' | ||
+ | |||
+ | Enter a value: yes | ||
+ | |||
+ | |||
+ | Apply complete! Resources: 0 added, 0 changed, 0 destroyed. | ||
+ | |||
+ | Outputs: | ||
+ | |||
+ | Choice_var1 = " | ||
+ | choice_obj = { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | $ | ||
+ | </ | ||
+ | |||
+ |
terraform/map.1739875077.txt.gz · Last modified: by andrew