Skip to content

Commit f33623e

Browse files
Make LinkedVpcNetwork mutable (#14757) (#23949)
[upstream:f8458f0f629c654db38142f293872365a828d9f5] Signed-off-by: Modular Magician <[email protected]>
1 parent d019555 commit f33623e

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

.changelog/14757.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
networkconnectivity: added update support for `linked_vpc_network` in `google_network_connectivity_spoke`
3+
```

google/services/networkconnectivity/resource_network_connectivity_spoke.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,6 @@ The only allowed value for now is "ALL_IPV4_RANGES".`,
228228
"linked_vpc_network": {
229229
Type: schema.TypeList,
230230
Optional: true,
231-
ForceNew: true,
232231
Description: `VPC network that is associated with the spoke.`,
233232
MaxItems: 1,
234233
Elem: &schema.Resource{
@@ -626,6 +625,12 @@ func resourceNetworkConnectivitySpokeUpdate(d *schema.ResourceData, meta interfa
626625
} else if v, ok := d.GetOkExists("linked_router_appliance_instances"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, linkedRouterApplianceInstancesProp)) {
627626
obj["linkedRouterApplianceInstances"] = linkedRouterApplianceInstancesProp
628627
}
628+
linkedVpcNetworkProp, err := expandNetworkConnectivitySpokeLinkedVpcNetwork(d.Get("linked_vpc_network"), d, config)
629+
if err != nil {
630+
return err
631+
} else if v, ok := d.GetOkExists("linked_vpc_network"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, linkedVpcNetworkProp)) {
632+
obj["linkedVpcNetwork"] = linkedVpcNetworkProp
633+
}
629634
labelsProp, err := expandNetworkConnectivitySpokeEffectiveLabels(d.Get("effective_labels"), d, config)
630635
if err != nil {
631636
return err
@@ -659,6 +664,11 @@ func resourceNetworkConnectivitySpokeUpdate(d *schema.ResourceData, meta interfa
659664
"linkedRouterApplianceInstances.includeImportRanges")
660665
}
661666

667+
if d.HasChange("linked_vpc_network") {
668+
updateMask = append(updateMask, "linkedVpcNetwork.excludeExportRanges",
669+
"linkedVpcNetwork.includeExportRanges")
670+
}
671+
662672
if d.HasChange("effective_labels") {
663673
updateMask = append(updateMask, "labels")
664674
}

google/services/networkconnectivity/resource_network_connectivity_spoke_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -665,11 +665,11 @@ resource "google_network_connectivity_spoke" "primary" {
665665
hub = google_network_connectivity_hub.basic_hub.id
666666
linked_vpc_network {
667667
exclude_export_ranges = [
668-
"198.51.100.0/24",
668+
"198.51.110.0/24",
669669
"10.10.0.0/16"
670670
]
671671
include_export_ranges = [
672-
"198.51.100.0/23",
672+
"198.51.110.0/23",
673673
"10.0.0.0/8"
674674
]
675675
uri = google_compute_network.network.self_link

0 commit comments

Comments
 (0)