Terraform: dynamic blocks

From wikieduonline
Revision as of 16:30, 31 October 2024 by Welcome (talk | contribs) (→‎See also)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

https://www.terraform.io/language/expressions/dynamic-blocks A dynamic block acts much like a for expression.

dynamic { }

Example[edit]

 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[edit]

See also[edit]

Advertising: