Skip to content

Add missing parameters to the Interface submodule #152

@ce-torresorona

Description

@ce-torresorona

TL;DR

Interface submodule attributes are out of date for version 6.31.0. I attempted doing a PR with the changes but no luck so I pass it on to the Google team.

https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_router_interface

Expected behavior

A router interface must have specified either ip_range or exactly one of vpn_tunnel, interconnect_attachment or subnetwork, or both

Observed behavior

Latest attributes not declared therefore fails

Terraform Configuration

resource "google_compute_router_interface" "interface" {
  name                    = var.name
  project                 = var.project
  router                  = var.router
  region                  = var.region
  private_ip_address      = var.private_ip_address
  ip_range                = var.ip_range
  ip_version              = var.ip_version
  vpn_tunnel              = var.vpn_tunnel
  interconnect_attachment = var.interconnect_attachment
  subnetwork              = var.subnetwork
  redundant_interface     = var.redundant_interface
}

resource "google_compute_router_peer" "peers" {
  for_each = {
    for p in var.peers :
    p.name => p
  }

  name                      = each.value.name
  project                   = google_compute_router_interface.interface.project
  router                    = google_compute_router_interface.interface.router
  region                    = google_compute_router_interface.interface.region
  interface                 = google_compute_router_interface.interface.name
  peer_ip_address           = each.value.peer_ip_address
  peer_asn                  = each.value.peer_asn
  advertised_route_priority = lookup(each.value, "advertised_route_priority", null)

  dynamic "bfd" {
    for_each = lookup(each.value, "bfd", null) == null ? [] : [""]
    content {
      session_initialization_mode = try(each.value.bfd.session_initialization_mode, null)
      min_receive_interval        = try(each.value.bfd.min_receive_interval, null)
      min_transmit_interval       = try(each.value.bfd.min_transmit_interval, null)
      multiplier                  = try(each.value.bfd.multiplier, null)
    }
  }
}

variable "name" {
  description = "Name of the router interface"
  type        = string
}

variable "project" {
  description = "The project ID to deploy to"
  type        = string
}

variable "router" {
  description = "Name of the router the interface will be attached to"
  type        = string
}

variable "region" {
  description = "Region where the router exists"
  type        = string
}

variable "private_ip_address" {
  description = "Private IP address for the interface"
  type        = string
  default     = null
}

variable "ip_range" {
  description = "IP range for the interface"
  type        = string
  default     = null
}

variable "ip_version" {
  description = "IP version for the interface (IPV4 or IPV6)"
  type        = string
  default     = null
}

variable "vpn_tunnel" {
  description = "VPN tunnel name that this interface will be linked to"
  type        = string
  default     = null
}

variable "interconnect_attachment" {
  description = "Interconnect attachment name that this interface will be linked to"
  type        = string
  default     = null
}

variable "subnetwork" {
  description = "Subnetwork for this interface"
  type        = string
  default     = null
}

variable "redundant_interface" {
  description = "Name of the interface that will be paired for redundancy"
  type        = string
  default     = null
}

variable "peers" {
  description = "BGP peers for this interface. Each peer should be configured as an object with name, peer_ip_address, peer_asn, and optionally advertised_route_priority and bfd"
  type = list(object({
    name                      = string
    peer_ip_address           = string
    peer_asn                  = number
    advertised_route_priority = optional(number)
    bfd = optional(object({
      session_initialization_mode = optional(string)
      min_receive_interval        = optional(number)
      min_transmit_interval       = optional(number)
      multiplier                  = optional(number)
    }))
  }))
  default = []
}

terraform {
  required_version = ">= 1.3"
  required_providers {

    google = {
      source  = "hashicorp/google"
      version = ">= 4.51, < 7"
    }
  }

  provider_meta "google" {
    module_name = "blueprints/terraform/terraform-google-cloud-router:interface/v6.31.0"
  }
}

Terraform Version

Terraform v1.9.8

Terraform Provider Versions

provider[registry.terraform.io/hashicorp/google] >= 4.51.0, < 7.0.0
provider[registry.terraform.io/hashicorp/google-beta]

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions