Hi I am new to Terraform and IAC in general, so learning on the job. I am working on writing a standard Azure VM module.
I am stuck on how I access the value of a nested map.
Is there any documentation around this?
my map looks like this:
variable vm_configuration {
type = map(object({
vm_resource_group = string
vm_rg_location = string
vm_as_name = string
vm_name = string
vm_size = string
vm_image_publisher = string
vm_image_offer = string
vm_image_sku = string
vm_image_version = string
vm_admin_username = string
vm_admin_password = string
vm_os_disk_caching = string
vm_storage_account_type = string
# vm_custom_data = string
# vm_boot_diag_storage = string
vm_tags = map(any)
vm_nics = map(object({
nic_name = string <<< I want to access this value.
ipconfig_name = string
subnet_block_id = string
}))
}))
}
the code block in the module looks like this. It’s not working obviously.
resource "azurerm_network_interface" "vm_nic" {
for_each = var.vm_configuration
name = each.value.nic_name
location = each.value["vm_rg_location"]
resource_group_name = each.value["vm_resource_group"]
ip_configuration {
name = each.value.vm_nics.each.key["ipconfig_name"]
subnet_id = each.value.vm_nics.each.key.each.value["subnet_block_id"]
private_ip_address_allocation = "Dynamic"
}
tags = each.value["vm_tags"]
}