Skip to content

Commit 49d1117

Browse files
Add allow_fewer_zones_deployment to Redis Cluster (#14676) (#10434)
[upstream:1c5e11505716be5e67b1897fc7ba9da374c992ef] Signed-off-by: Modular Magician <magic-modules@google.com>
1 parent 438cdbd commit 49d1117

File tree

5 files changed

+39
-2
lines changed

5 files changed

+39
-2
lines changed

.changelog/14676.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
memorystore: added `allow_fewer_zones_deployment` field to `google_redis_cluster` resource
3+
```

google-beta/services/redis/resource_redis_cluster.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,15 @@ projects/{projectId}/locations/{locationId}/clusters/{clusterId}`,
7272
Required: true,
7373
Description: `Required. Number of shards for the Redis cluster.`,
7474
},
75+
"allow_fewer_zones_deployment": {
76+
Type: schema.TypeBool,
77+
Optional: true,
78+
ForceNew: true,
79+
Description: `Allows customers to specify if they are okay with deploying a multi-zone
80+
cluster in less than 3 zones. Once set, if there is a zonal outage during
81+
the cluster creation, the cluster will only be deployed in 2 zones, and
82+
stay within the 2 zones for its lifecycle.`,
83+
},
7584
"authorization_mode": {
7685
Type: schema.TypeString,
7786
Optional: true,
@@ -814,6 +823,12 @@ func resourceRedisClusterCreate(d *schema.ResourceData, meta interface{}) error
814823
} else if v, ok := d.GetOkExists("zone_distribution_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(zoneDistributionConfigProp)) && (ok || !reflect.DeepEqual(v, zoneDistributionConfigProp)) {
815824
obj["zoneDistributionConfig"] = zoneDistributionConfigProp
816825
}
826+
allowFewerZonesDeploymentProp, err := expandRedisClusterAllowFewerZonesDeployment(d.Get("allow_fewer_zones_deployment"), d, config)
827+
if err != nil {
828+
return err
829+
} else if v, ok := d.GetOkExists("allow_fewer_zones_deployment"); !tpgresource.IsEmptyValue(reflect.ValueOf(allowFewerZonesDeploymentProp)) && (ok || !reflect.DeepEqual(v, allowFewerZonesDeploymentProp)) {
830+
obj["allowFewerZonesDeployment"] = allowFewerZonesDeploymentProp
831+
}
817832
pscConfigsProp, err := expandRedisClusterPscConfigs(d.Get("psc_configs"), d, config)
818833
if err != nil {
819834
return err
@@ -1019,6 +1034,9 @@ func resourceRedisClusterRead(d *schema.ResourceData, meta interface{}) error {
10191034
if err := d.Set("zone_distribution_config", flattenRedisClusterZoneDistributionConfig(res["zoneDistributionConfig"], d, config)); err != nil {
10201035
return fmt.Errorf("Error reading Cluster: %s", err)
10211036
}
1037+
if err := d.Set("allow_fewer_zones_deployment", flattenRedisClusterAllowFewerZonesDeployment(res["allowFewerZonesDeployment"], d, config)); err != nil {
1038+
return fmt.Errorf("Error reading Cluster: %s", err)
1039+
}
10221040
if err := d.Set("discovery_endpoints", flattenRedisClusterDiscoveryEndpoints(res["discoveryEndpoints"], d, config)); err != nil {
10231041
return fmt.Errorf("Error reading Cluster: %s", err)
10241042
}
@@ -1448,6 +1466,10 @@ func flattenRedisClusterZoneDistributionConfigZone(v interface{}, d *schema.Reso
14481466
return v
14491467
}
14501468

1469+
func flattenRedisClusterAllowFewerZonesDeployment(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
1470+
return v
1471+
}
1472+
14511473
func flattenRedisClusterDiscoveryEndpoints(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
14521474
if v == nil {
14531475
return v
@@ -2282,6 +2304,10 @@ func expandRedisClusterZoneDistributionConfigZone(v interface{}, d tpgresource.T
22822304
return v, nil
22832305
}
22842306

2307+
func expandRedisClusterAllowFewerZonesDeployment(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
2308+
return v, nil
2309+
}
2310+
22852311
func expandRedisClusterPscConfigs(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
22862312
l := v.([]interface{})
22872313
req := make([]interface{}, 0, len(l))

google-beta/services/redis/resource_redis_cluster_generated_meta.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ api_service_name: 'redis.googleapis.com'
55
api_version: 'v1beta1'
66
api_resource_type_kind: 'Cluster'
77
fields:
8+
- field: 'allow_fewer_zones_deployment'
89
- field: 'authorization_mode'
910
- field: 'automated_backup_config.fixed_frequency_schedule.start_time.hours'
1011
- field: 'automated_backup_config.retention'

google-beta/services/redis/resource_redis_cluster_generated_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ resource "google_redis_cluster" "cluster-aof" {
521521
maxmemory-policy = "volatile-ttl"
522522
}
523523
deletion_protection_enabled = %{deletion_protection_enabled}
524-
524+
allow_fewer_zones_deployment = true
525525
zone_distribution_config {
526526
mode = "MULTI_ZONE"
527527
}

website/docs/r/redis_cluster.html.markdown

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ resource "google_redis_cluster" "cluster-aof" {
494494
maxmemory-policy = "volatile-ttl"
495495
}
496496
deletion_protection_enabled = true
497-
497+
allow_fewer_zones_deployment = true
498498
zone_distribution_config {
499499
mode = "MULTI_ZONE"
500500
}
@@ -648,6 +648,13 @@ The following arguments are supported:
648648
Immutable. Zone distribution config for Memorystore Redis cluster.
649649
Structure is [documented below](#nested_zone_distribution_config).
650650

651+
* `allow_fewer_zones_deployment` -
652+
(Optional)
653+
Allows customers to specify if they are okay with deploying a multi-zone
654+
cluster in less than 3 zones. Once set, if there is a zonal outage during
655+
the cluster creation, the cluster will only be deployed in 2 zones, and
656+
stay within the 2 zones for its lifecycle.
657+
651658
* `psc_configs` -
652659
(Optional)
653660
Required. Each PscConfig configures the consumer network where two

0 commit comments

Comments
 (0)