-
Notifications
You must be signed in to change notification settings - Fork 262
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Resource V2 SCC Findings Export to Big Query Folder Config (#1151…
…7) (#8079) [upstream:68282ea6e38b34150888bdff9bae1a27c73bb7f9] Signed-off-by: Modular Magician <[email protected]>
- Loading branch information
1 parent
3e4b099
commit 06cab40
Showing
6 changed files
with
972 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_v2_folder_scc_big_query_exports` | ||
``` |
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
159 changes: 159 additions & 0 deletions
159
google-beta/services/securitycenterv2/resource_scc_v2_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,159 @@ | ||
// Copyright (c) HashiCorp, Inc. | ||
// SPDX-License-Identifier: MPL-2.0 | ||
package securitycenterv2_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-testing/helper/resource" | ||
"github.com/hashicorp/terraform-provider-google-beta/google-beta/acctest" | ||
"github.com/hashicorp/terraform-provider-google-beta/google-beta/envvar" | ||
) | ||
|
||
func TestAccSecurityCenterV2FolderBigQueryExportConfig_basic(t *testing.T) { | ||
t.Parallel() | ||
|
||
randomSuffix := acctest.RandString(t, 10) | ||
dataset_id := "tf_test_" + randomSuffix | ||
orgID := envvar.GetTestOrgFromEnv(t) | ||
|
||
context := map[string]interface{}{ | ||
"org_id": orgID, | ||
"random_suffix": randomSuffix, | ||
"dataset_id": dataset_id, | ||
"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{ | ||
"random": {}, | ||
"time": {}, | ||
}, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccSecurityCenterV2FolderBigQueryExportConfig_basic(context), | ||
}, | ||
{ | ||
ResourceName: "google_scc_v2_folder_scc_big_query_exports.default", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"update_time"}, | ||
}, | ||
{ | ||
Config: testAccSecurityCenterV2FolderBigQueryExportConfig_update(context), | ||
}, | ||
{ | ||
ResourceName: "google_scc_v2_folder_scc_big_query_exports.default", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"update_time"}, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccSecurityCenterV2FolderBigQueryExportConfig_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_v2_folder_scc_big_query_exports" "default" { | ||
big_query_export_id = "%{big_query_export_id}" | ||
folder = google_folder.folder.folder_id | ||
dataset = google_bigquery_dataset.default.id | ||
location = "global" | ||
description = "Cloud Security Command Center Findings Big Query Export Config" | ||
filter = "state=\"ACTIVE\" AND NOT mute=\"MUTED\"" | ||
lifecycle { | ||
ignore_changes = [name] | ||
} | ||
depends_on = [time_sleep.wait_1_minute] | ||
} | ||
resource "time_sleep" "wait_for_cleanup" { | ||
create_duration = "3m" | ||
depends_on = [google_scc_v2_folder_scc_big_query_exports.default] | ||
} | ||
`, context) | ||
} | ||
|
||
func testAccSecurityCenterV2FolderBigQueryExportConfig_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_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 "google_scc_v2_folder_scc_big_query_exports" "default" { | ||
big_query_export_id = "%{big_query_export_id}" | ||
folder = google_folder.folder.folder_id | ||
dataset = google_bigquery_dataset.default.id | ||
location = "global" | ||
description = "SCC Findings Big Query Export Update" | ||
filter = "state=\"ACTIVE\" AND NOT mute=\"MUTED\"" | ||
lifecycle { | ||
ignore_changes = [name] | ||
} | ||
} | ||
resource "time_sleep" "wait_for_cleanup" { | ||
create_duration = "3m" | ||
depends_on = [google_scc_v2_folder_scc_big_query_exports.default] | ||
} | ||
`, context) | ||
} |
Oops, something went wrong.