Skip to content

Commit 2891332

Browse files
Add allow_fewer_zones_deployment to Memorystore (#14677) (#23845)
[upstream:b6ee44125ce6bbe9732bc9bbfc867906113cc9cd] Signed-off-by: Modular Magician <[email protected]>
1 parent be9f297 commit 2891332

File tree

5 files changed

+83
-44
lines changed

5 files changed

+83
-44
lines changed

.changelog/14677.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_memorystore_instance` resource
3+
```

google/services/memorystore/resource_memorystore_instance.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,15 @@ This value is subject to the following restrictions:
8585
Required: true,
8686
Description: `Required. Number of shards for the instance.`,
8787
},
88+
"allow_fewer_zones_deployment": {
89+
Type: schema.TypeBool,
90+
Optional: true,
91+
ForceNew: true,
92+
Description: `Allows customers to specify if they are okay with deploying a multi-zone
93+
instance in less than 3 zones. Once set, if there is a zonal outage during
94+
the instance creation, the instance will only be deployed in 2 zones, and
95+
stay within the 2 zones for its lifecycle.`,
96+
},
8897
"authorization_mode": {
8998
Type: schema.TypeString,
9099
Computed: true,
@@ -1035,6 +1044,12 @@ func resourceMemorystoreInstanceCreate(d *schema.ResourceData, meta interface{})
10351044
} else if v, ok := d.GetOkExists("zone_distribution_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(zoneDistributionConfigProp)) && (ok || !reflect.DeepEqual(v, zoneDistributionConfigProp)) {
10361045
obj["zoneDistributionConfig"] = zoneDistributionConfigProp
10371046
}
1047+
allowFewerZonesDeploymentProp, err := expandMemorystoreInstanceAllowFewerZonesDeployment(d.Get("allow_fewer_zones_deployment"), d, config)
1048+
if err != nil {
1049+
return err
1050+
} else if v, ok := d.GetOkExists("allow_fewer_zones_deployment"); !tpgresource.IsEmptyValue(reflect.ValueOf(allowFewerZonesDeploymentProp)) && (ok || !reflect.DeepEqual(v, allowFewerZonesDeploymentProp)) {
1051+
obj["allowFewerZonesDeployment"] = allowFewerZonesDeploymentProp
1052+
}
10381053
deletionProtectionEnabledProp, err := expandMemorystoreInstanceDeletionProtectionEnabled(d.Get("deletion_protection_enabled"), d, config)
10391054
if err != nil {
10401055
return err
@@ -1257,6 +1272,9 @@ func resourceMemorystoreInstanceRead(d *schema.ResourceData, meta interface{}) e
12571272
if err := d.Set("zone_distribution_config", flattenMemorystoreInstanceZoneDistributionConfig(res["zoneDistributionConfig"], d, config)); err != nil {
12581273
return fmt.Errorf("Error reading Instance: %s", err)
12591274
}
1275+
if err := d.Set("allow_fewer_zones_deployment", flattenMemorystoreInstanceAllowFewerZonesDeployment(res["allowFewerZonesDeployment"], d, config)); err != nil {
1276+
return fmt.Errorf("Error reading Instance: %s", err)
1277+
}
12601278
if err := d.Set("deletion_protection_enabled", flattenMemorystoreInstanceDeletionProtectionEnabled(res["deletionProtectionEnabled"], d, config)); err != nil {
12611279
return fmt.Errorf("Error reading Instance: %s", err)
12621280
}
@@ -2101,6 +2119,10 @@ func flattenMemorystoreInstanceZoneDistributionConfigMode(v interface{}, d *sche
21012119
return v
21022120
}
21032121

2122+
func flattenMemorystoreInstanceAllowFewerZonesDeployment(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
2123+
return v
2124+
}
2125+
21042126
func flattenMemorystoreInstanceDeletionProtectionEnabled(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
21052127
return v
21062128
}
@@ -2914,6 +2936,10 @@ func expandMemorystoreInstanceZoneDistributionConfigMode(v interface{}, d tpgres
29142936
return v, nil
29152937
}
29162938

2939+
func expandMemorystoreInstanceAllowFewerZonesDeployment(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
2940+
return v, nil
2941+
}
2942+
29172943
func expandMemorystoreInstanceDeletionProtectionEnabled(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
29182944
return v, nil
29192945
}

google/services/memorystore/resource_memorystore_instance_generated_meta.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ api_version: 'v1'
66
api_resource_type_kind: 'Instance'
77
autogen_status: true
88
fields:
9+
- field: 'allow_fewer_zones_deployment'
910
- field: 'authorization_mode'
1011
- field: 'automated_backup_config.fixed_frequency_schedule.start_time.hours'
1112
- field: 'automated_backup_config.retention'

google/services/memorystore/resource_memorystore_instance_generated_test.go

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -151,41 +151,42 @@ func TestAccMemorystoreInstance_memorystoreInstanceFullExample(t *testing.T) {
151151
func testAccMemorystoreInstance_memorystoreInstanceFullExample(context map[string]interface{}) string {
152152
return acctest.Nprintf(`
153153
resource "google_memorystore_instance" "instance-full" {
154-
instance_id = "tf-test-full-instance%{random_suffix}"
155-
shard_count = 1
154+
instance_id = "tf-test-full-instance%{random_suffix}"
155+
shard_count = 1
156156
desired_auto_created_endpoints {
157-
network = google_compute_network.producer_net.id
158-
project_id = data.google_project.project.project_id
159-
}
160-
location = "us-central1"
161-
replica_count = 1
162-
node_type = "SHARED_CORE_NANO"
163-
transit_encryption_mode = "TRANSIT_ENCRYPTION_DISABLED"
164-
authorization_mode = "AUTH_DISABLED"
165-
kms_key = "%{kms_key_name}"
166-
engine_configs = {
167-
maxmemory-policy = "volatile-ttl"
157+
network = google_compute_network.producer_net.id
158+
project_id = data.google_project.project.project_id
159+
}
160+
location = "us-central1"
161+
replica_count = 1
162+
node_type = "SHARED_CORE_NANO"
163+
transit_encryption_mode = "TRANSIT_ENCRYPTION_DISABLED"
164+
authorization_mode = "AUTH_DISABLED"
165+
kms_key = "%{kms_key_name}"
166+
engine_configs = {
167+
maxmemory-policy = "volatile-ttl"
168168
}
169+
allow_fewer_zones_deployment = true
169170
zone_distribution_config {
170-
mode = "SINGLE_ZONE"
171-
zone = "us-central1-b"
171+
mode = "SINGLE_ZONE"
172+
zone = "us-central1-b"
172173
}
173174
maintenance_policy {
174175
weekly_maintenance_window {
175-
day = "MONDAY"
176+
day = "MONDAY"
176177
start_time {
177-
hours = 1
178-
minutes = 0
179-
seconds = 0
180-
nanos = 0
178+
hours = 1
179+
minutes = 0
180+
seconds = 0
181+
nanos = 0
181182
}
182183
}
183184
}
184185
engine_version = "VALKEY_7_2"
185186
deletion_protection_enabled = false
186-
mode = "CLUSTER"
187+
mode = "CLUSTER"
187188
persistence_config {
188-
mode = "RDB"
189+
mode = "RDB"
189190
rdb_config {
190191
rdb_snapshot_period = "ONE_HOUR"
191192
rdb_snapshot_start_time = "2024-10-02T15:01:23Z"

website/docs/r/memorystore_instance.html.markdown

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -104,41 +104,42 @@ data "google_project" "project" {
104104

105105
```hcl
106106
resource "google_memorystore_instance" "instance-full" {
107-
instance_id = "full-instance"
108-
shard_count = 1
107+
instance_id = "full-instance"
108+
shard_count = 1
109109
desired_auto_created_endpoints {
110-
network = google_compute_network.producer_net.id
111-
project_id = data.google_project.project.project_id
112-
}
113-
location = "us-central1"
114-
replica_count = 1
115-
node_type = "SHARED_CORE_NANO"
116-
transit_encryption_mode = "TRANSIT_ENCRYPTION_DISABLED"
117-
authorization_mode = "AUTH_DISABLED"
118-
kms_key = "my-key"
119-
engine_configs = {
120-
maxmemory-policy = "volatile-ttl"
110+
network = google_compute_network.producer_net.id
111+
project_id = data.google_project.project.project_id
112+
}
113+
location = "us-central1"
114+
replica_count = 1
115+
node_type = "SHARED_CORE_NANO"
116+
transit_encryption_mode = "TRANSIT_ENCRYPTION_DISABLED"
117+
authorization_mode = "AUTH_DISABLED"
118+
kms_key = "my-key"
119+
engine_configs = {
120+
maxmemory-policy = "volatile-ttl"
121121
}
122+
allow_fewer_zones_deployment = true
122123
zone_distribution_config {
123-
mode = "SINGLE_ZONE"
124-
zone = "us-central1-b"
124+
mode = "SINGLE_ZONE"
125+
zone = "us-central1-b"
125126
}
126127
maintenance_policy {
127128
weekly_maintenance_window {
128-
day = "MONDAY"
129+
day = "MONDAY"
129130
start_time {
130-
hours = 1
131-
minutes = 0
132-
seconds = 0
133-
nanos = 0
131+
hours = 1
132+
minutes = 0
133+
seconds = 0
134+
nanos = 0
134135
}
135136
}
136137
}
137138
engine_version = "VALKEY_7_2"
138139
deletion_protection_enabled = false
139-
mode = "CLUSTER"
140+
mode = "CLUSTER"
140141
persistence_config {
141-
mode = "RDB"
142+
mode = "RDB"
142143
rdb_config {
143144
rdb_snapshot_period = "ONE_HOUR"
144145
rdb_snapshot_start_time = "2024-10-02T15:01:23Z"
@@ -467,6 +468,13 @@ The following arguments are supported:
467468
Zone distribution configuration for allocation of instance resources.
468469
Structure is [documented below](#nested_zone_distribution_config).
469470

471+
* `allow_fewer_zones_deployment` -
472+
(Optional)
473+
Allows customers to specify if they are okay with deploying a multi-zone
474+
instance in less than 3 zones. Once set, if there is a zonal outage during
475+
the instance creation, the instance will only be deployed in 2 zones, and
476+
stay within the 2 zones for its lifecycle.
477+
470478
* `deletion_protection_enabled` -
471479
(Optional)
472480
Optional. If set to true deletion of the instance will fail.

0 commit comments

Comments
 (0)