Group router information under router_config
This commit is contained in:
parent
b25ee97d15
commit
84d3b83f81
|
@ -55,21 +55,21 @@ resource "google_compute_router" "cr" {
|
||||||
region = var.region
|
region = var.region
|
||||||
bgp {
|
bgp {
|
||||||
advertise_mode = (
|
advertise_mode = (
|
||||||
var.custom_advertise != null ? "CUSTOM" : "DEFAULT"
|
var.router_config.custom_advertise != null ? "CUSTOM" : "DEFAULT"
|
||||||
)
|
)
|
||||||
advertised_groups = (
|
advertised_groups = (
|
||||||
try(var.custom_advertise.all_subnets, false)
|
try(var.router_config.custom_advertise.all_subnets, false)
|
||||||
? ["ALL_SUBNETS"] : []
|
? ["ALL_SUBNETS"] : []
|
||||||
)
|
)
|
||||||
dynamic "advertised_ip_ranges" {
|
dynamic "advertised_ip_ranges" {
|
||||||
for_each = try(var.custom_advertise.ip_ranges, {})
|
for_each = try(var.router_config.custom_advertise.ip_ranges, {})
|
||||||
content {
|
content {
|
||||||
description = advertised_ip_ranges.key
|
description = advertised_ip_ranges.key
|
||||||
range = advertised_ip_ranges.value
|
range = advertised_ip_ranges.value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
asn = var.asn
|
asn = var.router_config.asn
|
||||||
keepalive_interval = try(var.keepalive, null)
|
keepalive_interval = try(var.router_config.keepalive, null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ resource "google_compute_router_interface" "intf1" {
|
||||||
router = google_compute_router.cr.name
|
router = google_compute_router.cr.name
|
||||||
region = var.region
|
region = var.region
|
||||||
subnetwork = var.vpc_config.subnet_self_link
|
subnetwork = var.vpc_config.subnet_self_link
|
||||||
private_ip_address = var.ip_intf1
|
private_ip_address = var.router_config.ip_interface1
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "google_compute_router_interface" "intf2" {
|
resource "google_compute_router_interface" "intf2" {
|
||||||
|
@ -88,7 +88,7 @@ resource "google_compute_router_interface" "intf2" {
|
||||||
router = google_compute_router.cr.name
|
router = google_compute_router.cr.name
|
||||||
region = var.region
|
region = var.region
|
||||||
subnetwork = var.vpc_config.subnet_self_link
|
subnetwork = var.vpc_config.subnet_self_link
|
||||||
private_ip_address = var.ip_intf2
|
private_ip_address = var.router_config.ip_interface2
|
||||||
redundant_interface = google_compute_router_interface.intf1.name
|
redundant_interface = google_compute_router_interface.intf1.name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ resource "google_compute_router_peer" "peer1" {
|
||||||
router = google_compute_router.cr.name
|
router = google_compute_router.cr.name
|
||||||
region = var.region
|
region = var.region
|
||||||
interface = google_compute_router_interface.intf1.name
|
interface = google_compute_router_interface.intf1.name
|
||||||
peer_asn = var.peer_asn
|
peer_asn = var.router_config.peer_asn
|
||||||
peer_ip_address = each.value.ip
|
peer_ip_address = each.value.ip
|
||||||
router_appliance_instance = each.value.vm
|
router_appliance_instance = each.value.vm
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,7 @@ resource "google_compute_router_peer" "peer2" {
|
||||||
router = google_compute_router.cr.name
|
router = google_compute_router.cr.name
|
||||||
region = var.region
|
region = var.region
|
||||||
interface = google_compute_router_interface.intf2.name
|
interface = google_compute_router_interface.intf2.name
|
||||||
peer_asn = var.peer_asn
|
peer_asn = var.router_config.peer_asn
|
||||||
peer_ip_address = each.value.ip
|
peer_ip_address = each.value.ip
|
||||||
router_appliance_instance = each.value.vm
|
router_appliance_instance = each.value.vm
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,20 +14,6 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
variable "asn" {
|
|
||||||
description = "Autonomous System Number for the CR. All spokes in a hub should use the same ASN."
|
|
||||||
type = number
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "custom_advertise" {
|
|
||||||
description = "IP ranges to advertise if not using default route advertisement (subnet ranges)."
|
|
||||||
type = object({
|
|
||||||
all_subnets = bool
|
|
||||||
ip_ranges = map(string) # map of descriptions and address ranges
|
|
||||||
})
|
|
||||||
default = null
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "data_transfer" {
|
variable "data_transfer" {
|
||||||
description = "Site-to-site data transfer feature, available only in some regions."
|
description = "Site-to-site data transfer feature, available only in some regions."
|
||||||
type = bool
|
type = bool
|
||||||
|
@ -43,39 +29,21 @@ variable "hub" {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "ip_intf1" {
|
|
||||||
description = "IP address for the CR interface 1. It must belong to the primary range of the subnet. If you don't specify a value Google will try to find a free address."
|
|
||||||
type = string
|
|
||||||
default = null
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "ip_intf2" {
|
|
||||||
description = "IP address for the CR interface 2. It must belong to the primary range of the subnet. If you don't specify a value Google will try to find a free address."
|
|
||||||
type = string
|
|
||||||
default = null
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "keepalive" {
|
|
||||||
description = "The interval in seconds between BGP keepalive messages that are sent to the peer."
|
|
||||||
type = number
|
|
||||||
default = null
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "name" {
|
variable "name" {
|
||||||
description = "The name of the NCC spoke."
|
description = "The name of the NCC spoke."
|
||||||
type = string
|
type = string
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "peer_asn" {
|
|
||||||
description = "Peer Autonomous System Number used by the router appliances."
|
|
||||||
type = number
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "project_id" {
|
variable "project_id" {
|
||||||
description = "The ID of the project where the NCC hub & spokes will be created."
|
description = "The ID of the project where the NCC hub & spokes will be created."
|
||||||
type = string
|
type = string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "region" {
|
||||||
|
description = "Region where the spoke is located."
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
|
||||||
variable "router_appliances" {
|
variable "router_appliances" {
|
||||||
description = "List of router appliances this spoke is associated with."
|
description = "List of router appliances this spoke is associated with."
|
||||||
type = list(object({
|
type = list(object({
|
||||||
|
@ -84,9 +52,19 @@ variable "router_appliances" {
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "region" {
|
variable "router_config" {
|
||||||
description = "Region where the spoke is located."
|
description = "Configuration of the Cloud Router."
|
||||||
type = string
|
type = object({
|
||||||
|
asn = number
|
||||||
|
custom_advertise = optional(object({
|
||||||
|
all_subnets = bool
|
||||||
|
ip_ranges = map(string) # map of descriptions and address ranges
|
||||||
|
}))
|
||||||
|
ip_interface1 = optional(string)
|
||||||
|
ip_interface2 = optional(string)
|
||||||
|
keepalive = optional(number)
|
||||||
|
peer_asn = number
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "vpc_config" {
|
variable "vpc_config" {
|
||||||
|
|
Loading…
Reference in New Issue