QuestionQ11

Terraform configuration

The Exhibit section on this page displays part of a configuration you have been asked to modify.

data "azurerm_resource_group" "example" \{  
  name = var.resource_group_name  
\}  
  
resource "azurerm_virtual_network" "example" \{  
  name = ____________________  
\}  

The Azure Virtual Network name must be the resource-group name, followed by a dash and the word “vnet”.

Which expression meets this requirement?

  • A “${azurerm_resource_group.example.name}-vnet”
  • B join(“-”,var.resource_group_name,“vnet”)
  • C concat(data.azurerm_resource_group.example.name, “-”, “vnet”)
  • D “${data.azurerm_resource_group.example.name}-vnet”
Explanation

Terraform data-source attributes use the data.<TYPE>.<NAME>.<ATTRIBUTE> reference form. Interpolating data.azurerm_resource_group.example.name into a string template and appending -vnet yields the required virtual-network name. Terraform’s join function requires a separator and a single list of strings, while concat combines sequence values rather than individual string fragments.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!