-
Notifications
You must be signed in to change notification settings - Fork 264
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Resource v1 SCC Findings Export to BQ Folder Config (#11587) (#8183)
[upstream:6d67e349fe1f372cb7cb1bc1f720f858dab78187] Signed-off-by: Modular Magician <[email protected]>
- Loading branch information
1 parent
750b702
commit da8f625
Showing
6 changed files
with
929 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:new-resource | ||
`google_scc_folder_scc_big_query_export` | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
133 changes: 133 additions & 0 deletions
133
google-beta/services/securitycenter/resource_scc_folder_big_query_export_config_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
// Copyright (c) HashiCorp, Inc. | ||
// SPDX-License-Identifier: MPL-2.0 | ||
package securitycenter_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-testing/helper/resource" | ||
"github.com/hashicorp/terraform-plugin-testing/plancheck" | ||
"github.com/hashicorp/terraform-provider-google-beta/google-beta/acctest" | ||
"github.com/hashicorp/terraform-provider-google-beta/google-beta/envvar" | ||
) | ||
|
||
func TestAccSecurityCenterFolderBigQueryExportConfig_update(t *testing.T) { | ||
t.Parallel() | ||
|
||
randomSuffix := acctest.RandString(t, 10) | ||
dataset_id := "tf_test_" + randomSuffix | ||
dataset_id2 := dataset_id + "2" | ||
orgID := envvar.GetTestOrgFromEnv(t) | ||
|
||
context := map[string]interface{}{ | ||
"org_id": orgID, | ||
"random_suffix": randomSuffix, | ||
"dataset_id": dataset_id, | ||
"dataset_id2": dataset_id2, | ||
"big_query_export_id": "tf-test-export-" + randomSuffix, | ||
"folder_name": "tf-test-folder-name-" + randomSuffix, | ||
} | ||
|
||
acctest.VcrTest(t, resource.TestCase{ | ||
PreCheck: func() { acctest.AccTestPreCheck(t) }, | ||
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), | ||
ExternalProviders: map[string]resource.ExternalProvider{ | ||
"time": {}, | ||
}, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccSecurityCenterFolderBigQueryExportConfig_basic(context), | ||
}, | ||
{ | ||
ResourceName: "google_scc_folder_scc_big_query_export.default", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"update_time"}, | ||
}, | ||
{ | ||
Config: testAccSecurityCenterFolderBigQueryExportConfig_update(context), | ||
ConfigPlanChecks: resource.ConfigPlanChecks{ | ||
PreApply: []plancheck.PlanCheck{ | ||
plancheck.ExpectResourceAction("google_scc_folder_scc_big_query_export.default", plancheck.ResourceActionUpdate), | ||
}, | ||
}, | ||
}, | ||
{ | ||
ResourceName: "google_scc_folder_scc_big_query_export.default", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"update_time"}, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccSecurityCenterFolderBigQueryExportConfig_basic(context map[string]interface{}) string { | ||
return acctest.Nprintf(` | ||
resource "google_folder" "folder" { | ||
parent = "organizations/%{org_id}" | ||
display_name = "%{folder_name}" | ||
deletion_protection = false | ||
} | ||
resource "google_bigquery_dataset" "default" { | ||
dataset_id = "%{dataset_id}" | ||
friendly_name = "test" | ||
description = "This is a test description" | ||
location = "US" | ||
default_table_expiration_ms = 3600000 | ||
default_partition_expiration_ms = null | ||
labels = { | ||
env = "default" | ||
} | ||
lifecycle { | ||
ignore_changes = [default_partition_expiration_ms] | ||
} | ||
} | ||
resource "time_sleep" "wait_1_minute" { | ||
depends_on = [google_bigquery_dataset.default] | ||
create_duration = "3m" | ||
} | ||
resource "google_scc_folder_scc_big_query_export" "default" { | ||
big_query_export_id = "%{big_query_export_id}" | ||
folder = google_folder.folder.folder_id | ||
dataset = google_bigquery_dataset.default.id | ||
description = "Cloud Security Command Center Findings Big Query Export Config" | ||
filter = "state=\"ACTIVE\" AND NOT mute=\"MUTED\"" | ||
depends_on = [time_sleep.wait_1_minute] | ||
} | ||
`, context) | ||
} | ||
|
||
func testAccSecurityCenterFolderBigQueryExportConfig_update(context map[string]interface{}) string { | ||
return acctest.Nprintf(` | ||
resource "google_folder" "folder" { | ||
parent = "organizations/%{org_id}" | ||
display_name = "%{folder_name}" | ||
deletion_protection = false | ||
} | ||
resource "google_bigquery_dataset" "default" { | ||
dataset_id = "%{dataset_id2}" | ||
friendly_name = "test" | ||
description = "This is a test description" | ||
location = "US" | ||
default_table_expiration_ms = 3600000 | ||
default_partition_expiration_ms = null | ||
labels = { | ||
env = "default" | ||
} | ||
lifecycle { | ||
ignore_changes = [default_partition_expiration_ms] | ||
} | ||
} | ||
resource "google_scc_folder_scc_big_query_export" "default" { | ||
big_query_export_id = "%{big_query_export_id}" | ||
folder = google_folder.folder.folder_id | ||
dataset = google_bigquery_dataset.default.id | ||
description = "SCC Findings Big Query Export Update" | ||
filter = "" | ||
} | ||
`, context) | ||
} |
Oops, something went wrong.