Skip to content

Commit beb56b0

Browse files
Accecpt AlloyDB cluster database version as an input (#9798) (#16967)
[upstream:f2ee7d847b87c0ea348cdbba3330dfc354df46e4] Signed-off-by: Modular Magician <[email protected]>
1 parent a703924 commit beb56b0

File tree

4 files changed

+37
-8
lines changed

4 files changed

+37
-8
lines changed

.changelog/9798.txt

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
```release-note:enhancement
2+
3+
AlloyDB: removed output label to `databaseVersion` field
4+
5+
```

google/services/alloydb/resource_alloydb_cluster.go

+26-5
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,12 @@ If not set, defaults to 14 days.`,
265265
},
266266
},
267267
},
268+
"database_version": {
269+
Type: schema.TypeString,
270+
Computed: true,
271+
Optional: true,
272+
Description: `The database engine major version. This is an optional field and it's populated at the Cluster creation time. This field cannot be changed after cluster creation.`,
273+
},
268274
"display_name": {
269275
Type: schema.TypeString,
270276
Optional: true,
@@ -478,11 +484,6 @@ It is specified in the form: "projects/{projectNumber}/global/networks/{network_
478484
},
479485
},
480486
},
481-
"database_version": {
482-
Type: schema.TypeString,
483-
Computed: true,
484-
Description: `The database engine major version. This is an output-only field and it's populated at the Cluster creation time. This field cannot be changed after cluster creation.`,
485-
},
486487
"effective_annotations": {
487488
Type: schema.TypeMap,
488489
Computed: true,
@@ -627,6 +628,12 @@ func resourceAlloydbClusterCreate(d *schema.ResourceData, meta interface{}) erro
627628
} else if v, ok := d.GetOkExists("etag"); !tpgresource.IsEmptyValue(reflect.ValueOf(etagProp)) && (ok || !reflect.DeepEqual(v, etagProp)) {
628629
obj["etag"] = etagProp
629630
}
631+
databaseVersionProp, err := expandAlloydbClusterDatabaseVersion(d.Get("database_version"), d, config)
632+
if err != nil {
633+
return err
634+
} else if v, ok := d.GetOkExists("database_version"); !tpgresource.IsEmptyValue(reflect.ValueOf(databaseVersionProp)) && (ok || !reflect.DeepEqual(v, databaseVersionProp)) {
635+
obj["databaseVersion"] = databaseVersionProp
636+
}
630637
initialUserProp, err := expandAlloydbClusterInitialUser(d.Get("initial_user"), d, config)
631638
if err != nil {
632639
return err
@@ -965,6 +972,12 @@ func resourceAlloydbClusterUpdate(d *schema.ResourceData, meta interface{}) erro
965972
} else if v, ok := d.GetOkExists("etag"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, etagProp)) {
966973
obj["etag"] = etagProp
967974
}
975+
databaseVersionProp, err := expandAlloydbClusterDatabaseVersion(d.Get("database_version"), d, config)
976+
if err != nil {
977+
return err
978+
} else if v, ok := d.GetOkExists("database_version"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, databaseVersionProp)) {
979+
obj["databaseVersion"] = databaseVersionProp
980+
}
968981
initialUserProp, err := expandAlloydbClusterInitialUser(d.Get("initial_user"), d, config)
969982
if err != nil {
970983
return err
@@ -1036,6 +1049,10 @@ func resourceAlloydbClusterUpdate(d *schema.ResourceData, meta interface{}) erro
10361049
updateMask = append(updateMask, "etag")
10371050
}
10381051

1052+
if d.HasChange("database_version") {
1053+
updateMask = append(updateMask, "databaseVersion")
1054+
}
1055+
10391056
if d.HasChange("initial_user") {
10401057
updateMask = append(updateMask, "initialUser")
10411058
}
@@ -1869,6 +1886,10 @@ func expandAlloydbClusterEtag(v interface{}, d tpgresource.TerraformResourceData
18691886
return v, nil
18701887
}
18711888

1889+
func expandAlloydbClusterDatabaseVersion(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
1890+
return v, nil
1891+
}
1892+
18721893
func expandAlloydbClusterInitialUser(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
18731894
l := v.([]interface{})
18741895
if len(l) == 0 || l[0] == nil {

google/services/alloydb/resource_alloydb_cluster_generated_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ resource "google_alloydb_cluster" "full" {
102102
cluster_id = "tf-test-alloydb-cluster-full%{random_suffix}"
103103
location = "us-central1"
104104
network = google_compute_network.default.id
105+
database_version = "POSTGRES_15"
105106
106107
initial_user {
107108
user = "tf-test-alloydb-cluster-full%{random_suffix}"

website/docs/r/alloydb_cluster.html.markdown

+5-3
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ resource "google_alloydb_cluster" "full" {
6666
cluster_id = "alloydb-cluster-full"
6767
location = "us-central1"
6868
network = google_compute_network.default.id
69+
database_version = "POSTGRES_15"
6970
7071
initial_user {
7172
user = "alloydb-cluster-full"
@@ -303,6 +304,10 @@ The following arguments are supported:
303304
**Note**: This field is non-authoritative, and will only manage the annotations present in your configuration.
304305
Please refer to the field `effective_annotations` for all of the annotations present on the resource.
305306

307+
* `database_version` -
308+
(Optional)
309+
The database engine major version. This is an optional field and it's populated at the Cluster creation time. This field cannot be changed after cluster creation.
310+
306311
* `initial_user` -
307312
(Optional)
308313
Initial user to setup during cluster creation.
@@ -542,9 +547,6 @@ In addition to the arguments listed above, the following computed attributes are
542547
* `state` -
543548
Output only. The current serving state of the cluster.
544549

545-
* `database_version` -
546-
The database engine major version. This is an output-only field and it's populated at the Cluster creation time. This field cannot be changed after cluster creation.
547-
548550
* `backup_source` -
549551
Cluster created from backup.
550552
Structure is [documented below](#nested_backup_source).

0 commit comments

Comments
 (0)