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
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.
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