Terraform: for each

From wikieduonline
Revision as of 18:01, 14 May 2023 by Welcome (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

for_each ref

Examples[edit]

Official examples[edit]

resource "azurerm_resource_group" "rg" {
  for_each = {
    a_group = "eastus"
    another_group = "westus2"
  }
  name     = each.key
  location = each.value
}


resource "aws_ssm_parameter" "secret" {
  for_each    = toset(var.secrets)
  name        = each.key
  description = each.key
  type        = "SecureString"
  value       = "1"

  lifecycle {
    ignore_changes = [value]
  }
}

Errors[edit]

Related[edit]

See also[edit]

Advertising: