Starting with output variables

I am using Azure and I have started to use the play with output variables in-order to reuse code.

I have run into the following error when I perform a terraform apply

“Error: Unsupported attribute
on output.tf line 2, in output “azurerm_resource_group”:
2: value = “${azurerm_resource_group.demotest.name.id}”
This value does not have any attributes”

Within the main.tf file I have the following block:

resource “azurerm_resource_group” “demotest” {
name = “rg001”
location = “uksouth”
}

When I refer to the terraform online docs I can see that azurerm_resource_group has an attribute called id (https://www.terraform.io/docs/providers/azurerm/r/resource_group.html)
Therefore I am unsure why I get the error above. I get a similar error when I use the following block within the output.tf for my network module. Again the guid attribute is listed on the terraform online docs.

output “virtual_networkconfiguration_id” {
value = “${azurerm_virtual_network.example.name.guid}”
}

The goal is to work on outputs so that I can play with re-using code through the use of modules within Azure

The id attribute is an attribute of the resource, not of the resource’s name attribute.

Use azurerm_resource_group.demotest.id instead of azurerm_resource_group.demotest.name.id.