Skip to content

Commit 807b5d9

Browse files
Adding nodeType field in the terraform (#10090) (#17742)
[upstream:a9d6aed791af556fb2adbd28ea509a9fd838098e] Signed-off-by: Modular Magician <[email protected]>
1 parent 75e4d03 commit 807b5d9

File tree

4 files changed

+52
-0
lines changed

4 files changed

+52
-0
lines changed

.changelog/10090.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
redis: added `node_type` and `precise_size_gb` fields to `google_redis_cluster`
3+
```

google/services/redis/resource_redis_cluster.go

+38
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,15 @@ projects/{network_project_id_or_number}/global/networks/{network_id}.`,
9494
Description: `Optional. The authorization mode of the Redis cluster. If not provided, auth feature is disabled for the cluster. Default value: "AUTH_MODE_DISABLED" Possible values: ["AUTH_MODE_UNSPECIFIED", "AUTH_MODE_IAM_AUTH", "AUTH_MODE_DISABLED"]`,
9595
Default: "AUTH_MODE_DISABLED",
9696
},
97+
"node_type": {
98+
Type: schema.TypeString,
99+
Computed: true,
100+
Optional: true,
101+
ForceNew: true,
102+
ValidateFunc: verify.ValidateEnum([]string{"REDIS_SHARED_CORE_NANO", "REDIS_HIGHMEM_MEDIUM", "REDIS_HIGHMEM_XLARGE", "REDIS_STANDARD_SMALL", ""}),
103+
Description: `The nodeType for the Redis cluster.
104+
If not provided, REDIS_HIGHMEM_MEDIUM will be used as default Possible values: ["REDIS_SHARED_CORE_NANO", "REDIS_HIGHMEM_MEDIUM", "REDIS_HIGHMEM_XLARGE", "REDIS_STANDARD_SMALL"]`,
105+
},
97106
"region": {
98107
Type: schema.TypeString,
99108
Computed: true,
@@ -161,6 +170,11 @@ projects/{network_project_id}/global/networks/{network_id}.`,
161170
},
162171
},
163172
},
173+
"precise_size_gb": {
174+
Type: schema.TypeFloat,
175+
Computed: true,
176+
Description: `Output only. Redis memory precise size in GB for the entire cluster.`,
177+
},
164178
"psc_connections": {
165179
Type: schema.TypeList,
166180
Computed: true,
@@ -270,6 +284,12 @@ func resourceRedisClusterCreate(d *schema.ResourceData, meta interface{}) error
270284
} else if v, ok := d.GetOkExists("transit_encryption_mode"); !tpgresource.IsEmptyValue(reflect.ValueOf(transitEncryptionModeProp)) && (ok || !reflect.DeepEqual(v, transitEncryptionModeProp)) {
271285
obj["transitEncryptionMode"] = transitEncryptionModeProp
272286
}
287+
nodeTypeProp, err := expandRedisClusterNodeType(d.Get("node_type"), d, config)
288+
if err != nil {
289+
return err
290+
} else if v, ok := d.GetOkExists("node_type"); !tpgresource.IsEmptyValue(reflect.ValueOf(nodeTypeProp)) && (ok || !reflect.DeepEqual(v, nodeTypeProp)) {
291+
obj["nodeType"] = nodeTypeProp
292+
}
273293
pscConfigsProp, err := expandRedisClusterPscConfigs(d.Get("psc_configs"), d, config)
274294
if err != nil {
275295
return err
@@ -406,6 +426,9 @@ func resourceRedisClusterRead(d *schema.ResourceData, meta interface{}) error {
406426
if err := d.Set("transit_encryption_mode", flattenRedisClusterTransitEncryptionMode(res["transitEncryptionMode"], d, config)); err != nil {
407427
return fmt.Errorf("Error reading Cluster: %s", err)
408428
}
429+
if err := d.Set("node_type", flattenRedisClusterNodeType(res["nodeType"], d, config)); err != nil {
430+
return fmt.Errorf("Error reading Cluster: %s", err)
431+
}
409432
if err := d.Set("discovery_endpoints", flattenRedisClusterDiscoveryEndpoints(res["discoveryEndpoints"], d, config)); err != nil {
410433
return fmt.Errorf("Error reading Cluster: %s", err)
411434
}
@@ -421,6 +444,9 @@ func resourceRedisClusterRead(d *schema.ResourceData, meta interface{}) error {
421444
if err := d.Set("size_gb", flattenRedisClusterSizeGb(res["sizeGb"], d, config)); err != nil {
422445
return fmt.Errorf("Error reading Cluster: %s", err)
423446
}
447+
if err := d.Set("precise_size_gb", flattenRedisClusterPreciseSizeGb(res["preciseSizeGb"], d, config)); err != nil {
448+
return fmt.Errorf("Error reading Cluster: %s", err)
449+
}
424450
if err := d.Set("shard_count", flattenRedisClusterShardCount(res["shardCount"], d, config)); err != nil {
425451
return fmt.Errorf("Error reading Cluster: %s", err)
426452
}
@@ -618,6 +644,10 @@ func flattenRedisClusterTransitEncryptionMode(v interface{}, d *schema.ResourceD
618644
return v
619645
}
620646

647+
func flattenRedisClusterNodeType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
648+
return v
649+
}
650+
621651
func flattenRedisClusterDiscoveryEndpoints(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
622652
if v == nil {
623653
return v
@@ -814,6 +844,10 @@ func flattenRedisClusterSizeGb(v interface{}, d *schema.ResourceData, config *tr
814844
return v // let terraform core handle it otherwise
815845
}
816846

847+
func flattenRedisClusterPreciseSizeGb(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
848+
return v
849+
}
850+
817851
func flattenRedisClusterShardCount(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
818852
// Handles the string fixed64 format
819853
if strVal, ok := v.(string); ok {
@@ -839,6 +873,10 @@ func expandRedisClusterTransitEncryptionMode(v interface{}, d tpgresource.Terraf
839873
return v, nil
840874
}
841875

876+
func expandRedisClusterNodeType(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
877+
return v, nil
878+
}
879+
842880
func expandRedisClusterPscConfigs(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
843881
l := v.([]interface{})
844882
req := make([]interface{}, 0, len(l))

google/services/redis/resource_redis_cluster_generated_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ resource "google_redis_cluster" "cluster-ha" {
6666
}
6767
region = "us-central1"
6868
replica_count = 1
69+
node_type = "REDIS_SHARED_CORE_NANO"
6970
transit_encryption_mode = "TRANSIT_ENCRYPTION_MODE_DISABLED"
7071
authorization_mode = "AUTH_MODE_DISABLED"
7172
depends_on = [

website/docs/r/redis_cluster.html.markdown

+10
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ resource "google_redis_cluster" "cluster-ha" {
4545
}
4646
region = "us-central1"
4747
replica_count = 1
48+
node_type = "REDIS_SHARED_CORE_NANO"
4849
transit_encryption_mode = "TRANSIT_ENCRYPTION_MODE_DISABLED"
4950
authorization_mode = "AUTH_MODE_DISABLED"
5051
depends_on = [
@@ -126,6 +127,12 @@ The following arguments are supported:
126127
Default value is `TRANSIT_ENCRYPTION_MODE_DISABLED`.
127128
Possible values are: `TRANSIT_ENCRYPTION_MODE_UNSPECIFIED`, `TRANSIT_ENCRYPTION_MODE_DISABLED`, `TRANSIT_ENCRYPTION_MODE_SERVER_AUTHENTICATION`.
128129

130+
* `node_type` -
131+
(Optional)
132+
The nodeType for the Redis cluster.
133+
If not provided, REDIS_HIGHMEM_MEDIUM will be used as default
134+
Possible values are: `REDIS_SHARED_CORE_NANO`, `REDIS_HIGHMEM_MEDIUM`, `REDIS_HIGHMEM_XLARGE`, `REDIS_STANDARD_SMALL`.
135+
129136
* `replica_count` -
130137
(Optional)
131138
Optional. The number of replica nodes per shard.
@@ -172,6 +179,9 @@ In addition to the arguments listed above, the following computed attributes are
172179
* `size_gb` -
173180
Output only. Redis memory size in GB for the entire cluster.
174181

182+
* `precise_size_gb` -
183+
Output only. Redis memory precise size in GB for the entire cluster.
184+
175185

176186
<a name="nested_discovery_endpoints"></a>The `discovery_endpoints` block contains:
177187

0 commit comments

Comments
 (0)