Skip to content

Commit 0cff190

Browse files
rhariadyimrannayer
andauthored
feat: partner interconnect (#147)
Signed-off-by: Ricky Hariady <[email protected]> Co-authored-by: Imran Nayer <[email protected]>
1 parent 532c95d commit 0cff190

File tree

3 files changed

+32
-7
lines changed

3 files changed

+32
-7
lines changed

modules/interconnect_attachment/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,16 @@
88
| admin\_enabled | Whether the VLAN attachment is enabled or disabled | `bool` | `true` | no |
99
| bandwidth | Provisioned bandwidth capacity for the interconnect attachment | `string` | `"BPS_10G"` | no |
1010
| candidate\_subnets | Up to 16 candidate prefixes that can be used to restrict the allocation of cloudRouterIpAddress and customerRouterIpAddress for this attachment. All prefixes must be within link-local address space (169.254.0.0/16) and must be /29 or shorter (/28, /27, etc). | `list(string)` | `null` | no |
11+
| create\_interface | Whether to create router interface (and peer) for this attachment. Set this to false for PARTNER type. | `bool` | `true` | no |
1112
| description | An optional description of this resource | `string` | `null` | no |
13+
| edge\_availability\_domain | Desired availability domain for the attachment. Only available for type PARTNER, at creation time. | `string` | `null` | no |
1214
| encryption | Indicates the user-supplied encryption option of this interconnect attachment. | `string` | `"NONE"` | no |
13-
| interconnect | URL of the underlying Interconnect object that this attachment's traffic will traverse through. | `string` | n/a | yes |
14-
| interface | Interface to deploy for this attachment. | <pre>object({<br> name = string<br> })</pre> | n/a | yes |
15+
| interconnect | URL of the underlying Interconnect object that this attachment's traffic will traverse through. | `string` | `""` | no |
16+
| interface | Interface to deploy for this attachment. | <pre>object({<br> name = string<br> })</pre> | `null` | no |
1517
| 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 |
1618
| 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 |
1719
| 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> md5_authentication_key = optional(object({<br> name = string<br> key = string<br> }))<br> })</pre> | n/a | yes |
20+
| 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> | `null` | no |
1921
| project | The project ID to deploy to | `string` | n/a | yes |
2022
| region | Region where the attachment resides | `string` | n/a | yes |
2123
| router | Name of the router the attachment resides | `string` | n/a | yes |

modules/interconnect_attachment/main.tf

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ resource "google_compute_interconnect_attachment" "attachment" {
2222
interconnect = var.interconnect
2323
admin_enabled = var.admin_enabled
2424
type = var.type
25+
edge_availability_domain = var.edge_availability_domain
2526
description = var.description
26-
bandwidth = var.bandwidth
27+
bandwidth = var.type == "DEDICATED" ? var.bandwidth : null
2728
mtu = var.mtu
2829
candidate_subnets = var.candidate_subnets
2930
vlan_tag8021q = var.vlan_tag8021q
@@ -32,21 +33,28 @@ resource "google_compute_interconnect_attachment" "attachment" {
3233
}
3334

3435
module "interface" {
36+
count = var.create_interface ? 1 : 0
37+
3538
source = "../interface"
36-
name = var.interface.name
39+
name = try(var.interface.name, null)
3740
project = var.project
3841
router = var.router
3942
region = var.region
4043
ip_range = google_compute_interconnect_attachment.attachment.cloud_router_ip_address
4144
interconnect_attachment = google_compute_interconnect_attachment.attachment.self_link
4245
peers = [{
43-
name = var.peer.name
46+
name = try(var.peer.name, null)
4447

4548
# Peer IP Address must not contain the subnet mask, else will throw an invalid IP address error.
4649
peer_ip_address = element(split("/", google_compute_interconnect_attachment.attachment.customer_router_ip_address), 0)
47-
peer_asn = var.peer.peer_asn
50+
peer_asn = try(var.peer.peer_asn, null)
4851
advertised_route_priority = try(var.peer.advertised_route_priority, null)
4952
bfd = try(var.peer.bfd, null)
5053
md5_authentication_key = try(var.peer.md5_authentication_key, null)
5154
}]
5255
}
56+
57+
moved {
58+
from = module.interface
59+
to = module.interface[0]
60+
}

modules/interconnect_attachment/variables.tf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ variable "region" {
3737
variable "interconnect" {
3838
type = string
3939
description = "URL of the underlying Interconnect object that this attachment's traffic will traverse through."
40+
default = ""
4041
}
4142

4243
variable "admin_enabled" {
@@ -63,6 +64,12 @@ variable "mtu" {
6364
default = null
6465
}
6566

67+
variable "edge_availability_domain" {
68+
type = string
69+
description = "Desired availability domain for the attachment. Only available for type PARTNER, at creation time."
70+
default = null
71+
}
72+
6673
variable "description" {
6774
type = string
6875
description = "An optional description of this resource"
@@ -93,11 +100,18 @@ variable "ipsec_internal_addresses" {
93100
default = []
94101
}
95102

103+
variable "create_interface" {
104+
type = bool
105+
description = "Whether to create router interface (and peer) for this attachment. Set this to false for PARTNER type."
106+
default = true
107+
}
108+
96109
variable "interface" {
97110
description = "Interface to deploy for this attachment."
98111
type = object({
99112
name = string
100113
})
114+
default = null
101115
}
102116

103117
variable "peer" {
@@ -117,4 +131,5 @@ variable "peer" {
117131
key = string
118132
}))
119133
})
134+
default = null
120135
}

0 commit comments

Comments
 (0)