Skip to content
This repository has been archived by the owner on Nov 27, 2020. It is now read-only.

Feature/support address prefix as array #2

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

eissko
Copy link
Contributor

@eissko eissko commented Jul 2, 2020

Description

There is usually situation when you need to override the default route of VNET or vnet peering by your custom rule which defines custom next hop (e.g. azure firewall). VNET can define multiple address spaces not only one. It is handy to define them as array. Of course it could be defined separately as new entry with new name and its address space - if you don't find it use-full, feel free to abandon the PR. The name of such route entry is then created by concatenation of the "route entry name" + "address space".

Enhancement

  • Adding support for address prefix defined as array.
  • Keeping backward compatibility of address prefix being type of string as well.
  • Extending capability of input tfvars which can define address prefix as array ["10.10.1.0/24","10.10.2.0/24"].

Example of tfvars

route_table = {
    name = "test_route"
    route_entries = {
      re1 = {
        name          = "myroute1"
        prefix        = "255.0.0.0/8"
        next_hop_type = "None"
      },
      re2 = {
        name                   = "myroute2"
        prefix                 = ["255.255.0.0/16","8.8.8.8/32"]
        next_hop_type          = "VirtualAppliance"
        next_hop_in_ip_address = "192.168.10.6"
      },
      re3 = {
        name                   = "defaultroute"
        prefix                 = "0.0.0.0/0"
        next_hop_type          = "VirtualAppliance"
        next_hop_in_ip_address = "192.168.10.5"
      },
    }
}

Tested:

# azurerm_resource_group.rg1 will be created
  + resource "azurerm_resource_group" "rg1" {
      + id       = (known after apply)
      + location = "westeurope"
      + name     = "test-route-table"
    }

 # module.route_table_test.azurerm_route_table.route_table will be created
  + resource "azurerm_route_table" "route_table" {
      + disable_bgp_route_propagation = false
      + id                            = (known after apply)
      + location                      = "westeurope"
      + name                          = "test_route"
      + resource_group_name           = "test-route-table"
      + route                         = [
          + {
              + address_prefix         = "255.0.0.0/8"
              + name                   = "myroute1-255.0.0.0_8"
              + next_hop_in_ip_address = null
              + next_hop_type          = "None"
            },
          + {
              + address_prefix         = "255.255.0.0/16"
              + name                   = "myroute2-255.255.0.0_16"
              + next_hop_in_ip_address = "192.168.10.6"
              + next_hop_type          = "VirtualAppliance"
            },
          + {
              + address_prefix         = "8.8.8.8/32"
              + name                   = "myroute2-8.8.8.8_32"
              + next_hop_in_ip_address = "192.168.10.6"
              + next_hop_type          = "VirtualAppliance"
            },
          + {
              + address_prefix         = "0.0.0.0/0"
              + name                   = "defaultroute-0.0.0.0_0"
              + next_hop_in_ip_address = "192.168.10.5"
              + next_hop_type          = "VirtualAppliance"
            },
        ]
      + subnets                       = (known after apply)
      + tags                          = {
          + "deployment" = "by terraform"
          + "module"     = "route_table"
        }
    }

Plan: 2 to add, 0 to change, 0 to destroy.

@arnaudlh arnaudlh added the enhancement New feature or request label Jul 7, 2020
@nyuen nyuen requested a review from arnaudlh July 21, 2020 06:33
Copy link
Member

@arnaudlh arnaudlh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants