Skip to content

Commit

Permalink
Update Network Connectivity Spoke Router and VPN Tunnels (#12519) (#8883
Browse files Browse the repository at this point in the history
)

[upstream:3a54268c0efd6991b9d9763d63742619b8787e9e]

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Dec 10, 2024
1 parent e7e8cdb commit 75dde0a
Show file tree
Hide file tree
Showing 4 changed files with 614 additions and 23 deletions.
6 changes: 6 additions & 0 deletions .changelog/12519.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
```release-note:enhancement
networkconnectivity: added support for updating `linked_vpn_tunnels.include_import_ranges`, `linked_interconnect_attachments.include_import_ranges`, `linked_router_appliance_instances. instances` and `linked_router_appliance_instances.include_import_ranges` in `google_network_connectivity_spoke`
```
```release-note:bug
networkconnectivity: fixed `linked_router_appliance_instances.instances.virtual_machine` and `linked_router_appliance_instances.instances.ip_address` attributes in `google_network_connectivity_spoke` to be correctly marked as required. Otherwise the request to create the resource will fail.
```
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ Please refer to the field 'effective_labels' for all of the labels present on th
"linked_interconnect_attachments": {
Type: schema.TypeList,
Optional: true,
ForceNew: true,
Description: `A collection of VLAN attachment resources. These resources should be redundant attachments that all advertise the same prefixes to Google Cloud. Alternatively, in active/passive configurations, all attachments should be capable of advertising the same prefixes.`,
MaxItems: 1,
Elem: &schema.Resource{
Expand Down Expand Up @@ -176,7 +175,6 @@ The only allowed value for now is "ALL_IPV4_RANGES".`,
"linked_router_appliance_instances": {
Type: schema.TypeList,
Optional: true,
ForceNew: true,
Description: `The URIs of linked Router appliance resources`,
MaxItems: 1,
Elem: &schema.Resource{
Expand All @@ -190,13 +188,13 @@ The only allowed value for now is "ALL_IPV4_RANGES".`,
Schema: map[string]*schema.Schema{
"ip_address": {
Type: schema.TypeString,
Optional: true,
Required: true,
ForceNew: true,
Description: `The IP address on the VM to use for peering.`,
},
"virtual_machine": {
Type: schema.TypeString,
Optional: true,
Required: true,
ForceNew: true,
DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName,
Description: `The URI of the virtual machine resource`,
Expand Down Expand Up @@ -263,7 +261,6 @@ The only allowed value for now is "ALL_IPV4_RANGES".`,
"linked_vpn_tunnels": {
Type: schema.TypeList,
Optional: true,
ForceNew: true,
Description: `The URIs of linked VPN tunnel resources`,
MaxItems: 1,
Elem: &schema.Resource{
Expand Down Expand Up @@ -573,6 +570,24 @@ func resourceNetworkConnectivitySpokeUpdate(d *schema.ResourceData, meta interfa
} else if v, ok := d.GetOkExists("description"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, descriptionProp)) {
obj["description"] = descriptionProp
}
linkedVpnTunnelsProp, err := expandNetworkConnectivitySpokeLinkedVpnTunnels(d.Get("linked_vpn_tunnels"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("linked_vpn_tunnels"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, linkedVpnTunnelsProp)) {
obj["linkedVpnTunnels"] = linkedVpnTunnelsProp
}
linkedInterconnectAttachmentsProp, err := expandNetworkConnectivitySpokeLinkedInterconnectAttachments(d.Get("linked_interconnect_attachments"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("linked_interconnect_attachments"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, linkedInterconnectAttachmentsProp)) {
obj["linkedInterconnectAttachments"] = linkedInterconnectAttachmentsProp
}
linkedRouterApplianceInstancesProp, err := expandNetworkConnectivitySpokeLinkedRouterApplianceInstances(d.Get("linked_router_appliance_instances"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("linked_router_appliance_instances"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, linkedRouterApplianceInstancesProp)) {
obj["linkedRouterApplianceInstances"] = linkedRouterApplianceInstancesProp
}
labelsProp, err := expandNetworkConnectivitySpokeEffectiveLabels(d.Get("effective_labels"), d, config)
if err != nil {
return err
Expand All @@ -593,6 +608,19 @@ func resourceNetworkConnectivitySpokeUpdate(d *schema.ResourceData, meta interfa
updateMask = append(updateMask, "description")
}

if d.HasChange("linked_vpn_tunnels") {
updateMask = append(updateMask, "linkedVpnTunnels.includeImportRanges")
}

if d.HasChange("linked_interconnect_attachments") {
updateMask = append(updateMask, "linkedInterconnectAttachments.includeImportRanges")
}

if d.HasChange("linked_router_appliance_instances") {
updateMask = append(updateMask, "linkedRouterApplianceInstances.instances",
"linkedRouterApplianceInstances.includeImportRanges")
}

if d.HasChange("effective_labels") {
updateMask = append(updateMask, "labels")
}
Expand Down
Loading

0 comments on commit 75dde0a

Please sign in to comment.