Skip to content

azurermRouteTable

Manages a Route Table

\~> NOTE on Route Tables and Routes: Terraform currently provides both a standalone Route resource, and allows for Routes to be defined in-line within the Route Table resource. At this time you cannot use a Route Table with in-line Routes in conjunction with any Route resources. Doing so will cause a conflict of Route configurations and will overwrite Routes.

Example Usage

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as azurerm from "./.gen/providers/azurerm";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: azurerm.
For a more precise conversion please use the --provider flag in convert.*/
const azurermResourceGroupExample = new azurerm.resourceGroup.ResourceGroup(
  this,
  "example",
  {
    location: "West Europe",
    name: "example-resources",
  }
);
const azurermRouteTableExample = new azurerm.routeTable.RouteTable(
  this,
  "example_1",
  {
    disable_bgp_route_propagation: false,
    location: azurermResourceGroupExample.location,
    name: "example-route-table",
    resource_group_name: azurermResourceGroupExample.name,
    route: [
      {
        address_prefix: "10.1.0.0/16",
        name: "route1",
        next_hop_type: "VnetLocal",
      },
    ],
    tags: {
      environment: "Production",
    },
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermRouteTableExample.overrideLogicalId("example");

Argument Reference

The following arguments are supported:

  • name - (Required) The name of the route table. Changing this forces a new resource to be created.

  • resourceGroupName - (Required) The name of the resource group in which to create the route table. Changing this forces a new resource to be created.

  • location - (Required) Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created.

  • route - (Optional) List of objects representing routes. Each object accepts the arguments documented below.

-> NOTE Since route can be configured both inline and via the separate azurermRoute resource, we have to explicitly set it to empty slice ([]) to remove it.

  • disableBgpRoutePropagation - (Optional) Boolean flag which controls propagation of routes learned by BGP on that route table. True means disable.

  • tags - (Optional) A mapping of tags to assign to the resource.


A route block support:

  • name - (Required) The name of the route.

  • addressPrefix - (Required) The destination to which the route applies. Can be CIDR (such as 10100/16) or Azure Service Tag (such as apiManagement, azureBackup or azureMonitor) format.

  • nextHopType - (Required) The type of Azure hop the packet should be sent to. Possible values are virtualNetworkGateway, vnetLocal, internet, virtualAppliance and none.

  • nextHopInIpAddress - (Optional) Contains the IP address packets should be forwarded to. Next hop values are only allowed in routes where the next hop type is virtualAppliance.

Attributes Reference

The following attributes are exported:

  • id - The Route Table ID.
  • subnets - The collection of Subnets associated with this route table.

Timeouts

The timeouts block allows you to specify timeouts for certain actions:

  • create - (Defaults to 30 minutes) Used when creating the Route Table.
  • update - (Defaults to 30 minutes) Used when updating the Route Table.
  • read - (Defaults to 5 minutes) Used when retrieving the Route Table.
  • delete - (Defaults to 30 minutes) Used when deleting the Route Table.

Import

Route Tables can be imported using the resourceId, e.g.

terraform import azurerm_route_table.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Network/routeTables/mytable1