Menu

Virtual Geek

Tales from real IT system administrators world and non-production environment

Terraform A reference to a resource type must be followed by at least one attribute access, specifying the resource name

After entering my resources information for Azure in Terraform configuration files and running a plan I was keep on receiving below error.

A reference to a resource type must be followed by at least one attribute access, specifying the resource name

terraform plan azure a reference to a resource type must be followed by at least one attribute access specifying the resource name.png

PS D:\Projects\Terraform\Module_create_multiple_resources_with_single_module_from_hashtable> terraform plan
╷
│ Error: Invalid reference
│
│   on sa.tf line 15, in module "Demo_Azure_Module_RG":
│   15:       rg_name = demo_RG1
│
│ A reference to a resource type must be followed by at least one attribute access, specifying the resource name.
╵
PS D:\Projects\Terraform\Module_create_multiple_resources_with_single_module_from_hashtable>

Solution to this problem is very simple. As you can see in the below screenshot, while providing information in terraform module or resource for example here resource group name was not surrounded by double quotes " ". I added quotes and it worked fine.

In given example rg_name is a string type and when providing explicit string value it should be inside double quotes.

terraform module resource azure azurerm provider features source resource_group location nbame rg tags storage account error.png

Useful Articles
Terraform one module deploy null or multiple resources based on input
Hashicorp Terraform map and object inside module and variable example
Create an Azure virtual machine scale set and load balancer using Terraform
Azure Terraform fixed Availibility Zones on Virtual Machine Scale Set
Writing and Using Terraform modules
Terraform Using one module variable in another module
Hashicorp Terraform dynamic block with example
Terraform for_each loop on map example
Terraform for_each loop on resource example
Terraform manage similar resources with for_each loop inside modules
Importing existing resources into Terraform - Step by Step
Importing already created module Infrastructure into Terraform and update state file
Conditionally create resources in Terraform

Go Back

Comment

Blog Search

Page Views

11497335

Follow me on Blogarama