diff --git a/mmv1/templates/terraform/examples/cloud_asset_folder_feed.tf.erb b/mmv1/templates/terraform/examples/cloud_asset_folder_feed.tf.erb index 77ef8f8c5ba7..84a8e50b132b 100644 --- a/mmv1/templates/terraform/examples/cloud_asset_folder_feed.tf.erb +++ b/mmv1/templates/terraform/examples/cloud_asset_folder_feed.tf.erb @@ -37,6 +37,7 @@ resource "google_pubsub_topic" "feed_output" { resource "google_folder" "my_folder" { display_name = "<%= ctx[:vars]["folder_name"] %>" parent = "organizations/<%= ctx[:test_env_vars]["org_id"] %>" + deletion_protection = false } # Find the project number of the project whose identity will be used for sending diff --git a/mmv1/templates/terraform/examples/folder_access_approval_active_key_version.tf.erb b/mmv1/templates/terraform/examples/folder_access_approval_active_key_version.tf.erb index 474dc36b1b21..3fa8d47af8bd 100644 --- a/mmv1/templates/terraform/examples/folder_access_approval_active_key_version.tf.erb +++ b/mmv1/templates/terraform/examples/folder_access_approval_active_key_version.tf.erb @@ -1,6 +1,7 @@ resource "google_folder" "my_folder" { display_name = "<%= ctx[:vars]['folder_name'] %>" parent = "organizations/<%= ctx[:test_env_vars]['org_id'] %>" + deletion_protection = false } resource "google_project" "my_project" { diff --git a/mmv1/templates/terraform/examples/folder_access_approval_full.tf.erb b/mmv1/templates/terraform/examples/folder_access_approval_full.tf.erb index 27927d1f06ec..140550f5a161 100644 --- a/mmv1/templates/terraform/examples/folder_access_approval_full.tf.erb +++ b/mmv1/templates/terraform/examples/folder_access_approval_full.tf.erb @@ -1,6 +1,7 @@ resource "google_folder" "my_folder" { display_name = "<%= ctx[:vars]['folder_name'] %>" parent = "organizations/<%= ctx[:test_env_vars]['org_id'] %>" + deletion_protection = false } resource "google_folder_access_approval_settings" "<%= ctx[:primary_resource_id] %>" { diff --git a/mmv1/templates/terraform/examples/go/cloud_asset_folder_feed.tf.tmpl b/mmv1/templates/terraform/examples/go/cloud_asset_folder_feed.tf.tmpl index 3666a76bff71..a164c381c778 100644 --- a/mmv1/templates/terraform/examples/go/cloud_asset_folder_feed.tf.tmpl +++ b/mmv1/templates/terraform/examples/go/cloud_asset_folder_feed.tf.tmpl @@ -37,6 +37,7 @@ resource "google_pubsub_topic" "feed_output" { resource "google_folder" "my_folder" { display_name = "{{index $.Vars "folder_name"}}" parent = "organizations/{{index $.TestEnvVars "org_id"}}" + deletion_protection = false } # Find the project number of the project whose identity will be used for sending diff --git a/mmv1/templates/terraform/examples/go/folder_access_approval_active_key_version.tf.tmpl b/mmv1/templates/terraform/examples/go/folder_access_approval_active_key_version.tf.tmpl index dc2770e2b6d8..df9ec2d3e80d 100644 --- a/mmv1/templates/terraform/examples/go/folder_access_approval_active_key_version.tf.tmpl +++ b/mmv1/templates/terraform/examples/go/folder_access_approval_active_key_version.tf.tmpl @@ -1,6 +1,7 @@ resource "google_folder" "my_folder" { display_name = "{{index $.Vars "folder_name"}}" parent = "organizations/{{index $.TestEnvVars "org_id"}}" + deletion_protection = false } resource "google_project" "my_project" { diff --git a/mmv1/templates/terraform/examples/go/folder_access_approval_full.tf.tmpl b/mmv1/templates/terraform/examples/go/folder_access_approval_full.tf.tmpl index 5bce3c5e52a2..fc08b3dee4f8 100644 --- a/mmv1/templates/terraform/examples/go/folder_access_approval_full.tf.tmpl +++ b/mmv1/templates/terraform/examples/go/folder_access_approval_full.tf.tmpl @@ -1,6 +1,7 @@ resource "google_folder" "my_folder" { display_name = "{{index $.Vars "folder_name"}}" parent = "organizations/{{index $.TestEnvVars "org_id"}}" + deletion_protection = false } resource "google_folder_access_approval_settings" "{{$.PrimaryResourceId}}" { diff --git a/mmv1/templates/terraform/examples/go/kms_autokey_config_all.tf.tmpl b/mmv1/templates/terraform/examples/go/kms_autokey_config_all.tf.tmpl index 2c4b2ec6c841..d2c504b6f355 100644 --- a/mmv1/templates/terraform/examples/go/kms_autokey_config_all.tf.tmpl +++ b/mmv1/templates/terraform/examples/go/kms_autokey_config_all.tf.tmpl @@ -3,6 +3,7 @@ resource "google_folder" "autokms_folder" { provider = google-beta display_name = "{{index $.Vars "folder_name"}}" parent = "organizations/{{index $.TestEnvVars "org_id"}}" + deletion_protection = false } # Create the key project diff --git a/mmv1/templates/terraform/examples/go/kms_key_handle_basic.tf.tmpl b/mmv1/templates/terraform/examples/go/kms_key_handle_basic.tf.tmpl index f681e7679bb3..daead61d342d 100644 --- a/mmv1/templates/terraform/examples/go/kms_key_handle_basic.tf.tmpl +++ b/mmv1/templates/terraform/examples/go/kms_key_handle_basic.tf.tmpl @@ -3,6 +3,7 @@ resource "google_folder" "autokms_folder" { provider = google-beta display_name = "folder-example" parent = "organizations/{{index $.TestEnvVars "org_id"}}" + deletion_protection = false } # Create the key project diff --git a/mmv1/templates/terraform/examples/go/logging_folder_settings_all.tf.tmpl b/mmv1/templates/terraform/examples/go/logging_folder_settings_all.tf.tmpl index bd11b5e2de7e..fbd552c14b33 100644 --- a/mmv1/templates/terraform/examples/go/logging_folder_settings_all.tf.tmpl +++ b/mmv1/templates/terraform/examples/go/logging_folder_settings_all.tf.tmpl @@ -9,6 +9,7 @@ resource "google_logging_folder_settings" "{{$.PrimaryResourceId}}" { resource "google_folder" "my_folder" { display_name = "{{index $.Vars "folder_name"}}" parent = "organizations/{{index $.TestEnvVars "org_id"}}" + deletion_protection = false } data "google_logging_folder_settings" "settings" { diff --git a/mmv1/templates/terraform/examples/go/org_policy_policy_folder.tf.tmpl b/mmv1/templates/terraform/examples/go/org_policy_policy_folder.tf.tmpl index c924f1226c53..6d58a8cbc60b 100644 --- a/mmv1/templates/terraform/examples/go/org_policy_policy_folder.tf.tmpl +++ b/mmv1/templates/terraform/examples/go/org_policy_policy_folder.tf.tmpl @@ -14,4 +14,5 @@ resource "google_org_policy_policy" "primary" { resource "google_folder" "basic" { parent = "organizations/123456789" display_name = "folder" + deletion_protection = false } diff --git a/mmv1/templates/terraform/examples/go/organization_security_policy_association_basic.tf.tmpl b/mmv1/templates/terraform/examples/go/organization_security_policy_association_basic.tf.tmpl index e803ddc2ff83..a8fd86eef059 100644 --- a/mmv1/templates/terraform/examples/go/organization_security_policy_association_basic.tf.tmpl +++ b/mmv1/templates/terraform/examples/go/organization_security_policy_association_basic.tf.tmpl @@ -2,6 +2,7 @@ resource "google_folder" "security_policy_target" { provider = google-beta display_name = "tf-test-secpol-%{random_suffix}" parent = "organizations/{{index $.TestEnvVars "org_id"}}" + deletion_protection = false } resource "google_compute_organization_security_policy" "policy" { diff --git a/mmv1/templates/terraform/examples/go/scc_folder_custom_module_basic.tf.tmpl b/mmv1/templates/terraform/examples/go/scc_folder_custom_module_basic.tf.tmpl index dc500936f42a..594d8ee62d72 100644 --- a/mmv1/templates/terraform/examples/go/scc_folder_custom_module_basic.tf.tmpl +++ b/mmv1/templates/terraform/examples/go/scc_folder_custom_module_basic.tf.tmpl @@ -1,6 +1,7 @@ resource "google_folder" "folder" { parent = "organizations/{{index $.TestEnvVars "org_id"}}" display_name = "{{index $.Vars "folder_display_name"}}" + deletion_protection = false } resource "google_scc_folder_custom_module" "{{$.PrimaryResourceId}}" { diff --git a/mmv1/templates/terraform/examples/go/scc_folder_custom_module_full.tf.tmpl b/mmv1/templates/terraform/examples/go/scc_folder_custom_module_full.tf.tmpl index 058069aae278..56c049c3436b 100644 --- a/mmv1/templates/terraform/examples/go/scc_folder_custom_module_full.tf.tmpl +++ b/mmv1/templates/terraform/examples/go/scc_folder_custom_module_full.tf.tmpl @@ -1,6 +1,7 @@ resource "google_folder" "folder" { parent = "organizations/{{index $.TestEnvVars "org_id"}}" display_name = "{{index $.Vars "folder_display_name"}}" + deletion_protection = false } resource "google_scc_folder_custom_module" "{{$.PrimaryResourceId}}" { diff --git a/mmv1/templates/terraform/examples/go/scc_management_folder_security_health_analytics_custom_module_basic.tf.tmpl b/mmv1/templates/terraform/examples/go/scc_management_folder_security_health_analytics_custom_module_basic.tf.tmpl index 49eb43a28cc2..a06a45f0fab6 100644 --- a/mmv1/templates/terraform/examples/go/scc_management_folder_security_health_analytics_custom_module_basic.tf.tmpl +++ b/mmv1/templates/terraform/examples/go/scc_management_folder_security_health_analytics_custom_module_basic.tf.tmpl @@ -1,6 +1,7 @@ resource "google_folder" "folder" { parent = "organizations/{{index $.TestEnvVars "org_id"}}" display_name = "{{index $.Vars "folder_display_name"}}" + deletion_protection = false } resource "google_scc_management_folder_security_health_analytics_custom_module" "{{$.PrimaryResourceId}}" { diff --git a/mmv1/templates/terraform/examples/go/scc_management_folder_security_health_analytics_custom_module_full.tf.tmpl b/mmv1/templates/terraform/examples/go/scc_management_folder_security_health_analytics_custom_module_full.tf.tmpl index 45964d5b11b8..1c328913e752 100644 --- a/mmv1/templates/terraform/examples/go/scc_management_folder_security_health_analytics_custom_module_full.tf.tmpl +++ b/mmv1/templates/terraform/examples/go/scc_management_folder_security_health_analytics_custom_module_full.tf.tmpl @@ -1,6 +1,7 @@ resource "google_folder" "folder" { parent = "organizations/{{index $.TestEnvVars "org_id"}}" display_name = "{{index $.Vars "folder_display_name"}}" + deletion_protection = false } resource "google_scc_management_folder_security_health_analytics_custom_module" "{{$.PrimaryResourceId}}" { diff --git a/mmv1/templates/terraform/examples/kms_autokey_config_all.tf.erb b/mmv1/templates/terraform/examples/kms_autokey_config_all.tf.erb index 5611cbc65db0..1d48d66afdc0 100644 --- a/mmv1/templates/terraform/examples/kms_autokey_config_all.tf.erb +++ b/mmv1/templates/terraform/examples/kms_autokey_config_all.tf.erb @@ -3,6 +3,7 @@ resource "google_folder" "autokms_folder" { provider = google-beta display_name = "<%= ctx[:vars]["folder_name"] %>" parent = "organizations/<%= ctx[:test_env_vars]['org_id'] %>" + deletion_protection = false } # Create the key project diff --git a/mmv1/templates/terraform/examples/kms_key_handle_basic.tf.erb b/mmv1/templates/terraform/examples/kms_key_handle_basic.tf.erb index a03be1027829..27df68625892 100644 --- a/mmv1/templates/terraform/examples/kms_key_handle_basic.tf.erb +++ b/mmv1/templates/terraform/examples/kms_key_handle_basic.tf.erb @@ -3,6 +3,7 @@ resource "google_folder" "autokms_folder" { provider = google-beta display_name = "folder-example" parent = "organizations/<%= ctx[:test_env_vars]['org_id'] %>" + deletion_protection = false } # Create the key project diff --git a/mmv1/templates/terraform/examples/logging_folder_settings_all.tf.erb b/mmv1/templates/terraform/examples/logging_folder_settings_all.tf.erb index 35a35ccd6fac..c9a44202cab3 100644 --- a/mmv1/templates/terraform/examples/logging_folder_settings_all.tf.erb +++ b/mmv1/templates/terraform/examples/logging_folder_settings_all.tf.erb @@ -9,6 +9,7 @@ resource "google_logging_folder_settings" "<%= ctx[:primary_resource_id] %>" { resource "google_folder" "my_folder" { display_name = "<%= ctx[:vars]['folder_name'] %>" parent = "organizations/<%= ctx[:test_env_vars]['org_id'] %>" + deletion_protection = false } data "google_logging_folder_settings" "settings" { diff --git a/mmv1/templates/terraform/examples/org_policy_policy_folder.tf.erb b/mmv1/templates/terraform/examples/org_policy_policy_folder.tf.erb index c924f1226c53..6d58a8cbc60b 100644 --- a/mmv1/templates/terraform/examples/org_policy_policy_folder.tf.erb +++ b/mmv1/templates/terraform/examples/org_policy_policy_folder.tf.erb @@ -14,4 +14,5 @@ resource "google_org_policy_policy" "primary" { resource "google_folder" "basic" { parent = "organizations/123456789" display_name = "folder" + deletion_protection = false } diff --git a/mmv1/templates/terraform/examples/organization_security_policy_association_basic.tf.erb b/mmv1/templates/terraform/examples/organization_security_policy_association_basic.tf.erb index 5ea24c0c0fa2..dd02a5433776 100644 --- a/mmv1/templates/terraform/examples/organization_security_policy_association_basic.tf.erb +++ b/mmv1/templates/terraform/examples/organization_security_policy_association_basic.tf.erb @@ -2,6 +2,7 @@ resource "google_folder" "security_policy_target" { provider = google-beta display_name = "tf-test-secpol-%{random_suffix}" parent = "organizations/<%= ctx[:test_env_vars]['org_id'] %>" + deletion_protection = false } resource "google_compute_organization_security_policy" "policy" { diff --git a/mmv1/templates/terraform/examples/scc_folder_custom_module_basic.tf.erb b/mmv1/templates/terraform/examples/scc_folder_custom_module_basic.tf.erb index 5a56b75249da..dd07ad92a244 100644 --- a/mmv1/templates/terraform/examples/scc_folder_custom_module_basic.tf.erb +++ b/mmv1/templates/terraform/examples/scc_folder_custom_module_basic.tf.erb @@ -1,6 +1,7 @@ resource "google_folder" "folder" { parent = "organizations/<%= ctx[:test_env_vars]['org_id'] %>" display_name = "<%= ctx[:vars]['folder_display_name'] %>" + deletion_protection = false } resource "google_scc_folder_custom_module" "<%= ctx[:primary_resource_id] %>" { diff --git a/mmv1/templates/terraform/examples/scc_folder_custom_module_full.tf.erb b/mmv1/templates/terraform/examples/scc_folder_custom_module_full.tf.erb index b54bcd04c701..cce74f61865d 100644 --- a/mmv1/templates/terraform/examples/scc_folder_custom_module_full.tf.erb +++ b/mmv1/templates/terraform/examples/scc_folder_custom_module_full.tf.erb @@ -1,6 +1,7 @@ resource "google_folder" "folder" { parent = "organizations/<%= ctx[:test_env_vars]['org_id'] %>" display_name = "<%= ctx[:vars]['folder_display_name'] %>" + deletion_protection = false } resource "google_scc_folder_custom_module" "<%= ctx[:primary_resource_id] %>" { diff --git a/mmv1/templates/terraform/examples/scc_management_folder_security_health_analytics_custom_module_basic.tf.erb b/mmv1/templates/terraform/examples/scc_management_folder_security_health_analytics_custom_module_basic.tf.erb index 9b773df17903..7042af8d7d20 100644 --- a/mmv1/templates/terraform/examples/scc_management_folder_security_health_analytics_custom_module_basic.tf.erb +++ b/mmv1/templates/terraform/examples/scc_management_folder_security_health_analytics_custom_module_basic.tf.erb @@ -1,6 +1,7 @@ resource "google_folder" "folder" { parent = "organizations/<%= ctx[:test_env_vars]['org_id'] %>" display_name = "<%= ctx[:vars]['folder_display_name'] %>" + deletion_protection = false } resource "google_scc_management_folder_security_health_analytics_custom_module" "<%= ctx[:primary_resource_id] %>" { diff --git a/mmv1/templates/terraform/examples/scc_management_folder_security_health_analytics_custom_module_full.tf.erb b/mmv1/templates/terraform/examples/scc_management_folder_security_health_analytics_custom_module_full.tf.erb index 0108ada4cd1a..c0974a7b35b5 100644 --- a/mmv1/templates/terraform/examples/scc_management_folder_security_health_analytics_custom_module_full.tf.erb +++ b/mmv1/templates/terraform/examples/scc_management_folder_security_health_analytics_custom_module_full.tf.erb @@ -1,6 +1,7 @@ resource "google_folder" "folder" { parent = "organizations/<%= ctx[:test_env_vars]['org_id'] %>" display_name = "<%= ctx[:vars]['folder_display_name'] %>" + deletion_protection = false } resource "google_scc_management_folder_security_health_analytics_custom_module" "<%= ctx[:primary_resource_id] %>" { diff --git a/mmv1/third_party/terraform/services/accessapproval/data_source_access_approval_folder_service_account_test.go b/mmv1/third_party/terraform/services/accessapproval/data_source_access_approval_folder_service_account_test.go index b8d5438a9cf2..4af0dc66ba87 100644 --- a/mmv1/third_party/terraform/services/accessapproval/data_source_access_approval_folder_service_account_test.go +++ b/mmv1/third_party/terraform/services/accessapproval/data_source_access_approval_folder_service_account_test.go @@ -40,6 +40,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. diff --git a/mmv1/third_party/terraform/services/accessapproval/resource_access_approval_folder_settings_test.go b/mmv1/third_party/terraform/services/accessapproval/resource_access_approval_folder_settings_test.go index d6515f0a1f01..c24eb6f568b2 100644 --- a/mmv1/third_party/terraform/services/accessapproval/resource_access_approval_folder_settings_test.go +++ b/mmv1/third_party/terraform/services/accessapproval/resource_access_approval_folder_settings_test.go @@ -67,6 +67,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. @@ -94,6 +95,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. @@ -121,6 +123,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. diff --git a/mmv1/third_party/terraform/services/compute/go/resource_compute_firewall_policy_rule_test.go b/mmv1/third_party/terraform/services/compute/go/resource_compute_firewall_policy_rule_test.go index d84a5a2d4449..7bf2366c2455 100644 --- a/mmv1/third_party/terraform/services/compute/go/resource_compute_firewall_policy_rule_test.go +++ b/mmv1/third_party/terraform/services/compute/go/resource_compute_firewall_policy_rule_test.go @@ -66,92 +66,93 @@ func TestAccComputeFirewallPolicyRule_update(t *testing.T) { } func TestAccComputeFirewallPolicyRule_multipleRules(t *testing.T) { - t.Parallel() + t.Parallel() - context := map[string]interface{}{ - "random_suffix": acctest.RandString(t, 10), - "org_name": fmt.Sprintf("organizations/%s", envvar.GetTestOrgFromEnv(t)), - } + context := map[string]interface{}{ + "random_suffix": acctest.RandString(t, 10), + "org_name": fmt.Sprintf("organizations/%s", envvar.GetTestOrgFromEnv(t)), + } - acctest.VcrTest(t, resource.TestCase{ - PreCheck: func() { acctest.AccTestPreCheck(t) }, - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), - Steps: []resource.TestStep{ - { - Config: testAccComputeFirewallPolicyRule_multiple(context), - }, - { - ResourceName: "google_compute_firewall_policy_rule.fw_policy_rule1", - ImportState: true, - ImportStateVerify: true, - // Referencing using ID causes import to fail - ImportStateVerifyIgnore: []string{"firewall_policy"}, - }, - { - ResourceName: "google_compute_firewall_policy_rule.fw_policy_rule2", - ImportState: true, - ImportStateVerify: true, - // Referencing using ID causes import to fail - ImportStateVerifyIgnore: []string{"firewall_policy"}, - }, - { - Config: testAccComputeFirewallPolicyRule_multipleAdd(context), - }, - { - ResourceName: "google_compute_firewall_policy_rule.fw_policy_rule3", - ImportState: true, - ImportStateVerify: true, - // Referencing using ID causes import to fail - ImportStateVerifyIgnore: []string{"firewall_policy"}, - }, - { - Config: testAccComputeFirewallPolicyRule_multipleRemove(context), - }, - }, - }) + acctest.VcrTest(t, resource.TestCase{ + PreCheck: func() { acctest.AccTestPreCheck(t) }, + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), + Steps: []resource.TestStep{ + { + Config: testAccComputeFirewallPolicyRule_multiple(context), + }, + { + ResourceName: "google_compute_firewall_policy_rule.fw_policy_rule1", + ImportState: true, + ImportStateVerify: true, + // Referencing using ID causes import to fail + ImportStateVerifyIgnore: []string{"firewall_policy"}, + }, + { + ResourceName: "google_compute_firewall_policy_rule.fw_policy_rule2", + ImportState: true, + ImportStateVerify: true, + // Referencing using ID causes import to fail + ImportStateVerifyIgnore: []string{"firewall_policy"}, + }, + { + Config: testAccComputeFirewallPolicyRule_multipleAdd(context), + }, + { + ResourceName: "google_compute_firewall_policy_rule.fw_policy_rule3", + ImportState: true, + ImportStateVerify: true, + // Referencing using ID causes import to fail + ImportStateVerifyIgnore: []string{"firewall_policy"}, + }, + { + Config: testAccComputeFirewallPolicyRule_multipleRemove(context), + }, + }, + }) } func TestAccComputeFirewallPolicyRule_securityProfileGroup_update(t *testing.T) { - t.Parallel() + t.Parallel() - context := map[string]interface{}{ - "random_suffix": acctest.RandString(t, 10), - "org_name": fmt.Sprintf("organizations/%s", envvar.GetTestOrgFromEnv(t)), - } + context := map[string]interface{}{ + "random_suffix": acctest.RandString(t, 10), + "org_name": fmt.Sprintf("organizations/%s", envvar.GetTestOrgFromEnv(t)), + } - acctest.VcrTest(t, resource.TestCase{ - PreCheck: func() { acctest.AccTestPreCheck(t) }, - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), - Steps: []resource.TestStep{ - { - Config: testAccComputeFirewallPolicyRule_securityProfileGroup_basic(context), - }, - { - ResourceName: "google_compute_firewall_policy_rule.fw_policy_rule1", - ImportState: true, - ImportStateVerify: true, - // Referencing using ID causes import to fail - ImportStateVerifyIgnore: []string{"firewall_policy"}, - }, - { - Config: testAccComputeFirewallPolicyRule_securityProfileGroup_update(context), - }, - { - ResourceName: "google_compute_firewall_policy_rule.fw_policy_rule1", - ImportState: true, - ImportStateVerify: true, - // Referencing using ID causes import to fail - ImportStateVerifyIgnore: []string{"firewall_policy", "target_resources"}, - }, - }, - }) + acctest.VcrTest(t, resource.TestCase{ + PreCheck: func() { acctest.AccTestPreCheck(t) }, + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), + Steps: []resource.TestStep{ + { + Config: testAccComputeFirewallPolicyRule_securityProfileGroup_basic(context), + }, + { + ResourceName: "google_compute_firewall_policy_rule.fw_policy_rule1", + ImportState: true, + ImportStateVerify: true, + // Referencing using ID causes import to fail + ImportStateVerifyIgnore: []string{"firewall_policy"}, + }, + { + Config: testAccComputeFirewallPolicyRule_securityProfileGroup_update(context), + }, + { + ResourceName: "google_compute_firewall_policy_rule.fw_policy_rule1", + ImportState: true, + ImportStateVerify: true, + // Referencing using ID causes import to fail + ImportStateVerifyIgnore: []string{"firewall_policy", "target_resources"}, + }, + }, + }) } func testAccComputeFirewallPolicyRule_securityProfileGroup_basic(context map[string]interface{}) string { - return acctest.Nprintf(` + return acctest.Nprintf(` 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" { @@ -197,10 +198,11 @@ resource "google_compute_firewall_policy_rule" "fw_policy_rule1" { } func testAccComputeFirewallPolicyRule_securityProfileGroup_update(context map[string]interface{}) string { - return acctest.Nprintf(` + return acctest.Nprintf(` 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" { @@ -276,6 +278,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" { @@ -341,6 +344,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" { @@ -416,6 +420,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" { @@ -467,6 +472,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" { @@ -539,6 +545,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" { @@ -632,6 +639,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" { diff --git a/mmv1/third_party/terraform/services/compute/go/resource_compute_firewall_policy_test.go b/mmv1/third_party/terraform/services/compute/go/resource_compute_firewall_policy_test.go index edd2ceab96de..2112aba5ce6f 100644 --- a/mmv1/third_party/terraform/services/compute/go/resource_compute_firewall_policy_test.go +++ b/mmv1/third_party/terraform/services/compute/go/resource_compute_firewall_policy_test.go @@ -3,6 +3,7 @@ package compute_test import ( "fmt" "testing" + "github.com/hashicorp/terraform-provider-google/google/acctest" "github.com/hashicorp/terraform-provider-google/google/envvar" @@ -50,10 +51,11 @@ func TestAccComputeFirewallPolicy_update(t *testing.T) { } func testAccComputeFirewallPolicy_basic(org, policyName, folderName string) string { - return fmt.Sprintf(` + return fmt.Sprintf(` resource "google_folder" "folder" { display_name = "%s" parent = "%s" + deletion_protection = false } resource "google_compute_firewall_policy" "default" { @@ -65,10 +67,11 @@ resource "google_compute_firewall_policy" "default" { } func testAccComputeFirewallPolicy_update(org, policyName, folderName string) string { - return fmt.Sprintf(` + return fmt.Sprintf(` resource "google_folder" "folder" { display_name = "%s" parent = "%s" + deletion_protection = false } resource "google_compute_firewall_policy" "default" { diff --git a/mmv1/third_party/terraform/services/compute/go/resource_compute_organization_security_policy_rule_test.go.tmpl b/mmv1/third_party/terraform/services/compute/go/resource_compute_organization_security_policy_rule_test.go.tmpl index e6f4ac117299..d9fcd19dbbf8 100644 --- a/mmv1/third_party/terraform/services/compute/go/resource_compute_organization_security_policy_rule_test.go.tmpl +++ b/mmv1/third_party/terraform/services/compute/go/resource_compute_organization_security_policy_rule_test.go.tmpl @@ -47,6 +47,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" { @@ -81,6 +82,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" { diff --git a/mmv1/third_party/terraform/services/compute/resource_compute_firewall_policy_association_test.go b/mmv1/third_party/terraform/services/compute/resource_compute_firewall_policy_association_test.go index 820991e5ca17..12e8f78881a7 100644 --- a/mmv1/third_party/terraform/services/compute/resource_compute_firewall_policy_association_test.go +++ b/mmv1/third_party/terraform/services/compute/resource_compute_firewall_policy_association_test.go @@ -40,11 +40,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" { diff --git a/mmv1/third_party/terraform/services/compute/resource_compute_firewall_policy_rule_test.go.erb b/mmv1/third_party/terraform/services/compute/resource_compute_firewall_policy_rule_test.go.erb index 44c240551ccf..30e24a27a9d1 100644 --- a/mmv1/third_party/terraform/services/compute/resource_compute_firewall_policy_rule_test.go.erb +++ b/mmv1/third_party/terraform/services/compute/resource_compute_firewall_policy_rule_test.go.erb @@ -153,6 +153,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" { @@ -202,6 +203,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" { @@ -277,6 +279,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" { @@ -342,6 +345,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" { @@ -417,6 +421,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" { @@ -468,6 +473,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" { @@ -540,6 +546,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" { @@ -633,6 +640,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" { diff --git a/mmv1/third_party/terraform/services/compute/resource_compute_firewall_policy_test.go.erb b/mmv1/third_party/terraform/services/compute/resource_compute_firewall_policy_test.go.erb index 49a7697eb998..4d1e67a0de86 100644 --- a/mmv1/third_party/terraform/services/compute/resource_compute_firewall_policy_test.go.erb +++ b/mmv1/third_party/terraform/services/compute/resource_compute_firewall_policy_test.go.erb @@ -55,6 +55,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" { @@ -70,6 +71,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" { diff --git a/mmv1/third_party/terraform/services/compute/resource_compute_organization_security_policy_rule_test.go.erb b/mmv1/third_party/terraform/services/compute/resource_compute_organization_security_policy_rule_test.go.erb index 4159475464f1..d0c2e2e56c1c 100644 --- a/mmv1/third_party/terraform/services/compute/resource_compute_organization_security_policy_rule_test.go.erb +++ b/mmv1/third_party/terraform/services/compute/resource_compute_organization_security_policy_rule_test.go.erb @@ -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" { @@ -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" { diff --git a/mmv1/third_party/terraform/services/iam2/go/resource_iam_deny_policy_test.go b/mmv1/third_party/terraform/services/iam2/go/resource_iam_deny_policy_test.go index 6bf0e6d54ba8..fab549dd3035 100644 --- a/mmv1/third_party/terraform/services/iam2/go/resource_iam_deny_policy_test.go +++ b/mmv1/third_party/terraform/services/iam2/go/resource_iam_deny_policy_test.go @@ -193,6 +193,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) } @@ -215,6 +216,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) } diff --git a/mmv1/third_party/terraform/services/iam2/resource_iam_deny_policy_test.go.erb b/mmv1/third_party/terraform/services/iam2/resource_iam_deny_policy_test.go.erb index db090a8cee0b..a3ffe0fe402e 100644 --- a/mmv1/third_party/terraform/services/iam2/resource_iam_deny_policy_test.go.erb +++ b/mmv1/third_party/terraform/services/iam2/resource_iam_deny_policy_test.go.erb @@ -194,6 +194,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) } @@ -216,6 +217,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) } diff --git a/mmv1/third_party/terraform/services/logging/data_source_google_logging_folder_settings_test.go b/mmv1/third_party/terraform/services/logging/data_source_google_logging_folder_settings_test.go index d56c11e3ceaa..96443cbc4c69 100644 --- a/mmv1/third_party/terraform/services/logging/data_source_google_logging_folder_settings_test.go +++ b/mmv1/third_party/terraform/services/logging/data_source_google_logging_folder_settings_test.go @@ -37,6 +37,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" { diff --git a/mmv1/third_party/terraform/services/logging/resource_logging_bucket_config_test.go b/mmv1/third_party/terraform/services/logging/resource_logging_bucket_config_test.go index 753e8333ff4c..12e363dfe457 100644 --- a/mmv1/third_party/terraform/services/logging/resource_logging_bucket_config_test.go +++ b/mmv1/third_party/terraform/services/logging/resource_logging_bucket_config_test.go @@ -256,6 +256,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" { diff --git a/mmv1/third_party/terraform/services/logging/resource_logging_folder_exclusion_test.go b/mmv1/third_party/terraform/services/logging/resource_logging_folder_exclusion_test.go index 34af9a5cfaf4..51a8a35058d5 100644 --- a/mmv1/third_party/terraform/services/logging/resource_logging_folder_exclusion_test.go +++ b/mmv1/third_party/terraform/services/logging/resource_logging_folder_exclusion_test.go @@ -237,6 +237,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) } @@ -253,6 +254,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) } @@ -262,6 +264,7 @@ func testAccLoggingFolderExclusion_multipleCfg(folderName, folderParent, exclusi resource "google_folder" "my-folder" { display_name = "%s" parent = "%s" + deletion_protection = false } `, folderName, folderParent) diff --git a/mmv1/third_party/terraform/services/logging/resource_logging_folder_settings_test.go b/mmv1/third_party/terraform/services/logging/resource_logging_folder_settings_test.go index 39128f267562..2acc95492791 100644 --- a/mmv1/third_party/terraform/services/logging/resource_logging_folder_settings_test.go +++ b/mmv1/third_party/terraform/services/logging/resource_logging_folder_settings_test.go @@ -58,6 +58,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" { @@ -81,6 +82,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) } diff --git a/mmv1/third_party/terraform/services/logging/resource_logging_folder_sink_test.go b/mmv1/third_party/terraform/services/logging/resource_logging_folder_sink_test.go index 72e20a264f0d..1c82b4f80abf 100644 --- a/mmv1/third_party/terraform/services/logging/resource_logging_folder_sink_test.go +++ b/mmv1/third_party/terraform/services/logging/resource_logging_folder_sink_test.go @@ -400,6 +400,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) } @@ -423,6 +424,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) } @@ -446,6 +448,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) } @@ -466,8 +469,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) } @@ -489,6 +493,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) } @@ -519,6 +524,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) } @@ -545,6 +551,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) } @@ -566,6 +573,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) } @@ -583,6 +591,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) } diff --git a/mmv1/third_party/terraform/services/orgpolicy/resource_org_policy_policy_test.go b/mmv1/third_party/terraform/services/orgpolicy/resource_org_policy_policy_test.go index adfa8d105ef5..e91cc848f72e 100644 --- a/mmv1/third_party/terraform/services/orgpolicy/resource_org_policy_policy_test.go +++ b/mmv1/third_party/terraform/services/orgpolicy/resource_org_policy_policy_test.go @@ -208,6 +208,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 } @@ -245,6 +246,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 } diff --git a/mmv1/third_party/terraform/services/resourcemanager/data_source_google_active_folder_test.go b/mmv1/third_party/terraform/services/resourcemanager/data_source_google_active_folder_test.go index 91f7ad0dcc24..3a65b6587f70 100644 --- a/mmv1/third_party/terraform/services/resourcemanager/data_source_google_active_folder_test.go +++ b/mmv1/third_party/terraform/services/resourcemanager/data_source_google_active_folder_test.go @@ -128,6 +128,7 @@ func testAccDataSourceGoogleActiveFolderConfig(parent string, displayName string resource "google_folder" "foobar" { parent = "%s" display_name = "%s" + deletion_protection = false } data "google_active_folder" "my_folder" { @@ -142,6 +143,7 @@ func testAccDataSourceGoogleActiveFolderConfig_Search(parent string, displayName resource "google_folder" "foobar" { parent = "%s" display_name = "%s" + deletion_protection = false } # Wait after folder creation to limit eventual consistency errors. diff --git a/mmv1/third_party/terraform/services/resourcemanager/data_source_google_folder.go b/mmv1/third_party/terraform/services/resourcemanager/data_source_google_folder.go index fb95137a83cc..f644f61c84c9 100644 --- a/mmv1/third_party/terraform/services/resourcemanager/data_source_google_folder.go +++ b/mmv1/third_party/terraform/services/resourcemanager/data_source_google_folder.go @@ -50,6 +50,10 @@ func DataSourceGoogleFolder() *schema.Resource { Type: schema.TypeString, Computed: true, }, + "deletion_protection": { + Type: schema.TypeBool, + Computed: true, + }, }, } } @@ -71,6 +75,10 @@ func dataSourceFolderRead(d *schema.ResourceData, meta interface{}) error { return fmt.Errorf("%s not found", id) } + if err := d.Set("deletion_protection", nil); err != nil { + return fmt.Errorf("Error setting deletion_protection: %s", err) + } + if v, ok := d.GetOk("lookup_organization"); ok && v.(bool) { organization, err := lookupOrganizationName(d.Id(), userAgent, d, config) if err != nil { diff --git a/mmv1/third_party/terraform/services/resourcemanager/data_source_google_folder_organization_policy_test.go b/mmv1/third_party/terraform/services/resourcemanager/data_source_google_folder_organization_policy_test.go index 81361f7ec30e..998a0664879b 100644 --- a/mmv1/third_party/terraform/services/resourcemanager/data_source_google_folder_organization_policy_test.go +++ b/mmv1/third_party/terraform/services/resourcemanager/data_source_google_folder_organization_policy_test.go @@ -33,6 +33,7 @@ func testAccDataSourceGoogleFolderOrganizationPolicy_basic(org, folder string) s resource "google_folder" "orgpolicy" { display_name = "%s" parent = "%s" + deletion_protection = false } resource "google_folder_organization_policy" "resource" { diff --git a/mmv1/third_party/terraform/services/resourcemanager/data_source_google_folder_test.go b/mmv1/third_party/terraform/services/resourcemanager/data_source_google_folder_test.go index d4501b2eded6..79ae8c9da658 100644 --- a/mmv1/third_party/terraform/services/resourcemanager/data_source_google_folder_test.go +++ b/mmv1/third_party/terraform/services/resourcemanager/data_source_google_folder_test.go @@ -123,6 +123,7 @@ func testAccCheckGoogleFolder_byFullNameConfig(parent string, displayName string resource "google_folder" "foobar" { parent = "%s" display_name = "%s" + deletion_protection = false } data "google_folder" "folder" { @@ -136,6 +137,7 @@ func testAccCheckGoogleFolder_byShortNameConfig(parent string, displayName strin resource "google_folder" "foobar" { parent = "%s" display_name = "%s" + deletion_protection = false } data "google_folder" "folder" { @@ -149,6 +151,7 @@ func testAccCheckGoogleFolder_lookupOrganizationConfig(parent string, displayNam resource "google_folder" "foobar" { parent = "%s" display_name = "%s" + deletion_protection = false } data "google_folder" "folder" { diff --git a/mmv1/third_party/terraform/services/resourcemanager/data_source_google_folders_test.go b/mmv1/third_party/terraform/services/resourcemanager/data_source_google_folders_test.go index ae106939dbca..88e59cccd32f 100644 --- a/mmv1/third_party/terraform/services/resourcemanager/data_source_google_folders_test.go +++ b/mmv1/third_party/terraform/services/resourcemanager/data_source_google_folders_test.go @@ -40,6 +40,7 @@ func testAccCheckGoogleFoldersConfig(parent string, displayName string) string { resource "google_folder" "foobar" { parent = "%s" display_name = "%s" + deletion_protection = false } data "google_folders" "root-test" { diff --git a/mmv1/third_party/terraform/services/resourcemanager/resource_google_folder.go b/mmv1/third_party/terraform/services/resourcemanager/resource_google_folder.go index 84688819328c..653da5651bc9 100644 --- a/mmv1/third_party/terraform/services/resourcemanager/resource_google_folder.go +++ b/mmv1/third_party/terraform/services/resourcemanager/resource_google_folder.go @@ -65,6 +65,12 @@ func ResourceGoogleFolder() *schema.Resource { Computed: true, Description: `Timestamp when the Folder was created. Assigned by the server. A timestamp in RFC3339 UTC "Zulu" format, accurate to nanoseconds. Example: "2014-10-02T15:01:23.045123456Z".`, }, + "deletion_protection": { + Type: schema.TypeBool, + Optional: true, + Default: true, + Description: `When the field is set to true or unset in Terraform state, a terraform apply or terraform destroy that would delete the instance will fail. When the field is set to false, deleting the instance is allowed.`, + }, }, UseJSONNumber: true, } @@ -136,7 +142,12 @@ func resourceGoogleFolderRead(d *schema.ResourceData, meta interface{}) error { if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("Folder Not Found : %s", d.Id())) } - + // Explicitly set client-side fields to default values if unset + if _, ok := d.GetOkExists("deletion_protection"); !ok { + if err := d.Set("deletion_protection", true); err != nil { + return fmt.Errorf("Error setting deletion_protection: %s", err) + } + } if err := d.Set("name", folder.Name); err != nil { return fmt.Errorf("Error setting name: %s", err) } @@ -166,6 +177,19 @@ func resourceGoogleFolderUpdate(d *schema.ResourceData, meta interface{}) error if err != nil { return err } + + clientSideFields := map[string]bool{"deletion_protection": true} + clientSideOnly := true + for field := range ResourceGoogleFolder().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + return nil + } + displayName := d.Get("display_name").(string) d.Partial(true) @@ -222,6 +246,11 @@ func resourceGoogleFolderDelete(d *schema.ResourceData, meta interface{}) error if err != nil { return err } + + if d.Get("deletion_protection").(bool) { + return fmt.Errorf("cannot destroy folder without setting deletion_protection=false and running `terraform apply`") + } + displayName := d.Get("display_name").(string) var op *resourceManagerV3.Operation diff --git a/mmv1/third_party/terraform/services/resourcemanager/resource_google_folder_iam_audit_config_test.go b/mmv1/third_party/terraform/services/resourcemanager/resource_google_folder_iam_audit_config_test.go index 1236dda5d310..30358b6b0a59 100644 --- a/mmv1/third_party/terraform/services/resourcemanager/resource_google_folder_iam_audit_config_test.go +++ b/mmv1/third_party/terraform/services/resourcemanager/resource_google_folder_iam_audit_config_test.go @@ -277,6 +277,7 @@ func testAccFolderAssociateAuditConfigBasic(org, fname, service string) string { resource "google_folder" "acceptance" { parent = "organizations/%s" display_name = "%s" + deletion_protection = false } resource "google_folder_iam_audit_config" "acceptance" { @@ -298,6 +299,7 @@ func testAccFolderAssociateAuditConfigMultiple(org, fname, service, service2 str resource "google_folder" "acceptance" { parent = "organizations/%s" display_name = "%s" + deletion_protection = false } resource "google_folder_iam_audit_config" "acceptance" { @@ -327,6 +329,7 @@ func testAccFolderAssociateAuditConfigUpdated(org, fname, service string) string resource "google_folder" "acceptance" { parent = "organizations/%s" display_name = "%s" + deletion_protection = false } resource "google_folder_iam_audit_config" "acceptance" { @@ -348,6 +351,7 @@ func testAccFolderAssociateAuditConfigDropMemberFromBasic(org, fname, service st resource "google_folder" "acceptance" { parent = "organizations/%s" display_name = "%s" + deletion_protection = false } resource "google_folder_iam_audit_config" "acceptance" { @@ -375,6 +379,7 @@ func testAccFolderAssociateAuditConfigMembers(org, fname, service string, member resource "google_folder" "acceptance" { parent = "organizations/%s" display_name = "%s" + deletion_protection = false } resource "google_folder_iam_audit_config" "acceptance" { @@ -392,6 +397,7 @@ func testAccFolderAssociateAuditConfigLogType(org, fname, service, logType strin resource "google_folder" "acceptance" { parent = "organizations/%s" display_name = "%s" + deletion_protection = false } resource "google_folder_iam_audit_config" "acceptance" { diff --git a/mmv1/third_party/terraform/services/resourcemanager/resource_google_folder_iam_binding_test.go b/mmv1/third_party/terraform/services/resourcemanager/resource_google_folder_iam_binding_test.go index 0bf14757725a..947d48010f30 100644 --- a/mmv1/third_party/terraform/services/resourcemanager/resource_google_folder_iam_binding_test.go +++ b/mmv1/third_party/terraform/services/resourcemanager/resource_google_folder_iam_binding_test.go @@ -293,6 +293,7 @@ func testAccFolderIamBasic(org, fname string) string { resource "google_folder" "acceptance" { parent = "organizations/%s" display_name = "%s" + deletion_protection = false } `, org, fname) } @@ -302,6 +303,7 @@ func testAccFolderAssociateBindingBasic(org, fname string) string { resource "google_folder" "acceptance" { parent = "organizations/%s" display_name = "%s" + deletion_protection = false } resource "google_folder_iam_binding" "acceptance" { @@ -317,6 +319,7 @@ func testAccFolderAssociateBindingMultiple(org, fname string) string { resource "google_folder" "acceptance" { parent = "organizations/%s" display_name = "%s" + deletion_protection = false } resource "google_folder_iam_binding" "acceptance" { @@ -338,6 +341,7 @@ func testAccFolderAssociateBindingUpdated(org, fname string) string { resource "google_folder" "acceptance" { parent = "organizations/%s" display_name = "%s" + deletion_protection = false } resource "google_folder_iam_binding" "acceptance" { @@ -353,6 +357,7 @@ func testAccFolderAssociateBindingDropMemberFromBasic(org, fname string) string resource "google_folder" "acceptance" { parent = "organizations/%s" display_name = "%s" + deletion_protection = false } resource "google_folder_iam_binding" "acceptance" { diff --git a/mmv1/third_party/terraform/services/resourcemanager/resource_google_folder_iam_member_test.go b/mmv1/third_party/terraform/services/resourcemanager/resource_google_folder_iam_member_test.go index a331a29b908d..c9f305e81f2a 100644 --- a/mmv1/third_party/terraform/services/resourcemanager/resource_google_folder_iam_member_test.go +++ b/mmv1/third_party/terraform/services/resourcemanager/resource_google_folder_iam_member_test.go @@ -127,6 +127,7 @@ func testAccFolderAssociateMemberBasic(org, fname string) string { resource "google_folder" "acceptance" { parent = "organizations/%s" display_name = "%s" + deletion_protection = false } resource "google_folder_iam_member" "acceptance" { @@ -142,6 +143,7 @@ func testAccFolderAssociateMemberMultiple(org, fname string) string { resource "google_folder" "acceptance" { parent = "organizations/%s" display_name = "%s" + deletion_protection = false } resource "google_folder_iam_member" "acceptance" { diff --git a/mmv1/third_party/terraform/services/resourcemanager/resource_google_folder_iam_policy_test.go b/mmv1/third_party/terraform/services/resourcemanager/resource_google_folder_iam_policy_test.go index 813180660a46..23e713b85ab7 100644 --- a/mmv1/third_party/terraform/services/resourcemanager/resource_google_folder_iam_policy_test.go +++ b/mmv1/third_party/terraform/services/resourcemanager/resource_google_folder_iam_policy_test.go @@ -109,6 +109,7 @@ func testAccFolderIamPolicy_basic(folder, parent, role, member string) string { resource "google_folder" "permissiontest" { display_name = "%s" parent = "%s" + deletion_protection = false } data "google_iam_policy" "test" { @@ -134,6 +135,7 @@ func testAccFolderIamPolicy_basic2(folder, parent, role, member, role2, member2 resource "google_folder" "permissiontest" { display_name = "%s" parent = "%s" + deletion_protection = false } data "google_iam_policy" "test" { @@ -160,6 +162,7 @@ func testAccFolderIamPolicy_auditConfigs(folder, parent, role, member string) st resource "google_folder" "permissiontest" { display_name = "%s" parent = "%s" + deletion_protection = false } data "google_iam_policy" "test" { diff --git a/mmv1/third_party/terraform/services/resourcemanager/resource_google_folder_organization_policy_test.go b/mmv1/third_party/terraform/services/resourcemanager/resource_google_folder_organization_policy_test.go index aea0240c779a..d9e85b03060f 100644 --- a/mmv1/third_party/terraform/services/resourcemanager/resource_google_folder_organization_policy_test.go +++ b/mmv1/third_party/terraform/services/resourcemanager/resource_google_folder_organization_policy_test.go @@ -310,6 +310,7 @@ func testAccFolderOrganizationPolicy_boolean(org, folder string, enforced bool) resource "google_folder" "orgpolicy" { display_name = "%s" parent = "%s" + deletion_protection = false } resource "google_folder_organization_policy" "bool" { @@ -329,6 +330,7 @@ func testAccFolderOrganizationPolicy_list_allowAll(org, folder string) string { resource "google_folder" "orgpolicy" { display_name = "%s" parent = "%s" + deletion_protection = false } resource "google_folder_organization_policy" "list" { @@ -349,6 +351,7 @@ func testAccFolderOrganizationPolicy_list_allowSome(org, folder, project string) resource "google_folder" "orgpolicy" { display_name = "%s" parent = "%s" + deletion_protection = false } resource "google_folder_organization_policy" "list" { @@ -369,6 +372,7 @@ func testAccFolderOrganizationPolicy_list_denySome(org, folder string) string { resource "google_folder" "orgpolicy" { display_name = "%s" parent = "%s" + deletion_protection = false } resource "google_folder_organization_policy" "list" { @@ -392,6 +396,7 @@ func testAccFolderOrganizationPolicy_restore_defaultTrue(org, folder string) str resource "google_folder" "orgpolicy" { display_name = "%s" parent = "%s" + deletion_protection = false } resource "google_folder_organization_policy" "restore" { diff --git a/mmv1/third_party/terraform/services/resourcemanager/resource_google_folder_test.go b/mmv1/third_party/terraform/services/resourcemanager/resource_google_folder_test.go index 120229adcf16..75f1a08ca995 100644 --- a/mmv1/third_party/terraform/services/resourcemanager/resource_google_folder_test.go +++ b/mmv1/third_party/terraform/services/resourcemanager/resource_google_folder_test.go @@ -42,9 +42,10 @@ func TestAccFolder_rename(t *testing.T) { testAccCheckGoogleFolderDisplayName(&folder, newFolderDisplayName), )}, { - ResourceName: "google_folder.folder1", - ImportState: true, - ImportStateVerify: true, + ResourceName: "google_folder.folder1", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"deletion_protection"}, }, }, }) @@ -153,6 +154,7 @@ func testAccFolder_basic(folder, parent string) string { resource "google_folder" "folder1" { display_name = "%s" parent = "%s" + deletion_protection = false } `, folder, parent) } @@ -162,11 +164,13 @@ func testAccFolder_move(folder1, folder2, parent string) string { resource "google_folder" "folder1" { display_name = "%s" parent = google_folder.folder2.name + deletion_protection = false } resource "google_folder" "folder2" { display_name = "%s" parent = "%s" + deletion_protection = false } `, folder1, folder2, parent) } diff --git a/mmv1/third_party/terraform/services/resourcemanager/resource_google_project_test.go b/mmv1/third_party/terraform/services/resourcemanager/resource_google_project_test.go index 4c72414f8b95..82248eca8fc5 100644 --- a/mmv1/third_party/terraform/services/resourcemanager/resource_google_project_test.go +++ b/mmv1/third_party/terraform/services/resourcemanager/resource_google_project_test.go @@ -411,6 +411,7 @@ resource "google_project" "acceptance" { resource "google_folder" "folder1" { display_name = "%s" parent = "organizations/%s" + deletion_protection = false } `, pid, pid, folderName, org) } @@ -427,6 +428,7 @@ resource "google_project" "acceptance" { resource "google_folder" "folder1" { display_name = "%s" parent = "organizations/%s" + deletion_protection = false } `, pid, pid, folderName, org) } @@ -443,6 +445,7 @@ resource "google_project" "acceptance" { resource "google_folder" "folder1" { display_name = "%s" parent = "organizations/%s" + deletion_protection = false } `, pid, pid, org, folderName, org) } diff --git a/mmv1/third_party/terraform/services/securitycenter/resource_scc_folder_custom_module_test.go b/mmv1/third_party/terraform/services/securitycenter/resource_scc_folder_custom_module_test.go index 11fd9d647aa2..08675ede43b2 100644 --- a/mmv1/third_party/terraform/services/securitycenter/resource_scc_folder_custom_module_test.go +++ b/mmv1/third_party/terraform/services/securitycenter/resource_scc_folder_custom_module_test.go @@ -70,6 +70,7 @@ func testAccSecurityCenterFolderCustomModule_sccFolderCustomModuleBasicExample(c resource "google_folder" "folder" { parent = "organizations/%{org_id}" display_name = "tf-test-folder-name%{random_suffix}" + deletion_protection = false } resource "time_sleep" "wait_1_minute" { @@ -107,6 +108,7 @@ func testAccSecurityCenterFolderCustomModule_sccFolderCustomModuleFullExample(co resource "google_folder" "folder" { parent = "organizations/%{org_id}" display_name = "tf-test-folder-name%{random_suffix}" + deletion_protection = false } resource "google_scc_folder_custom_module" "example" { @@ -149,6 +151,7 @@ func testAccSecurityCenterFolderCustomModule_sccFolderCustomModuleUpdate(context resource "google_folder" "folder" { parent = "organizations/%{org_id}" display_name = "tf-test-folder-name%{random_suffix}" + deletion_protection = false } resource "google_scc_folder_custom_module" "example" { diff --git a/mmv1/third_party/terraform/services/securitycentermanagement/resource_scc_management_folder_security_health_analytics_custom_module_test.go b/mmv1/third_party/terraform/services/securitycentermanagement/resource_scc_management_folder_security_health_analytics_custom_module_test.go index d7798136e117..b0135f014382 100644 --- a/mmv1/third_party/terraform/services/securitycentermanagement/resource_scc_management_folder_security_health_analytics_custom_module_test.go +++ b/mmv1/third_party/terraform/services/securitycentermanagement/resource_scc_management_folder_security_health_analytics_custom_module_test.go @@ -71,6 +71,7 @@ func testAccSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModule_sc resource "google_folder" "folder" { parent = "organizations/%{org_id}" display_name = "tf-test-folder-name%{random_suffix}" + deletion_protection = false } resource "time_sleep" "wait_1_minute" { @@ -109,6 +110,7 @@ func testAccSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModule_sc resource "google_folder" "folder" { parent = "organizations/%{org_id}" display_name = "tf-test-folder-name%{random_suffix}" + deletion_protection = false } resource "google_scc_management_folder_security_health_analytics_custom_module" "example" { @@ -152,6 +154,7 @@ func testAccSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModule_sc resource "google_folder" "folder" { parent = "organizations/%{org_id}" display_name = "tf-test-folder-name%{random_suffix}" + deletion_protection = false } resource "google_scc_management_folder_security_health_analytics_custom_module" "example" { diff --git a/mmv1/third_party/terraform/website/docs/guides/version_6_upgrade.html.markdown b/mmv1/third_party/terraform/website/docs/guides/version_6_upgrade.html.markdown index 4e886659ef41..5f3f94dd6fda 100644 --- a/mmv1/third_party/terraform/website/docs/guides/version_6_upgrade.html.markdown +++ b/mmv1/third_party/terraform/website/docs/guides/version_6_upgrade.html.markdown @@ -205,6 +205,19 @@ resource blocks that contain both fields in a conflicting pair, and remove one o The fields that are removed from the configuration will still have Computed values, that are derived from the API. +## Resource: `google_folder` + +### Folder deletion now prevented by default with `deletion_protection` + +The field `deletion_protection` has been added with a default value of `true`. This field prevents +Terraform from destroying or recreating the Folder. In 6.0.0, existing folders will have +`deletion_protection` set to `true` during the next refresh unless otherwise set in configuration. + +**`deletion_protection` does NOT prevent deletion outside of Terraform.** + +To disable deletion protection, explicitly set this field to `false` in configuration +and then run `terraform apply` to apply the change. + ## Resource: `google_storage_bucket` ### `lifecycle_rule.condition.no_age` is now removed diff --git a/mmv1/third_party/tgc/tests/data/example_google_logging_folder_bucket_config.tf b/mmv1/third_party/tgc/tests/data/example_google_logging_folder_bucket_config.tf index ef2e64b836b1..a9fe52aecb9f 100644 --- a/mmv1/third_party/tgc/tests/data/example_google_logging_folder_bucket_config.tf +++ b/mmv1/third_party/tgc/tests/data/example_google_logging_folder_bucket_config.tf @@ -14,6 +14,7 @@ provider "google" { resource "google_folder" "default" { display_name = "some-folder-name" parent = "organizations/{{.OrgID}}" + deletion_protection = false } resource "google_logging_folder_bucket_config" "basic" { diff --git a/mmv1/third_party/tgc/tests/data/example_project_create.tf b/mmv1/third_party/tgc/tests/data/example_project_create.tf index 2043396c2ad6..487a8b48873c 100644 --- a/mmv1/third_party/tgc/tests/data/example_project_create.tf +++ b/mmv1/third_party/tgc/tests/data/example_project_create.tf @@ -42,4 +42,5 @@ resource "google_project" "my_project-in-a-folder" { resource "google_folder" "department1" { display_name = "Department 1" parent = "organizations/{{.OrgID}}" + deletion_protection = false } diff --git a/mmv1/third_party/tgc/tests/data/example_project_create_empty_project_id.tf b/mmv1/third_party/tgc/tests/data/example_project_create_empty_project_id.tf index 374df42c4fea..d260d17b364b 100644 --- a/mmv1/third_party/tgc/tests/data/example_project_create_empty_project_id.tf +++ b/mmv1/third_party/tgc/tests/data/example_project_create_empty_project_id.tf @@ -48,4 +48,5 @@ resource "random_string" "suffix" { resource "google_folder" "department1" { display_name = "Department 1" parent = "organizations/{{.OrgID}}" + deletion_protection = false } diff --git a/tpgtools/overrides/assuredworkloads/samples/workload/basic.tf.tmpl b/tpgtools/overrides/assuredworkloads/samples/workload/basic.tf.tmpl index 8d303ef61437..51db686c8b2f 100644 --- a/tpgtools/overrides/assuredworkloads/samples/workload/basic.tf.tmpl +++ b/tpgtools/overrides/assuredworkloads/samples/workload/basic.tf.tmpl @@ -18,4 +18,5 @@ resource "google_assured_workloads_workload" "primary" { resource "google_folder" "folder1" { display_name = "{{name}}" parent = "organizations/{{org_id}}" + deletion_protection = false } \ No newline at end of file diff --git a/tpgtools/overrides/assuredworkloads/samples/workload/basic_update.tf.tmpl b/tpgtools/overrides/assuredworkloads/samples/workload/basic_update.tf.tmpl index 4d5fb120eb93..f58d0caa2d31 100644 --- a/tpgtools/overrides/assuredworkloads/samples/workload/basic_update.tf.tmpl +++ b/tpgtools/overrides/assuredworkloads/samples/workload/basic_update.tf.tmpl @@ -18,4 +18,5 @@ resource "google_assured_workloads_workload" "primary" { resource "google_folder" "folder1" { display_name = "{{name}}" parent = "organizations/{{org_id}}" + deletion_protection = false } \ No newline at end of file diff --git a/tpgtools/overrides/assuredworkloads/samples/workload/full.tf.tmpl b/tpgtools/overrides/assuredworkloads/samples/workload/full.tf.tmpl index 6f6892ceb96f..d73ba356def2 100644 --- a/tpgtools/overrides/assuredworkloads/samples/workload/full.tf.tmpl +++ b/tpgtools/overrides/assuredworkloads/samples/workload/full.tf.tmpl @@ -14,4 +14,5 @@ resource "google_assured_workloads_workload" "primary" { resource "google_folder" "folder1" { display_name = "{{name}}" parent = "organizations/{{org_id}}" + deletion_protection = false } diff --git a/tpgtools/overrides/compute/samples/firewallpolicyrule/basic_fir_sec_rule.tf.tmpl b/tpgtools/overrides/compute/samples/firewallpolicyrule/basic_fir_sec_rule.tf.tmpl index e3176d43aee0..243065e67d61 100644 --- a/tpgtools/overrides/compute/samples/firewallpolicyrule/basic_fir_sec_rule.tf.tmpl +++ b/tpgtools/overrides/compute/samples/firewallpolicyrule/basic_fir_sec_rule.tf.tmpl @@ -11,6 +11,7 @@ resource "google_network_security_address_group" "basic_global_networksecurity_a resource "google_folder" "folder" { display_name = "{{policy}}" parent = "organizations/{{org_id}}" + deletion_protection = false } resource "google_compute_firewall_policy" "default" { diff --git a/tpgtools/overrides/compute/samples/firewallpolicyrule/basic_fir_sec_rule_update.tf.tmpl b/tpgtools/overrides/compute/samples/firewallpolicyrule/basic_fir_sec_rule_update.tf.tmpl index 82930ce33b3f..02a06ec9f717 100644 --- a/tpgtools/overrides/compute/samples/firewallpolicyrule/basic_fir_sec_rule_update.tf.tmpl +++ b/tpgtools/overrides/compute/samples/firewallpolicyrule/basic_fir_sec_rule_update.tf.tmpl @@ -11,6 +11,7 @@ resource "google_network_security_address_group" "basic_global_networksecurity_a resource "google_folder" "folder" { display_name = "{{policy}}" parent = "organizations/{{org_id}}" + deletion_protection = false } resource "google_compute_firewall_policy" "default" {