Skip to content

Commit

Permalink
Add deletion_protection field to Folders resource (#11293) (#7903)
Browse files Browse the repository at this point in the history
[upstream:a31848e911392a82ae25e89c4bac87c6275541fc]

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Aug 7, 2024
1 parent bd71dbe commit 794d80a
Show file tree
Hide file tree
Showing 47 changed files with 161 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .changelog/11293.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:breaking-change
google_folders: added `deletion_protection` field to `folders` to make deleting them require an explicit intent. `folder` resources now cannot be destroyed unless `deletion_protection = false` is set for the resource.
```
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func testAccDataSourceAccessApprovalFolderServiceAccount_basic(context map[strin
resource "google_folder" "my_folder" {
display_name = "tf-test-my-folder%{random_suffix}"
parent = "organizations/%{org_id}"
deletion_protection = false
}
# Wait after folder creation to limit eventual consistency errors.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ func testAccAccessApprovalFolderSettings_full(context map[string]interface{}) st
resource "google_folder" "my_folder" {
display_name = "tf-test-my-folder%{random_suffix}"
parent = "organizations/%{org_id}"
deletion_protection = false
}
# Wait after folder creation to limit eventual consistency errors.
Expand Down Expand Up @@ -96,6 +97,7 @@ func testAccAccessApprovalFolderSettings_update(context map[string]interface{})
resource "google_folder" "my_folder" {
display_name = "tf-test-my-folder%{random_suffix}"
parent = "organizations/%{org_id}"
deletion_protection = false
}
# Wait after folder creation to limit eventual consistency errors.
Expand Down Expand Up @@ -123,6 +125,7 @@ func testAccAccessApprovalFolderSettings_activeKeyVersion(context map[string]int
resource "google_folder" "my_folder" {
display_name = "tf-test-my-folder%{random_suffix}"
parent = "organizations/%{org_id}"
deletion_protection = false
}
# Wait after folder creation to limit eventual consistency errors.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ resource "google_assured_workloads_workload" "primary" {
resource "google_folder" "folder1" {
display_name = "tf-test-name%{random_suffix}"
parent = "organizations/%{org_id}"
deletion_protection = false
}
`, context)
}
Expand All @@ -236,6 +237,7 @@ resource "google_assured_workloads_workload" "primary" {
resource "google_folder" "folder1" {
display_name = "tf-test-name%{random_suffix}"
parent = "organizations/%{org_id}"
deletion_protection = false
}
`, context)
}
Expand All @@ -258,6 +260,7 @@ resource "google_assured_workloads_workload" "primary" {
resource "google_folder" "folder1" {
display_name = "tf-test-name%{random_suffix}"
parent = "organizations/%{org_id}"
deletion_protection = false
}
`, context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ resource "google_pubsub_topic" "feed_output" {
resource "google_folder" "my_folder" {
display_name = "Networking%{random_suffix}"
parent = "organizations/%{org_id}"
deletion_protection = false
}
# Find the project number of the project whose identity will be used for sending
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,13 @@ func testAccComputeFirewallPolicyAssociation_basic(context map[string]interface{
resource "google_folder" "folder" {
display_name = "tf-test-folder-%{random_suffix}"
parent = "%{org_name}"
deletion_protection = false
}
resource "google_folder" "target_folder" {
display_name = "tf-test-target-%{random_suffix}"
parent = "%{org_name}"
deletion_protection = false
}
resource "google_compute_firewall_policy" "default" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ resource "google_network_security_address_group" "basic_global_networksecurity_a
resource "google_folder" "folder" {
display_name = "tf-test-policy%{random_suffix}"
parent = "organizations/%{org_id}"
deletion_protection = false
}
resource "google_compute_firewall_policy" "default" {
Expand Down Expand Up @@ -136,6 +137,7 @@ resource "google_network_security_address_group" "basic_global_networksecurity_a
resource "google_folder" "folder" {
display_name = "tf-test-policy%{random_suffix}"
parent = "organizations/%{org_id}"
deletion_protection = false
}
resource "google_compute_firewall_policy" "default" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ func testAccComputeFirewallPolicyRule_securityProfileGroup_basic(context map[str
resource "google_folder" "folder" {
display_name = "tf-test-folder-%{random_suffix}"
parent = "%{org_name}"
deletion_protection = false
}
resource "google_network_security_security_profile" "security_profile" {
Expand Down Expand Up @@ -203,6 +204,7 @@ func testAccComputeFirewallPolicyRule_securityProfileGroup_update(context map[st
resource "google_folder" "folder" {
display_name = "tf-test-folder-%{random_suffix}"
parent = "%{org_name}"
deletion_protection = false
}
resource "google_network_security_security_profile" "security_profile" {
Expand Down Expand Up @@ -278,6 +280,7 @@ resource "google_compute_network" "network2" {
resource "google_folder" "folder" {
display_name = "tf-test-folder-%{random_suffix}"
parent = "%{org_name}"
deletion_protection = false
}
resource "google_compute_firewall_policy" "fw_policy" {
Expand Down Expand Up @@ -343,6 +346,7 @@ resource "google_compute_network" "network2" {
resource "google_folder" "folder" {
display_name = "tf-test-folder-%{random_suffix}"
parent = "%{org_name}"
deletion_protection = false
}
resource "google_compute_firewall_policy" "fw_policy" {
Expand Down Expand Up @@ -418,6 +422,7 @@ resource "google_compute_network" "network2" {
resource "google_folder" "folder" {
display_name = "tf-test-folder-%{random_suffix}"
parent = "%{org_name}"
deletion_protection = false
}
resource "google_compute_firewall_policy" "fw_policy" {
Expand Down Expand Up @@ -469,6 +474,7 @@ func testAccComputeFirewallPolicyRule_multiple(context map[string]interface{}) s
resource "google_folder" "folder" {
display_name = "tf-test-folder-%{random_suffix}"
parent = "%{org_name}"
deletion_protection = false
}
resource "google_compute_firewall_policy" "fw_policy" {
Expand Down Expand Up @@ -541,6 +547,7 @@ func testAccComputeFirewallPolicyRule_multipleAdd(context map[string]interface{}
resource "google_folder" "folder" {
display_name = "tf-test-folder-%{random_suffix}"
parent = "%{org_name}"
deletion_protection = false
}
resource "google_compute_firewall_policy" "fw_policy" {
Expand Down Expand Up @@ -634,6 +641,7 @@ func testAccComputeFirewallPolicyRule_multipleRemove(context map[string]interfac
resource "google_folder" "folder" {
display_name = "tf-test-folder-%{random_suffix}"
parent = "%{org_name}"
deletion_protection = false
}
resource "google_compute_firewall_policy" "fw_policy" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ func testAccComputeFirewallPolicy_basic(org, policyName, folderName string) stri
resource "google_folder" "folder" {
display_name = "%s"
parent = "%s"
deletion_protection = false
}
resource "google_compute_firewall_policy" "default" {
Expand All @@ -71,6 +72,7 @@ func testAccComputeFirewallPolicy_update(org, policyName, folderName string) str
resource "google_folder" "folder" {
display_name = "%s"
parent = "%s"
deletion_protection = false
}
resource "google_compute_firewall_policy" "default" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ resource "google_folder" "security_policy_target" {
provider = google-beta
display_name = "tf-test-secpol-%{random_suffix}"
parent = "organizations/%{org_id}"
deletion_protection = false
}
resource "google_compute_organization_security_policy" "policy" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func testAccComputeOrganizationSecurityPolicyRule_organizationSecurityPolicyRule
resource "google_folder" "security_policy_target" {
display_name = "tf-test-secpol-%{random_suffix}"
parent = "organizations/%{org_id}"
deletion_protection = false
}
resource "google_compute_organization_security_policy" "policy" {
Expand Down Expand Up @@ -82,6 +83,7 @@ func testAccComputeOrganizationSecurityPolicyRule_organizationSecurityPolicyRule
resource "google_folder" "security_policy_target" {
display_name = "tf-test-secpol-%{random_suffix}"
parent = "organizations/%{org_id}"
deletion_protection = false
}
resource "google_compute_organization_security_policy" "policy" {
Expand Down
2 changes: 2 additions & 0 deletions google-beta/services/iam2/resource_iam_deny_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ resource "google_iam_deny_policy" "example" {
resource "google_folder" "folder" {
display_name = "tf-test-%{random_suffix}"
parent = "organizations/%{org_id}"
deletion_protection = false
}
`, context)
}
Expand All @@ -217,6 +218,7 @@ resource "google_iam_deny_policy" "example" {
resource "google_folder" "folder" {
display_name = "tf-test-%{random_suffix}"
parent = "organizations/%{org_id}"
deletion_protection = false
}
`, context)
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ resource "google_folder" "autokms_folder" {
provider = google-beta
display_name = "tf-test-my-folder%{random_suffix}"
parent = "organizations/%{org_id}"
deletion_protection = false
}
# Create the key project
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ resource "google_folder" "autokms_folder" {
provider = google-beta
display_name = "folder-example"
parent = "organizations/%{org_id}"
deletion_protection = false
}
# Create the key project
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func testAccLoggingFolderSettings_datasource(context map[string]interface{}) str
resource "google_folder" "default" {
display_name = "%{folder_name}"
parent = "organizations/%{org_id}"
deletion_protection = false
}
data "google_logging_folder_settings" "settings" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ func testAccLoggingBucketConfigFolder_basic(context map[string]interface{}, rete
resource "google_folder" "default" {
display_name = "%{folder_name}"
parent = "organizations/%{org_id}"
deletion_protection = false
}
resource "google_logging_folder_bucket_config" "basic" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ resource "google_logging_folder_exclusion" "basic" {
resource "google_folder" "my-folder" {
display_name = "%s"
parent = "%s"
deletion_protection = false
}
`, exclusionName, description, envvar.GetTestProjectFromEnv(), folderName, folderParent)
}
Expand All @@ -255,6 +256,7 @@ resource "google_logging_folder_exclusion" "full-folder" {
resource "google_folder" "my-folder" {
display_name = "%s"
parent = "%s"
deletion_protection = false
}
`, exclusionName, description, envvar.GetTestProjectFromEnv(), folderName, folderParent)
}
Expand All @@ -264,6 +266,7 @@ func testAccLoggingFolderExclusion_multipleCfg(folderName, folderParent, exclusi
resource "google_folder" "my-folder" {
display_name = "%s"
parent = "%s"
deletion_protection = false
}
`, folderName, folderParent)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ resource "google_logging_folder_settings" "example" {
resource "google_folder" "my_folder" {
display_name = "tf-test-folder-name%{random_suffix}"
parent = "organizations/%{org_id}"
deletion_protection = false
}
data "google_logging_folder_settings" "settings" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ resource "google_logging_folder_settings" "example" {
resource "google_folder" "my_folder" {
display_name = "tf-test-folder-%{random_suffix}"
parent = "organizations/%{org_id}"
deletion_protection = false
}
data "google_logging_folder_settings" "settings" {
Expand All @@ -83,6 +84,7 @@ resource "google_logging_folder_settings" "example" {
resource "google_folder" "my_folder" {
display_name = "tf-test-folder-%{random_suffix}"
parent = "organizations/%{org_id}"
deletion_protection = false
}
`, context)
}
13 changes: 11 additions & 2 deletions google-beta/services/logging/resource_logging_folder_sink_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ resource "google_storage_bucket" "log-bucket" {
resource "google_folder" "my-folder" {
display_name = "%s"
parent = "%s"
deletion_protection = false
}
`, sinkName, envvar.GetTestProjectFromEnv(), bucketName, folderName, folderParent)
}
Expand All @@ -425,6 +426,7 @@ resource "google_storage_bucket" "log-bucket" {
resource "google_folder" "my-folder" {
display_name = "%s"
parent = "%s"
deletion_protection = false
}
`, sinkName, envvar.GetTestProjectFromEnv(), bucketName, folderName, folderParent)
}
Expand All @@ -448,6 +450,7 @@ resource "google_storage_bucket" "log-bucket" {
resource "google_folder" "my-folder" {
display_name = "%s"
parent = "%s"
deletion_protection = false
}
`, sinkName, envvar.GetTestProjectFromEnv(), bucketName, folderName, folderParent)
}
Expand All @@ -468,8 +471,9 @@ resource "google_storage_bucket" "log-bucket" {
}
resource "google_folder" "my-folder" {
display_name = "%s"
parent = "%s"
display_name = "%s"
parent = "%s"
deletion_protection = false
}`, sinkName, bucketName, folderName, folderParent)
}

Expand All @@ -491,6 +495,7 @@ resource "google_storage_bucket" "log-bucket" {
resource "google_folder" "my-folder" {
display_name = "%s"
parent = "%s"
deletion_protection = false
}
`, sinkName, envvar.GetTestProjectFromEnv(), bucketName, folderName, folderParent)
}
Expand Down Expand Up @@ -521,6 +526,7 @@ resource "google_storage_bucket" "log-bucket" {
resource "google_folder" "my-folder" {
display_name = "%s"
parent = "%s"
deletion_protection = false
}
`, sinkName, envvar.GetTestProjectFromEnv(), bucketName, folderName, folderParent)
}
Expand All @@ -547,6 +553,7 @@ resource "google_bigquery_dataset" "logging_sink" {
resource "google_folder" "my-folder" {
display_name = "%s"
parent = "%s"
deletion_protection = false
}`, sinkName, envvar.GetTestProjectFromEnv(), envvar.GetTestProjectFromEnv(), bqDatasetID, folderName, folderParent)
}

Expand All @@ -568,6 +575,7 @@ resource "google_bigquery_dataset" "logging_sink" {
resource "google_folder" "my-folder" {
display_name = "%s"
parent = "%s"
deletion_protection = false
}`, sinkName, envvar.GetTestProjectFromEnv(), envvar.GetTestProjectFromEnv(), bqDatasetID, folderName, folderParent)
}

Expand All @@ -585,6 +593,7 @@ resource "google_logging_folder_sink" "intercept_update" {
resource "google_folder" "intercept_folder" {
display_name = "%s"
parent = "%s"
deletion_protection = false
}
`, sinkName, envvar.GetTestProjectFromEnv(), envvar.GetTestProjectFromEnv(), intercept_children, folderName, folderParent)
}
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ resource "google_org_policy_policy" "primary" {
resource "google_folder" "basic" {
parent = "organizations/%{org_id}"
display_name = "tf-test-folder%{random_suffix}"
deletion_protection = false
}
Expand Down Expand Up @@ -247,6 +248,7 @@ resource "google_org_policy_policy" "primary" {
resource "google_folder" "basic" {
parent = "organizations/%{org_id}"
display_name = "tf-test-folder%{random_suffix}"
deletion_protection = false
}
Expand Down
Loading

0 comments on commit 794d80a

Please sign in to comment.