Difference between revisions of "Terraform: dynamic blocks"
Jump to navigation
Jump to search
(2 intermediate revisions by one other user not shown) | |||
Line 10: | Line 10: | ||
name = parameter.value.name | name = parameter.value.name | ||
value = parameter.value.value | value = parameter.value.value | ||
− | apply_method = lookup(parameter.value, "apply_method", null) | + | apply_method = [[lookup]](parameter.value, "apply_method", null) |
} | } | ||
} | } | ||
+ | |||
+ | |||
+ | <pre> | ||
+ | locals { | ||
+ | dynamic = "key_b" | ||
+ | my_map_json = jsonencode({ | ||
+ | key_a = "something" | ||
+ | (local.dynamic) = "else" | ||
+ | }) | ||
+ | # ... | ||
+ | } | ||
+ | </pre> | ||
+ | Ref: https://github.com/hashicorp/terraform/issues/27037#issuecomment-734356738 | ||
== Related == | == Related == |
Revision as of 09:48, 20 August 2024
https://www.terraform.io/language/expressions/dynamic-blocks
A dynamic block acts much like a for
expression.
dynamic { }
Example
dynamic "parameter" { for_each = var.parameters content { name = parameter.value.name value = parameter.value.value apply_method = lookup(parameter.value, "apply_method", null) } }
locals { dynamic = "key_b" my_map_json = jsonencode({ key_a = "something" (local.dynamic) = "else" }) # ... }
Ref: https://github.com/hashicorp/terraform/issues/27037#issuecomment-734356738
Related
See also
Advertising: