hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.6k stars 4.65k forks source link

Virtual Hub Connection - "ID was missing the `virtualHubs` element" error #17191

Open fcatacut opened 2 years ago

fcatacut commented 2 years ago

Is there an existing issue for this?

Community Note

Terraform Version

1.0.5

AzureRM Provider Version

3.9.0

Affected Resource(s)/Data Source(s)

azurerm_virtual_hub_connection

Terraform Configuration Files

provider "azurerm" {
  features {}
}

variable "name" {
  default = "example"
}

variable "location" {
  default = "eastus2"
}

resource "azurerm_resource_group" "this" {
  name     = format("%s-rg", var.name)
  location = var.location
}

resource "azurerm_virtual_network" "this" {
  name                = format("%s-vnet", var.name)
  address_space       = ["172.0.0.0/16"]
  location            = azurerm_resource_group.this.location
  resource_group_name = azurerm_resource_group.this.name
}

resource "azurerm_route_table" "this" {
  name                = format("%s-rt", var.name)
  resource_group_name = azurerm_resource_group.this.name
  location            = azurerm_resource_group.this.location
}

resource "azurerm_virtual_wan" "this" {
  name                = format("%s-vwan", var.name)
  resource_group_name = azurerm_resource_group.this.name
  location            = azurerm_resource_group.this.location
}

resource "azurerm_virtual_hub" "this" {
  name                = format("%s-vhub", var.name)
  resource_group_name = azurerm_resource_group.this.name
  location            = azurerm_resource_group.this.location
  virtual_wan_id      = azurerm_virtual_wan.this.id
  address_prefix      = "10.0.0.0/23"
}

resource "azurerm_virtual_hub_connection" "this" {
  name                      = format("%s-vhubconn", var.name)
  virtual_hub_id            = azurerm_virtual_hub.this.id
  remote_virtual_network_id = azurerm_virtual_network.this.id
  routing {
    associated_route_table_id = azurerm_route_table.this.id
    propagated_route_table {
      route_table_ids = [azurerm_route_table.this.id]
    }
  }
}

Debug Output/Panic Output

https://gist.github.com/fcatacut/787df94a0727794dabb61e148264d637

Expected Behaviour

The virtual hub connection should be succcessfully provisioned.

Actual Behaviour

The following errors occur:

Error: ID was missing the virtualHubs element

with azurerm_virtual_hub_connection.this, on main.tf line 50, in resource "azurerm_virtual_hub_connection" "this": 50: associated_route_table_id = azurerm_route_table.this.id

Error: ID was missing the virtualHubs element

with azurerm_virtual_hub_connection.this, on main.tf line 52, in resource "azurerm_virtual_hub_connection" "this": 52: route_table_ids = [azurerm_route_table.this.id]

Steps to Reproduce

terraform apply

Important Factoids

No response

References

No response

rcskosir commented 2 months ago

Thanks for opening this issue. Have you been able to try this on any of the more recent 3.x versions or on the new 4.x versions to see if this issue still persists?