data-platform-hq / terraform-azurerm-route-table

Terraform module for route table and its routes creation

Home Page:https://registry.terraform.io/modules/data-platform-hq/route-table/azurerm/latest

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Azure route table Terraform module

Terraform module for route table creation with routes and subnet associations.

Usage

This module is provisioning route table with routes and subnet associations. Below is an example that provisions route table with three routes.

locals {
  routes = {
    "route1" = {
      address_prefix = "10.0.0.0/16"
      next_hop_type  = "VirtualAppliance"
      next_hop_ip    = "10.2.0.3"
    }
    "route2" = {
      address_prefix = "10.1.0.0/16"
      next_hop_type  = "VirtualNetworkGateway"
    }
    "route3" = {
      address_prefix = "10.2.0.0/16"
      next_hop_type  = "VnetLocal"
    }
  }
}

data "azurerm_subnet" "subnet1" {
  name                 = "subnet1"
  virtual_network_name = "example-vnet"
  resource_group_name  = "example-rg"
}

data "azurerm_subnet" "subnet2" {
  name                 = "subnet2"
  virtual_network_name = "example-vnet"
  resource_group_name  = "example-rg"
}

module "route_table" {
  source  = "data-platform-hq/route-table/azurerm"
  
  route_table_name = "example-route-table"
  location         = var.location
  resource_group   = var.resource_group
  subnet_ids       = {
    (data.azurerm_subnet.subnet1.name) = data.azurerm_subnet.subnet1.id
    (data.azurerm_subnet.subnet2.name) = data.azurerm_subnet.subnet2.id
  }
  routes = local.routes
}

Requirements

Name Version
terraform >= 1.0.0
azurerm >= 4.0.1

Providers

Name Version
azurerm >= 4.0.1

Modules

No modules.

Resources

Name Type
azurerm_route.this resource
azurerm_route_table.this resource
azurerm_subnet_route_table_association.this resource

Inputs

Name Description Type Default Required
bgp_route_propagation_enabled Boolean flag which controls propagation of routes learned by BGP on that route table. True means enable. bool false no
location Specifies the supported Azure location where the resource exists string n/a yes
resource_group The name of the resource group in which to create the route table string n/a yes
route_table_name Route table name string n/a yes
routes Map of route names to its address_prefix, next_hop_type
map(object({
address_prefix = string
next_hop_type = string
next_hop_ip = optional(string)
}))
{} no
subnet_ids Maps of subnet name to id, route table would associated to this subnets map(string) {} no
tags Resource tags map(any) {} no

Outputs

Name Description
route_table Map of route table name to ID

License

Apache 2 Licensed. For more information please see LICENSE

About

Terraform module for route table and its routes creation

https://registry.terraform.io/modules/data-platform-hq/route-table/azurerm/latest

License:Other


Languages

Language:HCL 100.0%