Skip to content

Commit 416e04c

Browse files
Add periodic export configuration to Instance.yaml (#15759)
Co-authored-by: Scott Suarez <[email protected]>
1 parent ed43b8c commit 416e04c

File tree

2 files changed

+147
-0
lines changed

2 files changed

+147
-0
lines changed

mmv1/products/looker/Instance.yaml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,58 @@ properties:
426426
The client secret for the Oauth config.
427427
required: true
428428
# Oauth Object - End
429+
# Periodic Export Config Object
430+
- name: 'periodicExportConfig'
431+
type: NestedObject
432+
description: |
433+
Configuration for periodic export.
434+
update_mask_fields:
435+
- 'periodic_export_config'
436+
properties:
437+
- name: 'kmsKey'
438+
type: String
439+
description: |
440+
Name of the CMEK key in KMS.
441+
Format:
442+
projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}
443+
required: true
444+
- name: 'gcsUri'
445+
type: String
446+
description: |
447+
Cloud Storage bucket URI for periodic export.
448+
Format: gs://{bucket_name}
449+
required: true
450+
- name: 'startTime'
451+
type: NestedObject
452+
description: |
453+
Time in UTC to start the periodic export job.
454+
required: true
455+
properties:
456+
- name: 'hours'
457+
type: Integer
458+
description: |
459+
Hours of day in 24 hour format. Should be from 0 to 23.
460+
validation:
461+
function: 'validation.IntBetween(0,23)'
462+
- name: 'minutes'
463+
type: Integer
464+
description: |
465+
Minutes of hour of day. Must be from 0 to 59.
466+
validation:
467+
function: 'validation.IntBetween(0,60)'
468+
- name: 'seconds'
469+
type: Integer
470+
description: |
471+
Seconds of minutes of the time. Must normally be from 0 to 59.
472+
validation:
473+
function: 'validation.IntBetween(0,60)'
474+
- name: 'nanos'
475+
type: Integer
476+
description: |
477+
Fractions of seconds in nanoseconds. Must be from 0 to 999,999,999.
478+
validation:
479+
function: 'validation.IntBetween(0,999999999)'
480+
# Periodic Export Config Object - End
429481
- name: 'platformEdition'
430482
type: Enum
431483
description: |

mmv1/third_party/terraform/services/looker/resource_looker_instance_test.go

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,98 @@ resource "google_looker_instance" "test" {
127127
}
128128
`, context["random_suffix"])
129129
}
130+
131+
func TestAccLookerInstance_updatePeriodicExport(t *testing.T) {
132+
t.Parallel()
133+
134+
context := map[string]interface{}{
135+
"random_suffix": acctest.RandString(t, 10),
136+
}
137+
138+
acctest.BootstrapIamMembers(t, []acctest.IamMember{
139+
{
140+
// For writing/managing the export files in GCS
141+
Member: "serviceAccount:service-{project_number}@gcp-sa-looker.iam.gserviceaccount.com",
142+
Role: "roles/storage.objectAdmin",
143+
},
144+
{
145+
// For using the KMS key to encrypt the export (Required for periodic_export_config)
146+
Member: "serviceAccount:service-{project_number}@gcp-sa-looker.iam.gserviceaccount.com",
147+
Role: "roles/cloudkms.cryptoKeyEncrypterDecrypter",
148+
},
149+
})
150+
151+
acctest.VcrTest(t, resource.TestCase{
152+
PreCheck: func() { acctest.AccTestPreCheck(t) },
153+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
154+
Steps: []resource.TestStep{
155+
{
156+
Config: testAccLookerInstance_basic(context),
157+
},
158+
{
159+
ResourceName: "google_looker_instance.test",
160+
ImportState: true,
161+
ImportStateVerify: true,
162+
ImportStateVerifyIgnore: []string{"oauth_config", "region"},
163+
},
164+
{
165+
Config: testAccLookerInstance_periodicExport(context),
166+
},
167+
{
168+
ResourceName: "google_looker_instance.test",
169+
ImportState: true,
170+
ImportStateVerify: true,
171+
ImportStateVerifyIgnore: []string{"oauth_config", "region"},
172+
},
173+
},
174+
})
175+
}
176+
177+
func testAccLookerInstance_periodicExport(context map[string]interface{}) string {
178+
return fmt.Sprintf(`
179+
resource "google_storage_bucket" "export" {
180+
name = "tf-test-looker-export-%s"
181+
location = "US"
182+
force_destroy = true
183+
}
184+
185+
resource "google_kms_key_ring" "keyring" {
186+
name = "tf-test-looker-keyring-%s"
187+
location = "us-west1"
188+
}
189+
190+
resource "google_kms_crypto_key" "key" {
191+
name = "tf-test-looker-key-%s"
192+
key_ring = google_kms_key_ring.keyring.id
193+
}
194+
195+
resource "google_looker_instance" "test" {
196+
name = "tf-test-looker-%s"
197+
platform_edition = "LOOKER_CORE_ENTERPRISE_ANNUAL"
198+
region = "us-central1"
199+
public_ip_enabled = true
200+
psc_enabled = true
201+
202+
psc_config {
203+
allowed_vpcs = []
204+
}
205+
206+
periodic_export_config {
207+
gcs_uri = "gs://${google_storage_bucket.export.name}"
208+
kms_key = google_kms_crypto_key.key.id
209+
210+
start_time {
211+
hours = 12
212+
minutes = 30
213+
seconds = 0
214+
nanos = 0
215+
}
216+
}
217+
218+
oauth_config {
219+
client_id = "my-client-id"
220+
client_secret = "my-client-secret"
221+
}
222+
}
223+
`, context["random_suffix"], context["random_suffix"], context["random_suffix"], context["random_suffix"])
224+
}

0 commit comments

Comments
 (0)