Hi guys
I need your help to figure out about a blocking point in my code.
I using the module azure vnet to create the environement for each app we have in the company on azure .
I trying to use a local for naming my subnets with a suffix variable by giving the module a variable for subnets like local.subnet_names = ["snet-prd-weu-${var.app-name}-01"]
but the given variable value seem not compatible with what expected and I got this error.
Error: Ambiguous attribute key
on main.tf line 21, in module “vnet”:
21: local.subnet_names = azurerm_network_security_group.polo_booking.id
If this expression is intended to be a reference, wrap it in parentheses. If
it’s instead intended as a literal name containing periods, wrap it in quotes
to create a string literal.
the global code is :
module “vnet” {
source = “Azure/vnet/azurerm”
version = “2.4.0”
vnet_name = “vnet-prd-weu-polo-booking-01”
resource_group_name = azurerm_resource_group.polo_env.name
address_space = [“address_space”]
subnet_prefixes = [“subnet_prefixes”]
subnet_names = local.subnet_names
nsg_ids = {
local.subnet_names = azurerm_network_security_group.polo_booking.id
}
route_tables_ids = {
local.subnet_names = azurerm_route_table.rt_polo_booking.id
}
tags = {
environement = “prd”
Projet = “”
appli = “”
}
depends_on = [azurerm_resource_group.polo_env]
}
add network security group
resource “azurerm_network_security_group” “polo_booking” {
name = local.network_security_group
resource_group_name = azurerm_resource_group.polo_env.name
location = azurerm_resource_group.polo_env.location
}
the gitbub of this module is here :
thanks for your help this make me crazy.
I know it’s expect a list for the subnet_names but I can’t understand even if I use tolist() function to the local.subnet_names I got the same error.
Thanks by advance