Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove network in google_alloydb_cluster #7999

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/11460.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:deprecation
alloydb: `network` removed in `google_alloy_db_cluster`. Use `network_config.network` instead.
```
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ resource "google_alloydb_backup" "default" {
resource "google_alloydb_cluster" "default" {
cluster_id = "tf-test-alloydb-cluster%{random_suffix}"
location = "us-central1"
network = data.google_compute_network.default.id
network_config {
network = data.google_compute_network.default.id
}
}

resource "google_alloydb_instance" "default" {
Expand Down Expand Up @@ -129,7 +131,9 @@ resource "google_alloydb_backup" "default" {
resource "google_alloydb_cluster" "default" {
cluster_id = "tf-test-alloydb-cluster%{random_suffix}"
location = "us-central1"
network = data.google_compute_network.default.id
network_config {
network = data.google_compute_network.default.id
}
}

resource "google_alloydb_instance" "default" {
Expand Down
16 changes: 12 additions & 4 deletions google-beta/services/alloydb/resource_alloydb_backup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ resource "google_alloydb_backup" "default" {
resource "google_alloydb_cluster" "default" {
cluster_id = "tf-test-alloydb-cluster%{random_suffix}"
location = "us-central1"
network = data.google_compute_network.default.id
network_config {
network = data.google_compute_network.default.id
}
}

resource "google_alloydb_instance" "default" {
Expand Down Expand Up @@ -96,7 +98,9 @@ resource "google_alloydb_backup" "default" {
resource "google_alloydb_cluster" "default" {
cluster_id = "tf-test-alloydb-cluster%{random_suffix}"
location = "us-central1"
network = data.google_compute_network.default.id
network_config {
network = data.google_compute_network.default.id
}
}

resource "google_alloydb_instance" "default" {
Expand Down Expand Up @@ -144,7 +148,9 @@ resource "google_alloydb_backup" "default" {
resource "google_alloydb_cluster" "default" {
location = "us-central1"
cluster_id = "tf-test-alloydb-cluster%{random_suffix}"
network = data.google_compute_network.default.id
network_config {
network = data.google_compute_network.default.id
}
}

data "google_project" "project" { }
Expand Down Expand Up @@ -211,7 +217,9 @@ resource "google_alloydb_backup" "default" {
resource "google_alloydb_cluster" "default" {
cluster_id = "tf-test-alloydb-cluster%{random_suffix}"
location = "us-central1"
network = data.google_compute_network.default.id
network_config {
network = data.google_compute_network.default.id
}
}

resource "google_alloydb_instance" "default" {
Expand Down
40 changes: 1 addition & 39 deletions google-beta/services/alloydb/resource_alloydb_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,17 +383,6 @@ Please refer to the field 'effective_labels' for all of the labels present on th
},
},
},
"network": {
Type: schema.TypeString,
Computed: true,
Optional: true,
Deprecated: "`network` is deprecated and will be removed in a future major release. Instead, use `network_config` to define the network configuration.",
DiffSuppressFunc: tpgresource.ProjectNumberDiffSuppress,
Description: `The relative resource name of the VPC network on which the instance can be accessed. It is specified in the following form:

