mk101
mk101

Reputation: 21

Terraform - use resource name and string for name

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

Upvotes: 2

Views: 5008

Answers (1)

user11714757
user11714757

Reputation:

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

Upvotes: 3

Related Questions