Skip to content

Commit e6f8b6c

Browse files
authored
feat: MD5 authentication for BGP support (#149)
Signed-off-by: Ricky Hariady <[email protected]>
1 parent 2f1bd8f commit e6f8b6c

File tree

6 files changed

+23
-6
lines changed

6 files changed

+23
-6
lines changed

modules/interconnect_attachment/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
| ipsec\_internal\_addresses | URL of addresses that have been reserved for the interconnect attachment, Used only for interconnect attachment that has the encryption option as IPSEC. | `list(string)` | `[]` | no |
1616
| mtu | Maximum Transmission Unit (MTU), in bytes, of packets passing through this interconnect attachment. Currently, only 1440 and 1500 are allowed. If not specified, the value will default to 1440. | `string` | `null` | no |
1717
| name | The name of the interconnect attachment | `string` | n/a | yes |
18-
| peer | BGP Peer for this attachment. | <pre>object({<br> name = string<br> peer_asn = string<br> advertised_route_priority = optional(number)<br> bfd = optional(object({<br> session_initialization_mode = string<br> min_transmit_interval = optional(number)<br> min_receive_interval = optional(number)<br> multiplier = optional(number)<br> }))<br> })</pre> | n/a | yes |
18+
| peer | BGP Peer for this attachment. | <pre>object({<br> name = string<br> peer_asn = string<br> advertised_route_priority = optional(number)<br> bfd = optional(object({<br> session_initialization_mode = string<br> min_transmit_interval = optional(number)<br> min_receive_interval = optional(number)<br> multiplier = optional(number)<br> }))<br> md5_authentication_key = optional(object({<br> name = string<br> key = string<br> }))<br> })</pre> | n/a | yes |
1919
| project | The project ID to deploy to | `string` | n/a | yes |
2020
| region | Region where the attachment resides | `string` | n/a | yes |
2121
| router | Name of the router the attachment resides | `string` | n/a | yes |

modules/interconnect_attachment/main.tf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ module "interface" {
4545
# Peer IP Address must not contain the subnet mask, else will throw an invalid IP address error.
4646
peer_ip_address = element(split("/", google_compute_interconnect_attachment.attachment.customer_router_ip_address), 0)
4747
peer_asn = var.peer.peer_asn
48-
advertised_route_priority = lookup(var.peer, "advertised_route_priority", null)
49-
bfd = lookup(var.peer, "bfd", null)
48+
advertised_route_priority = try(var.peer.advertised_route_priority, null)
49+
bfd = try(var.peer.bfd, null)
50+
md5_authentication_key = try(var.peer.md5_authentication_key, null)
5051
}]
5152
}

modules/interconnect_attachment/variables.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,5 +112,9 @@ variable "peer" {
112112
min_receive_interval = optional(number)
113113
multiplier = optional(number)
114114
}))
115+
md5_authentication_key = optional(object({
116+
name = string
117+
key = string
118+
}))
115119
})
116120
}

modules/interface/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
| interconnect\_attachment | The name or resource link to the VLAN interconnect for this interface | `string` | `null` | no |
99
| ip\_range | IP address and range of the interface | `string` | `null` | no |
1010
| name | The name of the interface | `string` | n/a | yes |
11-
| peers | BGP peers for this interface. | <pre>list(object({<br> name = string<br> peer_ip_address = string<br> peer_asn = string<br> advertised_route_priority = optional(number)<br> bfd = object({<br> session_initialization_mode = string<br> min_transmit_interval = optional(number)<br> min_receive_interval = optional(number)<br> multiplier = optional(number)<br> })<br> }))</pre> | `[]` | no |
11+
| peers | BGP peers for this interface. | <pre>list(object({<br> name = string<br> peer_ip_address = string<br> peer_asn = string<br> advertised_route_priority = optional(number)<br> bfd = object({<br> session_initialization_mode = string<br> min_transmit_interval = optional(number)<br> min_receive_interval = optional(number)<br> multiplier = optional(number)<br> })<br> md5_authentication_key = optional(object({<br> name = string<br> key = string<br> }))<br> }))</pre> | `[]` | no |
1212
| project | The project ID to deploy to | `string` | n/a | yes |
1313
| region | Region where the interface resides | `string` | n/a | yes |
1414
| router | Name of the router the interface resides | `string` | n/a | yes |

modules/interface/main.tf

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,23 @@ resource "google_compute_router_peer" "peers" {
3737
interface = google_compute_router_interface.interface.name
3838
peer_ip_address = each.value.peer_ip_address
3939
peer_asn = each.value.peer_asn
40-
advertised_route_priority = lookup(each.value, "advertised_route_priority", null)
40+
advertised_route_priority = try(each.value.advertised_route_priority, null)
4141

4242
dynamic "bfd" {
43-
for_each = lookup(each.value, "bfd", null) == null ? [] : [""]
43+
for_each = try(each.value.bfd, null) == null ? [] : [""]
4444
content {
4545
session_initialization_mode = try(each.value.bfd.session_initialization_mode, null)
4646
min_receive_interval = try(each.value.bfd.min_receive_interval, null)
4747
min_transmit_interval = try(each.value.bfd.min_transmit_interval, null)
4848
multiplier = try(each.value.bfd.multiplier, null)
4949
}
5050
}
51+
52+
dynamic "md5_authentication_key" {
53+
for_each = try(each.value.md5_authentication_key, null) == null ? [] : [""]
54+
content {
55+
name = each.value.md5_authentication_key.name
56+
key = each.value.md5_authentication_key.key
57+
}
58+
}
5159
}

modules/interface/variables.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ variable "peers" {
6464
min_receive_interval = optional(number)
6565
multiplier = optional(number)
6666
})
67+
md5_authentication_key = optional(object({
68+
name = string
69+
key = string
70+
}))
6771
}))
6872
description = "BGP peers for this interface."
6973
default = []

0 commit comments

Comments
 (0)