1
votes

strange question. Can I, instead of using a variable, also use the resource property of an resource + a string to construct a name:

For example:

resource "azurerm_network_security_group" "nsgvmss" {
  name     = **"NSG - azurerm_resource_virtual_machine_scale_set.vmss.name"** 
  location = azurerm_resource_group.rgapp.location 
  resource_group_name = azurerm_resource_group.rgapp.name
}

this works of course with variables like "NSG, ${var.vssname}" but again,

was wondering if i can use the resource name of the object in TF as well

Thanks

1

1 Answers

2
votes

This is called string interpolation. Also see expressions (which isn't as pre-0.12-centric)

...
 name     = "NSG - ${azurerm_resource_virtual_machine_scale_set.vmss.name}"
...