Azure / terraform-azurerm-routetable

This Terraform module deploys a Route Table in Azure with a route or a set of routes passed in as input parameters. The routes are newly created with explicit next hop specified as input parameters.
MIT License
6 stars 21 forks source link

Use dynamic instead of count #2

Open vamsee-konda opened 3 years ago

vamsee-konda commented 3 years ago

Hi,

Isn't it better to use dynamic than count for this module?

resource "azurerm_route_table" "rtable" {
  name                          = "${var.route_table_name}"
  location                      = "${var.location}"
  resource_group_name           = "${var.resource_group_name}"
  disable_bgp_route_propagation = "${var.disable_bgp_route_propagation}"

  dynamic "route" {
    for_each = var.routes
    content {
      name = route.value["route_name"]
      address_prefix = route.value["address_prefix"]
      next_hop_type = route.value["next_hop_type"]
      next_hop_in_ip_address = route.value["next_hop_type"] == "VirtualAppliance" ? route.value["next_hop_in_ip_address"] : null
    }
  }
}

resource "azurerm_subnet_route_table_association" "example" {
  subnet_id      = var.subnet_id
  route_table_id = azurerm_route_table.rtable.id
  count = var.create_submodule_routetable_association
}

There is some additional code in here for association with a subnet.