Skip to content

Commit 2635e4e

Browse files
authored
fix: Automate filling peer ip address (#6)
1 parent 5ec92c0 commit 2635e4e

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

modules/interconnect_attachment/main.tf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@ module "interface" {
3636
ip_range = google_compute_interconnect_attachment.attachment.cloud_router_ip_address
3737
interconnect_attachment = google_compute_interconnect_attachment.attachment.self_link
3838
peers = [{
39-
name = var.peer.name
40-
peer_ip_address = var.peer.peer_ip_address
39+
name = var.peer.name
40+
41+
# Peer IP Address must not contain the subnet mask, else will throw an invalid IP address error.
42+
peer_ip_address = element(split("/", google_compute_interconnect_attachment.attachment.customer_router_ip_address), 0)
4143
peer_asn = var.peer.peer_asn
4244
advertised_route_priority = lookup(var.peer, "advertised_route_priority", null)
4345
}]

modules/interconnect_attachment/outputs.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,8 @@ output "attachment" {
1818
value = google_compute_interconnect_attachment.attachment
1919
description = "The created attachment"
2020
}
21+
22+
output "customer_router_ip_address" {
23+
value = google_compute_interconnect_attachment.attachment.customer_router_ip_address
24+
description = "IPv4 address + prefix length to be configured on the customer router subinterface for this interconnect attachment."
25+
}

modules/interconnect_attachment/variables.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ variable "interface" {
8080
}
8181

8282
# Type: object, with fields:
83-
# - peer_ip_address (string, required): IP address of the BGP interface outside Google Cloud Platform.
8483
# - peer_asn (string, required): Peer BGP Autonomous System Number (ASN).
8584
# - advertised_route_priority (number, optional): The priority of routes advertised to this BGP peer.
8685
variable "peer" {

0 commit comments

Comments
 (0)