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"
}
}
...........
}
Thanks to yorinasub17 over at the terraform github I found my answer.
The outputs are nested under outputs, so the path to id is dependency.vm01.outputs.id, not dependency.vm01.id as you are referencing in the code snippet. See the dependency block reference for more info.