Skip to content

Commit 2059bb4

Browse files
Remove network in google_alloydb_cluster (#11460) (#7999)
[upstream:b00ae4cbecdb41c147382576338422b02046947a] Signed-off-by: Modular Magician <[email protected]>
1 parent c28588a commit 2059bb4

17 files changed

+350
-172
lines changed

.changelog/11460.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:deprecation
2+
alloydb: `network` removed in `google_alloy_db_cluster`. Use `network_config.network` instead.
3+
```

google-beta/services/alloydb/resource_alloydb_backup_generated_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ resource "google_alloydb_backup" "default" {
6969
resource "google_alloydb_cluster" "default" {
7070
cluster_id = "tf-test-alloydb-cluster%{random_suffix}"
7171
location = "us-central1"
72-
network = data.google_compute_network.default.id
72+
network_config {
73+
network = data.google_compute_network.default.id
74+
}
7375
}
7476
7577
resource "google_alloydb_instance" "default" {
@@ -129,7 +131,9 @@ resource "google_alloydb_backup" "default" {
129131
resource "google_alloydb_cluster" "default" {
130132
cluster_id = "tf-test-alloydb-cluster%{random_suffix}"
131133
location = "us-central1"
132-
network = data.google_compute_network.default.id
134+
network_config {
135+
network = data.google_compute_network.default.id
136+
}
133137
}
134138
135139
resource "google_alloydb_instance" "default" {

google-beta/services/alloydb/resource_alloydb_backup_test.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ resource "google_alloydb_backup" "default" {
6262
resource "google_alloydb_cluster" "default" {
6363
cluster_id = "tf-test-alloydb-cluster%{random_suffix}"
6464
location = "us-central1"
65-
network = data.google_compute_network.default.id
65+
network_config {
66+
network = data.google_compute_network.default.id
67+
}
6668
}
6769
6870
resource "google_alloydb_instance" "default" {
@@ -96,7 +98,9 @@ resource "google_alloydb_backup" "default" {
9698
resource "google_alloydb_cluster" "default" {
9799
cluster_id = "tf-test-alloydb-cluster%{random_suffix}"
98100
location = "us-central1"
99-
network = data.google_compute_network.default.id
101+
network_config {
102+
network = data.google_compute_network.default.id
103+
}
100104
}
101105
102106
resource "google_alloydb_instance" "default" {
@@ -144,7 +148,9 @@ resource "google_alloydb_backup" "default" {
144148
resource "google_alloydb_cluster" "default" {
145149
location = "us-central1"
146150
cluster_id = "tf-test-alloydb-cluster%{random_suffix}"
147-
network = data.google_compute_network.default.id
151+
network_config {
152+
network = data.google_compute_network.default.id
153+
}
148154
}
149155
150156
data "google_project" "project" { }
@@ -211,7 +217,9 @@ resource "google_alloydb_backup" "default" {
211217
resource "google_alloydb_cluster" "default" {
212218
cluster_id = "tf-test-alloydb-cluster%{random_suffix}"
213219
location = "us-central1"
214-
network = data.google_compute_network.default.id
220+
network_config {
221+
network = data.google_compute_network.default.id
222+
}
215223
}
216224
217225
resource "google_alloydb_instance" "default" {

google-beta/services/alloydb/resource_alloydb_cluster.go

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -383,17 +383,6 @@ Please refer to the field 'effective_labels' for all of the labels present on th
383383
},
384384
},
385385
},
386-
"network": {
387-
Type: schema.TypeString,
388-
Computed: true,
389-
Optional: true,
390-
Deprecated: "`network` is deprecated and will be removed in a future major release. Instead, use `network_config` to define the network configuration.",
391-
DiffSuppressFunc: tpgresource.ProjectNumberDiffSuppress,
392-
Description: `The relative resource name of the VPC network on which the instance can be accessed. It is specified in the following form:
393-
394-
"projects/{projectNumber}/global/networks/{network_id}".`,
395-
ExactlyOneOf: []string{"network", "network_config.0.network", "psc_config.0.psc_enabled"},
396-
},
397386
"network_config": {
398387
Type: schema.TypeList,
399388
Computed: true,
@@ -414,7 +403,7 @@ If set, the instance IPs for this cluster will be created in the allocated range
414403
DiffSuppressFunc: tpgresource.ProjectNumberDiffSuppress,
415404
Description: `The resource link for the VPC network in which cluster resources are created and from which they are accessible via Private IP. The network must belong to the same project as the cluster.
416405
It is specified in the form: "projects/{projectNumber}/global/networks/{network_id}".`,
417-
ExactlyOneOf: []string{"network", "network_config.0.network", "psc_config.0.psc_enabled"},
406+
ExactlyOneOf: []string{"network_config.0.network", "psc_config.0.psc_enabled"},
418407
},
419408
},
420409
},
@@ -675,12 +664,6 @@ func resourceAlloydbClusterCreate(d *schema.ResourceData, meta interface{}) erro
675664
} else if v, ok := d.GetOkExists("encryption_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(encryptionConfigProp)) && (ok || !reflect.DeepEqual(v, encryptionConfigProp)) {
676665
obj["encryptionConfig"] = encryptionConfigProp
677666
}
678-
networkProp, err := expandAlloydbClusterNetwork(d.Get("network"), d, config)
679-
if err != nil {
680-
return err
681-
} else if v, ok := d.GetOkExists("network"); !tpgresource.IsEmptyValue(reflect.ValueOf(networkProp)) && (ok || !reflect.DeepEqual(v, networkProp)) {
682-
obj["network"] = networkProp
683-
}
684667
networkConfigProp, err := expandAlloydbClusterNetworkConfig(d.Get("network_config"), d, config)
685668
if err != nil {
686669
return err
@@ -958,9 +941,6 @@ func resourceAlloydbClusterRead(d *schema.ResourceData, meta interface{}) error
958941
if err := d.Set("continuous_backup_info", flattenAlloydbClusterContinuousBackupInfo(res["continuousBackupInfo"], d, config)); err != nil {
959942
return fmt.Errorf("Error reading Cluster: %s", err)
960943
}
961-
if err := d.Set("network", flattenAlloydbClusterNetwork(res["network"], d, config)); err != nil {
962-
return fmt.Errorf("Error reading Cluster: %s", err)
963-
}
964944
if err := d.Set("network_config", flattenAlloydbClusterNetworkConfig(res["networkConfig"], d, config)); err != nil {
965945
return fmt.Errorf("Error reading Cluster: %s", err)
966946
}
@@ -1041,12 +1021,6 @@ func resourceAlloydbClusterUpdate(d *schema.ResourceData, meta interface{}) erro
10411021
} else if v, ok := d.GetOkExists("encryption_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, encryptionConfigProp)) {
10421022
obj["encryptionConfig"] = encryptionConfigProp
10431023
}
1044-
networkProp, err := expandAlloydbClusterNetwork(d.Get("network"), d, config)
1045-
if err != nil {
1046-
return err
1047-
} else if v, ok := d.GetOkExists("network"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, networkProp)) {
1048-
obj["network"] = networkProp
1049-
}
10501024
networkConfigProp, err := expandAlloydbClusterNetworkConfig(d.Get("network_config"), d, config)
10511025
if err != nil {
10521026
return err
@@ -1139,10 +1113,6 @@ func resourceAlloydbClusterUpdate(d *schema.ResourceData, meta interface{}) erro
11391113
updateMask = append(updateMask, "encryptionConfig")
11401114
}
11411115

1142-
if d.HasChange("network") {
1143-
updateMask = append(updateMask, "network")
1144-
}
1145-
11461116
if d.HasChange("network_config") {
11471117
updateMask = append(updateMask, "networkConfig")
11481118
}
@@ -1507,10 +1477,6 @@ func flattenAlloydbClusterContinuousBackupInfoEncryptionInfoKmsKeyVersions(v int
15071477
return v
15081478
}
15091479

1510-
func flattenAlloydbClusterNetwork(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
1511-
return v
1512-
}
1513-
15141480
func flattenAlloydbClusterNetworkConfig(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
15151481
if v == nil {
15161482
return nil
@@ -2093,10 +2059,6 @@ func expandAlloydbClusterEncryptionConfigKmsKeyName(v interface{}, d tpgresource
20932059
return v, nil
20942060
}
20952061

2096-
func expandAlloydbClusterNetwork(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
2097-
return v, nil
2098-
}
2099-
21002062
func expandAlloydbClusterNetworkConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
21012063
l := v.([]interface{})
21022064
if len(l) == 0 || l[0] == nil {

google-beta/services/alloydb/resource_alloydb_cluster_generated_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,9 @@ func testAccAlloydbCluster_alloydbSecondaryClusterBasicTestExample(context map[s
187187
resource "google_alloydb_cluster" "primary" {
188188
cluster_id = "tf-test-alloydb-primary-cluster%{random_suffix}"
189189
location = "us-central1"
190-
network = data.google_compute_network.default.id
190+
network_config {
191+
network = data.google_compute_network.default.id
192+
}
191193
}
192194
193195
resource "google_alloydb_instance" "primary" {
@@ -203,7 +205,9 @@ resource "google_alloydb_instance" "primary" {
203205
resource "google_alloydb_cluster" "secondary" {
204206
cluster_id = "tf-test-alloydb-secondary-cluster%{random_suffix}"
205207
location = "us-east1"
206-
network = data.google_compute_network.default.id
208+
network_config {
209+
network = data.google_compute_network.default.id
210+
}
207211
cluster_type = "SECONDARY"
208212
209213
continuous_backup_config {

google-beta/services/alloydb/resource_alloydb_cluster_restore_test.go

Lines changed: 57 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ func testAccAlloydbClusterAndInstanceAndBackup(context map[string]interface{}) s
8888
resource "google_alloydb_cluster" "source" {
8989
cluster_id = "tf-test-alloydb-cluster%{random_suffix}"
9090
location = "us-central1"
91-
network = data.google_compute_network.default.id
91+
network_config {
92+
network = data.google_compute_network.default.id
93+
}
9294
}
9395
9496
resource "google_alloydb_instance" "source" {
@@ -119,7 +121,9 @@ func testAccAlloydbClusterAndInstanceAndBackup_OnlyOneSourceAllowed(context map[
119121
resource "google_alloydb_cluster" "source" {
120122
cluster_id = "tf-test-alloydb-cluster%{random_suffix}"
121123
location = "us-central1"
122-
network = data.google_compute_network.default.id
124+
network_config {
125+
network = data.google_compute_network.default.id
126+
}
123127
}
124128
125129
resource "google_alloydb_instance" "source" {
@@ -139,7 +143,9 @@ resource "google_alloydb_backup" "default" {
139143
resource "google_alloydb_cluster" "restored" {
140144
cluster_id = "tf-test-alloydb-backup-restored-cluster-%{random_suffix}"
141145
location = "us-central1"
142-
network = data.google_compute_network.default.id
146+
network_config {
147+
network = data.google_compute_network.default.id
148+
}
143149
restore_backup_source {
144150
backup_name = google_alloydb_backup.default.name
145151
}
@@ -167,7 +173,9 @@ func testAccAlloydbClusterAndInstanceAndBackup_SourceClusterAndPointInTimeRequir
167173
resource "google_alloydb_cluster" "source" {
168174
cluster_id = "tf-test-alloydb-cluster%{random_suffix}"
169175
location = "us-central1"
170-
network = data.google_compute_network.default.id
176+
network_config {
177+
network = data.google_compute_network.default.id
178+
}
171179
}
172180
173181
resource "google_alloydb_instance" "source" {
@@ -187,7 +195,9 @@ resource "google_alloydb_backup" "default" {
187195
resource "google_alloydb_cluster" "restored" {
188196
cluster_id = "tf-test-alloydb-backup-restored-cluster-%{random_suffix}"
189197
location = "us-central1"
190-
network = data.google_compute_network.default.id
198+
network_config {
199+
network = data.google_compute_network.default.id
200+
}
191201
192202
restore_continuous_backup_source {
193203
cluster = google_alloydb_cluster.source.name
@@ -211,7 +221,9 @@ func testAccAlloydbClusterAndInstanceAndBackup_RestoredFromBackup(context map[st
211221
resource "google_alloydb_cluster" "source" {
212222
cluster_id = "tf-test-alloydb-cluster%{random_suffix}"
213223
location = "us-central1"
214-
network = data.google_compute_network.default.id
224+
network_config {
225+
network = data.google_compute_network.default.id
226+
}
215227
}
216228
217229
resource "google_alloydb_instance" "source" {
@@ -231,7 +243,9 @@ resource "google_alloydb_backup" "default" {
231243
resource "google_alloydb_cluster" "restored_from_backup" {
232244
cluster_id = "tf-test-alloydb-backup-restored-cluster-%{random_suffix}"
233245
location = "us-central1"
234-
network = data.google_compute_network.default.id
246+
network_config {
247+
network = data.google_compute_network.default.id
248+
}
235249
restore_backup_source {
236250
backup_name = google_alloydb_backup.default.name
237251
}
@@ -256,7 +270,9 @@ func testAccAlloydbClusterAndInstanceAndBackup_RestoredFromBackupAndRestoredFrom
256270
resource "google_alloydb_cluster" "source" {
257271
cluster_id = "tf-test-alloydb-cluster%{random_suffix}"
258272
location = "us-central1"
259-
network = data.google_compute_network.default.id
273+
network_config {
274+
network = data.google_compute_network.default.id
275+
}
260276
}
261277
262278
resource "google_alloydb_instance" "source" {
@@ -276,7 +292,9 @@ resource "google_alloydb_backup" "default" {
276292
resource "google_alloydb_cluster" "restored_from_backup" {
277293
cluster_id = "tf-test-alloydb-backup-restored-cluster-%{random_suffix}"
278294
location = "us-central1"
279-
network = data.google_compute_network.default.id
295+
network_config {
296+
network = data.google_compute_network.default.id
297+
}
280298
restore_backup_source {
281299
backup_name = google_alloydb_backup.default.name
282300
}
@@ -289,7 +307,9 @@ resource "google_alloydb_cluster" "restored_from_backup" {
289307
resource "google_alloydb_cluster" "restored_from_point_in_time" {
290308
cluster_id = "tf-test-alloydb-pitr-restored-cluster-%{random_suffix}"
291309
location = "us-central1"
292-
network = data.google_compute_network.default.id
310+
network_config {
311+
network = data.google_compute_network.default.id
312+
}
293313
restore_continuous_backup_source {
294314
cluster = google_alloydb_cluster.source.name
295315
point_in_time = google_alloydb_backup.default.update_time
@@ -315,7 +335,9 @@ func testAccAlloydbClusterAndInstanceAndBackup_RestoredFromBackupAndRestoredFrom
315335
resource "google_alloydb_cluster" "source" {
316336
cluster_id = "tf-test-alloydb-cluster%{random_suffix}"
317337
location = "us-central1"
318-
network = data.google_compute_network.default.id
338+
network_config {
339+
network = data.google_compute_network.default.id
340+
}
319341
}
320342
321343
resource "google_alloydb_instance" "source" {
@@ -335,7 +357,9 @@ resource "google_alloydb_backup" "default" {
335357
resource "google_alloydb_cluster" "restored_from_backup" {
336358
cluster_id = "tf-test-alloydb-backup-restored-cluster-%{random_suffix}"
337359
location = "us-central1"
338-
network = data.google_compute_network.default.id
360+
network_config {
361+
network = data.google_compute_network.default.id
362+
}
339363
restore_backup_source {
340364
backup_name = google_alloydb_backup.default.name
341365
}
@@ -353,7 +377,9 @@ resource "google_alloydb_cluster" "restored_from_backup" {
353377
resource "google_alloydb_cluster" "restored_from_point_in_time" {
354378
cluster_id = "tf-test-alloydb-pitr-restored-cluster-%{random_suffix}"
355379
location = "us-central1"
356-
network = data.google_compute_network.default.id
380+
network_config {
381+
network = data.google_compute_network.default.id
382+
}
357383
restore_continuous_backup_source {
358384
cluster = google_alloydb_cluster.source.name
359385
point_in_time = google_alloydb_backup.default.update_time
@@ -384,7 +410,9 @@ func testAccAlloydbClusterAndInstanceAndBackup_RestoredFromBackupAndRestoredFrom
384410
resource "google_alloydb_cluster" "source" {
385411
cluster_id = "tf-test-alloydb-cluster%{random_suffix}"
386412
location = "us-central1"
387-
network = data.google_compute_network.default.id
413+
network_config {
414+
network = data.google_compute_network.default.id
415+
}
388416
}
389417
390418
resource "google_alloydb_instance" "source" {
@@ -412,7 +440,9 @@ resource "google_alloydb_backup" "default2" {
412440
resource "google_alloydb_cluster" "restored_from_backup" {
413441
cluster_id = "tf-test-alloydb-backup-restored-cluster-%{random_suffix}"
414442
location = "us-central1"
415-
network = data.google_compute_network.default.id
443+
network_config {
444+
network = data.google_compute_network.default.id
445+
}
416446
restore_backup_source {
417447
backup_name = google_alloydb_backup.default2.name
418448
}
@@ -432,7 +462,9 @@ resource "google_alloydb_cluster" "restored_from_backup" {
432462
resource "google_alloydb_cluster" "restored_from_point_in_time" {
433463
cluster_id = "tf-test-alloydb-pitr-restored-cluster-%{random_suffix}"
434464
location = "us-central1"
435-
network = data.google_compute_network.default.id
465+
network_config {
466+
network = data.google_compute_network.default.id
467+
}
436468
restore_continuous_backup_source {
437469
cluster = google_alloydb_cluster.restored_from_backup.name
438470
point_in_time = google_alloydb_backup.default.update_time
@@ -463,7 +495,9 @@ func testAccAlloydbClusterAndInstanceAndBackup_RestoredFromBackupAndRestoredFrom
463495
resource "google_alloydb_cluster" "source" {
464496
cluster_id = "tf-test-alloydb-cluster%{random_suffix}"
465497
location = "us-central1"
466-
network = data.google_compute_network.default.id
498+
network_config {
499+
network = data.google_compute_network.default.id
500+
}
467501
}
468502
469503
resource "google_alloydb_instance" "source" {
@@ -483,7 +517,9 @@ resource "google_alloydb_backup" "default" {
483517
resource "google_alloydb_cluster" "restored_from_backup" {
484518
cluster_id = "tf-test-alloydb-backup-restored-cluster-%{random_suffix}"
485519
location = "us-central1"
486-
network = data.google_compute_network.default.id
520+
network_config {
521+
network = data.google_compute_network.default.id
522+
}
487523
restore_backup_source {
488524
backup_name = google_alloydb_backup.default.name
489525
}
@@ -492,7 +528,9 @@ resource "google_alloydb_cluster" "restored_from_backup" {
492528
resource "google_alloydb_cluster" "restored_from_point_in_time" {
493529
cluster_id = "tf-test-alloydb-pitr-restored-cluster-%{random_suffix}"
494530
location = "us-central1"
495-
network = data.google_compute_network.default.id
531+
network_config {
532+
network = data.google_compute_network.default.id
533+
}
496534
restore_continuous_backup_source {
497535
cluster = google_alloydb_cluster.source.name
498536
point_in_time = google_alloydb_backup.default.update_time

0 commit comments

Comments
 (0)