"projects/{projectNumber}/global/networks/{network_id}".`,
ExactlyOneOf: []string{"network", "network_config.0.network", "psc_config.0.psc_enabled"},
},
"network_config": {
Type: schema.TypeList,
Computed: true,
Expand All @@ -414,7 +403,7 @@ If set, the instance IPs for this cluster will be created in the allocated range
DiffSuppressFunc: tpgresource.ProjectNumberDiffSuppress,
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.
It is specified in the form: "projects/{projectNumber}/global/networks/{network_id}".`,
ExactlyOneOf: []string{"network", "network_config.0.network", "psc_config.0.psc_enabled"},
ExactlyOneOf: []string{"network_config.0.network", "psc_config.0.psc_enabled"},
},
},
},
Expand Down Expand Up @@ -675,12 +664,6 @@ func resourceAlloydbClusterCreate(d *schema.ResourceData, meta interface{}) erro
} else if v, ok := d.GetOkExists("encryption_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(encryptionConfigProp)) && (ok || !reflect.DeepEqual(v, encryptionConfigProp)) {
obj["encryptionConfig"] = encryptionConfigProp
}
networkProp, err := expandAlloydbClusterNetwork(d.Get("network"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("network"); !tpgresource.IsEmptyValue(reflect.ValueOf(networkProp)) && (ok || !reflect.DeepEqual(v, networkProp)) {
obj["network"] = networkProp
}
networkConfigProp, err := expandAlloydbClusterNetworkConfig(d.Get("network_config"), d, config)
if err != nil {
return err
Expand Down Expand Up @@ -958,9 +941,6 @@ func resourceAlloydbClusterRead(d *schema.ResourceData, meta interface{}) error
if err := d.Set("continuous_backup_info", flattenAlloydbClusterContinuousBackupInfo(res["continuousBackupInfo"], d, config)); err != nil {
return fmt.Errorf("Error reading Cluster: %s", err)
}
if err := d.Set("network", flattenAlloydbClusterNetwork(res["network"], d, config)); err != nil {
return fmt.Errorf("Error reading Cluster: %s", err)
}
if err := d.Set("network_config", flattenAlloydbClusterNetworkConfig(res["networkConfig"], d, config)); err != nil {
return fmt.Errorf("Error reading Cluster: %s", err)
}
Expand Down Expand Up @@ -1041,12 +1021,6 @@ func resourceAlloydbClusterUpdate(d *schema.ResourceData, meta interface{}) erro
} else if v, ok := d.GetOkExists("encryption_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, encryptionConfigProp)) {
obj["encryptionConfig"] = encryptionConfigProp
}
networkProp, err := expandAlloydbClusterNetwork(d.Get("network"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("network"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, networkProp)) {
obj["network"] = networkProp
}
networkConfigProp, err := expandAlloydbClusterNetworkConfig(d.Get("network_config"), d, config)
if err != nil {
return err
Expand Down Expand Up @@ -1139,10 +1113,6 @@ func resourceAlloydbClusterUpdate(d *schema.ResourceData, meta interface{}) erro
updateMask = append(updateMask, "encryptionConfig")
}

if d.HasChange("network") {
updateMask = append(updateMask, "network")
}

if d.HasChange("network_config") {
updateMask = append(updateMask, "networkConfig")
}
Expand Down Expand Up @@ -1507,10 +1477,6 @@ func flattenAlloydbClusterContinuousBackupInfoEncryptionInfoKmsKeyVersions(v int
return v
}

func flattenAlloydbClusterNetwork(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}

func flattenAlloydbClusterNetworkConfig(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
if v == nil {
return nil
Expand Down Expand Up @@ -2093,10 +2059,6 @@ func expandAlloydbClusterEncryptionConfigKmsKeyName(v interface{}, d tpgresource
return v, nil
}

func expandAlloydbClusterNetwork(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}

func expandAlloydbClusterNetworkConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
l := v.([]interface{})
if len(l) == 0 || l[0] == nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,9 @@ func testAccAlloydbCluster_alloydbSecondaryClusterBasicTestExample(context map[s
resource "google_alloydb_cluster" "primary" {
cluster_id = "tf-test-alloydb-primary-cluster%{random_suffix}"
location = "us-central1"
network = data.google_compute_network.default.id
network_config {
network = data.google_compute_network.default.id
}
}

resource "google_alloydb_instance" "primary" {
Expand All @@ -203,7 +205,9 @@ resource "google_alloydb_instance" "primary" {
resource "google_alloydb_cluster" "secondary" {
cluster_id = "tf-test-alloydb-secondary-cluster%{random_suffix}"
location = "us-east1"
network = data.google_compute_network.default.id
network_config {
network = data.google_compute_network.default.id
}
cluster_type = "SECONDARY"

continuous_backup_config {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ func testAccAlloydbClusterAndInstanceAndBackup(context map[string]interface{}) s
resource "google_alloydb_cluster" "source" {
cluster_id = "tf-test-alloydb-cluster%{random_suffix}"
location = "us-central1"
network = data.google_compute_network.default.id
network_config {
network = data.google_compute_network.default.id
}
}

resource "google_alloydb_instance" "source" {
Expand Down Expand Up @@ -119,7 +121,9 @@ func testAccAlloydbClusterAndInstanceAndBackup_OnlyOneSourceAllowed(context map[
resource "google_alloydb_cluster" "source" {
cluster_id = "tf-test-alloydb-cluster%{random_suffix}"
location = "us-central1"
network = data.google_compute_network.default.id
network_config {
network = data.google_compute_network.default.id
}
}

resource "google_alloydb_instance" "source" {
Expand All @@ -139,7 +143,9 @@ resource "google_alloydb_backup" "default" {
resource "google_alloydb_cluster" "restored" {
cluster_id = "tf-test-alloydb-backup-restored-cluster-%{random_suffix}"
location = "us-central1"
network = data.google_compute_network.default.id
network_config {
network = data.google_compute_network.default.id
}
restore_backup_source {
backup_name = google_alloydb_backup.default.name
}
Expand Down Expand Up @@ -167,7 +173,9 @@ func testAccAlloydbClusterAndInstanceAndBackup_SourceClusterAndPointInTimeRequir
resource "google_alloydb_cluster" "source" {
cluster_id = "tf-test-alloydb-cluster%{random_suffix}"
location = "us-central1"
network = data.google_compute_network.default.id
network_config {
network = data.google_compute_network.default.id
}
}

resource "google_alloydb_instance" "source" {
Expand All @@ -187,7 +195,9 @@ resource "google_alloydb_backup" "default" {
resource "google_alloydb_cluster" "restored" {
cluster_id = "tf-test-alloydb-backup-restored-cluster-%{random_suffix}"
location = "us-central1"
network = data.google_compute_network.default.id
network_config {
network = data.google_compute_network.default.id
}

restore_continuous_backup_source {
cluster = google_alloydb_cluster.source.name
Expand All @@ -211,7 +221,9 @@ func testAccAlloydbClusterAndInstanceAndBackup_RestoredFromBackup(context map[st
resource "google_alloydb_cluster" "source" {
cluster_id = "tf-test-alloydb-cluster%{random_suffix}"
location = "us-central1"
network = data.google_compute_network.default.id
network_config {
network = data.google_compute_network.default.id
}
}

resource "google_alloydb_instance" "source" {
Expand All @@ -231,7 +243,9 @@ resource "google_alloydb_backup" "default" {
resource "google_alloydb_cluster" "restored_from_backup" {
cluster_id = "tf-test-alloydb-backup-restored-cluster-%{random_suffix}"
location = "us-central1"
network = data.google_compute_network.default.id
network_config {
network = data.google_compute_network.default.id
}
restore_backup_source {
backup_name = google_alloydb_backup.default.name
}
Expand All @@ -256,7 +270,9 @@ func testAccAlloydbClusterAndInstanceAndBackup_RestoredFromBackupAndRestoredFrom
resource "google_alloydb_cluster" "source" {
cluster_id = "tf-test-alloydb-cluster%{random_suffix}"
location = "us-central1"
network = data.google_compute_network.default.id
network_config {
network = data.google_compute_network.default.id
}
}

resource "google_alloydb_instance" "source" {
Expand All @@ -276,7 +292,9 @@ resource "google_alloydb_backup" "default" {
resource "google_alloydb_cluster" "restored_from_backup" {
cluster_id = "tf-test-alloydb-backup-restored-cluster-%{random_suffix}"
location = "us-central1"
network = data.google_compute_network.default.id
network_config {
network = data.google_compute_network.default.id
}
restore_backup_source {
backup_name = google_alloydb_backup.default.name
}
Expand All @@ -289,7 +307,9 @@ resource "google_alloydb_cluster" "restored_from_backup" {
resource "google_alloydb_cluster" "restored_from_point_in_time" {
cluster_id = "tf-test-alloydb-pitr-restored-cluster-%{random_suffix}"
location = "us-central1"
network = data.google_compute_network.default.id
network_config {
network = data.google_compute_network.default.id
}
restore_continuous_backup_source {
cluster = google_alloydb_cluster.source.name
point_in_time = google_alloydb_backup.default.update_time
Expand All @@ -315,7 +335,9 @@ func testAccAlloydbClusterAndInstanceAndBackup_RestoredFromBackupAndRestoredFrom
resource "google_alloydb_cluster" "source" {
cluster_id = "tf-test-alloydb-cluster%{random_suffix}"
location = "us-central1"
network = data.google_compute_network.default.id
network_config {
network = data.google_compute_network.default.id
}
}

resource "google_alloydb_instance" "source" {
Expand All @@ -335,7 +357,9 @@ resource "google_alloydb_backup" "default" {
resource "google_alloydb_cluster" "restored_from_backup" {
cluster_id = "tf-test-alloydb-backup-restored-cluster-%{random_suffix}"
location = "us-central1"
network = data.google_compute_network.default.id
network_config {
network = data.google_compute_network.default.id
}
restore_backup_source {
backup_name = google_alloydb_backup.default.name
}
Expand All @@ -353,7 +377,9 @@ resource "google_alloydb_cluster" "restored_from_backup" {
resource "google_alloydb_cluster" "restored_from_point_in_time" {
cluster_id = "tf-test-alloydb-pitr-restored-cluster-%{random_suffix}"
location = "us-central1"
network = data.google_compute_network.default.id
network_config {
network = data.google_compute_network.default.id
}
restore_continuous_backup_source {
cluster = google_alloydb_cluster.source.name
point_in_time = google_alloydb_backup.default.update_time
Expand Down Expand Up @@ -384,7 +410,9 @@ func testAccAlloydbClusterAndInstanceAndBackup_RestoredFromBackupAndRestoredFrom
resource "google_alloydb_cluster" "source" {
cluster_id = "tf-test-alloydb-cluster%{random_suffix}"
location = "us-central1"
network = data.google_compute_network.default.id
network_config {
network = data.google_compute_network.default.id
}
}

resource "google_alloydb_instance" "source" {
Expand Down Expand Up @@ -412,7 +440,9 @@ resource "google_alloydb_backup" "default2" {
resource "google_alloydb_cluster" "restored_from_backup" {
cluster_id = "tf-test-alloydb-backup-restored-cluster-%{random_suffix}"
location = "us-central1"
network = data.google_compute_network.default.id
network_config {
network = data.google_compute_network.default.id
}
restore_backup_source {
backup_name = google_alloydb_backup.default2.name
}
Expand All @@ -432,7 +462,9 @@ resource "google_alloydb_cluster" "restored_from_backup" {
resource "google_alloydb_cluster" "restored_from_point_in_time" {
cluster_id = "tf-test-alloydb-pitr-restored-cluster-%{random_suffix}"
location = "us-central1"
network = data.google_compute_network.default.id
network_config {
network = data.google_compute_network.default.id
}
restore_continuous_backup_source {
cluster = google_alloydb_cluster.restored_from_backup.name
point_in_time = google_alloydb_backup.default.update_time
Expand Down Expand Up @@ -463,7 +495,9 @@ func testAccAlloydbClusterAndInstanceAndBackup_RestoredFromBackupAndRestoredFrom
resource "google_alloydb_cluster" "source" {
cluster_id = "tf-test-alloydb-cluster%{random_suffix}"
location = "us-central1"
network = data.google_compute_network.default.id
network_config {
network = data.google_compute_network.default.id
}
}

resource "google_alloydb_instance" "source" {
Expand All @@ -483,7 +517,9 @@ resource "google_alloydb_backup" "default" {
resource "google_alloydb_cluster" "restored_from_backup" {
cluster_id = "tf-test-alloydb-backup-restored-cluster-%{random_suffix}"
location = "us-central1"
network = data.google_compute_network.default.id
network_config {
network = data.google_compute_network.default.id
}
restore_backup_source {
backup_name = google_alloydb_backup.default.name
}
Expand All @@ -492,7 +528,9 @@ resource "google_alloydb_cluster" "restored_from_backup" {
resource "google_alloydb_cluster" "restored_from_point_in_time" {
cluster_id = "tf-test-alloydb-pitr-restored-cluster-%{random_suffix}"
location = "us-central1"
network = data.google_compute_network.default.id
network_config {
network = data.google_compute_network.default.id
}
restore_continuous_backup_source {
cluster = google_alloydb_cluster.source.name
point_in_time = google_alloydb_backup.default.update_time
Expand Down
Loading