Skip to content

Commit 32698e5

Browse files
Add Resource v1 SCC Findings Export to BQ Folder Config (#11587)
[upstream:6d67e349fe1f372cb7cb1bc1f720f858dab78187] Signed-off-by: Modular Magician <[email protected]>
1 parent 750b702 commit 32698e5

6 files changed

+929
-2
lines changed

.changelog/11587.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:new-resource
2+
`google_scc_folder_scc_big_query_export`
3+
```

google-beta/provider/provider_mmv1_resources.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -481,9 +481,9 @@ var handwrittenIAMDatasources = map[string]*schema.Resource{
481481
}
482482

483483
// Resources
484-
// Generated resources: 523
484+
// Generated resources: 524
485485
// Generated IAM resources: 291
486-
// Total generated resources: 814
486+
// Total generated resources: 815
487487
var generatedResources = map[string]*schema.Resource{
488488
"google_folder_access_approval_settings": accessapproval.ResourceAccessApprovalFolderSettings(),
489489
"google_organization_access_approval_settings": accessapproval.ResourceAccessApprovalOrganizationSettings(),
@@ -1171,6 +1171,7 @@ var generatedResources = map[string]*schema.Resource{
11711171
"google_scc_event_threat_detection_custom_module": securitycenter.ResourceSecurityCenterEventThreatDetectionCustomModule(),
11721172
"google_scc_folder_custom_module": securitycenter.ResourceSecurityCenterFolderCustomModule(),
11731173
"google_scc_folder_notification_config": securitycenter.ResourceSecurityCenterFolderNotificationConfig(),
1174+
"google_scc_folder_scc_big_query_export": securitycenter.ResourceSecurityCenterFolderSccBigQueryExport(),
11741175
"google_scc_mute_config": securitycenter.ResourceSecurityCenterMuteConfig(),
11751176
"google_scc_notification_config": securitycenter.ResourceSecurityCenterNotificationConfig(),
11761177
"google_scc_organization_custom_module": securitycenter.ResourceSecurityCenterOrganizationCustomModule(),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
// Copyright (c) HashiCorp, Inc.
2+
// SPDX-License-Identifier: MPL-2.0
3+
package securitycenter_test
4+
5+
import (
6+
"testing"
7+
8+
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
9+
"github.com/hashicorp/terraform-plugin-testing/plancheck"
10+
"github.com/hashicorp/terraform-provider-google-beta/google-beta/acctest"
11+
"github.com/hashicorp/terraform-provider-google-beta/google-beta/envvar"
12+
)
13+
14+
func TestAccSecurityCenterFolderBigQueryExportConfig_update(t *testing.T) {
15+
t.Parallel()
16+
17+
randomSuffix := acctest.RandString(t, 10)
18+
dataset_id := "tf_test_" + randomSuffix
19+
dataset_id2 := dataset_id + "2"
20+
orgID := envvar.GetTestOrgFromEnv(t)
21+
22+
context := map[string]interface{}{
23+
"org_id": orgID,
24+
"random_suffix": randomSuffix,
25+
"dataset_id": dataset_id,
26+
"dataset_id2": dataset_id2,
27+
"big_query_export_id": "tf-test-export-" + randomSuffix,
28+
"folder_name": "tf-test-folder-name-" + randomSuffix,
29+
}
30+
31+
acctest.VcrTest(t, resource.TestCase{
32+
PreCheck: func() { acctest.AccTestPreCheck(t) },
33+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
34+
ExternalProviders: map[string]resource.ExternalProvider{
35+
"time": {},
36+
},
37+
Steps: []resource.TestStep{
38+
{
39+
Config: testAccSecurityCenterFolderBigQueryExportConfig_basic(context),
40+
},
41+
{
42+
ResourceName: "google_scc_folder_scc_big_query_export.default",
43+
ImportState: true,
44+
ImportStateVerify: true,
45+
ImportStateVerifyIgnore: []string{"update_time"},
46+
},
47+
{
48+
Config: testAccSecurityCenterFolderBigQueryExportConfig_update(context),
49+
ConfigPlanChecks: resource.ConfigPlanChecks{
50+
PreApply: []plancheck.PlanCheck{
51+
plancheck.ExpectResourceAction("google_scc_folder_scc_big_query_export.default", plancheck.ResourceActionUpdate),
52+
},
53+
},
54+
},
55+
{
56+
ResourceName: "google_scc_folder_scc_big_query_export.default",
57+
ImportState: true,
58+
ImportStateVerify: true,
59+
ImportStateVerifyIgnore: []string{"update_time"},
60+
},
61+
},
62+
})
63+
}
64+
65+
func testAccSecurityCenterFolderBigQueryExportConfig_basic(context map[string]interface{}) string {
66+
return acctest.Nprintf(`
67+
resource "google_folder" "folder" {
68+
parent = "organizations/%{org_id}"
69+
display_name = "%{folder_name}"
70+
deletion_protection = false
71+
}
72+
resource "google_bigquery_dataset" "default" {
73+
dataset_id = "%{dataset_id}"
74+
friendly_name = "test"
75+
description = "This is a test description"
76+
location = "US"
77+
default_table_expiration_ms = 3600000
78+
default_partition_expiration_ms = null
79+
labels = {
80+
env = "default"
81+
}
82+
lifecycle {
83+
ignore_changes = [default_partition_expiration_ms]
84+
}
85+
}
86+
resource "time_sleep" "wait_1_minute" {
87+
depends_on = [google_bigquery_dataset.default]
88+
create_duration = "3m"
89+
}
90+
resource "google_scc_folder_scc_big_query_export" "default" {
91+
big_query_export_id = "%{big_query_export_id}"
92+
folder = google_folder.folder.folder_id
93+
dataset = google_bigquery_dataset.default.id
94+
description = "Cloud Security Command Center Findings Big Query Export Config"
95+
filter = "state=\"ACTIVE\" AND NOT mute=\"MUTED\""
96+
97+
depends_on = [time_sleep.wait_1_minute]
98+
}
99+
100+
`, context)
101+
}
102+
103+
func testAccSecurityCenterFolderBigQueryExportConfig_update(context map[string]interface{}) string {
104+
return acctest.Nprintf(`
105+
resource "google_folder" "folder" {
106+
parent = "organizations/%{org_id}"
107+
display_name = "%{folder_name}"
108+
deletion_protection = false
109+
}
110+
resource "google_bigquery_dataset" "default" {
111+
dataset_id = "%{dataset_id2}"
112+
friendly_name = "test"
113+
description = "This is a test description"
114+
location = "US"
115+
default_table_expiration_ms = 3600000
116+
default_partition_expiration_ms = null
117+
labels = {
118+
env = "default"
119+
}
120+
lifecycle {
121+
ignore_changes = [default_partition_expiration_ms]
122+
}
123+
}
124+
resource "google_scc_folder_scc_big_query_export" "default" {
125+
big_query_export_id = "%{big_query_export_id}"
126+
folder = google_folder.folder.folder_id
127+
dataset = google_bigquery_dataset.default.id
128+
description = "SCC Findings Big Query Export Update"
129+
filter = ""
130+
}
131+
132+
`, context)
133+
}

0 commit comments

Comments
 (0)