-
Notifications
You must be signed in to change notification settings - Fork 266
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed name of SCC v2 org bigquery export resource (#11661) (#8166)
[upstream:b073e8765bbbb4d8878af5fa13eb1d9a9fb71f35] Signed-off-by: Modular Magician <[email protected]>
- Loading branch information
1 parent
39cff5e
commit 541c568
Showing
9 changed files
with
983 additions
and
9 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:deprecation | ||
securitycenterv2: deprecated `google_scc_v2_organization_scc_big_query_exports`. Use `google_scc_v2_organization_scc_big_query_export` instead. | ||
``` |
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
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
139 changes: 139 additions & 0 deletions
139
...a/services/securitycenterv2/resource_scc_v2_organization_big_query_exports_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,139 @@ | ||
// Copyright (c) HashiCorp, Inc. | ||
// SPDX-License-Identifier: MPL-2.0 | ||
package securitycenterv2_test | ||
|
||
import ( | ||
"fmt" | ||
"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 TestAccSecurityCenterV2OrganizationBigQueryExportsConfig_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, | ||
"name": fmt.Sprintf("organizations/%s/locations/global/bigQueryExports/%s", | ||
orgID, "tf-test-export-"+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: testAccSecurityCenterV2OrganizationBigQueryExportsConfig_basic(context), | ||
}, | ||
{ | ||
ResourceName: "google_scc_v2_organization_scc_big_query_exports.default", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"update_time"}, | ||
}, | ||
{ | ||
Config: testAccSecurityCenterV2OrganizationBigQueryExportsConfig_update(context), | ||
}, | ||
{ | ||
ResourceName: "google_scc_v2_organization_scc_big_query_exports.default", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"update_time"}, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccSecurityCenterV2OrganizationBigQueryExportsConfig_basic(context map[string]interface{}) string { | ||
return acctest.Nprintf(` | ||
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_organization_scc_big_query_exports" "default" { | ||
name = "%{name}" | ||
big_query_export_id = "%{big_query_export_id}" | ||
organization = "%{org_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\"" | ||
depends_on = [time_sleep.wait_1_minute] | ||
} | ||
resource "time_sleep" "wait_for_cleanup" { | ||
create_duration = "3m" | ||
depends_on = [google_scc_v2_organization_scc_big_query_exports.default] | ||
} | ||
`, context) | ||
} | ||
|
||
func testAccSecurityCenterV2OrganizationBigQueryExportsConfig_update(context map[string]interface{}) string { | ||
return acctest.Nprintf(` | ||
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_organization_scc_big_query_exports" "default" { | ||
name = "%{name}" | ||
big_query_export_id = "%{big_query_export_id}" | ||
organization = "%{org_id}" | ||
dataset = google_bigquery_dataset.default.id | ||
location = "global" | ||
description = "SCC Findings Big Query Export Update" | ||
filter = "state=\"ACTIVE\" AND NOT mute=\"MUTED\"" | ||
} | ||
resource "time_sleep" "wait_for_cleanup" { | ||
create_duration = "3m" | ||
depends_on = [google_scc_v2_organization_scc_big_query_exports.default] | ||
} | ||
`, context) | ||
} |
Oops, something went wrong.