'Terragrunt - Unsupported attribute --- but tfstate has the attribute

I cannot figure this out, it's happened a couple of times and this time I'm unable to work around it.

The error I'm getting from terragrunt is

terragrunt.hcl:25,47-50: Unsupported attribute; This object does not have an attribute named "id".

My issue is that the id which I'm trying to reference is present in the tfstate, why can it not see it?

Shortened code below terragrunt.hcl

dependency "vm01" {
  config_path = "../vm01"
}

include {
  path = find_in_parent_folders()
}

terraform {
  source = "//core/azurerm_virtual_machine_extension"
}

locals {
  vm_name = "vm01"
}

inputs = {
  name                  = local.vm_name
  virtual_machine_id    = dependency.vm01.id
.....
}

output.hcl

output "id" {
  value = azurerm_windows_virtual_machine.vm.id
}

tfstate pulled directly from backend storage account

{
  "version": 4,
  "terraform_version": "0.14.7",
  "serial": 4,
  "lineage": "abcde-guid-abcde",
  "outputs": {
    "id": {
      "value": "/subscriptions/abcde-guid-abcde/resourceGroups/rg-name/providers/Microsoft.Compute/virtualMachines/vm01",
      "type": "string"
    }
  }
...........
}


Solution 1:[1]

As this is correct for this situation, it can also happened due to output not being available :

In your ../vm01 dependence you need to terra grunt refresh first and then the output will be available in your module

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Eyal Solomon