Accessing nested value in map or object

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"]

It looks like what you need here is one ip_configuration block per element in vm_nics. If so, a good tool for this job would be dynamic blocks:

rsource "azurerm_network_interface" "vm_nic" {
  for_each = var.vm_configuration

  # ...

  dynamic "ip_configuration" {
    for_each = each.value.vm_nics
    content {
      nic_name  = ip_configuration.key
      subnet_id = ip_configuration.value.subnet_block_id

      private_ip_address_allocation = "Dynamic"

I’m not sure if I assigned the right attribute to each argument here but hopefully this shows the pattern enough that you can adapt it to what you wanted. Inside that dynamic block, the symbol ip_configuration (named after the block type) represents the current element of each.value_vm_nics; you could think of ip_configuration as the equilvalent of each for this dynamic block itself, so each is still available in there and still refers to the current element of var.vm_configuration in case you need to use a mixture of the two inside.

the nic is a sub block in a block for the virtual machine. As per the map