Skip to content

Commit 28d29f1

Browse files
mw valkey terraform changes (#13049)
1 parent d5a4184 commit 28d29f1

File tree

4 files changed

+201
-15
lines changed

4 files changed

+201
-15
lines changed

mmv1/products/memorystore/Instance.yaml

+119
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,125 @@ properties:
254254
type: String
255255
description: "Optional. The fsync mode. \n Possible values:\n NEVER\nEVERY_SEC\nALWAYS"
256256
default_from_api: true
257+
- name: 'maintenancePolicy'
258+
type: NestedObject
259+
description: Maintenance policy for a cluster
260+
properties:
261+
- name: 'createTime'
262+
type: String
263+
description: |
264+
The time when the policy was created.
265+
A timestamp in RFC3339 UTC "Zulu" format, with nanosecond
266+
resolution and up to nine fractional digits.
267+
output: true
268+
- name: 'updateTime'
269+
type: String
270+
description: |
271+
The time when the policy was last updated.
272+
A timestamp in RFC3339 UTC "Zulu" format, with nanosecond
273+
resolution and up to nine fractional digits.
274+
output: true
275+
- name: 'weeklyMaintenanceWindow'
276+
type: Array
277+
description: |
278+
Optional. Maintenance window that is applied to resources covered by this policy.
279+
Minimum 1. For the current version, the maximum number
280+
of weekly_window is expected to be one.
281+
item_type:
282+
type: NestedObject
283+
properties:
284+
- name: 'day'
285+
type: Enum
286+
description: |
287+
The day of week that maintenance updates occur.
288+
289+
- DAY_OF_WEEK_UNSPECIFIED: The day of the week is unspecified.
290+
- MONDAY: Monday
291+
- TUESDAY: Tuesday
292+
- WEDNESDAY: Wednesday
293+
- THURSDAY: Thursday
294+
- FRIDAY: Friday
295+
- SATURDAY: Saturday
296+
- SUNDAY: Sunday
297+
required: true
298+
enum_values:
299+
- 'DAY_OF_WEEK_UNSPECIFIED'
300+
- 'MONDAY'
301+
- 'TUESDAY'
302+
- 'WEDNESDAY'
303+
- 'THURSDAY'
304+
- 'FRIDAY'
305+
- 'SATURDAY'
306+
- 'SUNDAY'
307+
- name: 'duration'
308+
type: String
309+
description: |
310+
Duration of the maintenance window.
311+
The current window is fixed at 1 hour.
312+
A duration in seconds with up to nine fractional digits,
313+
terminated by 's'. Example: "3.5s".
314+
output: true
315+
- name: 'startTime'
316+
type: NestedObject
317+
description: |
318+
Start time of the window in UTC time.
319+
required: true
320+
send_empty_value: true
321+
allow_empty_object: true
322+
properties:
323+
- name: 'hours'
324+
type: Integer
325+
description: |
326+
Hours of day in 24 hour format. Should be from 0 to 23.
327+
An API may choose to allow the value "24:00:00" for scenarios like business closing time.
328+
validation:
329+
function: 'validation.IntBetween(0,23)'
330+
- name: 'minutes'
331+
type: Integer
332+
description: |
333+
Minutes of hour of day. Must be from 0 to 59.
334+
validation:
335+
function: 'validation.IntBetween(0,59)'
336+
- name: 'seconds'
337+
type: Integer
338+
description: |
339+
Seconds of minutes of the time. Must normally be from 0 to 59.
340+
An API may allow the value 60 if it allows leap-seconds.
341+
validation:
342+
function: 'validation.IntBetween(0,60)'
343+
- name: 'nanos'
344+
type: Integer
345+
description: |
346+
Fractions of seconds in nanoseconds. Must be from 0 to 999,999,999.
347+
validation:
348+
function: 'validation.IntBetween(0,999999999)'
349+
- name: 'maintenanceSchedule'
350+
type: NestedObject
351+
description: Upcoming maintenance schedule.
352+
output: true
353+
properties:
354+
- name: 'startTime'
355+
type: String
356+
description: |
357+
The start time of any upcoming scheduled maintenance for this cluster.
358+
A timestamp in RFC3339 UTC "Zulu" format, with nanosecond
359+
resolution and up to nine fractional digits.
360+
output: true
361+
- name: 'endTime'
362+
type: String
363+
description: |
364+
The end time of any upcoming scheduled maintenance for this cluster.
365+
A timestamp in RFC3339 UTC "Zulu" format, with nanosecond
366+
resolution and up to nine fractional digits.
367+
output: true
368+
- name: 'scheduleDeadlineTime'
369+
type: String
370+
description: |
371+
The deadline that the maintenance schedule start time
372+
can not go beyond, including reschedule.
373+
A timestamp in RFC3339 UTC "Zulu" format, with nanosecond
374+
resolution and up to nine fractional digits.
375+
output: true
257376
- name: 'engineVersion'
258377
type: String
259378
description: "Optional. Engine version of the instance."

mmv1/templates/terraform/examples/memorystore_instance_basic.tf.tmpl

+11
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@ resource "google_memorystore_instance" "{{$.PrimaryResourceId}}" {
77
}
88
location = "us-central1"
99
deletion_protection_enabled = false
10+
maintenance_policy {
11+
weekly_maintenance_window {
12+
day = "MONDAY"
13+
start_time {
14+
hours = 1
15+
minutes = 0
16+
seconds = 0
17+
nanos = 0
18+
}
19+
}
20+
}
1021
depends_on = [
1122
google_network_connectivity_service_connection_policy.default
1223
]

mmv1/templates/terraform/examples/memorystore_instance_full.tf.tmpl

+11
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,17 @@ resource "google_memorystore_instance" "{{$.PrimaryResourceId}}" {
1717
mode = "SINGLE_ZONE"
1818
zone = "us-central1-b"
1919
}
20+
maintenance_policy {
21+
weekly_maintenance_window {
22+
day = "MONDAY"
23+
start_time {
24+
hours = 1
25+
minutes = 0
26+
seconds = 0
27+
nanos = 0
28+
}
29+
}
30+
}
2031
engine_version = "VALKEY_7_2"
2132
deletion_protection_enabled = false
2233
mode = "CLUSTER"

mmv1/third_party/terraform/services/memorystore/resource_memorystore_instance_test.go

+60-15
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func TestAccMemorystoreInstance_updateReplicaCount(t *testing.T) {
2222
Steps: []resource.TestStep{
2323
{
2424
// create instance with replica count 1
25-
Config: createOrUpdateMemorystoreInstance(&InstanceParams{name: name, replicaCount: 1, shardCount: 3, preventDestroy: true, zoneDistributionMode: "MULTI_ZONE", deletionProtectionEnabled: false}),
25+
Config: createOrUpdateMemorystoreInstance(&InstanceParams{name: name, replicaCount: 1, shardCount: 3, preventDestroy: true, zoneDistributionMode: "MULTI_ZONE", deletionProtectionEnabled: false, maintenanceDay: "MONDAY", maintenanceHours: 1, maintenanceMinutes: 0, maintenanceSeconds: 0, maintenanceNanos: 0}),
2626
},
2727
{
2828
ResourceName: "google_memorystore_instance.test",
@@ -31,7 +31,7 @@ func TestAccMemorystoreInstance_updateReplicaCount(t *testing.T) {
3131
},
3232
{
3333
// update replica count to 2
34-
Config: createOrUpdateMemorystoreInstance(&InstanceParams{name: name, replicaCount: 2, shardCount: 3, preventDestroy: true, zoneDistributionMode: "MULTI_ZONE", deletionProtectionEnabled: false}),
34+
Config: createOrUpdateMemorystoreInstance(&InstanceParams{name: name, replicaCount: 2, shardCount: 3, preventDestroy: true, zoneDistributionMode: "MULTI_ZONE", deletionProtectionEnabled: false, maintenanceDay: "MONDAY", maintenanceHours: 1, maintenanceMinutes: 0, maintenanceSeconds: 0, maintenanceNanos: 0}),
3535
},
3636
{
3737
ResourceName: "google_memorystore_instance.test",
@@ -40,7 +40,7 @@ func TestAccMemorystoreInstance_updateReplicaCount(t *testing.T) {
4040
},
4141
{
4242
// clean up the resource
43-
Config: createOrUpdateMemorystoreInstance(&InstanceParams{name: name, replicaCount: 2, shardCount: 3, preventDestroy: false, zoneDistributionMode: "MULTI_ZONE", deletionProtectionEnabled: false}),
43+
Config: createOrUpdateMemorystoreInstance(&InstanceParams{name: name, replicaCount: 2, shardCount: 3, preventDestroy: false, zoneDistributionMode: "MULTI_ZONE", deletionProtectionEnabled: false, maintenanceDay: "MONDAY", maintenanceHours: 1, maintenanceMinutes: 0, maintenanceSeconds: 0, maintenanceNanos: 0}),
4444
},
4545
},
4646
})
@@ -59,7 +59,7 @@ func TestAccMemorystoreInstance_updateShardCount(t *testing.T) {
5959
Steps: []resource.TestStep{
6060
{
6161
// create cluster with shard count 3
62-
Config: createOrUpdateMemorystoreInstance(&InstanceParams{name: name, replicaCount: 1, shardCount: 3, preventDestroy: true, zoneDistributionMode: "MULTI_ZONE", deletionProtectionEnabled: false}),
62+
Config: createOrUpdateMemorystoreInstance(&InstanceParams{name: name, replicaCount: 1, shardCount: 3, preventDestroy: true, zoneDistributionMode: "MULTI_ZONE", deletionProtectionEnabled: false, maintenanceDay: "MONDAY", maintenanceHours: 1, maintenanceMinutes: 0, maintenanceSeconds: 0, maintenanceNanos: 0}),
6363
},
6464
{
6565
ResourceName: "google_memorystore_instance.test",
@@ -68,7 +68,7 @@ func TestAccMemorystoreInstance_updateShardCount(t *testing.T) {
6868
},
6969
{
7070
// update shard count to 5
71-
Config: createOrUpdateMemorystoreInstance(&InstanceParams{name: name, replicaCount: 1, shardCount: 5, preventDestroy: true, zoneDistributionMode: "MULTI_ZONE", deletionProtectionEnabled: false}),
71+
Config: createOrUpdateMemorystoreInstance(&InstanceParams{name: name, replicaCount: 1, shardCount: 5, preventDestroy: true, zoneDistributionMode: "MULTI_ZONE", deletionProtectionEnabled: false, maintenanceDay: "MONDAY", maintenanceHours: 1, maintenanceMinutes: 0, maintenanceSeconds: 0, maintenanceNanos: 0}),
7272
},
7373
{
7474
ResourceName: "google_memorystore_instance.test",
@@ -77,7 +77,7 @@ func TestAccMemorystoreInstance_updateShardCount(t *testing.T) {
7777
},
7878
{
7979
// clean up the resource
80-
Config: createOrUpdateMemorystoreInstance(&InstanceParams{name: name, replicaCount: 1, shardCount: 5, preventDestroy: false, zoneDistributionMode: "MULTI_ZONE", deletionProtectionEnabled: false}),
80+
Config: createOrUpdateMemorystoreInstance(&InstanceParams{name: name, replicaCount: 1, shardCount: 5, preventDestroy: false, zoneDistributionMode: "MULTI_ZONE", deletionProtectionEnabled: false, maintenanceDay: "MONDAY", maintenanceHours: 1, maintenanceMinutes: 0, maintenanceSeconds: 0, maintenanceNanos: 0}),
8181
},
8282
},
8383
})
@@ -103,7 +103,12 @@ func TestAccMemorystoreInstance_updateRedisConfigs(t *testing.T) {
103103
engineConfigs: map[string]string{
104104
"maxmemory-policy": "volatile-ttl",
105105
},
106-
deletionProtectionEnabled: false}),
106+
deletionProtectionEnabled: false,
107+
maintenanceDay: "MONDAY",
108+
maintenanceHours: 1,
109+
maintenanceMinutes: 0,
110+
maintenanceSeconds: 0,
111+
maintenanceNanos: 0}),
107112
},
108113
{
109114
ResourceName: "google_memorystore_instance.test",
@@ -120,7 +125,12 @@ func TestAccMemorystoreInstance_updateRedisConfigs(t *testing.T) {
120125
"maxmemory-policy": "allkeys-lru",
121126
"maxmemory-clients": "90%",
122127
},
123-
deletionProtectionEnabled: false}),
128+
deletionProtectionEnabled: false,
129+
maintenanceDay: "MONDAY",
130+
maintenanceHours: 1,
131+
maintenanceMinutes: 0,
132+
maintenanceSeconds: 0,
133+
maintenanceNanos: 0}),
124134
},
125135
{
126136
ResourceName: "google_memorystore_instance.test",
@@ -137,7 +147,12 @@ func TestAccMemorystoreInstance_updateRedisConfigs(t *testing.T) {
137147
"maxmemory-policy": "allkeys-lru",
138148
"maxmemory-clients": "90%",
139149
},
140-
deletionProtectionEnabled: false}),
150+
deletionProtectionEnabled: false,
151+
maintenanceDay: "MONDAY",
152+
maintenanceHours: 1,
153+
maintenanceMinutes: 0,
154+
maintenanceSeconds: 0,
155+
maintenanceNanos: 0}),
141156
},
142157
},
143158
})
@@ -161,7 +176,11 @@ func TestAccMemorystoreInstance_updateDeletionProtection(t *testing.T) {
161176
shardCount: 3,
162177
zoneDistributionMode: "MULTI_ZONE",
163178
deletionProtectionEnabled: true,
164-
}),
179+
maintenanceDay: "MONDAY",
180+
maintenanceHours: 1,
181+
maintenanceMinutes: 0,
182+
maintenanceSeconds: 0,
183+
maintenanceNanos: 0}),
165184
},
166185
{
167186
ResourceName: "google_memorystore_instance.test",
@@ -175,7 +194,11 @@ func TestAccMemorystoreInstance_updateDeletionProtection(t *testing.T) {
175194
shardCount: 3,
176195
zoneDistributionMode: "MULTI_ZONE",
177196
deletionProtectionEnabled: false,
178-
}),
197+
maintenanceDay: "MONDAY",
198+
maintenanceHours: 1,
199+
maintenanceMinutes: 0,
200+
maintenanceSeconds: 0,
201+
maintenanceNanos: 0}),
179202
},
180203
{
181204
ResourceName: "google_memorystore_instance.test",
@@ -285,7 +308,7 @@ func TestAccMemorystoreInstance_updatePersistence(t *testing.T) {
285308
Steps: []resource.TestStep{
286309
{
287310
// create instance with AOF enabled
288-
Config: createOrUpdateMemorystoreInstance(&InstanceParams{name: name, replicaCount: 0, shardCount: 3, preventDestroy: true, zoneDistributionMode: "MULTI_ZONE", persistenceMode: "AOF", deletionProtectionEnabled: false}),
311+
Config: createOrUpdateMemorystoreInstance(&InstanceParams{name: name, replicaCount: 0, shardCount: 3, preventDestroy: true, zoneDistributionMode: "MULTI_ZONE", persistenceMode: "AOF", deletionProtectionEnabled: false, maintenanceDay: "MONDAY", maintenanceHours: 1, maintenanceMinutes: 0, maintenanceSeconds: 0, maintenanceNanos: 0}),
289312
},
290313
{
291314
ResourceName: "google_memorystore_instance.test",
@@ -294,7 +317,7 @@ func TestAccMemorystoreInstance_updatePersistence(t *testing.T) {
294317
},
295318
{
296319
// update persitence to RDB
297-
Config: createOrUpdateMemorystoreInstance(&InstanceParams{name: name, replicaCount: 0, shardCount: 3, preventDestroy: true, zoneDistributionMode: "MULTI_ZONE", persistenceMode: "RDB", deletionProtectionEnabled: false}),
320+
Config: createOrUpdateMemorystoreInstance(&InstanceParams{name: name, replicaCount: 0, shardCount: 3, preventDestroy: true, zoneDistributionMode: "MULTI_ZONE", persistenceMode: "RDB", deletionProtectionEnabled: false, maintenanceDay: "MONDAY", maintenanceHours: 1, maintenanceMinutes: 0, maintenanceSeconds: 0, maintenanceNanos: 0}),
298321
},
299322
{
300323
ResourceName: "google_memorystore_instance.test",
@@ -303,7 +326,7 @@ func TestAccMemorystoreInstance_updatePersistence(t *testing.T) {
303326
},
304327
{
305328
// clean up the resource
306-
Config: createOrUpdateMemorystoreInstance(&InstanceParams{name: name, replicaCount: 0, shardCount: 3, preventDestroy: false, zoneDistributionMode: "MULTI_ZONE", persistenceMode: "RDB", deletionProtectionEnabled: false}),
329+
Config: createOrUpdateMemorystoreInstance(&InstanceParams{name: name, replicaCount: 0, shardCount: 3, preventDestroy: false, zoneDistributionMode: "MULTI_ZONE", persistenceMode: "RDB", deletionProtectionEnabled: false, maintenanceDay: "MONDAY", maintenanceHours: 1, maintenanceMinutes: 0, maintenanceSeconds: 0, maintenanceNanos: 0}),
307330
},
308331
},
309332
})
@@ -320,6 +343,11 @@ type InstanceParams struct {
320343
zone string
321344
deletionProtectionEnabled bool
322345
persistenceMode string
346+
maintenanceDay string
347+
maintenanceHours int
348+
maintenanceMinutes int
349+
maintenanceSeconds int
350+
maintenanceNanos int
323351
engineVersion string
324352
}
325353

@@ -345,6 +373,22 @@ func createOrUpdateMemorystoreInstance(params *InstanceParams) string {
345373
}
346374
`, params.zoneDistributionMode, params.zone)
347375
}
376+
maintenancePolicyBlock := ``
377+
if params.maintenanceDay != "" {
378+
maintenancePolicyBlock = fmt.Sprintf(`
379+
maintenance_policy {
380+
weekly_maintenance_window {
381+
day = "%s"
382+
start_time {
383+
hours = %d
384+
minutes = %d
385+
seconds = %d
386+
nanos = %d
387+
}
388+
}
389+
}
390+
`, params.maintenanceDay, params.maintenanceHours, params.maintenanceMinutes, params.maintenanceSeconds, params.maintenanceNanos)
391+
}
348392
persistenceBlock := ``
349393
if params.persistenceMode != "" {
350394
persistenceBlock = fmt.Sprintf(`
@@ -370,6 +414,7 @@ resource "google_memorystore_instance" "test" {
370414
%s
371415
}
372416
%s
417+
%s
373418
%s
374419
depends_on = [
375420
google_network_connectivity_service_connection_policy.default
@@ -402,5 +447,5 @@ resource "google_compute_network" "producer_net" {
402447
403448
data "google_project" "project" {
404449
}
405-
`, params.name, params.replicaCount, params.shardCount, params.nodeType, params.deletionProtectionEnabled, params.engineVersion, strBuilder.String(), zoneDistributionConfigBlock, persistenceBlock, lifecycleBlock, params.name, params.name, params.name)
450+
`, params.name, params.replicaCount, params.shardCount, params.nodeType, params.deletionProtectionEnabled, params.engineVersion, strBuilder.String(), zoneDistributionConfigBlock, maintenancePolicyBlock, persistenceBlock, lifecycleBlock, params.name, params.name, params.name)
406451
}

0 commit comments

Comments
 (0)