Skip to content

Commit c58dbe9

Browse files
alloydb: Revert incorrect removal of machine_type from machine_config (it is GA) (#14470) (#23562)
[upstream:74b39560c129dbb2fbf72e0c90c45a046a1ebafc] Signed-off-by: Modular Magician <[email protected]>
1 parent 0d42c42 commit c58dbe9

File tree

5 files changed

+33
-2
lines changed

5 files changed

+33
-2
lines changed

.changelog/14470.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
alloydb: Restored support for the machine_type field in the machine_config block. It is GA.
3+
```

google/services/alloydb/resource_alloydb_instance.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,14 @@ Please refer to the field 'effective_labels' for all of the labels present on th
194194
Optional: true,
195195
Description: `The number of CPU's in the VM instance.`,
196196
},
197+
"machine_type": {
198+
Type: schema.TypeString,
199+
Computed: true,
200+
Optional: true,
201+
Description: `Machine type of the VM instance.
202+
E.g. "n2-highmem-4", "n2-highmem-8", "c4a-highmem-4-lssd".
203+
'cpu_count' must match the number of vCPUs in the machine type.`,
204+
},
197205
},
198206
},
199207
},
@@ -1180,6 +1188,8 @@ func flattenAlloydbInstanceMachineConfig(v interface{}, d *schema.ResourceData,
11801188
transformed := make(map[string]interface{})
11811189
transformed["cpu_count"] =
11821190
flattenAlloydbInstanceMachineConfigCpuCount(original["cpuCount"], d, config)
1191+
transformed["machine_type"] =
1192+
flattenAlloydbInstanceMachineConfigMachineType(original["machineType"], d, config)
11831193
return []interface{}{transformed}
11841194
}
11851195
func flattenAlloydbInstanceMachineConfigCpuCount(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
@@ -1199,6 +1209,10 @@ func flattenAlloydbInstanceMachineConfigCpuCount(v interface{}, d *schema.Resour
11991209
return v // let terraform core handle it otherwise
12001210
}
12011211

1212+
func flattenAlloydbInstanceMachineConfigMachineType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
1213+
return v
1214+
}
1215+
12021216
func flattenAlloydbInstanceClientConnectionConfig(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
12031217
if v == nil {
12041218
return nil
@@ -1542,13 +1556,24 @@ func expandAlloydbInstanceMachineConfig(v interface{}, d tpgresource.TerraformRe
15421556
transformed["cpuCount"] = transformedCpuCount
15431557
}
15441558

1559+
transformedMachineType, err := expandAlloydbInstanceMachineConfigMachineType(original["machine_type"], d, config)
1560+
if err != nil {
1561+
return nil, err
1562+
} else if val := reflect.ValueOf(transformedMachineType); val.IsValid() && !tpgresource.IsEmptyValue(val) {
1563+
transformed["machineType"] = transformedMachineType
1564+
}
1565+
15451566
return transformed, nil
15461567
}
15471568

15481569
func expandAlloydbInstanceMachineConfigCpuCount(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
15491570
return v, nil
15501571
}
15511572

1573+
func expandAlloydbInstanceMachineConfigMachineType(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
1574+
return v, nil
1575+
}
1576+
15521577
func expandAlloydbInstanceClientConnectionConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
15531578
l := v.([]interface{})
15541579
if len(l) == 0 || l[0] == nil {

google/services/alloydb/resource_alloydb_instance_generated_meta.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ fields:
2626
- field: 'ip_address'
2727
- field: 'labels'
2828
- field: 'machine_config.cpu_count'
29+
- field: 'machine_config.machine_type'
2930
- field: 'name'
3031
- field: 'network_config.allocated_ip_range_override'
3132
- field: 'network_config.authorized_external_networks.cidr_range'

google/services/alloydb/resource_alloydb_instance_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
//
99
// This code is generated by Magic Modules using the following:
1010
//
11-
// Source file: https://github.com/GoogleCloudPlatform/magic-modules/tree/main/mmv1/third_party/terraform/services/alloydb/resource_alloydb_instance_test.go.tmpl
11+
// Source file: https://github.com/GoogleCloudPlatform/magic-modules/tree/main/mmv1/third_party/terraform/services/alloydb/resource_alloydb_instance_test.go
1212
//
1313
// DO NOT EDIT this file directly. Any changes made to this file will be
1414
// overwritten during the next generation cycle.
@@ -97,6 +97,7 @@ resource "google_alloydb_instance" "default" {
9797
9898
machine_config {
9999
cpu_count = 4
100+
machine_type = "n2-highmem-4"
100101
}
101102
102103
labels = {
@@ -969,6 +970,7 @@ resource "google_alloydb_instance" "default" {
969970
instance_type = "PRIMARY"
970971
machine_config {
971972
cpu_count = 2
973+
machine_type = "n2-highmem-2"
972974
}
973975
psc_instance_config {
974976
allowed_consumer_projects = ["${data.google_project.project.number}"]

website/docs/r/alloydb_instance.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ The following arguments are supported:
345345
The number of CPU's in the VM instance.
346346

347347
* `machine_type` -
348-
(Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html))
348+
(Optional)
349349
Machine type of the VM instance.
350350
E.g. "n2-highmem-4", "n2-highmem-8", "c4a-highmem-4-lssd".
351351
`cpu_count` must match the number of vCPUs in the machine type.

0 commit comments

Comments
 (0)