@@ -46,7 +46,137 @@ func TestAccMemorystoreInstance_updateReplicaCount(t *testing.T) {
46
46
})
47
47
}
48
48
49
- // Validate that shard count is updated for the instance
49
+ func TestAccMemorystoreInstance_automatedBackupConfig (t * testing.T ) {
50
+ t .Parallel ()
51
+
52
+ context := map [string ]interface {}{
53
+ "random_suffix" : acctest .RandString (t , 10 ),
54
+ }
55
+
56
+ acctest .VcrTest (t , resource.TestCase {
57
+ PreCheck : func () { acctest .AccTestPreCheck (t ) },
58
+ ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories (t ),
59
+ CheckDestroy : testAccCheckMemorystoreInstanceDestroyProducer (t ),
60
+ Steps : []resource.TestStep {
61
+ {
62
+ Config : testAccMemorystoreInstance_automatedBackupConfig (context ),
63
+ },
64
+ {
65
+ ResourceName : "google_memorystore_instance.test_abc" ,
66
+ ImportState : true ,
67
+ ImportStateVerify : true ,
68
+ },
69
+ {
70
+ Config : testAccMemorystoreInstance_automatedBackupConfigWithout (context ),
71
+ },
72
+ {
73
+ ResourceName : "google_memorystore_instance.test_abc" ,
74
+ ImportState : true ,
75
+ ImportStateVerify : true ,
76
+ },
77
+ },
78
+ })
79
+ }
80
+
81
+ func testAccMemorystoreInstance_automatedBackupConfig (context map [string ]interface {}) string {
82
+ return acctest .Nprintf (`
83
+ // Primary instance
84
+ resource "google_memorystore_instance" "test_abc" {
85
+ instance_id = "tf-test-instance-abc-%{random_suffix}"
86
+ shard_count = 1
87
+ location = "us-central1"
88
+ replica_count = 0
89
+ node_type = "SHARED_CORE_NANO"
90
+ deletion_protection_enabled = false
91
+ desired_psc_auto_connections {
92
+ network = google_compute_network.primary_producer_net.id
93
+ project_id = data.google_project.project.project_id
94
+ }
95
+ automated_backup_config {
96
+ retention = "259200s"
97
+ fixed_frequency_schedule {
98
+ start_time {
99
+ hours = 20
100
+ }
101
+ }
102
+ }
103
+ depends_on = [ google_network_connectivity_service_connection_policy.primary_policy ]
104
+ }
105
+
106
+ resource "google_network_connectivity_service_connection_policy" "primary_policy" {
107
+ name = "tf-test-abc-policy-%{random_suffix}"
108
+ location = "us-central1"
109
+ service_class = "gcp-memorystore"
110
+ description = "my basic service connection policy"
111
+ network = google_compute_network.primary_producer_net.id
112
+ psc_config {
113
+ subnetworks = [google_compute_subnetwork.primary_producer_subnet.id]
114
+ }
115
+ }
116
+
117
+ resource "google_compute_subnetwork" "primary_producer_subnet" {
118
+ name = "tf-test-abc-%{random_suffix}"
119
+ ip_cidr_range = "10.0.4.0/29"
120
+ region = "us-central1"
121
+ network = google_compute_network.primary_producer_net.id
122
+ }
123
+
124
+ resource "google_compute_network" "primary_producer_net" {
125
+ name = "tf-test-abc-net-%{random_suffix}"
126
+ auto_create_subnetworks = false
127
+ }
128
+
129
+ data "google_project" "project" {
130
+ }
131
+ ` , context )
132
+ }
133
+
134
+ func testAccMemorystoreInstance_automatedBackupConfigWithout (context map [string ]interface {}) string {
135
+ return acctest .Nprintf (`
136
+ // Primary instance
137
+ resource "google_memorystore_instance" "test_abc" {
138
+ instance_id = "tf-test-instance-abc-%{random_suffix}"
139
+ shard_count = 1
140
+ location = "us-central1"
141
+ replica_count = 0
142
+ node_type = "SHARED_CORE_NANO"
143
+ deletion_protection_enabled = false
144
+ desired_psc_auto_connections {
145
+ network = google_compute_network.primary_producer_net.id
146
+ project_id = data.google_project.project.project_id
147
+ }
148
+ depends_on = [ google_network_connectivity_service_connection_policy.primary_policy ]
149
+ }
150
+
151
+ resource "google_network_connectivity_service_connection_policy" "primary_policy" {
152
+ name = "tf-test-abc-policy-%{random_suffix}"
153
+ location = "us-central1"
154
+ service_class = "gcp-memorystore"
155
+ description = "my basic service connection policy"
156
+ network = google_compute_network.primary_producer_net.id
157
+ psc_config {
158
+ subnetworks = [google_compute_subnetwork.primary_producer_subnet.id]
159
+ }
160
+ }
161
+
162
+ resource "google_compute_subnetwork" "primary_producer_subnet" {
163
+ name = "tf-test-abc-%{random_suffix}"
164
+ ip_cidr_range = "10.0.4.0/29"
165
+ region = "us-central1"
166
+ network = google_compute_network.primary_producer_net.id
167
+ }
168
+
169
+ resource "google_compute_network" "primary_producer_net" {
170
+ name = "tf-test-abc-net-%{random_suffix}"
171
+ auto_create_subnetworks = false
172
+ }
173
+
174
+ data "google_project" "project" {
175
+ }
176
+ ` , context )
177
+ }
178
+
179
+ // Validate that shard count is updated for the cluster
50
180
func TestAccMemorystoreInstance_updateShardCount (t * testing.T ) {
51
181
t .Parallel ()
52
182
0 commit comments