-
Notifications
You must be signed in to change notification settings - Fork 4.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for azurerm_virtual_hub_route_table route as a distinct resource. #11169
Comments
Hi all, I've been looking at how we can solve this. Let me know if I have overlooked something. I have 2 additional options.
This option also allows the propagated route tables and static routes to be managed in this new resource. The downside to this is that you can either configure a connection inside the resource "azurerm_virtual_hub" "example" {
name = "example-vhub"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_resource_group.example.location
virtual_wan_id = azurerm_virtual_wan.example.id
address_prefix = "10.0.2.0/24"
}
resource "azurerm_virtual_hub_connection" "example" {
name = "example-vhubconn"
virtual_hub_id = azurerm_virtual_hub.example.id
remote_virtual_network_id = azurerm_virtual_network.example.id
}
resource "azurerm_virtual_hub_route_table" "example" {
name = "example-vhubroutetable"
virtual_hub_id = azurerm_virtual_hub.example.id
labels = ["label1"]
route {
name = "example-route"
destinations_type = "CIDR"
destinations = ["10.0.0.0/16"]
next_hop_type = "ResourceId"
next_hop = azurerm_virtual_hub_connection.example.id
}
}
resource "azurerm_virtual_hub_connection_routing" "example" {
virtual_hub_connection_id = azurerm_virtual_hub_connection.example.id
associated_route_table_id = azurerm_virtual_hub_route_table.example.id
propagated_route_table {
labels = ["some", "labels"]
route_table_ids = [
azurerm_virtual_hub_route_table.example1.id,
azurerm_virtual_hub_route_table.example2.id
]
}
static_vnet_route {
name = "testvnetroute"
address_prefixes = ["10.0.3.0/24", "10.0.4.0/24"]
next_hop_ip_address = "10.0.3.5"
}
static_vnet_route {
name = "testvnetroute2"
address_prefixes = ["10.0.5.0/24"]
next_hop_ip_address = "10.0.5.5"
}
}
The downside to this option is that multiple resources would need to be created for each of the elements in the resource "azurerm_virtual_hub" "example" {
name = "example-vhub"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_resource_group.example.location
virtual_wan_id = azurerm_virtual_wan.example.id
address_prefix = "10.0.2.0/24"
}
resource "azurerm_virtual_hub_connection" "example" {
name = "example-vhubconn"
virtual_hub_id = azurerm_virtual_hub.example.id
remote_virtual_network_id = azurerm_virtual_network.example.id
}
resource "azurerm_virtual_hub_route_table" "example" {
name = "example-vhubroutetable"
virtual_hub_id = azurerm_virtual_hub.example.id
labels = ["label1"]
route {
name = "example-route"
destinations_type = "CIDR"
destinations = ["10.0.0.0/16"]
next_hop_type = "ResourceId"
next_hop = azurerm_virtual_hub_connection.example.id
}
}
resource "azurerm_virtual_hub_connection_route_table_association" "example" {
virtual_hub_connection_id = azurerm_virtual_hub.example.id
route_table_id = azurerm_virtual_hub_route_table.example.id
} I think option 1 is the best way forward, as we only need to make 1 more resource. I have been able to build a rough implementation of option 2 and will begin implementing option 1. I'll create 2 x draft PRs and link to this issues for further discussion. |
Hi, I see that #11644 was closed as duplicate to this issue. @tombuildsstuff Do you know if the fix you're working on @josh-barker will help with this, as suggested in the issue above? Just to make sure we're aligned here as that one is a pretty important issue as well. |
This functionality has been released in v2.82.0 of the Terraform Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you! |
Hey @NikolaiKleppe, yep this new route resource can be used to create a route on a default route table. resource "azurerm_virtual_hub_route_table_route" "example" {
route_table_id = "${azurerm_virtual_hub.example.id}/hubRouteTables/defaultRouteTable"
name = "example-route"
destinations_type = "CIDR"
destinations = ["10.0.0.0/16"]
next_hop_type = "ResourceId"
next_hop = azurerm_virtual_hub_connection.example.id
} As that's a bit clunky, I'm going to create a new PR to add Example configuration: resource "azurerm_virtual_hub_route_table_route" "example" {
route_table_id = azurerm_virtual_hub.example.default_route_table_id
name = "example-route"
destinations_type = "CIDR"
destinations = ["10.0.0.0/16"]
next_hop_type = "ResourceId"
next_hop = azurerm_virtual_hub_connection.example.id
} I'll mention this issue and #11644 in the new PR when I've created it. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Community Note
Description
Support for azurerm_virtual_hub_route_table routes as a distinct resource. This would be useful as in the current implementation to routes for a azurerm_virtual_hub_route_table are created in the route block, a required parameter in that block is "next_hop", "next_hop" requires a azurerm_virtual_hub_connection ID.
If I'm defining a azurerm_virtual_hub_connection in the same Terraform and I want to either associate the route table with the connection using the "associated_route_table_id" in the routing block or associate a list of route table resources with the connection via the route_table_ids in the propagated_route_table block this causes a cyclical dependency due to the route requiring a connection to create and the connection requiring a route table to create. This would be solved if the azurerm_virtual_hub_route_table route could be created as a distinct resource in line with the way regular Route Table/Routes can be created.
New or Affected Resource(s)
Potential Terraform Configuration
References
The text was updated successfully, but these errors were encountered: