Search code examples
azureterraformbgp

Terraform AzureRM - route table BGP propagation failing


I'm trying to create a route table with bgp_route_propagation_enabled set as false. When I run my CI/CD pipeline it fails at the plan stage with the following error:

│ Error: Unsupported argument
│ 
│   on modules/vnet/module.tf line 39, in resource "azurerm_route_table" "rt":
│   39:   bgp_route_propagation_enabled = false
│ 
│ An argument named "bgp_route_propagation_enabled" is not expected here.

The resource block I'm using is:

resource "azurerm_route_table" "rt" {
  name                          = "test-resource"
  location                      = var.location
  resource_group_name           = var.resource_group_name
  bgp_route_propagation_enabled = false

    dynamic "route" {
    for_each = var.route-internet
    content {
      name                   = route.value["name"]
      address_prefix         = route.value["address_prefix"]
      next_hop_type          = route.value["next_hop"]
      next_hop_in_ip_address = route.value["ip"]
    } 
  }
}

I'm using Terraform version 1.8.0 and AzureRM version 3.103.1

I've tried the above code block and expecting BGP route propagation to be set to false.


Solution

  • Route table BGP propagation failing due to version issue

    As per the github release the property mentioned is supported from the 3.67 in route_table configuration

    Even through you provided a version 3.103.1 there might be some descrepences in state file version and endup failing as you mentioned.

    It's always best practice uses the latest version of provider which helps in achieving the best possible security and features.

    demo configuration:

    terraform {
      required_providers {
        azurerm = {
          source  = "hashicorp/azurerm"
          version = "=4.9.0"
        }
      }
    }
    
    provider "azurerm" {
      features {}
    } 
    .
    .
    resource "azurerm_route_table" "rt" {
      name                = "test-route-table"
      location            = data.azurerm_resource_group.rg.location
      resource_group_name = data.azurerm_resource_group.rg.name
      bgp_route_propagation_enabled = false
    
     
      dynamic "route" {
        for_each = var.route_internet
        content {
          name           = route.value["name"]
          address_prefix = route.value["address_prefix"]
          next_hop_type  = route.value["next_hop"]
          next_hop_in_ip_address = route.value["next_hop"] != "Internet" ? route.value["ip"] : null
        }
      }
    }
    

    Deployment:

    enter image description here