Skip to content

Commit 0c0a4d3

Browse files
Add the subnetLength field to the InterconnectAttachment resource (#10722) (#18187)
[upstream:c4ee9b0b5179102785d20a53daa89bc75c8990c5] Signed-off-by: Modular Magician <[email protected]>
1 parent 2cb1d48 commit 0c0a4d3

3 files changed

+98
-8
lines changed

google/services/compute/resource_compute_interconnect_attachment.go

+21-6
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,9 @@ domain. If not specified, the value will default to AVAILABILITY_DOMAIN_ANY.`,
154154
Description: `Indicates the user-supplied encryption option of this interconnect
155155
attachment. Can only be specified at attachment creation for PARTNER or
156156
DEDICATED attachments.
157-
158157
* NONE - This is the default value, which means that the VLAN attachment
159158
carries unencrypted traffic. VMs are able to send traffic to, or receive
160159
traffic from, such a VLAN attachment.
161-
162160
* IPSEC - The VLAN attachment carries only encrypted traffic that is
163161
encrypted by an IPsec device, such as an HA VPN gateway or third-party
164162
IPsec VPN. VMs cannot directly send traffic to, or receive traffic from,
@@ -182,17 +180,14 @@ be set if type is PARTNER.`,
182180
Description: `URL of addresses that have been reserved for the interconnect attachment,
183181
Used only for interconnect attachment that has the encryption option as
184182
IPSEC.
185-
186183
The addresses must be RFC 1918 IP address ranges. When creating HA VPN
187184
gateway over the interconnect attachment, if the attachment is configured
188185
to use an RFC 1918 IP address, then the VPN gateway's IP address will be
189186
allocated from the IP address range specified here.
190-
191187
For example, if the HA VPN gateway's interface 0 is paired to this
192188
interconnect attachment, then an RFC 1918 IP address for the VPN gateway
193189
interface 0 will be allocated from the IP address specified for this
194190
interconnect attachment.
195-
196191
If this field is not specified for interconnect attachment that has
197192
encryption option as IPSEC, later on when creating HA VPN gateway on this
198193
interconnect attachment, the HA VPN gateway's IP address will be
@@ -223,9 +218,19 @@ this interconnect attachment. Currently, only 1440 and 1500 are allowed. If not
223218
ValidateFunc: verify.ValidateEnum([]string{"IPV4_IPV6", "IPV4_ONLY", ""}),
224219
Description: `The stack type for this interconnect attachment to identify whether the IPv6
225220
feature is enabled or not. If not specified, IPV4_ONLY will be used.
226-
227221
This field can be both set at interconnect attachments creation and update
228222
interconnect attachment operations. Possible values: ["IPV4_IPV6", "IPV4_ONLY"]`,
223+
},
224+
"subnet_length": {
225+
Type: schema.TypeInt,
226+
Optional: true,
227+
ForceNew: true,
228+
Description: `Length of the IPv4 subnet mask. Allowed values: 29 (default), 30. The default value is 29,
229+
except for Cross-Cloud Interconnect connections that use an InterconnectRemoteLocation with a
230+
constraints.subnetLengthRange.min equal to 30. For example, connections that use an Azure
231+
remote location fall into this category. In these cases, the default value is 30, and
232+
requesting 29 returns an error. Where both 29 and 30 are allowed, 29 is preferred, because it
233+
gives Google Cloud Support more debugging visibility.`,
229234
},
230235
"type": {
231236
Type: schema.TypeString,
@@ -421,6 +426,12 @@ func resourceComputeInterconnectAttachmentCreate(d *schema.ResourceData, meta in
421426
} else if v, ok := d.GetOkExists("stack_type"); !tpgresource.IsEmptyValue(reflect.ValueOf(stackTypeProp)) && (ok || !reflect.DeepEqual(v, stackTypeProp)) {
422427
obj["stackType"] = stackTypeProp
423428
}
429+
subnetLengthProp, err := expandComputeInterconnectAttachmentSubnetLength(d.Get("subnet_length"), d, config)
430+
if err != nil {
431+
return err
432+
} else if v, ok := d.GetOkExists("subnet_length"); !tpgresource.IsEmptyValue(reflect.ValueOf(subnetLengthProp)) && (ok || !reflect.DeepEqual(v, subnetLengthProp)) {
433+
obj["subnetLength"] = subnetLengthProp
434+
}
424435
regionProp, err := expandComputeInterconnectAttachmentRegion(d.Get("region"), d, config)
425436
if err != nil {
426437
return err
@@ -1007,6 +1018,10 @@ func expandComputeInterconnectAttachmentStackType(v interface{}, d tpgresource.T
10071018
return v, nil
10081019
}
10091020

1021+
func expandComputeInterconnectAttachmentSubnetLength(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
1022+
return v, nil
1023+
}
1024+
10101025
func expandComputeInterconnectAttachmentRegion(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
10111026
f, err := tpgresource.ParseGlobalFieldValue("regions", v.(string), "project", d, config, true)
10121027
if err != nil {

google/services/compute/resource_compute_interconnect_attachment_generated_test.go

+68-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func TestAccComputeInterconnectAttachment_interconnectAttachmentBasicExample(t *
4949
ResourceName: "google_compute_interconnect_attachment.on_prem",
5050
ImportState: true,
5151
ImportStateVerify: true,
52-
ImportStateVerifyIgnore: []string{"candidate_subnets", "region", "router"},
52+
ImportStateVerifyIgnore: []string{"candidate_subnets", "region", "router", "subnet_length"},
5353
},
5454
},
5555
})
@@ -80,6 +80,72 @@ resource "google_compute_network" "foobar" {
8080
`, context)
8181
}
8282

83+
func TestAccComputeInterconnectAttachment_interconnectAttachmentDedicatedExample(t *testing.T) {
84+
t.Parallel()
85+
86+
context := map[string]interface{}{
87+
"random_suffix": acctest.RandString(t, 10),
88+
}
89+
90+
acctest.VcrTest(t, resource.TestCase{
91+
PreCheck: func() { acctest.AccTestPreCheck(t) },
92+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
93+
CheckDestroy: testAccCheckComputeInterconnectAttachmentDestroyProducer(t),
94+
Steps: []resource.TestStep{
95+
{
96+
Config: testAccComputeInterconnectAttachment_interconnectAttachmentDedicatedExample(context),
97+
},
98+
{
99+
ResourceName: "google_compute_interconnect_attachment.on_prem",
100+
ImportState: true,
101+
ImportStateVerify: true,
102+
ImportStateVerifyIgnore: []string{"candidate_subnets", "region", "router", "subnet_length"},
103+
},
104+
},
105+
})
106+
}
107+
108+
func testAccComputeInterconnectAttachment_interconnectAttachmentDedicatedExample(context map[string]interface{}) string {
109+
return acctest.Nprintf(`
110+
data "google_project" "project" {}
111+
112+
resource "google_compute_interconnect" "foobar" {
113+
name = "tf-test-interconenct-1%{random_suffix}"
114+
customer_name = "internal_customer" # Special customer only available for Google testing.
115+
interconnect_type = "IT_PRIVATE" # Special type only available for Google testing.
116+
link_type = "LINK_TYPE_ETHERNET_10G_LR"
117+
requested_link_count = 1
118+
location = "https://www.googleapis.com/compute/v1/projects/${data.google_project.project.name}/global/interconnectLocations/z2z-us-east4-zone1-lciadl-a" # Special location only available for Google testing.
119+
}
120+
121+
resource "google_compute_interconnect_attachment" "on_prem" {
122+
name = "tf-test-on-prem-attachment%{random_suffix}"
123+
type = "DEDICATED"
124+
interconnect = google_compute_interconnect.foobar.id
125+
router = google_compute_router.foobar.id
126+
mtu = 1500
127+
subnet_length = 29
128+
vlan_tag8021q = 1000
129+
region = "https://www.googleapis.com/compute/v1/projects/${data.google_project.project.name}/regions/us-east4"
130+
stack_type = "IPV4_ONLY"
131+
}
132+
133+
resource "google_compute_router" "foobar" {
134+
name = "tf-test-router-1%{random_suffix}"
135+
network = google_compute_network.foobar.name
136+
region = "us-east4"
137+
bgp {
138+
asn = 16550
139+
}
140+
}
141+
142+
resource "google_compute_network" "foobar" {
143+
name = "tf-test-network-1%{random_suffix}"
144+
auto_create_subnetworks = false
145+
}
146+
`, context)
147+
}
148+
83149
func TestAccComputeInterconnectAttachment_computeInterconnectAttachmentIpsecEncryptionExample(t *testing.T) {
84150
t.Parallel()
85151

@@ -99,7 +165,7 @@ func TestAccComputeInterconnectAttachment_computeInterconnectAttachmentIpsecEncr
99165
ResourceName: "google_compute_interconnect_attachment.ipsec-encrypted-interconnect-attachment",
100166
ImportState: true,
101167
ImportStateVerify: true,
102-
ImportStateVerifyIgnore: []string{"candidate_subnets", "region", "router"},
168+
ImportStateVerifyIgnore: []string{"candidate_subnets", "region", "router", "subnet_length"},
103169
},
104170
},
105171
})

website/docs/r/compute_interconnect_attachment.html.markdown

+9
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,15 @@ The following arguments are supported:
224224
interconnect attachment operations.
225225
Possible values are: `IPV4_IPV6`, `IPV4_ONLY`.
226226

227+
* `subnet_length` -
228+
(Optional)
229+
Length of the IPv4 subnet mask. Allowed values: 29 (default), 30. The default value is 29,
230+
except for Cross-Cloud Interconnect connections that use an InterconnectRemoteLocation with a
231+
constraints.subnetLengthRange.min equal to 30. For example, connections that use an Azure
232+
remote location fall into this category. In these cases, the default value is 30, and
233+
requesting 29 returns an error. Where both 29 and 30 are allowed, 29 is preferred, because it
234+
gives Google Cloud Support more debugging visibility.
235+
227236
* `region` -
228237
(Optional)
229238
Region where the regional interconnect attachment resides.

0 commit comments

Comments
 (0)