Difference between revisions of "Terraform: for each"
Jump to navigation
Jump to search
Line 7: | Line 7: | ||
a_group = "eastus" | a_group = "eastus" | ||
another_group = "westus2" | another_group = "westus2" | ||
+ | thirt_group = "XXXXXXX" | ||
} | } | ||
name = [[each.]]key | name = [[each.]]key |
Revision as of 06:50, 12 June 2024
for_each
ref
Examples
Official examples
resource "azurerm_resource_group" "rg" { for_each = { a_group = "eastus" another_group = "westus2" thirt_group = "XXXXXXX" } 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] } }
resource "opsgenie_user" "main" { for_each = local.myusers username = "${each.key}@yourdomain.com" full_name = each.value.name role = each.value.role timezone = each.value.timezone }
Errors
Related
See also
Advertising: