From 620627bf39c8b7a37002cd674a0ab16313df7592 Mon Sep 17 00:00:00 2001 From: Modular Magician Date: Mon, 11 May 2026 16:16:28 +0000 Subject: [PATCH] add support for universal `deletion_policy` (#17380) [upstream:e5b837d81166744565f99310316c189e91a14fae] Signed-off-by: Modular Magician --- .changelog/17380.txt | 3 + google/acctest/test_utils.go | 2 +- google/acctest/vcr_utils.go | 5 + google/fwmodels/provider_model.go | 1 + google/fwprovider/framework_provider.go | 3 + google/provider/provider.go | 9 ++ ...esource_folder_access_approval_settings.go | 47 +++++++++ ...cess_approval_settings_generated_meta.yaml | 2 + ...e_organization_access_approval_settings.go | 47 +++++++++ ...cess_approval_settings_generated_meta.yaml | 2 + ...source_project_access_approval_settings.go | 47 +++++++++ ...cess_approval_settings_generated_meta.yaml | 2 + ...rce_access_context_manager_access_level.go | 47 +++++++++ ..._context_manager_access_level_condition.go | 40 ++++++++ ...access_level_condition_generated_meta.yaml | 2 + ...t_manager_access_level_generated_meta.yaml | 2 + ...ce_access_context_manager_access_levels.go | 47 +++++++++ ..._manager_access_levels_generated_meta.yaml | 2 + ...ce_access_context_manager_access_policy.go | 47 +++++++++ ..._manager_access_policy_generated_meta.yaml | 2 + ...ss_context_manager_authorized_orgs_desc.go | 47 +++++++++ ...r_authorized_orgs_desc_generated_meta.yaml | 2 + ...ce_access_context_manager_egress_policy.go | 40 ++++++++ ..._manager_egress_policy_generated_meta.yaml | 2 + ...context_manager_gcp_user_access_binding.go | 47 +++++++++ ...cp_user_access_binding_generated_meta.yaml | 2 + ...e_access_context_manager_ingress_policy.go | 40 ++++++++ ...manager_ingress_policy_generated_meta.yaml | 2 + ...ccess_context_manager_service_perimeter.go | 47 +++++++++ ...service_perimeter_dry_run_egress_policy.go | 40 ++++++++ ..._dry_run_egress_policy_generated_meta.yaml | 2 + ...ervice_perimeter_dry_run_ingress_policy.go | 40 ++++++++ ...dry_run_ingress_policy_generated_meta.yaml | 2 + ...ager_service_perimeter_dry_run_resource.go | 40 ++++++++ ...meter_dry_run_resource_generated_meta.yaml | 2 + ...manager_service_perimeter_egress_policy.go | 40 ++++++++ ...erimeter_egress_policy_generated_meta.yaml | 2 + ...ager_service_perimeter_generated_meta.yaml | 2 + ...anager_service_perimeter_ingress_policy.go | 40 ++++++++ ...rimeter_ingress_policy_generated_meta.yaml | 2 + ...text_manager_service_perimeter_resource.go | 40 ++++++++ ...ice_perimeter_resource_generated_meta.yaml | 2 + ...cess_context_manager_service_perimeters.go | 47 +++++++++ ...ger_service_perimeters_generated_meta.yaml | 2 + .../resource_active_directory_domain.go | 45 +++++++++ ...ctive_directory_domain_generated_meta.yaml | 2 + .../resource_active_directory_domain_trust.go | 46 +++++++++ ...directory_domain_trust_generated_meta.yaml | 2 + .../alloydb/resource_alloydb_backup.go | 46 +++++++++ ...esource_alloydb_backup_generated_meta.yaml | 2 + .../alloydb/resource_alloydb_cluster.go | 56 +++++++---- ...source_alloydb_cluster_generated_meta.yaml | 4 +- .../alloydb/resource_alloydb_instance.go | 47 +++++++++ ...ource_alloydb_instance_generated_meta.yaml | 2 + .../services/alloydb/resource_alloydb_user.go | 47 +++++++++ .../resource_alloydb_user_generated_meta.yaml | 2 + .../apigee/resource_apigee_addons_config.go | 47 +++++++++ ...e_apigee_addons_config_generated_meta.yaml | 2 + google/services/apigee/resource_apigee_api.go | 21 ++++ .../apigee/resource_apigee_api_deployment.go | 40 ++++++++ ..._apigee_api_deployment_generated_meta.yaml | 2 + .../apigee/resource_apigee_api_meta.yaml | 2 + .../apigee/resource_apigee_api_product.go | 47 +++++++++ ...rce_apigee_api_product_generated_meta.yaml | 2 + .../apigee/resource_apigee_app_group.go | 47 +++++++++ ...ource_apigee_app_group_generated_meta.yaml | 2 + .../resource_apigee_control_plane_access.go | 1 + .../apigee/resource_apigee_developer.go | 47 +++++++++ .../apigee/resource_apigee_developer_app.go | 47 +++++++++ ...e_apigee_developer_app_generated_meta.yaml | 2 + ...ource_apigee_developer_generated_meta.yaml | 2 + .../apigee/resource_apigee_dns_zone.go | 40 ++++++++ ...source_apigee_dns_zone_generated_meta.yaml | 2 + .../resource_apigee_endpoint_attachment.go | 40 ++++++++ ...ee_endpoint_attachment_generated_meta.yaml | 2 + .../apigee/resource_apigee_env_keystore.go | 40 ++++++++ ...ce_apigee_env_keystore_generated_meta.yaml | 2 + .../apigee/resource_apigee_env_references.go | 47 +++++++++ ..._apigee_env_references_generated_meta.yaml | 2 + .../apigee/resource_apigee_envgroup.go | 47 +++++++++ .../resource_apigee_envgroup_attachment.go | 40 ++++++++ ...ee_envgroup_attachment_generated_meta.yaml | 2 + ...source_apigee_envgroup_generated_meta.yaml | 2 + .../apigee/resource_apigee_environment.go | 47 +++++++++ ...source_apigee_environment_addons_config.go | 1 + ...gee_environment_api_revision_deployment.go | 40 ++++++++ ...pi_revision_deployment_generated_meta.yaml | 2 + ...rce_apigee_environment_generated_meta.yaml | 2 + ...esource_apigee_environment_keyvaluemaps.go | 40 ++++++++ ...apigee_environment_keyvaluemaps_entries.go | 40 ++++++++ ...t_keyvaluemaps_entries_generated_meta.yaml | 2 + ...vironment_keyvaluemaps_generated_meta.yaml | 2 + .../apigee/resource_apigee_flowhook.go | 28 ++++++ .../apigee/resource_apigee_flowhook_meta.yaml | 2 + .../apigee/resource_apigee_instance.go | 47 +++++++++ .../resource_apigee_instance_attachment.go | 40 ++++++++ ...ee_instance_attachment_generated_meta.yaml | 2 + ...source_apigee_instance_generated_meta.yaml | 2 + ...esource_apigee_keystores_aliases_pkcs12.go | 28 ++++++ ..._apigee_keystores_aliases_pkcs12_meta.yaml | 2 + ...igee_keystores_aliases_self_signed_cert.go | 40 ++++++++ ...iases_self_signed_cert_generated_meta.yaml | 2 + .../apigee/resource_apigee_nat_address.go | 47 +++++++++ ...rce_apigee_nat_address_generated_meta.yaml | 2 + .../apigee/resource_apigee_organization.go | 47 +++++++++ ...ce_apigee_organization_generated_meta.yaml | 2 + .../apigee/resource_apigee_security_action.go | 40 ++++++++ ...apigee_security_action_generated_meta.yaml | 2 + .../resource_apigee_security_feedback.go | 47 +++++++++ ...igee_security_feedback_generated_meta.yaml | 2 + ...ce_apigee_security_monitoring_condition.go | 47 +++++++++ ...y_monitoring_condition_generated_meta.yaml | 2 + .../resource_apigee_security_profile_v2.go | 47 +++++++++ ...ee_security_profile_v2_generated_meta.yaml | 2 + .../apigee/resource_apigee_sharedflow.go | 21 ++++ .../resource_apigee_sharedflow_deployment.go | 23 +++++ ...rce_apigee_sharedflow_deployment_meta.yaml | 2 + .../resource_apigee_sharedflow_meta.yaml | 2 + .../services/apigee/resource_apigee_space.go | 47 +++++++++ .../resource_apigee_space_generated_meta.yaml | 2 + .../resource_apigee_sync_authorization.go | 1 + .../apigee/resource_apigee_target_server.go | 47 +++++++++ ...e_apigee_target_server_generated_meta.yaml | 2 + .../resource_apihub_api_hub_instance.go | 2 +- .../apihub/resource_apihub_curation.go | 46 +++++++++ ...source_apihub_curation_generated_meta.yaml | 2 + .../services/apihub/resource_apihub_plugin.go | 39 ++++++++ ...resource_apihub_plugin_generated_meta.yaml | 2 + .../apihub/resource_apihub_plugin_instance.go | 46 +++++++++ ...apihub_plugin_instance_generated_meta.yaml | 2 + .../services/apikeys/resource_apikeys_key.go | 21 ++++ .../apikeys/resource_apikeys_key_meta.yaml | 2 + ...p_engine_application_url_dispatch_rules.go | 46 +++++++++ ...ion_url_dispatch_rules_generated_meta.yaml | 2 + .../resource_app_engine_domain_mapping.go | 46 +++++++++ ..._engine_domain_mapping_generated_meta.yaml | 2 + .../resource_app_engine_firewall_rule.go | 46 +++++++++ ...p_engine_firewall_rule_generated_meta.yaml | 2 + ...esource_app_engine_flexible_app_version.go | 45 +++++++++ ...e_flexible_app_version_generated_meta.yaml | 2 + ...rce_app_engine_service_network_settings.go | 1 + ...source_app_engine_service_split_traffic.go | 1 + ...esource_app_engine_standard_app_version.go | 45 +++++++++ ...e_standard_app_version_generated_meta.yaml | 2 + .../apphub/resource_apphub_application.go | 46 +++++++++ ...rce_apphub_application_generated_meta.yaml | 2 + .../apphub/resource_apphub_boundary.go | 1 + .../apphub/resource_apphub_service.go | 46 +++++++++ ...esource_apphub_service_generated_meta.yaml | 2 + ...ource_apphub_service_project_attachment.go | 39 ++++++++ ...ice_project_attachment_generated_meta.yaml | 2 + .../apphub/resource_apphub_workload.go | 46 +++++++++ ...source_apphub_workload_generated_meta.yaml | 2 + .../resource_artifact_registry_repository.go | 46 +++++++++ ...ct_registry_repository_generated_meta.yaml | 2 + .../resource_artifact_registry_rule.go | 46 +++++++++ ...artifact_registry_rule_generated_meta.yaml | 2 + .../resource_assured_workloads_workload.go | 20 ++++ ...ource_assured_workloads_workload_meta.yaml | 2 + .../resource_backup_dr_backup_plan.go | 46 +++++++++ ...ource_backup_dr_backup_plan_association.go | 46 +++++++++ ...ackup_plan_association_generated_meta.yaml | 2 + ..._backup_dr_backup_plan_generated_meta.yaml | 2 + .../resource_backup_dr_backup_vault.go | 46 +++++++++ ...backup_dr_backup_vault_generated_meta.yaml | 2 + .../resource_backup_dr_management_server.go | 39 ++++++++ ...p_dr_management_server_generated_meta.yaml | 2 + .../resource_backup_dr_restore_workload.go | 26 +++++ ...up_dr_restore_workload_generated_meta.yaml | 2 + .../resource_beyondcorp_app_connection.go | 46 +++++++++ ...ondcorp_app_connection_generated_meta.yaml | 2 + .../resource_beyondcorp_app_connector.go | 46 +++++++++ ...yondcorp_app_connector_generated_meta.yaml | 2 + .../resource_beyondcorp_app_gateway.go | 35 ++++++- ...beyondcorp_app_gateway_generated_meta.yaml | 2 + .../resource_beyondcorp_security_gateway.go | 46 +++++++++ ...beyondcorp_security_gateway_application.go | 46 +++++++++ ...ty_gateway_application_generated_meta.yaml | 2 + ...dcorp_security_gateway_generated_meta.yaml | 2 + .../biglake/resource_biglake_catalog.go | 39 ++++++++ ...source_biglake_catalog_generated_meta.yaml | 2 + .../biglake/resource_biglake_database.go | 47 +++++++++ ...ource_biglake_database_generated_meta.yaml | 2 + .../biglake/resource_biglake_table.go | 47 +++++++++ ...resource_biglake_table_generated_meta.yaml | 2 + .../resource_biglake_iceberg_catalog.go | 46 +++++++++ ...iglake_iceberg_catalog_generated_meta.yaml | 2 + .../resource_biglake_iceberg_namespace.go | 46 +++++++++ ...lake_iceberg_namespace_generated_meta.yaml | 2 + .../resource_biglake_iceberg_table.go | 46 +++++++++ ..._biglake_iceberg_table_generated_meta.yaml | 2 + .../bigquery/resource_bigquery_dataset.go | 45 +++++++++ .../resource_bigquery_dataset_access.go | 39 ++++++++ ...igquery_dataset_access_generated_meta.yaml | 2 + ...ource_bigquery_dataset_generated_meta.yaml | 2 + .../bigquery/resource_bigquery_job.go | 2 +- .../bigquery/resource_bigquery_routine.go | 46 +++++++++ ...ource_bigquery_routine_generated_meta.yaml | 2 + .../resource_bigquery_row_access_policy.go | 46 +++++++++ ...uery_row_access_policy_generated_meta.yaml | 2 + .../bigquery/resource_bigquery_table.go | 17 +++- .../resource_bigquery_table_meta.yaml | 2 + ...ce_bigquery_analytics_hub_data_exchange.go | 46 +++++++++ ...tics_hub_data_exchange_generated_meta.yaml | 2 + ...resource_bigquery_analytics_hub_listing.go | 45 +++++++++ ..._analytics_hub_listing_generated_meta.yaml | 2 + ...uery_analytics_hub_listing_subscription.go | 39 ++++++++ ...b_listing_subscription_generated_meta.yaml | 2 + .../resource_bigquery_connection.go | 46 +++++++++ ...ce_bigquery_connection_generated_meta.yaml | 2 + ...esource_bigquery_datapolicy_data_policy.go | 46 +++++++++ ...datapolicy_data_policy_generated_meta.yaml | 2 + ...ource_bigquery_datapolicyv2_data_policy.go | 46 +++++++++ ...tapolicyv2_data_policy_generated_meta.yaml | 2 + .../resource_bigquery_data_transfer_config.go | 46 +++++++++ ...y_data_transfer_config_generated_meta.yaml | 2 + .../resource_bigquery_bi_reservation.go | 46 +++++++++ ...igquery_bi_reservation_generated_meta.yaml | 2 + .../resource_bigquery_capacity_commitment.go | 46 +++++++++ ...ry_capacity_commitment_generated_meta.yaml | 2 + .../resource_bigquery_reservation.go | 46 +++++++++ ...esource_bigquery_reservation_assignment.go | 39 ++++++++ ...reservation_assignment_generated_meta.yaml | 2 + ...e_bigquery_reservation_generated_meta.yaml | 2 + .../resource_bigquery_reservation_group.go | 39 ++++++++ ...uery_reservation_group_generated_meta.yaml | 2 + .../bigtable/resource_bigtable_app_profile.go | 46 +++++++++ ...e_bigtable_app_profile_generated_meta.yaml | 2 + .../resource_bigtable_authorized_view.go | 20 ++++ ...esource_bigtable_authorized_view_meta.yaml | 2 + .../bigtable/resource_bigtable_gc_policy.go | 45 +++++---- .../resource_bigtable_gc_policy_meta.yaml | 1 + .../bigtable/resource_bigtable_instance.go | 21 +++- .../resource_bigtable_instance_meta.yaml | 2 + .../resource_bigtable_logical_view.go | 46 +++++++++ ..._bigtable_logical_view_generated_meta.yaml | 2 + .../resource_bigtable_materialized_view.go | 46 +++++++++ ...able_materialized_view_generated_meta.yaml | 2 + .../resource_bigtable_schema_bundle.go | 46 +++++++++ ...bigtable_schema_bundle_generated_meta.yaml | 2 + .../bigtable/resource_bigtable_table.go | 20 ++++ .../resource_bigtable_table_meta.yaml | 2 + .../billingbudgets/resource_billing_budget.go | 47 +++++++++ ...esource_billing_budget_generated_meta.yaml | 2 + .../resource_binary_authorization_attestor.go | 46 +++++++++ ...authorization_attestor_generated_meta.yaml | 2 + .../resource_binary_authorization_policy.go | 46 +++++++++ ...y_authorization_policy_generated_meta.yaml | 2 + ...blockchain_node_engine_blockchain_nodes.go | 46 +++++++++ ...ngine_blockchain_nodes_generated_meta.yaml | 2 + ...esource_certificate_manager_certificate.go | 46 +++++++++ ...te_manager_certificate_generated_meta.yaml | 2 + ...ate_manager_certificate_issuance_config.go | 35 ++++++- ...ficate_issuance_config_generated_meta.yaml | 2 + ...rce_certificate_manager_certificate_map.go | 46 +++++++++ ...rtificate_manager_certificate_map_entry.go | 46 +++++++++ ..._certificate_map_entry_generated_meta.yaml | 2 + ...anager_certificate_map_generated_meta.yaml | 2 + ...e_certificate_manager_dns_authorization.go | 46 +++++++++ ...ager_dns_authorization_generated_meta.yaml | 2 + ...source_certificate_manager_trust_config.go | 46 +++++++++ ...e_manager_trust_config_generated_meta.yaml | 2 + google/services/ces/resource_ces_agent.go | 46 +++++++++ .../resource_ces_agent_generated_meta.yaml | 2 + google/services/ces/resource_ces_app.go | 46 +++++++++ .../ces/resource_ces_app_generated_meta.yaml | 2 + ...resource_ces_app_root_agent_association.go | 46 +++++++++ ...root_agent_association_generated_meta.yaml | 2 + .../services/ces/resource_ces_app_version.go | 39 ++++++++ ...source_ces_app_version_generated_meta.yaml | 2 + .../services/ces/resource_ces_deployment.go | 46 +++++++++ ...esource_ces_deployment_generated_meta.yaml | 2 + google/services/ces/resource_ces_example.go | 46 +++++++++ .../resource_ces_example_generated_meta.yaml | 2 + google/services/ces/resource_ces_guardrail.go | 46 +++++++++ ...resource_ces_guardrail_generated_meta.yaml | 2 + google/services/ces/resource_ces_tool.go | 46 +++++++++ .../ces/resource_ces_tool_generated_meta.yaml | 2 + google/services/ces/resource_ces_toolset.go | 46 +++++++++ .../resource_ces_toolset_generated_meta.yaml | 2 + .../resource_chronicle_dashboard_chart.go | 46 +++++++++ ...onicle_dashboard_chart_generated_meta.yaml | 2 + .../resource_chronicle_data_access_label.go | 46 +++++++++ ...icle_data_access_label_generated_meta.yaml | 2 + .../resource_chronicle_data_access_scope.go | 46 +++++++++ ...icle_data_access_scope_generated_meta.yaml | 2 + .../resource_chronicle_data_table.go | 50 +++++++--- ...e_chronicle_data_table_generated_meta.yaml | 4 +- .../resource_chronicle_data_table_row.go | 46 +++++++++ ...ronicle_data_table_row_generated_meta.yaml | 2 + .../resource_chronicle_reference_list.go | 1 + .../chronicle/resource_chronicle_rule.go | 53 ++++++---- .../resource_chronicle_rule_deployment.go | 1 + ...esource_chronicle_rule_generated_meta.yaml | 4 +- .../chronicle/resource_chronicle_watchlist.go | 46 +++++++++ ...ce_chronicle_watchlist_generated_meta.yaml | 2 + .../resource_cloud_asset_folder_feed.go | 47 +++++++++ ...loud_asset_folder_feed_generated_meta.yaml | 2 + .../resource_cloud_asset_organization_feed.go | 47 +++++++++ ...sset_organization_feed_generated_meta.yaml | 2 + .../resource_cloud_asset_project_feed.go | 46 +++++++++ ...oud_asset_project_feed_generated_meta.yaml | 2 + .../resource_billing_project_info.go | 46 +++++++++ ...e_billing_project_info_generated_meta.yaml | 2 + ...urce_cloudbuild_bitbucket_server_config.go | 46 +++++++++ ...itbucket_server_config_generated_meta.yaml | 2 + .../cloudbuild/resource_cloudbuild_trigger.go | 46 +++++++++ ...rce_cloudbuild_trigger_generated_meta.yaml | 2 + .../resource_cloudbuild_worker_pool.go | 20 ++++ .../resource_cloudbuild_worker_pool_meta.yaml | 2 + .../resource_cloudbuildv2_connection.go | 46 +++++++++ ...loudbuildv2_connection_generated_meta.yaml | 2 + .../resource_cloudbuildv2_repository.go | 39 ++++++++ ...loudbuildv2_repository_generated_meta.yaml | 2 + .../resource_clouddeploy_automation.go | 46 +++++++++ ...clouddeploy_automation_generated_meta.yaml | 2 + ...resource_clouddeploy_custom_target_type.go | 46 +++++++++ ...loy_custom_target_type_generated_meta.yaml | 2 + .../resource_clouddeploy_delivery_pipeline.go | 20 ++++ ...ce_clouddeploy_delivery_pipeline_meta.yaml | 2 + .../resource_clouddeploy_deploy_policy.go | 46 +++++++++ ...uddeploy_deploy_policy_generated_meta.yaml | 2 + .../resource_clouddeploy_target.go | 20 ++++ .../resource_clouddeploy_target_meta.yaml | 2 + .../resource_clouddomains_registration.go | 2 +- .../resource_cloudfunctions_function.go | 20 ++++ ...resource_cloudfunctions_function_meta.yaml | 2 + .../resource_cloudfunctions2_function.go | 46 +++++++++ ...oudfunctions2_function_generated_meta.yaml | 2 + .../resource_cloud_identity_group.go | 47 +++++++++ ...e_cloud_identity_group_generated_meta.yaml | 2 + ...esource_cloud_identity_group_membership.go | 45 +++++++++ ...ntity_group_membership_generated_meta.yaml | 2 + .../cloudids/resource_cloud_ids_endpoint.go | 46 +++++++++ ...rce_cloud_ids_endpoint_generated_meta.yaml | 2 + .../resource_cloud_quotas_quota_preference.go | 1 + .../resource_cloud_run_domain_mapping.go | 39 ++++++++ ...oud_run_domain_mapping_generated_meta.yaml | 2 + .../cloudrun/resource_cloud_run_service.go | 45 +++++++++ ...urce_cloud_run_service_generated_meta.yaml | 2 + .../cloudrunv2/resource_cloud_run_v2_job.go | 45 +++++++++ ...ource_cloud_run_v2_job_generated_meta.yaml | 2 + .../resource_cloud_run_v2_service.go | 45 +++++++++ ...e_cloud_run_v2_service_generated_meta.yaml | 2 + .../resource_cloud_run_v2_worker_pool.go | 45 +++++++++ ...oud_run_v2_worker_pool_generated_meta.yaml | 2 + .../resource_cloud_scheduler_job.go | 46 +++++++++ ...ce_cloud_scheduler_job_generated_meta.yaml | 2 + ...cloud_security_compliance_cloud_control.go | 47 +++++++++ ...mpliance_cloud_control_generated_meta.yaml | 2 + ...rce_cloud_security_compliance_framework.go | 47 +++++++++ ...ecurity_compliance_framework_deployment.go | 40 ++++++++ ...e_framework_deployment_generated_meta.yaml | 2 + ...y_compliance_framework_generated_meta.yaml | 2 + .../cloudtasks/resource_cloud_tasks_queue.go | 45 +++++++++ ...urce_cloud_tasks_queue_generated_meta.yaml | 2 + .../resource_colab_notebook_execution.go | 39 ++++++++ ...lab_notebook_execution_generated_meta.yaml | 2 + .../services/colab/resource_colab_runtime.go | 45 +++++++++ ...resource_colab_runtime_generated_meta.yaml | 2 + .../colab/resource_colab_runtime_template.go | 46 +++++++++ ...colab_runtime_template_generated_meta.yaml | 2 + .../services/colab/resource_colab_schedule.go | 45 +++++++++ ...esource_colab_schedule_generated_meta.yaml | 2 + .../composer/resource_composer_environment.go | 21 ++++ .../resource_composer_environment_meta.yaml | 2 + ...urce_composer_user_workloads_config_map.go | 46 +++++++++ ...r_workloads_config_map_generated_meta.yaml | 2 + ...resource_composer_user_workloads_secret.go | 21 ++++ ...e_composer_user_workloads_secret_meta.yaml | 2 + ...ta_source_google_compute_instance_group.go | 5 + .../compute/resource_compute_address.go | 46 +++++++++ ...source_compute_address_generated_meta.yaml | 2 + .../compute/resource_compute_attached_disk.go | 24 +++++ .../resource_compute_attached_disk_meta.yaml | 2 + .../compute/resource_compute_autoscaler.go | 46 +++++++++ ...rce_compute_autoscaler_generated_meta.yaml | 2 + .../resource_compute_backend_bucket.go | 46 +++++++++ ...compute_backend_bucket_generated_meta.yaml | 2 + ...e_compute_backend_bucket_signed_url_key.go | 39 ++++++++ ..._bucket_signed_url_key_generated_meta.yaml | 2 + .../resource_compute_backend_service.go | 46 +++++++++ ...ompute_backend_service_generated_meta.yaml | 2 + ..._compute_backend_service_signed_url_key.go | 39 ++++++++ ...service_signed_url_key_generated_meta.yaml | 2 + .../resource_compute_cross_site_network.go | 46 +++++++++ ...ute_cross_site_network_generated_meta.yaml | 2 + .../services/compute/resource_compute_disk.go | 45 +++++++++ ...resource_compute_disk_async_replication.go | 29 ++++++ ...e_compute_disk_async_replication_meta.yaml | 2 + .../resource_compute_disk_generated_meta.yaml | 2 + ...compute_disk_resource_policy_attachment.go | 39 ++++++++ ...urce_policy_attachment_generated_meta.yaml | 2 + .../resource_compute_external_vpn_gateway.go | 46 +++++++++ ...e_external_vpn_gateway_generated_meta.yaml | 2 + .../compute/resource_compute_firewall.go | 46 +++++++++ ...ource_compute_firewall_generated_meta.yaml | 2 + .../resource_compute_firewall_policy.go | 48 ++++++++++ ...rce_compute_firewall_policy_association.go | 48 ++++++++++ ...all_policy_association_generated_meta.yaml | 2 + ...ompute_firewall_policy_generated_meta.yaml | 2 + .../resource_compute_firewall_policy_rule.go | 48 ++++++++++ ...e_firewall_policy_rule_generated_meta.yaml | 2 + ...urce_compute_firewall_policy_with_rules.go | 47 +++++++++ ...wall_policy_with_rules_generated_meta.yaml | 2 + .../resource_compute_forwarding_rule.go | 45 +++++++++ ...ompute_forwarding_rule_generated_meta.yaml | 2 + .../resource_compute_global_address.go | 46 +++++++++ ...compute_global_address_generated_meta.yaml | 2 + ...resource_compute_global_forwarding_rule.go | 46 +++++++++ ...global_forwarding_rule_generated_meta.yaml | 2 + ...esource_compute_global_network_endpoint.go | 39 ++++++++ ...lobal_network_endpoint_generated_meta.yaml | 2 + ...e_compute_global_network_endpoint_group.go | 39 ++++++++ ...network_endpoint_group_generated_meta.yaml | 2 + .../resource_compute_ha_vpn_gateway.go | 46 +++++++++ ...compute_ha_vpn_gateway_generated_meta.yaml | 2 + .../compute/resource_compute_health_check.go | 46 +++++++++ ...e_compute_health_check_generated_meta.yaml | 2 + .../resource_compute_http_health_check.go | 46 +++++++++ ...pute_http_health_check_generated_meta.yaml | 2 + .../resource_compute_https_health_check.go | 46 +++++++++ ...ute_https_health_check_generated_meta.yaml | 2 + .../compute/resource_compute_image.go | 46 +++++++++ ...resource_compute_image_generated_meta.yaml | 2 + .../compute/resource_compute_instance.go | 20 ++++ ...e_compute_instance_from_template_meta.yaml | 2 + .../resource_compute_instance_group.go | 20 ++++ ...resource_compute_instance_group_manager.go | 8 ++ ...e_compute_instance_group_manager_meta.yaml | 2 + ...ource_compute_instance_group_membership.go | 39 ++++++++ ...tance_group_membership_generated_meta.yaml | 2 + .../resource_compute_instance_group_meta.yaml | 2 + ...ource_compute_instance_group_named_port.go | 39 ++++++++ ...tance_group_named_port_generated_meta.yaml | 2 + .../resource_compute_instance_meta.yaml | 4 +- .../resource_compute_instance_settings.go | 46 +++++++++ ...pute_instance_settings_generated_meta.yaml | 2 + .../resource_compute_instance_template.go | 1 + .../resource_compute_instant_snapshot.go | 46 +++++++++ ...mpute_instant_snapshot_generated_meta.yaml | 2 + .../compute/resource_compute_interconnect.go | 46 +++++++++ ...esource_compute_interconnect_attachment.go | 46 +++++++++ ...nterconnect_attachment_generated_meta.yaml | 2 + ...e_compute_interconnect_attachment_group.go | 46 +++++++++ ...nnect_attachment_group_generated_meta.yaml | 2 + ...e_compute_interconnect_generated_meta.yaml | 2 + .../resource_compute_interconnect_group.go | 46 +++++++++ ...ute_interconnect_group_generated_meta.yaml | 2 + ...esource_compute_managed_ssl_certificate.go | 39 ++++++++ ...anaged_ssl_certificate_generated_meta.yaml | 2 + .../compute/resource_compute_network.go | 45 +++++++++ .../resource_compute_network_attachment.go | 46 +++++++++ ...ute_network_attachment_generated_meta.yaml | 2 + .../resource_compute_network_endpoint.go | 39 ++++++++ ...mpute_network_endpoint_generated_meta.yaml | 2 + ...resource_compute_network_endpoint_group.go | 39 ++++++++ ...network_endpoint_group_generated_meta.yaml | 2 + .../resource_compute_network_endpoints.go | 46 +++++++++ ...pute_network_endpoints_generated_meta.yaml | 2 + ...esource_compute_network_firewall_policy.go | 46 +++++++++ ...ute_network_firewall_policy_association.go | 39 ++++++++ ...all_policy_association_generated_meta.yaml | 2 + ...etwork_firewall_policy_generated_meta.yaml | 2 + ...ce_compute_network_firewall_policy_rule.go | 46 +++++++++ ...k_firewall_policy_rule_generated_meta.yaml | 2 + ...pute_network_firewall_policy_with_rules.go | 46 +++++++++ ...wall_policy_with_rules_generated_meta.yaml | 2 + ...source_compute_network_generated_meta.yaml | 2 + .../resource_compute_network_peering.go | 24 +++++ ...resource_compute_network_peering_meta.yaml | 2 + ...e_compute_network_peering_routes_config.go | 1 + .../compute/resource_compute_node_group.go | 46 +++++++++ ...rce_compute_node_group_generated_meta.yaml | 2 + .../compute/resource_compute_node_template.go | 39 ++++++++ ..._compute_node_template_generated_meta.yaml | 2 + ...ce_compute_organization_security_policy.go | 47 +++++++++ ...rganization_security_policy_association.go | 40 ++++++++ ...ity_policy_association_generated_meta.yaml | 2 + ...zation_security_policy_generated_meta.yaml | 2 + ...mpute_organization_security_policy_rule.go | 47 +++++++++ ...n_security_policy_rule_generated_meta.yaml | 2 + .../resource_compute_packet_mirroring.go | 46 +++++++++ ...mpute_packet_mirroring_generated_meta.yaml | 2 + .../resource_compute_per_instance_config.go | 45 +++++++++ ...te_per_instance_config_generated_meta.yaml | 2 + .../resource_compute_preview_feature.go | 1 + ...source_compute_project_cloud_armor_tier.go | 46 +++++++++ ...oject_cloud_armor_tier_generated_meta.yaml | 2 + ...ce_compute_project_default_network_tier.go | 2 +- .../resource_compute_project_metadata.go | 20 ++++ .../resource_compute_project_metadata_item.go | 20 ++++ ...ce_compute_project_metadata_item_meta.yaml | 2 + ...esource_compute_project_metadata_meta.yaml | 2 + ...source_compute_public_advertised_prefix.go | 39 ++++++++ ...blic_advertised_prefix_generated_meta.yaml | 2 + ...esource_compute_public_delegated_prefix.go | 39 ++++++++ ...ublic_delegated_prefix_generated_meta.yaml | 2 + .../resource_compute_region_autoscaler.go | 46 +++++++++ ...pute_region_autoscaler_generated_meta.yaml | 2 + ...resource_compute_region_backend_service.go | 46 +++++++++ ...region_backend_service_generated_meta.yaml | 2 + ...e_compute_region_composite_health_check.go | 46 +++++++++ ...composite_health_check_generated_meta.yaml | 2 + .../compute/resource_compute_region_disk.go | 45 +++++++++ ...ce_compute_region_disk_generated_meta.yaml | 2 + ..._region_disk_resource_policy_attachment.go | 39 ++++++++ ...urce_policy_attachment_generated_meta.yaml | 2 + ...ompute_region_health_aggregation_policy.go | 46 +++++++++ ...lth_aggregation_policy_generated_meta.yaml | 2 + .../resource_compute_region_health_check.go | 46 +++++++++ ...te_region_health_check_generated_meta.yaml | 2 + .../resource_compute_region_health_source.go | 46 +++++++++ ...e_region_health_source_generated_meta.yaml | 2 + ...e_compute_region_instance_group_manager.go | 20 ++++ ...te_region_instance_group_manager_meta.yaml | 2 + ...source_compute_region_instance_template.go | 17 +++- ...compute_region_instance_template_meta.yaml | 2 + ...esource_compute_region_instant_snapshot.go | 46 +++++++++ ...egion_instant_snapshot_generated_meta.yaml | 2 + ...esource_compute_region_network_endpoint.go | 39 ++++++++ ...egion_network_endpoint_generated_meta.yaml | 2 + ...e_compute_region_network_endpoint_group.go | 39 ++++++++ ...network_endpoint_group_generated_meta.yaml | 2 + ..._compute_region_network_firewall_policy.go | 46 +++++++++ ...ion_network_firewall_policy_association.go | 39 ++++++++ ...all_policy_association_generated_meta.yaml | 2 + ...etwork_firewall_policy_generated_meta.yaml | 2 + ...ute_region_network_firewall_policy_rule.go | 46 +++++++++ ...k_firewall_policy_rule_generated_meta.yaml | 2 + ...gion_network_firewall_policy_with_rules.go | 46 +++++++++ ...wall_policy_with_rules_generated_meta.yaml | 2 + ...urce_compute_region_per_instance_config.go | 45 +++++++++ ...on_per_instance_config_generated_meta.yaml | 2 + ...resource_compute_region_security_policy.go | 46 +++++++++ ...region_security_policy_generated_meta.yaml | 2 + ...rce_compute_region_security_policy_rule.go | 46 +++++++++ ...n_security_policy_rule_generated_meta.yaml | 2 + ...resource_compute_region_ssl_certificate.go | 39 ++++++++ ...region_ssl_certificate_generated_meta.yaml | 2 + .../resource_compute_region_ssl_policy.go | 46 +++++++++ ...pute_region_ssl_policy_generated_meta.yaml | 2 + ...source_compute_region_target_http_proxy.go | 46 +++++++++ ...gion_target_http_proxy_generated_meta.yaml | 2 + ...ource_compute_region_target_https_proxy.go | 46 +++++++++ ...ion_target_https_proxy_generated_meta.yaml | 2 + ...esource_compute_region_target_tcp_proxy.go | 39 ++++++++ ...egion_target_tcp_proxy_generated_meta.yaml | 2 + .../resource_compute_region_url_map.go | 46 +++++++++ ...compute_region_url_map_generated_meta.yaml | 2 + .../compute/resource_compute_reservation.go | 45 +++++++++ ...ce_compute_reservation_generated_meta.yaml | 2 + .../resource_compute_resize_request.go | 39 ++++++++ ...compute_resize_request_generated_meta.yaml | 2 + .../resource_compute_resource_policy.go | 46 +++++++++ ...urce_compute_resource_policy_attachment.go | 39 ++++++++ ...urce_policy_attachment_generated_meta.yaml | 2 + ...ompute_resource_policy_generated_meta.yaml | 2 + .../compute/resource_compute_route.go | 39 ++++++++ ...resource_compute_route_generated_meta.yaml | 2 + .../compute/resource_compute_router.go | 46 +++++++++ ...esource_compute_router_generated_meta.yaml | 2 + .../resource_compute_router_interface.go | 25 +++++ ...esource_compute_router_interface_meta.yaml | 2 + .../compute/resource_compute_router_nat.go | 46 +++++++++ .../resource_compute_router_nat_address.go | 46 +++++++++ ...ute_router_nat_address_generated_meta.yaml | 2 + ...rce_compute_router_nat_generated_meta.yaml | 2 + .../compute/resource_compute_router_peer.go | 20 ++++ .../resource_compute_router_peer_meta.yaml | 2 + .../resource_compute_router_route_policy.go | 46 +++++++++ ...te_router_route_policy_generated_meta.yaml | 2 + .../resource_compute_security_policy.go | 20 ++++ ...resource_compute_security_policy_meta.yaml | 4 +- .../resource_compute_security_policy_rule.go | 46 +++++++++ ...e_security_policy_rule_generated_meta.yaml | 2 + .../resource_compute_service_attachment.go | 45 +++++++++ ...ute_service_attachment_generated_meta.yaml | 2 + ...esource_compute_shared_vpc_host_project.go | 28 ++++++ ..._compute_shared_vpc_host_project_meta.yaml | 2 + .../compute/resource_compute_snapshot.go | 46 +++++++++ ...ource_compute_snapshot_generated_meta.yaml | 2 + .../resource_compute_snapshot_settings.go | 1 + .../resource_compute_ssl_certificate.go | 39 ++++++++ ...ompute_ssl_certificate_generated_meta.yaml | 2 + .../compute/resource_compute_ssl_policy.go | 46 +++++++++ ...rce_compute_ssl_policy_generated_meta.yaml | 2 + .../compute/resource_compute_storage_pool.go | 45 +++++++++ ...e_compute_storage_pool_generated_meta.yaml | 2 + .../compute/resource_compute_subnetwork.go | 45 +++++++++ ...rce_compute_subnetwork_generated_meta.yaml | 2 + .../resource_compute_target_grpc_proxy.go | 46 +++++++++ ...pute_target_grpc_proxy_generated_meta.yaml | 2 + .../resource_compute_target_http_proxy.go | 46 +++++++++ ...pute_target_http_proxy_generated_meta.yaml | 2 + .../resource_compute_target_https_proxy.go | 46 +++++++++ ...ute_target_https_proxy_generated_meta.yaml | 2 + .../resource_compute_target_instance.go | 39 ++++++++ ...ompute_target_instance_generated_meta.yaml | 2 + .../compute/resource_compute_target_pool.go | 22 +++++ .../resource_compute_target_pool_meta.yaml | 2 + .../resource_compute_target_ssl_proxy.go | 46 +++++++++ ...mpute_target_ssl_proxy_generated_meta.yaml | 2 + .../resource_compute_target_tcp_proxy.go | 46 +++++++++ ...mpute_target_tcp_proxy_generated_meta.yaml | 2 + .../compute/resource_compute_url_map.go | 46 +++++++++ ...source_compute_url_map_generated_meta.yaml | 2 + .../compute/resource_compute_vpn_gateway.go | 39 ++++++++ ...ce_compute_vpn_gateway_generated_meta.yaml | 2 + .../compute/resource_compute_vpn_tunnel.go | 46 +++++++++ ...rce_compute_vpn_tunnel_generated_meta.yaml | 2 + .../compute/resource_compute_wire_group.go | 46 +++++++++ ...rce_compute_wire_group_generated_meta.yaml | 2 + .../resource_project_usage_export_bucket.go | 25 +++++ ...urce_project_usage_export_bucket_meta.yaml | 2 + ...e_contact_center_insights_analysis_rule.go | 46 +++++++++ ...insights_analysis_rule_generated_meta.yaml | 2 + ...contact_center_insights_assessment_rule.go | 46 +++++++++ ...sights_assessment_rule_generated_meta.yaml | 2 + ...tact_center_insights_auto_labeling_rule.go | 46 +++++++++ ...hts_auto_labeling_rule_generated_meta.yaml | 2 + ...rce_contact_center_insights_qa_question.go | 46 +++++++++ ...r_insights_qa_question_generated_meta.yaml | 2 + ...ce_contact_center_insights_qa_scorecard.go | 46 +++++++++ ..._insights_qa_scorecard_generated_meta.yaml | 2 + .../resource_contact_center_insights_view.go | 46 +++++++++ ...t_center_insights_view_generated_meta.yaml | 2 + .../container/resource_container_cluster.go | 20 ++++ .../resource_container_cluster_meta.yaml | 2 + .../container/resource_container_node_pool.go | 20 ++++ .../resource_container_node_pool_meta.yaml | 2 + .../resource_container_analysis_note.go | 46 +++++++++ ...ontainer_analysis_note_generated_meta.yaml | 2 + .../resource_container_analysis_occurrence.go | 46 +++++++++ ...er_analysis_occurrence_generated_meta.yaml | 2 + .../resource_container_attached_cluster.go | 47 ++++++--- ...ainer_attached_cluster_generated_meta.yaml | 4 +- .../resource_container_aws_cluster.go | 20 ++++ .../resource_container_aws_cluster_meta.yaml | 2 + .../resource_container_aws_node_pool.go | 21 ++++ ...resource_container_aws_node_pool_meta.yaml | 2 + .../resource_container_azure_client.go | 24 +++++ .../resource_container_azure_client_meta.yaml | 2 + .../resource_container_azure_cluster.go | 20 ++++ ...resource_container_azure_cluster_meta.yaml | 2 + .../resource_container_azure_node_pool.go | 20 ++++ ...source_container_azure_node_pool_meta.yaml | 2 + ...se_migration_service_connection_profile.go | 46 +++++++++ ...ice_connection_profile_generated_meta.yaml | 2 + ...atabase_migration_service_migration_job.go | 46 +++++++++ ..._service_migration_job_generated_meta.yaml | 2 + ...se_migration_service_private_connection.go | 35 ++++++- ...ice_private_connection_generated_meta.yaml | 2 + .../resource_data_catalog_entry.go | 47 +++++++++ ...rce_data_catalog_entry_generated_meta.yaml | 2 + .../resource_data_catalog_entry_group.go | 46 +++++++++ ...ta_catalog_entry_group_generated_meta.yaml | 2 + .../resource_data_catalog_policy_tag.go | 47 +++++++++ ...ata_catalog_policy_tag_generated_meta.yaml | 2 + .../datacatalog/resource_data_catalog_tag.go | 47 +++++++++ ...ource_data_catalog_tag_generated_meta.yaml | 2 + .../resource_data_catalog_tag_template.go | 46 +++++++++ ...a_catalog_tag_template_generated_meta.yaml | 2 + .../resource_data_catalog_taxonomy.go | 46 +++++++++ ..._data_catalog_taxonomy_generated_meta.yaml | 2 + .../dataflow/resource_dataflow_job.go | 19 ++++ .../dataflow/resource_dataflow_job_meta.yaml | 2 + .../dataform/resource_dataform_folder.go | 46 +++++++++ ...source_dataform_folder_generated_meta.yaml | 2 + .../dataform/resource_dataform_team_folder.go | 46 +++++++++ ...e_dataform_team_folder_generated_meta.yaml | 2 + .../resource_data_fusion_instance.go | 46 +++++++++ ...e_data_fusion_instance_generated_meta.yaml | 2 + .../resource_data_lineage_config.go | 47 +++++++++ ...ce_data_lineage_config_generated_meta.yaml | 2 + ...ata_loss_prevention_deidentify_template.go | 47 +++++++++ ...on_deidentify_template_generated_meta.yaml | 2 + ...e_data_loss_prevention_discovery_config.go | 47 +++++++++ ...ntion_discovery_config_generated_meta.yaml | 2 + ...e_data_loss_prevention_inspect_template.go | 47 +++++++++ ...ntion_inspect_template_generated_meta.yaml | 2 + ...source_data_loss_prevention_job_trigger.go | 47 +++++++++ ...prevention_job_trigger_generated_meta.yaml | 2 + ...e_data_loss_prevention_stored_info_type.go | 48 ++++++++++ ...ntion_stored_info_type_generated_meta.yaml | 2 + .../resource_data_pipeline_pipeline.go | 46 +++++++++ ...data_pipeline_pipeline_generated_meta.yaml | 2 + .../dataplex/resource_dataplex_aspect_type.go | 46 +++++++++ ...e_dataplex_aspect_type_generated_meta.yaml | 2 + .../dataplex/resource_dataplex_asset.go | 20 ++++ .../resource_dataplex_asset_meta.yaml | 2 + .../dataplex/resource_dataplex_datascan.go | 46 +++++++++ ...urce_dataplex_datascan_generated_meta.yaml | 2 + .../dataplex/resource_dataplex_entry.go | 46 +++++++++ ...esource_dataplex_entry_generated_meta.yaml | 2 + .../dataplex/resource_dataplex_entry_group.go | 46 +++++++++ ...e_dataplex_entry_group_generated_meta.yaml | 2 + .../dataplex/resource_dataplex_entry_link.go | 46 +++++++++ ...ce_dataplex_entry_link_generated_meta.yaml | 2 + .../dataplex/resource_dataplex_entry_type.go | 46 +++++++++ ...ce_dataplex_entry_type_generated_meta.yaml | 2 + .../dataplex/resource_dataplex_glossary.go | 46 +++++++++ .../resource_dataplex_glossary_category.go | 46 +++++++++ ...plex_glossary_category_generated_meta.yaml | 2 + ...urce_dataplex_glossary_generated_meta.yaml | 2 + .../resource_dataplex_glossary_term.go | 46 +++++++++ ...dataplex_glossary_term_generated_meta.yaml | 2 + .../dataplex/resource_dataplex_lake.go | 20 ++++ .../dataplex/resource_dataplex_lake_meta.yaml | 2 + .../dataplex/resource_dataplex_task.go | 46 +++++++++ ...resource_dataplex_task_generated_meta.yaml | 2 + .../dataplex/resource_dataplex_zone.go | 20 ++++ .../dataplex/resource_dataplex_zone_meta.yaml | 2 + .../resource_dataproc_autoscaling_policy.go | 46 +++++++++ ...roc_autoscaling_policy_generated_meta.yaml | 2 + .../dataproc/resource_dataproc_batch.go | 35 ++++++- ...esource_dataproc_batch_generated_meta.yaml | 2 + .../dataproc/resource_dataproc_cluster.go | 20 ++++ .../resource_dataproc_cluster_meta.yaml | 2 + .../dataproc/resource_dataproc_job.go | 16 ++++ .../dataproc/resource_dataproc_job_meta.yaml | 2 + .../resource_dataproc_session_template.go | 46 +++++++++ ...aproc_session_template_generated_meta.yaml | 2 + .../resource_dataproc_workflow_template.go | 15 +++ ...ource_dataproc_workflow_template_meta.yaml | 2 + ...ce_dataproc_gdc_application_environment.go | 46 +++++++++ ...pplication_environment_generated_meta.yaml | 2 + .../resource_dataproc_gdc_service_instance.go | 35 ++++++- ...c_gdc_service_instance_generated_meta.yaml | 2 + ...resource_dataproc_gdc_spark_application.go | 35 ++++++- ..._gdc_spark_application_generated_meta.yaml | 2 + .../resource_dataproc_metastore_federation.go | 45 +++++++++ ...c_metastore_federation_generated_meta.yaml | 2 + .../resource_dataproc_metastore_service.go | 46 +++++++++ ...proc_metastore_service_generated_meta.yaml | 2 + .../resource_datastream_connection_profile.go | 46 +++++++++ ...eam_connection_profile_generated_meta.yaml | 2 + .../resource_datastream_private_connection.go | 39 +++++--- ...eam_private_connection_generated_meta.yaml | 4 +- .../datastream/resource_datastream_stream.go | 45 +++++++++ ...urce_datastream_stream_generated_meta.yaml | 2 + .../resource_deployment_manager_deployment.go | 46 +++++++++ ...ent_manager_deployment_generated_meta.yaml | 2 + ...rce_developer_connect_account_connector.go | 46 +++++++++ ...nect_account_connector_generated_meta.yaml | 2 + .../resource_developer_connect_connection.go | 46 +++++++++ ...per_connect_connection_generated_meta.yaml | 2 + ...e_developer_connect_git_repository_link.go | 35 ++++++- ...ct_git_repository_link_generated_meta.yaml | 2 + ...ource_developer_connect_insights_config.go | 46 +++++++++ ...onnect_insights_config_generated_meta.yaml | 2 + .../dialogflow/resource_dialogflow_agent.go | 46 +++++++++ ...ource_dialogflow_agent_generated_meta.yaml | 2 + ...esource_dialogflow_conversation_profile.go | 46 +++++++++ ...w_conversation_profile_generated_meta.yaml | 2 + .../resource_dialogflow_entity_type.go | 46 +++++++++ ...dialogflow_entity_type_generated_meta.yaml | 2 + .../resource_dialogflow_environment.go | 46 +++++++++ ...dialogflow_environment_generated_meta.yaml | 2 + .../resource_dialogflow_fulfillment.go | 46 +++++++++ ...dialogflow_fulfillment_generated_meta.yaml | 2 + .../resource_dialogflow_generator.go | 46 +++++++++ ...e_dialogflow_generator_generated_meta.yaml | 2 + .../dialogflow/resource_dialogflow_intent.go | 46 +++++++++ ...urce_dialogflow_intent_generated_meta.yaml | 2 + .../dialogflow/resource_dialogflow_version.go | 47 +++++++++ ...rce_dialogflow_version_generated_meta.yaml | 2 + .../resource_dialogflow_cx_agent.go | 45 +++++++++ ...ce_dialogflow_cx_agent_generated_meta.yaml | 2 + .../resource_dialogflow_cx_entity_type.go | 47 +++++++++ ...logflow_cx_entity_type_generated_meta.yaml | 2 + .../resource_dialogflow_cx_environment.go | 48 ++++++++++ ...logflow_cx_environment_generated_meta.yaml | 2 + .../resource_dialogflow_cx_flow.go | 45 +++++++++ ...rce_dialogflow_cx_flow_generated_meta.yaml | 2 + ...ource_dialogflow_cx_generative_settings.go | 1 + .../resource_dialogflow_cx_generator.go | 47 +++++++++ ...ialogflow_cx_generator_generated_meta.yaml | 2 + .../resource_dialogflow_cx_intent.go | 46 +++++++++ ...e_dialogflow_cx_intent_generated_meta.yaml | 2 + .../resource_dialogflow_cx_page.go | 47 +++++++++ ...rce_dialogflow_cx_page_generated_meta.yaml | 2 + .../resource_dialogflow_cx_playbook.go | 47 +++++++++ ...dialogflow_cx_playbook_generated_meta.yaml | 2 + ...esource_dialogflow_cx_security_settings.go | 46 +++++++++ ...w_cx_security_settings_generated_meta.yaml | 2 + .../resource_dialogflow_cx_test_case.go | 47 +++++++++ ...ialogflow_cx_test_case_generated_meta.yaml | 2 + .../resource_dialogflow_cx_tool.go | 47 +++++++++ ...rce_dialogflow_cx_tool_generated_meta.yaml | 2 + .../resource_dialogflow_cx_tool_version.go | 40 ++++++++ ...ogflow_cx_tool_version_generated_meta.yaml | 2 + .../resource_dialogflow_cx_version.go | 48 ++++++++++ ..._dialogflow_cx_version_generated_meta.yaml | 2 + .../resource_dialogflow_cx_webhook.go | 47 +++++++++ ..._dialogflow_cx_webhook_generated_meta.yaml | 2 + .../resource_discovery_engine_acl_config.go | 1 + .../resource_discovery_engine_assistant.go | 46 +++++++++ ...overy_engine_assistant_generated_meta.yaml | 2 + .../resource_discovery_engine_chat_engine.go | 46 +++++++++ ...ery_engine_chat_engine_generated_meta.yaml | 2 + .../resource_discovery_engine_cmek_config.go | 46 +++++++++ ...ery_engine_cmek_config_generated_meta.yaml | 2 + .../resource_discovery_engine_control.go | 46 +++++++++ ...scovery_engine_control_generated_meta.yaml | 2 + ...esource_discovery_engine_data_connector.go | 46 +++++++++ ..._engine_data_connector_generated_meta.yaml | 2 + .../resource_discovery_engine_data_store.go | 46 +++++++++ ...very_engine_data_store_generated_meta.yaml | 2 + ...esource_discovery_engine_license_config.go | 1 + ..._discovery_engine_recommendation_engine.go | 46 +++++++++ ..._recommendation_engine_generated_meta.yaml | 2 + .../resource_discovery_engine_schema.go | 39 ++++++++ ...iscovery_engine_schema_generated_meta.yaml | 2 + ...resource_discovery_engine_search_engine.go | 46 +++++++++ ...y_engine_search_engine_generated_meta.yaml | 2 + ...esource_discovery_engine_serving_config.go | 1 + .../resource_discovery_engine_sitemap.go | 39 ++++++++ ...scovery_engine_sitemap_generated_meta.yaml | 2 + .../resource_discovery_engine_target_site.go | 39 ++++++++ ...ery_engine_target_site_generated_meta.yaml | 2 + .../resource_discovery_engine_user_store.go | 1 + ...resource_discovery_engine_widget_config.go | 1 + .../services/dns/resource_dns_managed_zone.go | 45 +++++++++ ...ource_dns_managed_zone_generated_meta.yaml | 2 + google/services/dns/resource_dns_policy.go | 46 +++++++++ .../resource_dns_policy_generated_meta.yaml | 2 + .../services/dns/resource_dns_record_set.go | 20 ++++ .../dns/resource_dns_record_set_meta.yaml | 2 + .../dns/resource_dns_response_policy.go | 46 +++++++++ ...ce_dns_response_policy_generated_meta.yaml | 2 + .../dns/resource_dns_response_policy_rule.go | 46 +++++++++ ...s_response_policy_rule_generated_meta.yaml | 2 + .../resource_document_ai_processor.go | 39 ++++++++ ..._document_ai_processor_generated_meta.yaml | 2 + .../documentai/resource_document_ai_schema.go | 46 +++++++++ ...rce_document_ai_schema_generated_meta.yaml | 2 + ...e_document_ai_warehouse_document_schema.go | 40 ++++++++ ...ehouse_document_schema_generated_meta.yaml | 2 + .../resource_edgecontainer_cluster.go | 46 +++++++++ ..._edgecontainer_cluster_generated_meta.yaml | 2 + .../resource_edgecontainer_node_pool.go | 46 +++++++++ ...dgecontainer_node_pool_generated_meta.yaml | 2 + .../resource_edgecontainer_vpn_connection.go | 46 +++++++++ ...ntainer_vpn_connection_generated_meta.yaml | 2 + ...rce_edgenetwork_interconnect_attachment.go | 35 ++++++- ...nterconnect_attachment_generated_meta.yaml | 2 + .../resource_edgenetwork_network.go | 35 ++++++- ...ce_edgenetwork_network_generated_meta.yaml | 2 + .../resource_edgenetwork_subnet.go | 35 ++++++- ...rce_edgenetwork_subnet_generated_meta.yaml | 2 + .../resource_essential_contacts_contact.go | 47 +++++++++ ...ntial_contacts_contact_generated_meta.yaml | 2 + .../eventarc/resource_eventarc_channel.go | 46 +++++++++ ...ource_eventarc_channel_generated_meta.yaml | 2 + .../eventarc/resource_eventarc_enrollment.go | 46 +++++++++ ...ce_eventarc_enrollment_generated_meta.yaml | 2 + .../resource_eventarc_google_api_source.go | 46 +++++++++ ...tarc_google_api_source_generated_meta.yaml | 2 + ...resource_eventarc_google_channel_config.go | 1 + .../eventarc/resource_eventarc_message_bus.go | 46 +++++++++ ...e_eventarc_message_bus_generated_meta.yaml | 2 + .../eventarc/resource_eventarc_pipeline.go | 46 +++++++++ ...urce_eventarc_pipeline_generated_meta.yaml | 2 + .../eventarc/resource_eventarc_trigger.go | 46 +++++++++ ...ource_eventarc_trigger_generated_meta.yaml | 2 + .../filestore/resource_filestore_backup.go | 46 +++++++++ ...ource_filestore_backup_generated_meta.yaml | 2 + .../filestore/resource_filestore_instance.go | 45 +++++++++ ...rce_filestore_instance_generated_meta.yaml | 2 + .../filestore/resource_filestore_snapshot.go | 46 +++++++++ ...rce_filestore_snapshot_generated_meta.yaml | 2 + ...ce_firebase_app_check_app_attest_config.go | 1 + ...resource_firebase_app_check_debug_token.go | 46 +++++++++ ..._app_check_debug_token_generated_meta.yaml | 2 + ..._firebase_app_check_device_check_config.go | 1 + ...irebase_app_check_play_integrity_config.go | 1 + ...e_app_check_recaptcha_enterprise_config.go | 1 + ..._firebase_app_check_recaptcha_v3_config.go | 1 + ...urce_firebase_app_check_resource_policy.go | 46 +++++++++ ..._check_resource_policy_generated_meta.yaml | 2 + ...ource_firebase_app_check_service_config.go | 46 +++++++++ ...p_check_service_config_generated_meta.yaml | 2 + .../resource_firebase_app_hosting_backend.go | 46 +++++++++ ...se_app_hosting_backend_generated_meta.yaml | 2 + .../resource_firebase_app_hosting_build.go | 2 +- ...rce_firebase_app_hosting_default_domain.go | 1 + .../resource_firebase_app_hosting_domain.go | 46 +++++++++ ...ase_app_hosting_domain_generated_meta.yaml | 2 + .../resource_firebase_app_hosting_traffic.go | 1 + .../resource_firebase_data_connect_service.go | 51 +++++++--- ...e_data_connect_service_generated_meta.yaml | 4 +- ...ce_firebase_remote_config_remote_config.go | 1 + .../resource_firebaserules_release.go | 24 +++++ .../resource_firebaserules_release_meta.yaml | 2 + .../resource_firebaserules_ruleset.go | 24 +++++ .../resource_firebaserules_ruleset_meta.yaml | 2 + .../resource_firestore_backup_schedule.go | 46 +++++++++ ...estore_backup_schedule_generated_meta.yaml | 2 + .../firestore/resource_firestore_database.go | 61 ++++++++---- ...rce_firestore_database_generated_meta.yaml | 4 +- .../firestore/resource_firestore_document.go | 46 +++++++++ ...rce_firestore_document_generated_meta.yaml | 2 + .../firestore/resource_firestore_field.go | 46 +++++++++ ...source_firestore_field_generated_meta.yaml | 2 + .../firestore/resource_firestore_index.go | 46 +++++---- ...source_firestore_index_generated_meta.yaml | 4 +- .../resource_firestore_user_creds.go | 39 ++++++++ ...e_firestore_user_creds_generated_meta.yaml | 2 + .../resource_gemini_code_repository_index.go | 45 +++++++++ ..._code_repository_index_generated_meta.yaml | 2 + .../resource_gemini_code_tools_setting.go | 46 +++++++++ ...ource_gemini_code_tools_setting_binding.go | 46 +++++++++ ..._tools_setting_binding_generated_meta.yaml | 2 + ...ini_code_tools_setting_generated_meta.yaml | 2 + ...gemini_data_sharing_with_google_setting.go | 46 +++++++++ ...ata_sharing_with_google_setting_binding.go | 46 +++++++++ ...google_setting_binding_generated_meta.yaml | 2 + ...ng_with_google_setting_generated_meta.yaml | 2 + ...ce_gemini_gemini_gcp_enablement_setting.go | 46 +++++++++ ...i_gemini_gcp_enablement_setting_binding.go | 46 +++++++++ ...lement_setting_binding_generated_meta.yaml | 2 + ...gcp_enablement_setting_generated_meta.yaml | 2 + .../gemini/resource_gemini_logging_setting.go | 46 +++++++++ ...resource_gemini_logging_setting_binding.go | 46 +++++++++ ...ogging_setting_binding_generated_meta.yaml | 2 + ...gemini_logging_setting_generated_meta.yaml | 2 + ...resource_gemini_release_channel_setting.go | 46 +++++++++ ..._gemini_release_channel_setting_binding.go | 46 +++++++++ ...hannel_setting_binding_generated_meta.yaml | 2 + ...elease_channel_setting_generated_meta.yaml | 2 + .../resource_gemini_repository_group.go | 46 +++++++++ ...emini_repository_group_generated_meta.yaml | 2 + .../resource_gke_backup_backup_channel.go | 46 +++++++++ ..._backup_backup_channel_generated_meta.yaml | 2 + .../resource_gke_backup_backup_plan.go | 46 +++++++++ ...gke_backup_backup_plan_generated_meta.yaml | 2 + .../resource_gke_backup_restore_channel.go | 46 +++++++++ ...backup_restore_channel_generated_meta.yaml | 2 + .../resource_gke_backup_restore_plan.go | 46 +++++++++ ...ke_backup_restore_plan_generated_meta.yaml | 2 + .../resource_gke_hub_feature_membership.go | 19 ++++ ...ource_gke_hub_feature_membership_meta.yaml | 2 + .../gkehub/resource_gke_hub_membership.go | 46 +++++++++ ...rce_gke_hub_membership_generated_meta.yaml | 2 + .../gkehub2/resource_gke_hub_feature.go | 46 +++++++++ ...source_gke_hub_feature_generated_meta.yaml | 2 + .../gkehub2/resource_gke_hub_fleet.go | 46 +++++++++ ...resource_gke_hub_fleet_generated_meta.yaml | 2 + .../resource_gke_hub_membership_binding.go | 46 +++++++++ ...hub_membership_binding_generated_meta.yaml | 2 + .../gkehub2/resource_gke_hub_namespace.go | 46 +++++++++ ...urce_gke_hub_namespace_generated_meta.yaml | 2 + .../gkehub2/resource_gke_hub_scope.go | 46 +++++++++ ...resource_gke_hub_scope_generated_meta.yaml | 2 + ...esource_gke_hub_scope_rbac_role_binding.go | 46 +++++++++ ...cope_rbac_role_binding_generated_meta.yaml | 2 + ...urce_gkeonprem_bare_metal_admin_cluster.go | 1 + .../resource_gkeonprem_bare_metal_cluster.go | 46 +++++++++ ...rem_bare_metal_cluster_generated_meta.yaml | 2 + ...resource_gkeonprem_bare_metal_node_pool.go | 46 +++++++++ ...m_bare_metal_node_pool_generated_meta.yaml | 2 + ...resource_gkeonprem_vmware_admin_cluster.go | 1 + .../resource_gkeonprem_vmware_cluster.go | 46 +++++++++ ...eonprem_vmware_cluster_generated_meta.yaml | 2 + .../resource_gkeonprem_vmware_node_pool.go | 46 +++++++++ ...nprem_vmware_node_pool_generated_meta.yaml | 2 + .../resource_healthcare_consent_store.go | 48 ++++++++++ ...althcare_consent_store_generated_meta.yaml | 2 + .../healthcare/resource_healthcare_dataset.go | 46 +++++++++ ...rce_healthcare_dataset_generated_meta.yaml | 2 + .../resource_healthcare_dicom_store.go | 48 ++++++++++ ...healthcare_dicom_store_generated_meta.yaml | 2 + .../resource_healthcare_fhir_store.go | 48 ++++++++++ ..._healthcare_fhir_store_generated_meta.yaml | 2 + .../resource_healthcare_hl7_v2_store.go | 48 ++++++++++ ...ealthcare_hl7_v2_store_generated_meta.yaml | 2 + .../resource_healthcare_pipeline_job.go | 48 ++++++++++ ...ealthcare_pipeline_job_generated_meta.yaml | 2 + .../resource_healthcare_workspace.go | 48 ++++++++++ ...e_healthcare_workspace_generated_meta.yaml | 2 + .../resource_hypercomputecluster_cluster.go | 46 +++++++++ ...computecluster_cluster_generated_meta.yaml | 2 + .../resource_iam_access_boundary_policy.go | 47 +++++++++ ...access_boundary_policy_generated_meta.yaml | 2 + .../services/iam2/resource_iam_deny_policy.go | 47 +++++++++ ...source_iam_deny_policy_generated_meta.yaml | 2 + .../resource_iam_folders_policy_binding.go | 47 +++++++++ ...folders_policy_binding_generated_meta.yaml | 2 + ...source_iam_organizations_policy_binding.go | 47 +++++++++ ...zations_policy_binding_generated_meta.yaml | 2 + ...ce_iam_principal_access_boundary_policy.go | 47 +++++++++ ...access_boundary_policy_generated_meta.yaml | 2 + .../resource_iam_projects_policy_binding.go | 46 +++++++++ ...rojects_policy_binding_generated_meta.yaml | 2 + .../resource_iam_workload_identity_pool.go | 46 +++++++++ ...workload_identity_pool_generated_meta.yaml | 2 + ...workload_identity_pool_managed_identity.go | 46 +++++++++ ..._pool_managed_identity_generated_meta.yaml | 2 + ...ce_iam_workload_identity_pool_namespace.go | 46 +++++++++ ...dentity_pool_namespace_generated_meta.yaml | 2 + ...rce_iam_workload_identity_pool_provider.go | 46 +++++++++ ...identity_pool_provider_generated_meta.yaml | 2 + .../resource_iam_oauth_client.go | 46 +++++++++ .../resource_iam_oauth_client_credential.go | 46 +++++++++ ...auth_client_credential_generated_meta.yaml | 2 + ...ource_iam_oauth_client_generated_meta.yaml | 2 + .../resource_iam_workforce_pool.go | 47 +++++++++ ...rce_iam_workforce_pool_generated_meta.yaml | 2 + .../resource_iam_workforce_pool_provider.go | 47 +++++++++ ...orkforce_pool_provider_generated_meta.yaml | 2 + ...esource_iam_workforce_pool_provider_key.go | 40 ++++++++ ...orce_pool_provider_key_generated_meta.yaml | 2 + ...iam_workforce_pool_provider_scim_tenant.go | 47 +++++++++ ...l_provider_scim_tenant_generated_meta.yaml | 2 + ..._iam_workforce_pool_provider_scim_token.go | 47 +++++++++ ...ol_provider_scim_token_generated_meta.yaml | 2 + google/services/iap/resource_iap_client.go | 40 ++++++++ .../resource_iap_client_generated_meta.yaml | 2 + google/services/iap/resource_iap_settings.go | 47 +++++++++ .../resource_iap_settings_generated_meta.yaml | 2 + .../iap/resource_iap_tunnel_dest_group.go | 46 +++++++++ ..._iap_tunnel_dest_group_generated_meta.yaml | 2 + .../resource_identity_platform_config.go | 1 + ...y_platform_default_supported_idp_config.go | 46 +++++++++ ...t_supported_idp_config_generated_meta.yaml | 2 + ...e_identity_platform_inbound_saml_config.go | 46 +++++++++ ...rm_inbound_saml_config_generated_meta.yaml | 2 + ...urce_identity_platform_oauth_idp_config.go | 46 +++++++++ ...tform_oauth_idp_config_generated_meta.yaml | 2 + .../resource_identity_platform_tenant.go | 46 +++++++++ ...orm_tenant_default_supported_idp_config.go | 46 +++++++++ ...t_supported_idp_config_generated_meta.yaml | 2 + ...entity_platform_tenant_generated_meta.yaml | 2 + ...ity_platform_tenant_inbound_saml_config.go | 46 +++++++++ ...nt_inbound_saml_config_generated_meta.yaml | 2 + ...entity_platform_tenant_oauth_idp_config.go | 46 +++++++++ ...enant_oauth_idp_config_generated_meta.yaml | 2 + ...ource_integration_connectors_connection.go | 46 +++++++++ ..._connectors_connection_generated_meta.yaml | 2 + ...egration_connectors_endpoint_attachment.go | 46 +++++++++ ...rs_endpoint_attachment_generated_meta.yaml | 2 + ...rce_integration_connectors_managed_zone.go | 46 +++++++++ ...onnectors_managed_zone_generated_meta.yaml | 2 + .../resource_integrations_auth_config.go | 46 +++++++++ ...tegrations_auth_config_generated_meta.yaml | 2 + .../resource_integrations_client.go | 39 ++++++++ ...ce_integrations_client_generated_meta.yaml | 2 + .../kms/resource_kms_autokey_config.go | 47 +++++++++ ...rce_kms_autokey_config_generated_meta.yaml | 2 + .../services/kms/resource_kms_crypto_key.go | 48 ++++++++++ ...esource_kms_crypto_key_generated_meta.yaml | 2 + .../kms/resource_kms_crypto_key_version.go | 47 +++++++++ ...kms_crypto_key_version_generated_meta.yaml | 2 + .../kms/resource_kms_ekm_connection.go | 1 + .../kms/resource_kms_key_ring_import_job.go | 40 ++++++++ ...ms_key_ring_import_job_generated_meta.yaml | 2 + .../resource_kms_project_autokey_config.go | 46 +++++++++ ...project_autokey_config_generated_meta.yaml | 2 + ...ng_billing_account_bucket_config_meta.yaml | 3 + .../resource_logging_billing_account_sink.go | 20 ++++ ...rce_logging_billing_account_sink_meta.yaml | 2 + .../logging/resource_logging_bucket_config.go | 30 ++++++ ...rce_logging_folder_bucket_config_meta.yaml | 2 + .../resource_logging_folder_settings.go | 1 + .../logging/resource_logging_folder_sink.go | 20 ++++ .../resource_logging_folder_sink_meta.yaml | 2 + .../resource_logging_linked_dataset.go | 40 ++++++++ ...logging_linked_dataset_generated_meta.yaml | 2 + .../logging/resource_logging_log_scope.go | 47 +++++++++ ...urce_logging_log_scope_generated_meta.yaml | 2 + .../logging/resource_logging_log_view.go | 47 +++++++++ ...ource_logging_log_view_generated_meta.yaml | 2 + .../logging/resource_logging_metric.go | 46 +++++++++ ...esource_logging_metric_generated_meta.yaml | 2 + ...gging_organization_bucket_config_meta.yaml | 2 + .../resource_logging_organization_settings.go | 1 + .../resource_logging_organization_sink.go | 20 ++++ ...source_logging_organization_sink_meta.yaml | 2 + .../resource_logging_project_bucket_config.go | 3 + ...ce_logging_project_bucket_config_meta.yaml | 3 + .../logging/resource_logging_project_sink.go | 33 +++++-- .../resource_logging_project_sink_meta.yaml | 2 + .../logging/resource_logging_saved_query.go | 47 +++++++++ ...ce_logging_saved_query_generated_meta.yaml | 2 + .../services/logging/resource_logging_sink.go | 6 ++ .../looker/resource_looker_instance.go | 50 +++++++--- ...source_looker_instance_generated_meta.yaml | 4 +- .../lustre/resource_lustre_instance.go | 46 +++++++++ ...source_lustre_instance_generated_meta.yaml | 2 + .../resource_managed_kafka_acl.go | 46 +++++++++ ...urce_managed_kafka_acl_generated_meta.yaml | 2 + .../resource_managed_kafka_cluster.go | 46 +++++++++ ..._managed_kafka_cluster_generated_meta.yaml | 2 + .../resource_managed_kafka_connect_cluster.go | 46 +++++++++ ..._kafka_connect_cluster_generated_meta.yaml | 2 + .../resource_managed_kafka_connector.go | 46 +++++++++ ...anaged_kafka_connector_generated_meta.yaml | 2 + .../resource_managed_kafka_topic.go | 46 +++++++++ ...ce_managed_kafka_topic_generated_meta.yaml | 2 + .../memcache/resource_memcache_instance.go | 45 +++++++++ ...urce_memcache_instance_generated_meta.yaml | 2 + .../resource_memorystore_instance.go | 45 +++++++++ ...instance_desired_user_created_endpoints.go | 46 +++++++++ ...user_created_endpoints_generated_meta.yaml | 2 + ...e_memorystore_instance_generated_meta.yaml | 2 + .../resource_migration_center_group.go | 46 +++++++++ ...migration_center_group_generated_meta.yaml | 2 + ...esource_migration_center_preference_set.go | 46 +++++++++ ..._center_preference_set_generated_meta.yaml | 2 + .../mlengine/resource_ml_engine_model.go | 35 ++++++- ...source_ml_engine_model_generated_meta.yaml | 2 + .../resource_model_armor_template.go | 46 +++++++++ ...e_model_armor_template_generated_meta.yaml | 2 + .../resource_model_armor_floorsetting.go | 1 + .../resource_monitoring_alert_policy.go | 46 +++++++++ ...onitoring_alert_policy_generated_meta.yaml | 2 + .../resource_monitoring_custom_service.go | 46 +++++++++ ...itoring_custom_service_generated_meta.yaml | 2 + .../resource_monitoring_dashboard.go | 20 ++++ .../resource_monitoring_dashboard_meta.yaml | 2 + .../monitoring/resource_monitoring_group.go | 46 +++++++++ ...ource_monitoring_group_generated_meta.yaml | 2 + .../resource_monitoring_metric_descriptor.go | 46 +++++++++ ...ring_metric_descriptor_generated_meta.yaml | 2 + .../resource_monitoring_monitored_project.go | 40 ++++++++ ...ring_monitored_project_generated_meta.yaml | 2 + ...esource_monitoring_notification_channel.go | 45 +++++++++ ...g_notification_channel_generated_meta.yaml | 2 + .../monitoring/resource_monitoring_service.go | 46 +++++++++ ...rce_monitoring_service_generated_meta.yaml | 2 + .../monitoring/resource_monitoring_slo.go | 46 +++++++++ ...esource_monitoring_slo_generated_meta.yaml | 2 + ...resource_monitoring_uptime_check_config.go | 46 +++++++++ ...ng_uptime_check_config_generated_meta.yaml | 2 + .../resource_netapp_active_directory.go | 46 +++++++++ ...etapp_active_directory_generated_meta.yaml | 2 + .../services/netapp/resource_netapp_backup.go | 46 +++++++++ ...resource_netapp_backup_generated_meta.yaml | 2 + .../netapp/resource_netapp_backup_policy.go | 46 +++++++++ ...e_netapp_backup_policy_generated_meta.yaml | 2 + .../netapp/resource_netapp_backup_vault.go | 46 +++++++++ ...ce_netapp_backup_vault_generated_meta.yaml | 2 + .../netapp/resource_netapp_host_group.go | 46 +++++++++ ...urce_netapp_host_group_generated_meta.yaml | 2 + .../netapp/resource_netapp_kmsconfig.go | 46 +++++++++ ...ource_netapp_kmsconfig_generated_meta.yaml | 2 + .../netapp/resource_netapp_storage_pool.go | 46 +++++++++ ...ce_netapp_storage_pool_generated_meta.yaml | 2 + .../services/netapp/resource_netapp_volume.go | 50 +++++++--- ...resource_netapp_volume_generated_meta.yaml | 4 +- .../resource_netapp_volume_quota_rule.go | 46 +++++++++ ...tapp_volume_quota_rule_generated_meta.yaml | 2 + .../resource_netapp_volume_replication.go | 45 +++++++++ ...app_volume_replication_generated_meta.yaml | 2 + .../netapp/resource_netapp_volume_snapshot.go | 46 +++++++++ ...netapp_volume_snapshot_generated_meta.yaml | 2 + ...source_network_connectivity_destination.go | 46 +++++++++ ...nnectivity_destination_generated_meta.yaml | 2 + .../resource_network_connectivity_group.go | 46 +++++++++ ...ork_connectivity_group_generated_meta.yaml | 2 + .../resource_network_connectivity_hub.go | 46 +++++++++ ...twork_connectivity_hub_generated_meta.yaml | 2 + ...ctivity_multicloud_data_transfer_config.go | 46 +++++++++ ...d_data_transfer_config_generated_meta.yaml | 2 + ...network_connectivity_policy_based_route.go | 35 ++++++- ...ity_policy_based_route_generated_meta.yaml | 2 + ..._network_connectivity_regional_endpoint.go | 35 ++++++- ...vity_regional_endpoint_generated_meta.yaml | 2 + .../resource_network_connectivity_spoke.go | 46 +++++++++ ...ork_connectivity_spoke_generated_meta.yaml | 2 + ...rce_network_connectivity_internal_range.go | 46 +++++++++ ...ctivity_internal_range_generated_meta.yaml | 2 + ..._connectivity_service_connection_policy.go | 46 +++++++++ ...vice_connection_policy_generated_meta.yaml | 2 + ...work_management_connectivity_tests_test.go | 2 + ...ment_connectivity_test_generated_meta.yaml | 2 + ...k_management_connectivity_test_resource.go | 46 +++++++++ ...ement_organization_vpc_flow_logs_config.go | 47 +++++++++ ...n_vpc_flow_logs_config_generated_meta.yaml | 2 + ...network_management_vpc_flow_logs_config.go | 46 +++++++++ ...t_vpc_flow_logs_config_generated_meta.yaml | 2 + ...resource_network_security_address_group.go | 47 +++++++++ ...security_address_group_generated_meta.yaml | 2 + .../resource_network_security_authz_policy.go | 46 +++++++++ ..._security_authz_policy_generated_meta.yaml | 2 + ..._security_backend_authentication_config.go | 46 +++++++++ ..._authentication_config_generated_meta.yaml | 2 + ...urce_network_security_client_tls_policy.go | 46 +++++++++ ...rity_client_tls_policy_generated_meta.yaml | 2 + ...ce_network_security_dns_threat_detector.go | 46 +++++++++ ...ty_dns_threat_detector_generated_meta.yaml | 2 + ...urce_network_security_firewall_endpoint.go | 47 +++++++++ ..._security_firewall_endpoint_association.go | 47 +++++++++ ...l_endpoint_association_generated_meta.yaml | 2 + ...rity_firewall_endpoint_generated_meta.yaml | 2 + ...etwork_security_gateway_security_policy.go | 46 +++++++++ ...ateway_security_policy_generated_meta.yaml | 2 + ...k_security_gateway_security_policy_rule.go | 46 +++++++++ ...y_security_policy_rule_generated_meta.yaml | 2 + ...e_network_security_intercept_deployment.go | 46 +++++++++ ...y_intercept_deployment_generated_meta.yaml | 2 + ...ork_security_intercept_deployment_group.go | 46 +++++++++ ...rcept_deployment_group_generated_meta.yaml | 2 + ...twork_security_intercept_endpoint_group.go | 46 +++++++++ ...ty_intercept_endpoint_group_association.go | 46 +++++++++ ...oint_group_association_generated_meta.yaml | 2 + ...tercept_endpoint_group_generated_meta.yaml | 2 + ...e_network_security_mirroring_deployment.go | 46 +++++++++ ...y_mirroring_deployment_generated_meta.yaml | 2 + ...ork_security_mirroring_deployment_group.go | 46 +++++++++ ...oring_deployment_group_generated_meta.yaml | 2 + ...rce_network_security_mirroring_endpoint.go | 46 +++++++++ ...ity_mirroring_endpoint_generated_meta.yaml | 2 + ...twork_security_mirroring_endpoint_group.go | 46 +++++++++ ...ty_mirroring_endpoint_group_association.go | 46 +++++++++ ...oint_group_association_generated_meta.yaml | 2 + ...rroring_endpoint_group_generated_meta.yaml | 2 + ...ource_network_security_security_profile.go | 47 +++++++++ ...urity_security_profile_generated_meta.yaml | 2 + ...network_security_security_profile_group.go | 47 +++++++++ ...security_profile_group_generated_meta.yaml | 2 + ...urce_network_security_server_tls_policy.go | 46 +++++++++ ...rity_server_tls_policy_generated_meta.yaml | 2 + ..._network_security_tls_inspection_policy.go | 46 +++++++++ ..._tls_inspection_policy_generated_meta.yaml | 2 + .../resource_network_security_url_lists.go | 46 +++++++++ ...ork_security_url_lists_generated_meta.yaml | 2 + ...source_network_services_authz_extension.go | 46 +++++++++ ...rvices_authz_extension_generated_meta.yaml | 2 + ...urce_network_services_edge_cache_keyset.go | 46 +++++++++ ...ices_edge_cache_keyset_generated_meta.yaml | 2 + ...urce_network_services_edge_cache_origin.go | 46 +++++++++ ...ices_edge_cache_origin_generated_meta.yaml | 2 + ...rce_network_services_edge_cache_service.go | 46 +++++++++ ...ces_edge_cache_service_generated_meta.yaml | 2 + ...source_network_services_endpoint_policy.go | 46 +++++++++ ...rvices_endpoint_policy_generated_meta.yaml | 2 + .../resource_network_services_gateway.go | 45 +++++++++ ...twork_services_gateway_generated_meta.yaml | 2 + .../resource_network_services_grpc_route.go | 46 +++++++++ ...rk_services_grpc_route_generated_meta.yaml | 2 + .../resource_network_services_http_route.go | 46 +++++++++ ...rk_services_http_route_generated_meta.yaml | 2 + ...urce_network_services_lb_edge_extension.go | 46 +++++++++ ...ices_lb_edge_extension_generated_meta.yaml | 2 + ...rce_network_services_lb_route_extension.go | 46 +++++++++ ...ces_lb_route_extension_generated_meta.yaml | 2 + ...e_network_services_lb_traffic_extension.go | 46 +++++++++ ...s_lb_traffic_extension_generated_meta.yaml | 2 + .../resource_network_services_mesh.go | 46 +++++++++ ..._network_services_mesh_generated_meta.yaml | 2 + ...services_multicast_consumer_association.go | 46 +++++++++ ...t_consumer_association_generated_meta.yaml | 2 + ...ource_network_services_multicast_domain.go | 46 +++++++++ ...rk_services_multicast_domain_activation.go | 46 +++++++++ ...cast_domain_activation_generated_meta.yaml | 2 + ...vices_multicast_domain_generated_meta.yaml | 2 + ...network_services_multicast_domain_group.go | 46 +++++++++ ...multicast_domain_group_generated_meta.yaml | 2 + ...ces_multicast_group_consumer_activation.go | 46 +++++++++ ...up_consumer_activation_generated_meta.yaml | 2 + ...ces_multicast_group_producer_activation.go | 46 +++++++++ ...up_producer_activation_generated_meta.yaml | 2 + ..._network_services_multicast_group_range.go | 46 +++++++++ ...rvices_multicast_group_range_activation.go | 46 +++++++++ ...group_range_activation_generated_meta.yaml | 2 + ..._multicast_group_range_generated_meta.yaml | 2 + ...services_multicast_producer_association.go | 46 +++++++++ ...t_producer_association_generated_meta.yaml | 2 + ...source_network_services_service_binding.go | 35 ++++++- ...rvices_service_binding_generated_meta.yaml | 2 + .../resource_network_services_tcp_route.go | 46 +++++++++ ...ork_services_tcp_route_generated_meta.yaml | 2 + .../resource_network_services_tls_route.go | 46 +++++++++ ...ork_services_tls_route_generated_meta.yaml | 2 + .../resource_network_services_wasm_plugin.go | 46 +++++++++ ...k_services_wasm_plugin_generated_meta.yaml | 2 + .../resource_notebooks_environment.go | 46 +++++++++ ..._notebooks_environment_generated_meta.yaml | 2 + .../notebooks/resource_notebooks_instance.go | 45 +++++++++ ...rce_notebooks_instance_generated_meta.yaml | 2 + .../notebooks/resource_notebooks_runtime.go | 46 +++++++++ ...urce_notebooks_runtime_generated_meta.yaml | 2 + .../resource_observability_trace_scope.go | 46 +++++++++ ...ervability_trace_scope_generated_meta.yaml | 2 + ...rce_oracle_database_autonomous_database.go | 34 ++++++- ...se_autonomous_database_generated_meta.yaml | 2 + ...e_database_cloud_exadata_infrastructure.go | 34 ++++++- ...exadata_infrastructure_generated_meta.yaml | 2 + ...source_oracle_database_cloud_vm_cluster.go | 34 ++++++- ...abase_cloud_vm_cluster_generated_meta.yaml | 2 + .../resource_oracle_database_db_system.go | 34 ++++++- ...cle_database_db_system_generated_meta.yaml | 2 + ...source_oracle_database_exadb_vm_cluster.go | 45 +++++++++ ...abase_exadb_vm_cluster_generated_meta.yaml | 2 + ...acle_database_exascale_db_storage_vault.go | 34 ++++++- ...scale_db_storage_vault_generated_meta.yaml | 2 + .../resource_oracle_database_odb_network.go | 34 ++++++- ...e_database_odb_network_generated_meta.yaml | 2 + .../resource_oracle_database_odb_subnet.go | 34 ++++++- ...le_database_odb_subnet_generated_meta.yaml | 2 + .../resource_org_policy_custom_constraint.go | 47 +++++++++ ...licy_custom_constraint_generated_meta.yaml | 2 + .../orgpolicy/resource_org_policy_policy.go | 47 +++++++++ ...urce_org_policy_policy_generated_meta.yaml | 2 + ...resource_os_config_os_policy_assignment.go | 20 ++++ ...e_os_config_os_policy_assignment_meta.yaml | 2 + .../resource_os_config_patch_deployment.go | 39 ++++++++ ...onfig_patch_deployment_generated_meta.yaml | 2 + ...source_os_config_v2_policy_orchestrator.go | 46 +++++++++ ...onfig_v2_policy_orchestrator_for_folder.go | 47 +++++++++ ...rchestrator_for_folder_generated_meta.yaml | 2 + ...v2_policy_orchestrator_for_organization.go | 47 +++++++++ ...rator_for_organization_generated_meta.yaml | 2 + ...v2_policy_orchestrator_generated_meta.yaml | 2 + .../resource_os_login_ssh_public_key.go | 47 +++++++++ ...s_login_ssh_public_key_generated_meta.yaml | 2 + .../resource_parallelstore_instance.go | 46 +++++++++ ...parallelstore_instance_generated_meta.yaml | 2 + ...ource_parameter_manager_parameters_test.go | 10 +- .../resource_parameter_manager_parameter.go | 46 +++++++++ ...eter_manager_parameter_generated_meta.yaml | 2 + ...rce_parameter_manager_parameter_version.go | 47 +++++++++ ...ager_parameter_version_generated_meta.yaml | 2 + ...ameter_manager_regional_parameters_test.go | 10 +- ...ce_parameter_manager_regional_parameter.go | 46 +++++++++ ...ger_regional_parameter_generated_meta.yaml | 2 + ...eter_manager_regional_parameter_version.go | 47 +++++++++ ...onal_parameter_version_generated_meta.yaml | 2 + .../privateca/resource_privateca_ca_pool.go | 46 +++++++++ ...urce_privateca_ca_pool_generated_meta.yaml | 2 + .../resource_privateca_certificate.go | 46 +++++++++ ...esource_privateca_certificate_authority.go | 45 +++++++++ ..._certificate_authority_generated_meta.yaml | 2 + ..._privateca_certificate_generated_meta.yaml | 2 + ...resource_privateca_certificate_template.go | 46 +++++++++ ...a_certificate_template_generated_meta.yaml | 2 + ...e_privileged_access_manager_entitlement.go | 47 +++++++++ ...ss_manager_entitlement_generated_meta.yaml | 2 + .../services/pubsub/resource_pubsub_schema.go | 46 +++++++++ ...resource_pubsub_schema_generated_meta.yaml | 2 + .../pubsub/resource_pubsub_subscription.go | 46 +++++++++ ...ce_pubsub_subscription_generated_meta.yaml | 2 + .../services/pubsub/resource_pubsub_topic.go | 46 +++++++++ .../resource_pubsub_topic_generated_meta.yaml | 2 + .../resource_pubsub_lite_reservation.go | 46 +++++++++ ...ubsub_lite_reservation_generated_meta.yaml | 2 + .../resource_pubsub_lite_subscription.go | 46 +++++++++ ...bsub_lite_subscription_generated_meta.yaml | 2 + .../pubsublite/resource_pubsub_lite_topic.go | 46 +++++++++ ...urce_pubsub_lite_topic_generated_meta.yaml | 2 + .../resource_recaptcha_enterprise_key.go | 20 ++++ ...esource_recaptcha_enterprise_key_meta.yaml | 2 + .../services/redis/resource_redis_cluster.go | 46 +++++++++ ...resource_redis_cluster_generated_meta.yaml | 2 + ..._redis_cluster_user_created_connections.go | 46 +++++++++ ...er_created_connections_generated_meta.yaml | 2 + .../services/redis/resource_redis_instance.go | 45 +++++++++ ...esource_redis_instance_generated_meta.yaml | 2 + .../data_source_google_folder.go | 4 + .../list_google_service_account.go | 2 +- .../resource_google_billing_subaccount.go | 31 ++++-- ...source_google_billing_subaccount_meta.yaml | 2 + .../resourcemanager/resource_google_folder.go | 21 +++- .../resource_google_folder_meta.yaml | 2 + ...ource_google_folder_organization_policy.go | 24 +++++ ...oogle_folder_organization_policy_meta.yaml | 2 + ...rce_google_organization_iam_custom_role.go | 24 +++++ ...gle_organization_iam_custom_role_meta.yaml | 2 + .../resource_google_organization_policy.go | 24 +++++ ...ource_google_organization_policy_meta.yaml | 2 + .../resource_google_project.go | 11 ++- ...resource_google_project_iam_custom_role.go | 20 ++++ ...e_google_project_iam_custom_role_meta.yaml | 2 + ...urce_google_project_organization_policy.go | 24 +++++ ...ogle_project_organization_policy_meta.yaml | 2 + .../resource_google_project_service.go | 15 +++ .../resource_google_project_service_meta.yaml | 2 + .../resource_google_service_account.go | 28 +++++- .../resource_google_service_account_key.go | 30 ++++++ ...ource_google_service_account_key_meta.yaml | 2 + .../resource_google_service_account_meta.yaml | 2 + .../resource_resource_manager_lien.go | 40 ++++++++ ..._resource_manager_lien_generated_meta.yaml | 2 + .../resource_resource_manager_capability.go | 1 + ...data_source_secret_manager_secrets_test.go | 10 +- .../resource_secret_manager_secret.go | 45 +++++++++ ..._secret_manager_secret_generated_meta.yaml | 2 + .../resource_secret_manager_secret_version.go | 54 +++++++---- ...manager_secret_version_generated_meta.yaml | 4 +- ...ce_secret_manager_regional_secrets_test.go | 10 +- ...resource_secret_manager_regional_secret.go | 45 +++++++++ ...anager_regional_secret_generated_meta.yaml | 2 + ..._secret_manager_regional_secret_version.go | 53 ++++++---- ...egional_secret_version_generated_meta.yaml | 4 +- ...ource_secure_source_manager_branch_rule.go | 46 +++++++++ ...ce_manager_branch_rule_generated_meta.yaml | 2 + .../resource_secure_source_manager_hook.go | 46 +++++++++ ...re_source_manager_hook_generated_meta.yaml | 2 + ...resource_secure_source_manager_instance.go | 49 ++++++---- ...ource_manager_instance_generated_meta.yaml | 4 +- ...source_secure_source_manager_repository.go | 67 ++++++++----- ...rce_manager_repository_generated_meta.yaml | 4 +- ...cc_event_threat_detection_custom_module.go | 47 +++++++++ ...etection_custom_module_generated_meta.yaml | 2 + .../resource_scc_folder_custom_module.go | 47 +++++++++ ...c_folder_custom_module_generated_meta.yaml | 2 + ...resource_scc_folder_notification_config.go | 47 +++++++++ ...er_notification_config_generated_meta.yaml | 2 + ...esource_scc_folder_scc_big_query_export.go | 47 +++++++++ ...r_scc_big_query_export_generated_meta.yaml | 2 + .../resource_scc_mute_config.go | 47 +++++++++ ...source_scc_mute_config_generated_meta.yaml | 2 + .../resource_scc_notification_config.go | 47 +++++++++ ...cc_notification_config_generated_meta.yaml | 2 + ...resource_scc_organization_custom_module.go | 47 +++++++++ ...nization_custom_module_generated_meta.yaml | 2 + ...e_scc_organization_scc_big_query_export.go | 47 +++++++++ ...n_scc_big_query_export_generated_meta.yaml | 2 + .../resource_scc_project_custom_module.go | 46 +++++++++ ..._project_custom_module_generated_meta.yaml | 2 + ...esource_scc_project_notification_config.go | 46 +++++++++ ...ct_notification_config_generated_meta.yaml | 2 + ...source_scc_project_scc_big_query_export.go | 46 +++++++++ ...t_scc_big_query_export_generated_meta.yaml | 2 + .../securitycenter/resource_scc_source.go | 1 + ...security_health_analytics_custom_module.go | 47 +++++++++ ...nalytics_custom_module_generated_meta.yaml | 2 + ...on_event_threat_detection_custom_module.go | 47 +++++++++ ...etection_custom_module_generated_meta.yaml | 2 + ...security_health_analytics_custom_module.go | 47 +++++++++ ...nalytics_custom_module_generated_meta.yaml | 2 + ...security_health_analytics_custom_module.go | 46 +++++++++ ...nalytics_custom_module_generated_meta.yaml | 2 + .../resource_scc_v2_folder_mute_config.go | 47 +++++++++ ..._v2_folder_mute_config_generated_meta.yaml | 2 + ...ource_scc_v2_folder_notification_config.go | 47 +++++++++ ...er_notification_config_generated_meta.yaml | 2 + ...urce_scc_v2_folder_scc_big_query_export.go | 47 +++++++++ ...r_scc_big_query_export_generated_meta.yaml | 2 + ...esource_scc_v2_organization_mute_config.go | 47 +++++++++ ...ganization_mute_config_generated_meta.yaml | 2 + ...scc_v2_organization_notification_config.go | 47 +++++++++ ...on_notification_config_generated_meta.yaml | 2 + ...cc_v2_organization_scc_big_query_export.go | 47 +++++++++ ...n_scc_big_query_export_generated_meta.yaml | 2 + ...c_v2_organization_scc_big_query_exports.go | 47 +++++++++ ..._scc_big_query_exports_generated_meta.yaml | 2 + .../resource_scc_v2_organization_source.go | 1 + .../resource_scc_v2_project_mute_config.go | 46 +++++++++ ...v2_project_mute_config_generated_meta.yaml | 2 + ...urce_scc_v2_project_notification_config.go | 46 +++++++++ ...ct_notification_config_generated_meta.yaml | 2 + ...rce_scc_v2_project_scc_big_query_export.go | 46 +++++++++ ...t_scc_big_query_export_generated_meta.yaml | 2 + .../resource_securityposture_posture.go | 48 ++++++++++ ...urce_securityposture_posture_deployment.go | 47 +++++++++ ...ure_posture_deployment_generated_meta.yaml | 2 + ...ecurityposture_posture_generated_meta.yaml | 2 + .../resource_service_directory_endpoint.go | 47 +++++++++ ...ice_directory_endpoint_generated_meta.yaml | 2 + .../resource_service_directory_namespace.go | 46 +++++++++ ...ce_directory_namespace_generated_meta.yaml | 2 + .../resource_service_directory_service.go | 47 +++++++++ ...vice_directory_service_generated_meta.yaml | 2 + .../resource_endpoints_service.go | 25 ++++- .../resource_endpoints_service_meta.yaml | 2 + ...le_service_networking_peered_dns_domain.go | 5 + ...le_service_networking_peered_dns_domain.go | 24 +++++ ...ice_networking_peered_dns_domain_meta.yaml | 2 + .../resource_service_networking_connection.go | 28 ++++-- ...ce_service_networking_connection_meta.yaml | 1 + ...service_networking_vpc_service_controls.go | 1 + .../resource_site_verification_owner.go | 23 +++++ ...resource_site_verification_owner_meta.yaml | 2 + ...resource_site_verification_web_resource.go | 40 ++++++++ ...ification_web_resource_generated_meta.yaml | 2 + .../resource_sourcerepo_repository.go | 46 +++++++++ ..._sourcerepo_repository_generated_meta.yaml | 2 + .../resource_spanner_backup_schedule.go | 46 +++++++++ ...panner_backup_schedule_generated_meta.yaml | 2 + .../spanner/resource_spanner_database.go | 45 +++++++++ ...ource_spanner_database_generated_meta.yaml | 2 + .../spanner/resource_spanner_instance.go | 45 +++++++++ .../resource_spanner_instance_config.go | 46 +++++++++ ...panner_instance_config_generated_meta.yaml | 2 + ...ource_spanner_instance_generated_meta.yaml | 2 + .../resource_spanner_instance_partition.go | 46 +++++++++ ...ner_instance_partition_generated_meta.yaml | 2 + ...data_source_sql_database_instances_test.go | 4 + google/services/sql/resource_sql_database.go | 63 ++++++++---- .../resource_sql_database_generated_meta.yaml | 4 +- .../sql/resource_sql_database_instance.go | 20 ++++ .../resource_sql_database_instance_meta.yaml | 2 + ...urce_sql_source_representation_instance.go | 39 ++++++++ ...epresentation_instance_generated_meta.yaml | 2 + google/services/sql/resource_sql_ssl_cert.go | 25 +++++ .../sql/resource_sql_ssl_cert_meta.yaml | 2 + google/services/sql/resource_sql_user.go | 29 +++--- .../services/sql/resource_sql_user_meta.yaml | 1 + .../resource_storage_anywhere_cache.go | 47 +++++++++ ...storage_anywhere_cache_generated_meta.yaml | 2 + .../storage/resource_storage_bucket.go | 20 ++++ .../resource_storage_bucket_access_control.go | 47 +++++++++ ..._bucket_access_control_generated_meta.yaml | 2 + .../storage/resource_storage_bucket_acl.go | 33 ++++++- .../resource_storage_bucket_acl_meta.yaml | 2 + .../storage/resource_storage_bucket_meta.yaml | 2 + .../storage/resource_storage_bucket_object.go | 27 ++++-- ...e_storage_default_object_access_control.go | 47 +++++++++ ..._object_access_control_generated_meta.yaml | 2 + .../resource_storage_default_object_acl.go | 25 +++++ ...ource_storage_default_object_acl_meta.yaml | 2 + .../storage/resource_storage_folder.go | 44 +++++++++ ...esource_storage_folder_generated_meta.yaml | 2 + .../storage/resource_storage_hmac_key.go | 46 +++++++++ ...ource_storage_hmac_key_generated_meta.yaml | 2 + .../resource_storage_managed_folder.go | 44 +++++++++ ...storage_managed_folder_generated_meta.yaml | 2 + .../resource_storage_object_access_control.go | 47 +++++++++ ..._object_access_control_generated_meta.yaml | 2 + .../storage/resource_storage_object_acl.go | 34 ++++++- .../resource_storage_object_acl_meta.yaml | 2 + .../resource_storage_batch_operations_job.go | 45 +++++++++ ...e_batch_operations_job_generated_meta.yaml | 2 + ...rage_control_folder_intelligence_config.go | 1 + ...ontrol_organization_intelligence_config.go | 1 + ...age_control_project_intelligence_config.go | 1 + ...esource_storage_insights_dataset_config.go | 45 +++++++++ ...nsights_dataset_config_generated_meta.yaml | 2 + ...resource_storage_insights_report_config.go | 45 +++++++++ ...insights_report_config_generated_meta.yaml | 2 + .../resource_storage_transfer_agent_pool.go | 46 +++++++++ ...ge_transfer_agent_pool_generated_meta.yaml | 2 + .../resource_storage_transfer_job.go | 20 ++++ .../resource_storage_transfer_job_meta.yaml | 2 + .../resource_tags_location_tag_binding.go | 28 ++++++ ...source_tags_location_tag_binding_meta.yaml | 2 + .../tags/resource_tags_tag_binding.go | 40 ++++++++ ...ource_tags_tag_binding_generated_meta.yaml | 2 + google/services/tags/resource_tags_tag_key.go | 47 +++++++++ .../resource_tags_tag_key_generated_meta.yaml | 2 + .../services/tags/resource_tags_tag_value.go | 47 +++++++++ ...esource_tags_tag_value_generated_meta.yaml | 2 + .../transcoder/resource_transcoder_job.go | 35 ++++++- ...esource_transcoder_job_generated_meta.yaml | 2 + .../resource_transcoder_job_template.go | 35 ++++++- ...ranscoder_job_template_generated_meta.yaml | 2 + .../resource_vector_search_collection.go | 46 +++++++++ ...ctor_search_collection_generated_meta.yaml | 2 + .../resource_vertex_ai_cache_config.go | 1 + .../vertexai/resource_vertex_ai_dataset.go | 46 +++++++++ ...urce_vertex_ai_dataset_generated_meta.yaml | 2 + ...urce_vertex_ai_deployment_resource_pool.go | 39 ++++++++ ...ployment_resource_pool_generated_meta.yaml | 2 + .../vertexai/resource_vertex_ai_endpoint.go | 46 +++++++++ ...rce_vertex_ai_endpoint_generated_meta.yaml | 2 + ...i_endpoint_with_model_garden_deployment.go | 26 +++++ ...odel_garden_deployment_generated_meta.yaml | 2 + .../resource_vertex_ai_feature_group.go | 46 +++++++++ ...esource_vertex_ai_feature_group_feature.go | 46 +++++++++ ..._feature_group_feature_generated_meta.yaml | 2 + ...ertex_ai_feature_group_generated_meta.yaml | 2 + ...resource_vertex_ai_feature_online_store.go | 45 +++++++++ ...tex_ai_feature_online_store_featureview.go | 46 +++++++++ ...line_store_featureview_generated_meta.yaml | 2 + ...i_feature_online_store_generated_meta.yaml | 2 + .../resource_vertex_ai_featurestore.go | 45 +++++++++ ...ource_vertex_ai_featurestore_entitytype.go | 48 ++++++++++ ...rtex_ai_featurestore_entitytype_feature.go | 48 ++++++++++ ...ore_entitytype_feature_generated_meta.yaml | 2 + ...eaturestore_entitytype_generated_meta.yaml | 2 + ...vertex_ai_featurestore_generated_meta.yaml | 2 + .../vertexai/resource_vertex_ai_index.go | 46 +++++++++ .../resource_vertex_ai_index_endpoint.go | 46 +++++++++ ...vertex_ai_index_endpoint_deployed_index.go | 46 +++++++++ ...ndpoint_deployed_index_generated_meta.yaml | 2 + ...rtex_ai_index_endpoint_generated_meta.yaml | 2 + ...source_vertex_ai_index_generated_meta.yaml | 2 + .../resource_vertex_ai_rag_engine_config.go | 46 +++++++++ ...x_ai_rag_engine_config_generated_meta.yaml | 2 + .../resource_vertex_ai_reasoning_engine.go | 45 +++++++-- ...ex_ai_reasoning_engine_generated_meta.yaml | 4 +- .../resource_vertex_ai_tensorboard.go | 46 +++++++++ ..._vertex_ai_tensorboard_generated_meta.yaml | 2 + .../resource_vmwareengine_cluster.go | 46 +++++++++ ...e_vmwareengine_cluster_generated_meta.yaml | 2 + .../resource_vmwareengine_datastore.go | 46 +++++++++ ...vmwareengine_datastore_generated_meta.yaml | 2 + ...ource_vmwareengine_external_access_rule.go | 46 +++++++++ ...e_external_access_rule_generated_meta.yaml | 2 + .../resource_vmwareengine_external_address.go | 46 +++++++++ ...ngine_external_address_generated_meta.yaml | 2 + .../resource_vmwareengine_network.go | 46 +++++++++ ...e_vmwareengine_network_generated_meta.yaml | 2 + .../resource_vmwareengine_network_peering.go | 46 +++++++++ ...engine_network_peering_generated_meta.yaml | 2 + .../resource_vmwareengine_network_policy.go | 46 +++++++++ ...eengine_network_policy_generated_meta.yaml | 2 + .../resource_vmwareengine_private_cloud.go | 45 +++++++++ ...reengine_private_cloud_generated_meta.yaml | 2 + .../resource_vpc_access_connector.go | 46 +++++++++ ...e_vpc_access_connector_generated_meta.yaml | 2 + .../workbench/resource_workbench_instance.go | 45 +++++++++ ...rce_workbench_instance_generated_meta.yaml | 2 + .../workflows/resource_workflows_workflow.go | 45 +++++++++ ...rce_workflows_workflow_generated_meta.yaml | 2 + .../resource_workstations_workstation.go | 46 +++++++++ ...source_workstations_workstation_cluster.go | 46 +++++++++ ...ns_workstation_cluster_generated_meta.yaml | 2 + ...esource_workstations_workstation_config.go | 46 +++++++++ ...ons_workstation_config_generated_meta.yaml | 2 + ...rkstations_workstation_generated_meta.yaml | 2 + google/tpgresource/utils.go | 96 +++++++++++++++++++ google/transport/config.go | 2 + ...context_manager_access_level.html.markdown | 6 ++ ...nager_access_level_condition.html.markdown | 6 ++ ...ontext_manager_access_levels.html.markdown | 6 ++ ...ontext_manager_access_policy.html.markdown | 6 ++ ...manager_authorized_orgs_desc.html.markdown | 6 ++ ...ontext_manager_egress_policy.html.markdown | 6 ++ ...ager_gcp_user_access_binding.html.markdown | 6 ++ ...ntext_manager_ingress_policy.html.markdown | 6 ++ ...xt_manager_service_perimeter.html.markdown | 6 ++ ...imeter_dry_run_egress_policy.html.markdown | 6 ++ ...meter_dry_run_ingress_policy.html.markdown | 6 ++ ...e_perimeter_dry_run_resource.html.markdown | 6 ++ ...vice_perimeter_egress_policy.html.markdown | 6 ++ ...ice_perimeter_ingress_policy.html.markdown | 6 ++ ...r_service_perimeter_resource.html.markdown | 6 ++ ...t_manager_service_perimeters.html.markdown | 6 ++ .../r/active_directory_domain.html.markdown | 6 ++ ...ctive_directory_domain_trust.html.markdown | 6 ++ .../r/active_directory_peering.html.markdown | 6 ++ website/docs/r/alloydb_backup.html.markdown | 6 ++ website/docs/r/alloydb_cluster.html.markdown | 9 +- website/docs/r/alloydb_instance.html.markdown | 6 ++ website/docs/r/alloydb_user.html.markdown | 6 ++ website/docs/r/api_gateway_api.html.markdown | 6 ++ .../r/api_gateway_api_config.html.markdown | 6 ++ .../docs/r/api_gateway_gateway.html.markdown | 6 ++ .../docs/r/apigee_addons_config.html.markdown | 6 ++ website/docs/r/apigee_api.html.markdown | 8 ++ .../r/apigee_api_deployment.html.markdown | 6 ++ .../docs/r/apigee_api_product.html.markdown | 6 ++ website/docs/r/apigee_app_group.html.markdown | 6 ++ .../apigee_control_plane_access.html.markdown | 6 ++ website/docs/r/apigee_developer.html.markdown | 6 ++ .../docs/r/apigee_developer_app.html.markdown | 6 ++ website/docs/r/apigee_dns_zone.html.markdown | 6 ++ .../apigee_endpoint_attachment.html.markdown | 6 ++ .../docs/r/apigee_env_keystore.html.markdown | 6 ++ .../r/apigee_env_references.html.markdown | 6 ++ website/docs/r/apigee_envgroup.html.markdown | 6 ++ .../apigee_envgroup_attachment.html.markdown | 6 ++ .../docs/r/apigee_environment.html.markdown | 6 ++ ...ee_environment_addons_config.html.markdown | 6 ++ ...ment_api_revision_deployment.html.markdown | 6 ++ ...gee_environment_keyvaluemaps.html.markdown | 6 ++ ...ronment_keyvaluemaps_entries.html.markdown | 6 ++ website/docs/r/apigee_flowhook.html.markdown | 8 ++ website/docs/r/apigee_instance.html.markdown | 6 ++ .../apigee_instance_attachment.html.markdown | 6 ++ ...gee_keystores_aliases_pkcs12.html.markdown | 8 ++ ...res_aliases_self_signed_cert.html.markdown | 6 ++ .../docs/r/apigee_nat_address.html.markdown | 6 ++ .../docs/r/apigee_organization.html.markdown | 6 ++ .../r/apigee_security_action.html.markdown | 6 ++ .../r/apigee_security_feedback.html.markdown | 6 ++ ...ecurity_monitoring_condition.html.markdown | 6 ++ .../apigee_security_profile_v2.html.markdown | 6 ++ .../docs/r/apigee_sharedflow.html.markdown | 8 ++ ...apigee_sharedflow_deployment.html.markdown | 7 ++ website/docs/r/apigee_space.html.markdown | 6 ++ .../r/apigee_sync_authorization.html.markdown | 6 ++ .../docs/r/apigee_target_server.html.markdown | 6 ++ .../r/apihub_api_hub_instance.html.markdown | 6 ++ website/docs/r/apihub_curation.html.markdown | 6 ++ ...ub_host_project_registration.html.markdown | 6 ++ website/docs/r/apihub_plugin.html.markdown | 6 ++ .../r/apihub_plugin_instance.html.markdown | 6 ++ website/docs/r/apikeys_key.html.markdown | 7 ++ ...plication_url_dispatch_rules.html.markdown | 6 ++ .../r/app_engine_domain_mapping.html.markdown | 6 ++ .../r/app_engine_firewall_rule.html.markdown | 6 ++ ..._engine_flexible_app_version.html.markdown | 6 ++ ...ine_service_network_settings.html.markdown | 6 ++ ...engine_service_split_traffic.html.markdown | 6 ++ ..._engine_standard_app_version.html.markdown | 6 ++ .../docs/r/apphub_application.html.markdown | 6 ++ website/docs/r/apphub_boundary.html.markdown | 6 ++ website/docs/r/apphub_service.html.markdown | 6 ++ ...b_service_project_attachment.html.markdown | 6 ++ website/docs/r/apphub_workload.html.markdown | 6 ++ ...artifact_registry_repository.html.markdown | 6 ++ .../r/artifact_registry_rule.html.markdown | 6 ++ ...tifact_registry_vpcsc_config.html.markdown | 6 ++ .../assured_workloads_workload.html.markdown | 7 ++ .../r/backup_dr_backup_plan.html.markdown | 6 ++ ...p_dr_backup_plan_association.html.markdown | 6 ++ .../r/backup_dr_backup_vault.html.markdown | 6 ++ .../backup_dr_management_server.html.markdown | 6 ++ .../backup_dr_restore_workload.html.markdown | 6 ++ .../r/backup_dr_service_config.html.markdown | 6 ++ .../r/beyondcorp_app_connection.html.markdown | 6 ++ .../r/beyondcorp_app_connector.html.markdown | 6 ++ .../r/beyondcorp_app_gateway.html.markdown | 6 ++ .../beyondcorp_security_gateway.html.markdown | 6 ++ ...security_gateway_application.html.markdown | 6 ++ website/docs/r/biglake_catalog.html.markdown | 6 ++ website/docs/r/biglake_database.html.markdown | 6 ++ .../r/biglake_iceberg_catalog.html.markdown | 6 ++ .../r/biglake_iceberg_namespace.html.markdown | 6 ++ .../r/biglake_iceberg_table.html.markdown | 6 ++ website/docs/r/biglake_table.html.markdown | 6 ++ ..._analytics_hub_data_exchange.html.markdown | 6 ++ ...b_data_exchange_subscription.html.markdown | 6 ++ ...gquery_analytics_hub_listing.html.markdown | 6 ++ ...ics_hub_listing_subscription.html.markdown | 6 ++ .../r/bigquery_bi_reservation.html.markdown | 6 ++ ...bigquery_capacity_commitment.html.markdown | 6 ++ .../docs/r/bigquery_connection.html.markdown | 6 ++ ...igquery_data_transfer_config.html.markdown | 6 ++ ...query_datapolicy_data_policy.html.markdown | 6 ++ ...ery_datapolicyv2_data_policy.html.markdown | 6 ++ website/docs/r/bigquery_dataset.html.markdown | 6 ++ .../r/bigquery_dataset_access.html.markdown | 6 ++ website/docs/r/bigquery_job.html.markdown | 6 ++ .../docs/r/bigquery_reservation.html.markdown | 6 ++ ...query_reservation_assignment.html.markdown | 6 ++ .../bigquery_reservation_group.html.markdown | 6 ++ website/docs/r/bigquery_routine.html.markdown | 6 ++ .../bigquery_row_access_policy.html.markdown | 6 ++ website/docs/r/bigquery_table.html.markdown | 8 ++ .../docs/r/bigtable_app_profile.html.markdown | 6 ++ .../r/bigtable_authorized_view.html.markdown | 7 ++ .../docs/r/bigtable_gc_policy.html.markdown | 13 ++- .../docs/r/bigtable_instance.html.markdown | 8 ++ .../r/bigtable_logical_view.html.markdown | 6 ++ .../bigtable_materialized_view.html.markdown | 6 ++ .../r/bigtable_schema_bundle.html.markdown | 6 ++ website/docs/r/bigtable_table.html.markdown | 7 ++ website/docs/r/billing_budget.html.markdown | 6 ++ .../docs/r/billing_project_info.html.markdown | 6 ++ ...inary_authorization_attestor.html.markdown | 6 ++ .../binary_authorization_policy.html.markdown | 6 ++ ...node_engine_blockchain_nodes.html.markdown | 6 ++ ...tificate_manager_certificate.html.markdown | 6 ++ ..._certificate_issuance_config.html.markdown | 6 ++ ...cate_manager_certificate_map.html.markdown | 6 ++ ...anager_certificate_map_entry.html.markdown | 6 ++ ...te_manager_dns_authorization.html.markdown | 6 ++ ...ificate_manager_trust_config.html.markdown | 6 ++ website/docs/r/ces_agent.html.markdown | 6 ++ website/docs/r/ces_app.html.markdown | 6 ++ ...s_app_root_agent_association.html.markdown | 6 ++ website/docs/r/ces_app_version.html.markdown | 6 ++ website/docs/r/ces_deployment.html.markdown | 6 ++ website/docs/r/ces_evaluation.html.markdown | 6 ++ website/docs/r/ces_example.html.markdown | 6 ++ website/docs/r/ces_guardrail.html.markdown | 6 ++ website/docs/r/ces_tool.html.markdown | 6 ++ website/docs/r/ces_toolset.html.markdown | 6 ++ .../r/chronicle_dashboard_chart.html.markdown | 6 ++ .../chronicle_data_access_label.html.markdown | 6 ++ .../chronicle_data_access_scope.html.markdown | 6 ++ .../docs/r/chronicle_data_table.html.markdown | 9 +- .../r/chronicle_data_table_row.html.markdown | 6 ++ website/docs/r/chronicle_feed.html.markdown | 6 ++ .../chronicle_native_dashboard.html.markdown | 6 ++ .../r/chronicle_reference_list.html.markdown | 6 ++ .../docs/r/chronicle_retrohunt.html.markdown | 6 ++ website/docs/r/chronicle_rule.html.markdown | 13 ++- .../r/chronicle_rule_deployment.html.markdown | 6 ++ .../docs/r/chronicle_watchlist.html.markdown | 6 ++ .../r/cloud_asset_folder_feed.html.markdown | 6 ++ ...loud_asset_organization_feed.html.markdown | 6 ++ .../r/cloud_asset_project_feed.html.markdown | 6 ++ .../docs/r/cloud_identity_group.html.markdown | 6 ++ ...ud_identity_group_membership.html.markdown | 6 ++ .../r/cloud_identity_policy.html.markdown | 6 ++ .../docs/r/cloud_ids_endpoint.html.markdown | 6 ++ ...otas_quota_adjuster_settings.html.markdown | 6 ++ ...loud_quotas_quota_preference.html.markdown | 6 ++ .../r/cloud_run_domain_mapping.html.markdown | 6 ++ .../docs/r/cloud_run_service.html.markdown | 6 ++ website/docs/r/cloud_run_v2_job.html.markdown | 6 ++ .../docs/r/cloud_run_v2_service.html.markdown | 6 ++ .../r/cloud_run_v2_worker_pool.html.markdown | 6 ++ .../docs/r/cloud_scheduler_job.html.markdown | 6 ++ ...ity_compliance_cloud_control.html.markdown | 6 ++ ...ecurity_compliance_framework.html.markdown | 6 ++ ...pliance_framework_deployment.html.markdown | 6 ++ .../docs/r/cloud_tasks_queue.html.markdown | 6 ++ ...uild_bitbucket_server_config.html.markdown | 6 ++ .../docs/r/cloudbuild_trigger.html.markdown | 6 ++ .../r/cloudbuild_worker_pool.html.markdown | 8 +- .../r/cloudbuildv2_connection.html.markdown | 6 ++ .../r/cloudbuildv2_repository.html.markdown | 6 ++ .../r/clouddeploy_automation.html.markdown | 6 ++ ...ouddeploy_custom_target_type.html.markdown | 6 ++ ...louddeploy_delivery_pipeline.html.markdown | 8 +- .../r/clouddeploy_deploy_policy.html.markdown | 6 ++ .../docs/r/clouddeploy_target.html.markdown | 8 +- .../r/clouddomains_registration.html.markdown | 6 ++ .../r/cloudfunctions2_function.html.markdown | 6 ++ .../r/cloudfunctions_function.html.markdown | 7 ++ .../r/colab_notebook_execution.html.markdown | 6 ++ website/docs/r/colab_runtime.html.markdown | 6 ++ .../r/colab_runtime_template.html.markdown | 6 ++ website/docs/r/colab_schedule.html.markdown | 6 ++ .../docs/r/composer_environment.html.markdown | 8 ++ ...er_user_workloads_config_map.html.markdown | 6 ++ ...mposer_user_workloads_secret.html.markdown | 7 ++ website/docs/r/compute_address.html.markdown | 6 ++ .../r/compute_attached_disk.html.markdown | 7 ++ .../docs/r/compute_autoscaler.html.markdown | 6 ++ .../r/compute_backend_bucket.html.markdown | 6 ++ ...ackend_bucket_signed_url_key.html.markdown | 6 ++ .../r/compute_backend_service.html.markdown | 6 ++ ...ckend_service_signed_url_key.html.markdown | 6 ++ .../compute_cross_site_network.html.markdown | 6 ++ website/docs/r/compute_disk.html.markdown | 6 ++ ...mpute_disk_async_replication.html.markdown | 7 ++ ...k_resource_policy_attachment.html.markdown | 6 ++ ...compute_external_vpn_gateway.html.markdown | 6 ++ website/docs/r/compute_firewall.html.markdown | 6 ++ .../r/compute_firewall_policy.html.markdown | 6 ++ ..._firewall_policy_association.html.markdown | 6 ++ ...compute_firewall_policy_rule.html.markdown | 6 ++ ...e_firewall_policy_with_rules.html.markdown | 6 ++ .../r/compute_forwarding_rule.html.markdown | 6 ++ .../compute_future_reservation.html.markdown | 6 ++ .../r/compute_global_address.html.markdown | 6 ++ ...mpute_global_forwarding_rule.html.markdown | 6 ++ ...pute_global_network_endpoint.html.markdown | 6 ++ ...lobal_network_endpoint_group.html.markdown | 6 ++ .../r/compute_ha_vpn_gateway.html.markdown | 6 ++ .../docs/r/compute_health_check.html.markdown | 6 ++ .../r/compute_http_health_check.html.markdown | 6 ++ .../compute_https_health_check.html.markdown | 6 ++ website/docs/r/compute_image.html.markdown | 6 ++ website/docs/r/compute_instance.html.markdown | 7 ++ .../r/compute_instance_group.html.markdown | 7 ++ ...mpute_instance_group_manager.html.markdown | 7 ++ ...te_instance_group_membership.html.markdown | 6 ++ ...te_instance_group_named_port.html.markdown | 6 ++ .../r/compute_instance_settings.html.markdown | 6 ++ .../r/compute_instant_snapshot.html.markdown | 6 ++ .../docs/r/compute_interconnect.html.markdown | 6 ++ ...pute_interconnect_attachment.html.markdown | 6 ++ ...nterconnect_attachment_group.html.markdown | 6 ++ .../compute_interconnect_group.html.markdown | 6 ++ .../r/compute_machine_image.html.markdown | 6 ++ ...pute_managed_ssl_certificate.html.markdown | 6 ++ website/docs/r/compute_network.html.markdown | 6 ++ .../compute_network_attachment.html.markdown | 6 ++ ...etwork_edge_security_service.html.markdown | 6 ++ .../r/compute_network_endpoint.html.markdown | 6 ++ ...mpute_network_endpoint_group.html.markdown | 6 ++ .../r/compute_network_endpoints.html.markdown | 6 ++ ...pute_network_firewall_policy.html.markdown | 6 ++ ..._firewall_policy_association.html.markdown | 6 ++ ...policy_packet_mirroring_rule.html.markdown | 6 ++ ...network_firewall_policy_rule.html.markdown | 6 ++ ...k_firewall_policy_with_rules.html.markdown | 6 ++ .../r/compute_network_peering.html.markdown | 8 ++ ...etwork_peering_routes_config.html.markdown | 6 ++ .../docs/r/compute_node_group.html.markdown | 6 ++ .../r/compute_node_template.html.markdown | 6 ++ ...organization_security_policy.html.markdown | 6 ++ ..._security_policy_association.html.markdown | 6 ++ ...ization_security_policy_rule.html.markdown | 6 ++ .../r/compute_packet_mirroring.html.markdown | 6 ++ .../compute_per_instance_config.html.markdown | 6 ++ .../r/compute_preview_feature.html.markdown | 6 ++ ...ute_project_cloud_armor_tier.html.markdown | 6 ++ .../r/compute_project_metadata.html.markdown | 7 ++ ...ompute_project_metadata_item.html.markdown | 7 ++ ...ute_public_advertised_prefix.html.markdown | 6 ++ ...pute_public_delegated_prefix.html.markdown | 6 ++ .../r/compute_region_autoscaler.html.markdown | 6 ++ ...ompute_region_backend_bucket.html.markdown | 6 ++ ...mpute_region_backend_service.html.markdown | 6 ++ .../r/compute_region_commitment.html.markdown | 6 ++ ...egion_composite_health_check.html.markdown | 6 ++ .../docs/r/compute_region_disk.html.markdown | 6 ++ ...k_resource_policy_attachment.html.markdown | 6 ++ ...on_health_aggregation_policy.html.markdown | 6 ++ .../compute_region_health_check.html.markdown | 6 ++ ...compute_region_health_source.html.markdown | 6 ++ ...egion_instance_group_manager.html.markdown | 7 ++ ...ute_region_instance_template.html.markdown | 7 ++ ...pute_region_instant_snapshot.html.markdown | 6 ++ ...pute_region_network_endpoint.html.markdown | 6 ++ ...egion_network_endpoint_group.html.markdown | 6 ++ ...gion_network_firewall_policy.html.markdown | 6 ++ ..._firewall_policy_association.html.markdown | 6 ++ ...network_firewall_policy_rule.html.markdown | 6 ++ ...k_firewall_policy_with_rules.html.markdown | 6 ++ ...e_region_per_instance_config.html.markdown | 6 ++ ...ompute_region_resize_request.html.markdown | 6 ++ ...mpute_region_security_policy.html.markdown | 6 ++ ..._region_security_policy_rule.html.markdown | 6 ++ ...mpute_region_ssl_certificate.html.markdown | 6 ++ .../r/compute_region_ssl_policy.html.markdown | 6 ++ ...ute_region_target_http_proxy.html.markdown | 6 ++ ...te_region_target_https_proxy.html.markdown | 6 ++ ...pute_region_target_tcp_proxy.html.markdown | 6 ++ .../r/compute_region_url_map.html.markdown | 6 ++ .../docs/r/compute_reservation.html.markdown | 6 ++ .../r/compute_resize_request.html.markdown | 6 ++ .../r/compute_resource_policy.html.markdown | 6 ++ ...e_resource_policy_attachment.html.markdown | 6 ++ .../docs/r/compute_rollout_plan.html.markdown | 6 ++ website/docs/r/compute_route.html.markdown | 6 ++ website/docs/r/compute_router.html.markdown | 6 ++ .../r/compute_router_interface.html.markdown | 7 ++ .../r/compute_router_named_set.html.markdown | 6 ++ .../docs/r/compute_router_nat.html.markdown | 6 ++ .../compute_router_nat_address.html.markdown | 6 ++ .../docs/r/compute_router_peer.html.markdown | 7 ++ .../compute_router_route_policy.html.markdown | 6 ++ .../r/compute_security_policy.html.markdown | 7 ++ ...compute_security_policy_rule.html.markdown | 6 ++ .../compute_service_attachment.html.markdown | 6 ++ ...pute_shared_vpc_host_project.html.markdown | 7 ++ website/docs/r/compute_snapshot.html.markdown | 6 ++ .../r/compute_snapshot_settings.html.markdown | 6 ++ .../r/compute_ssl_certificate.html.markdown | 6 ++ .../docs/r/compute_ssl_policy.html.markdown | 6 ++ .../docs/r/compute_storage_pool.html.markdown | 6 ++ .../docs/r/compute_subnetwork.html.markdown | 6 ++ .../r/compute_target_grpc_proxy.html.markdown | 6 ++ .../r/compute_target_http_proxy.html.markdown | 6 ++ .../compute_target_https_proxy.html.markdown | 6 ++ .../r/compute_target_instance.html.markdown | 6 ++ .../docs/r/compute_target_pool.html.markdown | 7 ++ .../r/compute_target_ssl_proxy.html.markdown | 6 ++ .../r/compute_target_tcp_proxy.html.markdown | 6 ++ website/docs/r/compute_url_map.html.markdown | 6 ++ .../docs/r/compute_vpn_gateway.html.markdown | 6 ++ .../docs/r/compute_vpn_tunnel.html.markdown | 6 ++ .../docs/r/compute_wire_group.html.markdown | 6 ++ ...enter_insights_analysis_rule.html.markdown | 6 ++ ...ter_insights_assessment_rule.html.markdown | 6 ++ ..._insights_auto_labeling_rule.html.markdown | 6 ++ ..._center_insights_qa_question.html.markdown | 6 ++ ...center_insights_qa_scorecard.html.markdown | 6 ++ ...sights_qa_scorecard_revision.html.markdown | 6 ++ ...contact_center_insights_view.html.markdown | 6 ++ .../r/container_analysis_note.html.markdown | 6 ++ ...ontainer_analysis_occurrence.html.markdown | 6 ++ .../container_attached_cluster.html.markdown | 10 +- .../r/container_aws_cluster.html.markdown | 8 +- .../r/container_aws_node_pool.html.markdown | 8 +- .../r/container_azure_client.html.markdown | 7 ++ .../r/container_azure_cluster.html.markdown | 8 +- .../r/container_azure_node_pool.html.markdown | 8 +- .../docs/r/container_cluster.html.markdown | 8 ++ .../docs/r/container_node_pool.html.markdown | 7 ++ .../docs/r/data_catalog_entry.html.markdown | 6 ++ .../r/data_catalog_entry_group.html.markdown | 6 ++ .../r/data_catalog_policy_tag.html.markdown | 6 ++ website/docs/r/data_catalog_tag.html.markdown | 6 ++ .../r/data_catalog_tag_template.html.markdown | 6 ++ .../r/data_catalog_taxonomy.html.markdown | 6 ++ .../docs/r/data_fusion_instance.html.markdown | 6 ++ .../docs/r/data_lineage_config.html.markdown | 6 ++ ...evention_deidentify_template.html.markdown | 6 ++ ..._prevention_discovery_config.html.markdown | 6 ++ ..._prevention_inspect_template.html.markdown | 6 ++ ..._loss_prevention_job_trigger.html.markdown | 6 ++ ..._prevention_stored_info_type.html.markdown | 6 ++ .../r/data_pipeline_pipeline.html.markdown | 6 ++ ...n_service_connection_profile.html.markdown | 6 ++ ...ration_service_migration_job.html.markdown | 6 ++ ...n_service_private_connection.html.markdown | 6 ++ .../dataflow_flex_template_job.html.markdown | 7 ++ website/docs/r/dataflow_job.html.markdown | 6 ++ website/docs/r/dataform_config.html.markdown | 6 ++ website/docs/r/dataform_folder.html.markdown | 6 ++ .../docs/r/dataform_repository.html.markdown | 10 +- ...rm_repository_release_config.html.markdown | 6 ++ ...m_repository_workflow_config.html.markdown | 6 ++ .../docs/r/dataform_team_folder.html.markdown | 6 ++ .../docs/r/dataplex_aspect_type.html.markdown | 6 ++ website/docs/r/dataplex_asset.html.markdown | 8 +- .../docs/r/dataplex_data_asset.html.markdown | 6 ++ .../r/dataplex_data_product.html.markdown | 6 ++ ...plex_data_product_data_asset.html.markdown | 6 ++ .../docs/r/dataplex_datascan.html.markdown | 6 ++ website/docs/r/dataplex_entry.html.markdown | 6 ++ .../docs/r/dataplex_entry_group.html.markdown | 6 ++ .../docs/r/dataplex_entry_link.html.markdown | 6 ++ .../docs/r/dataplex_entry_type.html.markdown | 6 ++ .../docs/r/dataplex_glossary.html.markdown | 6 ++ .../dataplex_glossary_category.html.markdown | 6 ++ .../r/dataplex_glossary_term.html.markdown | 6 ++ website/docs/r/dataplex_lake.html.markdown | 7 ++ website/docs/r/dataplex_task.html.markdown | 6 ++ website/docs/r/dataplex_zone.html.markdown | 8 +- .../dataproc_autoscaling_policy.html.markdown | 6 ++ website/docs/r/dataproc_batch.html.markdown | 6 ++ website/docs/r/dataproc_cluster.html.markdown | 8 ++ ..._gdc_application_environment.html.markdown | 6 ++ ...ataproc_gdc_service_instance.html.markdown | 6 ++ ...taproc_gdc_spark_application.html.markdown | 6 ++ website/docs/r/dataproc_job.html.markdown | 7 ++ ...ataproc_metastore_federation.html.markdown | 6 ++ .../dataproc_metastore_service.html.markdown | 6 ++ .../r/dataproc_session_template.html.markdown | 6 ++ .../dataproc_workflow_template.html.markdown | 7 ++ ...atastream_connection_profile.html.markdown | 6 ++ ...atastream_private_connection.html.markdown | 7 +- .../docs/r/datastream_stream.html.markdown | 6 ++ ...eployment_manager_deployment.html.markdown | 6 ++ ...er_connect_account_connector.html.markdown | 6 ++ ...developer_connect_connection.html.markdown | 6 ++ ..._connect_git_repository_link.html.markdown | 6 ++ ...oper_connect_insights_config.html.markdown | 6 ++ website/docs/r/dialogflow_agent.html.markdown | 6 ++ ...logflow_conversation_profile.html.markdown | 6 ++ .../docs/r/dialogflow_cx_agent.html.markdown | 6 ++ .../r/dialogflow_cx_entity_type.html.markdown | 6 ++ .../r/dialogflow_cx_environment.html.markdown | 6 ++ .../docs/r/dialogflow_cx_flow.html.markdown | 6 ++ ...gflow_cx_generative_settings.html.markdown | 6 ++ .../r/dialogflow_cx_generator.html.markdown | 6 ++ .../docs/r/dialogflow_cx_intent.html.markdown | 6 ++ .../docs/r/dialogflow_cx_page.html.markdown | 6 ++ .../r/dialogflow_cx_playbook.html.markdown | 6 ++ ...logflow_cx_security_settings.html.markdown | 6 ++ .../r/dialogflow_cx_test_case.html.markdown | 6 ++ .../docs/r/dialogflow_cx_tool.html.markdown | 6 ++ .../dialogflow_cx_tool_version.html.markdown | 6 ++ .../r/dialogflow_cx_version.html.markdown | 6 ++ .../r/dialogflow_cx_webhook.html.markdown | 6 ++ .../dialogflow_encryption_spec.html.markdown | 6 ++ .../r/dialogflow_entity_type.html.markdown | 6 ++ .../r/dialogflow_environment.html.markdown | 6 ++ .../r/dialogflow_fulfillment.html.markdown | 6 ++ .../docs/r/dialogflow_generator.html.markdown | 6 ++ .../docs/r/dialogflow_intent.html.markdown | 6 ++ .../docs/r/dialogflow_version.html.markdown | 6 ++ .../discovery_engine_acl_config.html.markdown | 6 ++ .../discovery_engine_assistant.html.markdown | 6 ++ ...discovery_engine_chat_engine.html.markdown | 6 ++ ...discovery_engine_cmek_config.html.markdown | 6 ++ .../r/discovery_engine_control.html.markdown | 6 ++ ...covery_engine_data_connector.html.markdown | 6 ++ .../discovery_engine_data_store.html.markdown | 6 ++ ...covery_engine_license_config.html.markdown | 6 ++ ...engine_recommendation_engine.html.markdown | 6 ++ .../r/discovery_engine_schema.html.markdown | 6 ++ ...scovery_engine_search_engine.html.markdown | 6 ++ ...covery_engine_serving_config.html.markdown | 6 ++ .../r/discovery_engine_sitemap.html.markdown | 6 ++ ...discovery_engine_target_site.html.markdown | 6 ++ .../discovery_engine_user_store.html.markdown | 6 ++ ...scovery_engine_widget_config.html.markdown | 6 ++ website/docs/r/dns_managed_zone.html.markdown | 6 ++ website/docs/r/dns_policy.html.markdown | 6 ++ website/docs/r/dns_record_set.html.markdown | 7 ++ .../docs/r/dns_response_policy.html.markdown | 6 ++ .../r/dns_response_policy_rule.html.markdown | 6 ++ .../r/document_ai_processor.html.markdown | 6 ++ ...ai_processor_default_version.html.markdown | 6 ++ .../docs/r/document_ai_schema.html.markdown | 6 ++ ...ai_warehouse_document_schema.html.markdown | 6 ++ ...cument_ai_warehouse_location.html.markdown | 6 ++ .../r/edgecontainer_cluster.html.markdown | 6 ++ .../r/edgecontainer_node_pool.html.markdown | 6 ++ ...edgecontainer_vpn_connection.html.markdown | 6 ++ ...work_interconnect_attachment.html.markdown | 6 ++ .../docs/r/edgenetwork_network.html.markdown | 6 ++ .../docs/r/edgenetwork_subnet.html.markdown | 6 ++ .../essential_contacts_contact.html.markdown | 6 ++ website/docs/r/eventarc_channel.html.markdown | 6 ++ .../docs/r/eventarc_enrollment.html.markdown | 6 ++ .../eventarc_google_api_source.html.markdown | 6 ++ ...entarc_google_channel_config.html.markdown | 6 ++ .../docs/r/eventarc_message_bus.html.markdown | 6 ++ .../docs/r/eventarc_pipeline.html.markdown | 6 ++ website/docs/r/eventarc_trigger.html.markdown | 6 ++ website/docs/r/filestore_backup.html.markdown | 6 ++ .../docs/r/filestore_instance.html.markdown | 6 ++ .../docs/r/filestore_snapshot.html.markdown | 6 ++ .../r/firebase_ai_logic_config.html.markdown | 6 ++ ...ase_ai_logic_prompt_template.html.markdown | 6 ++ ...i_logic_prompt_template_lock.html.markdown | 6 ++ .../docs/r/firebase_android_app.html.markdown | 10 +- ..._app_check_app_attest_config.html.markdown | 6 ++ ...rebase_app_check_debug_token.html.markdown | 6 ++ ...pp_check_device_check_config.html.markdown | 6 ++ ..._check_play_integrity_config.html.markdown | 6 ++ ..._recaptcha_enterprise_config.html.markdown | 6 ++ ...pp_check_recaptcha_v3_config.html.markdown | 6 ++ ...se_app_check_resource_policy.html.markdown | 6 ++ ...ase_app_check_service_config.html.markdown | 6 ++ ...firebase_app_hosting_backend.html.markdown | 6 ++ .../firebase_app_hosting_build.html.markdown | 6 ++ ...e_app_hosting_default_domain.html.markdown | 6 ++ .../firebase_app_hosting_domain.html.markdown | 6 ++ ...firebase_app_hosting_traffic.html.markdown | 6 ++ .../docs/r/firebase_apple_app.html.markdown | 10 +- ...irebase_data_connect_service.html.markdown | 9 +- .../firebase_database_instance.html.markdown | 6 ++ ...firebase_extensions_instance.html.markdown | 6 ++ .../r/firebase_hosting_channel.html.markdown | 6 ++ ...rebase_hosting_custom_domain.html.markdown | 6 ++ .../r/firebase_hosting_release.html.markdown | 6 ++ .../r/firebase_hosting_site.html.markdown | 6 ++ .../r/firebase_hosting_version.html.markdown | 6 ++ website/docs/r/firebase_project.html.markdown | 6 ++ ..._remote_config_remote_config.html.markdown | 6 ++ .../r/firebase_storage_bucket.html.markdown | 6 ++ ...ebase_storage_default_bucket.html.markdown | 6 ++ website/docs/r/firebase_web_app.html.markdown | 10 +- .../r/firebaserules_release.html.markdown | 8 +- .../r/firebaserules_ruleset.html.markdown | 8 +- .../r/firestore_backup_schedule.html.markdown | 6 ++ .../docs/r/firestore_database.html.markdown | 12 +-- .../docs/r/firestore_document.html.markdown | 6 ++ website/docs/r/firestore_field.html.markdown | 6 ++ website/docs/r/firestore_index.html.markdown | 11 ++- .../docs/r/firestore_user_creds.html.markdown | 6 ++ ...der_access_approval_settings.html.markdown | 6 ++ ...gemini_code_repository_index.html.markdown | 6 ++ .../r/gemini_code_tools_setting.html.markdown | 6 ++ ...i_code_tools_setting_binding.html.markdown | 6 ++ ..._sharing_with_google_setting.html.markdown | 6 ++ ..._with_google_setting_binding.html.markdown | 6 ++ ...emini_gcp_enablement_setting.html.markdown | 6 ++ ...p_enablement_setting_binding.html.markdown | 6 ++ .../r/gemini_logging_setting.html.markdown | 6 ++ ...mini_logging_setting_binding.html.markdown | 6 ++ ...mini_release_channel_setting.html.markdown | 6 ++ ...ease_channel_setting_binding.html.markdown | 6 ++ .../r/gemini_repository_group.html.markdown | 6 ++ .../r/gke_backup_backup_channel.html.markdown | 6 ++ .../r/gke_backup_backup_plan.html.markdown | 6 ++ .../gke_backup_restore_channel.html.markdown | 6 ++ .../r/gke_backup_restore_plan.html.markdown | 6 ++ website/docs/r/gke_hub_feature.html.markdown | 6 ++ .../gke_hub_feature_membership.html.markdown | 7 ++ website/docs/r/gke_hub_fleet.html.markdown | 6 ++ .../docs/r/gke_hub_membership.html.markdown | 6 ++ .../gke_hub_membership_binding.html.markdown | 6 ++ ...membership_rbac_role_binding.html.markdown | 6 ++ .../docs/r/gke_hub_namespace.html.markdown | 6 ++ .../r/gke_hub_rollout_sequence.html.markdown | 6 ++ website/docs/r/gke_hub_scope.html.markdown | 6 ++ ..._hub_scope_rbac_role_binding.html.markdown | 6 ++ ...rem_bare_metal_admin_cluster.html.markdown | 6 ++ ...gkeonprem_bare_metal_cluster.html.markdown | 6 ++ ...eonprem_bare_metal_node_pool.html.markdown | 6 ++ ...eonprem_vmware_admin_cluster.html.markdown | 6 ++ .../r/gkeonprem_vmware_cluster.html.markdown | 6 ++ .../gkeonprem_vmware_node_pool.html.markdown | 6 ++ .../r/google_billing_subaccount.html.markdown | 8 +- website/docs/r/google_folder.html.markdown | 7 ++ ...e_folder_organization_policy.html.markdown | 7 ++ ...organization_iam_custom_role.html.markdown | 7 ++ .../google_organization_policy.html.markdown | 7 ++ ...ogle_project_iam_custom_role.html.markdown | 7 ++ ...le_project_iam_member_remove.html.markdown | 7 ++ ..._project_organization_policy.html.markdown | 7 ++ .../r/google_project_service.html.markdown | 7 ++ .../r/google_service_account.html.markdown | 7 ++ .../google_service_account_key.html.markdown | 7 ++ ...networking_peered_dns_domain.html.markdown | 7 ++ ...le_tags_location_tag_binding.html.markdown | 7 ++ .../r/healthcare_consent_store.html.markdown | 6 ++ .../docs/r/healthcare_dataset.html.markdown | 6 ++ .../r/healthcare_dicom_store.html.markdown | 6 ++ .../r/healthcare_fhir_store.html.markdown | 6 ++ .../r/healthcare_hl7_v2_store.html.markdown | 6 ++ .../r/healthcare_pipeline_job.html.markdown | 6 ++ .../docs/r/healthcare_workspace.html.markdown | 6 ++ .../hypercomputecluster_cluster.html.markdown | 6 ++ .../iam_access_boundary_policy.html.markdown | 6 ++ website/docs/r/iam_deny_policy.html.markdown | 6 ++ .../iam_folders_policy_binding.html.markdown | 6 ++ website/docs/r/iam_oauth_client.html.markdown | 6 ++ .../iam_oauth_client_credential.html.markdown | 6 ++ ...organizations_policy_binding.html.markdown | 6 ++ ...cipal_access_boundary_policy.html.markdown | 6 ++ .../iam_projects_policy_binding.html.markdown | 6 ++ .../docs/r/iam_workforce_pool.html.markdown | 6 ++ .../iam_workforce_pool_provider.html.markdown | 6 ++ ..._workforce_pool_provider_key.html.markdown | 6 ++ ...ce_pool_provider_scim_tenant.html.markdown | 6 ++ ...rce_pool_provider_scim_token.html.markdown | 6 ++ .../iam_workload_identity_pool.html.markdown | 6 ++ ...entity_pool_managed_identity.html.markdown | 6 ++ ...load_identity_pool_namespace.html.markdown | 6 ++ ...kload_identity_pool_provider.html.markdown | 6 ++ website/docs/r/iap_brand.html.markdown | 6 ++ website/docs/r/iap_client.html.markdown | 6 ++ website/docs/r/iap_settings.html.markdown | 6 ++ .../r/iap_tunnel_dest_group.html.markdown | 6 ++ .../r/identity_platform_config.html.markdown | 6 ++ ...default_supported_idp_config.html.markdown | 6 ++ ...platform_inbound_saml_config.html.markdown | 6 ++ ...ty_platform_oauth_idp_config.html.markdown | 6 ++ .../r/identity_platform_tenant.html.markdown | 6 ++ ...default_supported_idp_config.html.markdown | 6 ++ ...m_tenant_inbound_saml_config.html.markdown | 6 ++ ...form_tenant_oauth_idp_config.html.markdown | 6 ++ ...ration_connectors_connection.html.markdown | 6 ++ ...nnectors_endpoint_attachment.html.markdown | 6 ++ ...tion_connectors_managed_zone.html.markdown | 6 ++ .../r/integrations_auth_config.html.markdown | 6 ++ .../docs/r/integrations_client.html.markdown | 6 ++ .../docs/r/kms_autokey_config.html.markdown | 6 ++ website/docs/r/kms_crypto_key.html.markdown | 6 ++ .../r/kms_crypto_key_version.html.markdown | 6 ++ .../docs/r/kms_ekm_connection.html.markdown | 6 ++ ...kms_folder_kaj_policy_config.html.markdown | 6 ++ website/docs/r/kms_key_handle.html.markdown | 6 ++ website/docs/r/kms_key_ring.html.markdown | 6 ++ .../r/kms_key_ring_import_job.html.markdown | 6 ++ ...ganization_kaj_policy_config.html.markdown | 6 ++ .../kms_project_autokey_config.html.markdown | 6 ++ ...ms_project_kaj_policy_config.html.markdown | 6 ++ .../r/kms_secret_ciphertext.html.markdown | 6 ++ ...illing_account_bucket_config.html.markdown | 7 ++ ...logging_billing_account_sink.html.markdown | 7 ++ ...logging_folder_bucket_config.html.markdown | 7 ++ .../r/logging_folder_settings.html.markdown | 6 ++ .../docs/r/logging_folder_sink.html.markdown | 7 ++ .../r/logging_linked_dataset.html.markdown | 6 ++ .../docs/r/logging_log_scope.html.markdown | 6 ++ website/docs/r/logging_log_view.html.markdown | 6 ++ website/docs/r/logging_metric.html.markdown | 6 ++ ...g_organization_bucket_config.html.markdown | 7 ++ ...ogging_organization_settings.html.markdown | 6 ++ .../r/logging_organization_sink.html.markdown | 7 ++ ...ogging_project_bucket_config.html.markdown | 7 ++ .../docs/r/logging_project_sink.html.markdown | 7 ++ .../docs/r/logging_saved_query.html.markdown | 6 ++ website/docs/r/looker_instance.html.markdown | 10 +- website/docs/r/lustre_instance.html.markdown | 6 ++ .../docs/r/managed_kafka_acl.html.markdown | 6 ++ .../r/managed_kafka_cluster.html.markdown | 6 ++ ...anaged_kafka_connect_cluster.html.markdown | 6 ++ .../r/managed_kafka_connector.html.markdown | 6 ++ .../docs/r/managed_kafka_topic.html.markdown | 6 ++ .../docs/r/memcache_instance.html.markdown | 6 ++ .../docs/r/memorystore_instance.html.markdown | 6 ++ ...sired_user_created_endpoints.html.markdown | 6 ++ .../r/migration_center_group.html.markdown | 6 ++ ...ration_center_preference_set.html.markdown | 6 ++ website/docs/r/ml_engine_model.html.markdown | 6 ++ .../r/model_armor_floorsetting.html.markdown | 6 ++ .../docs/r/model_armor_template.html.markdown | 6 ++ .../r/monitoring_alert_policy.html.markdown | 6 ++ .../r/monitoring_custom_service.html.markdown | 6 ++ .../docs/r/monitoring_dashboard.html.markdown | 6 ++ website/docs/r/monitoring_group.html.markdown | 6 ++ ...monitoring_metric_descriptor.html.markdown | 6 ++ ...monitoring_monitored_project.html.markdown | 6 ++ ...itoring_notification_channel.html.markdown | 6 ++ .../docs/r/monitoring_service.html.markdown | 6 ++ website/docs/r/monitoring_slo.html.markdown | 6 ++ ...nitoring_uptime_check_config.html.markdown | 6 ++ .../r/netapp_active_directory.html.markdown | 6 ++ website/docs/r/netapp_backup.html.markdown | 6 ++ .../docs/r/netapp_backup_policy.html.markdown | 6 ++ .../docs/r/netapp_backup_vault.html.markdown | 6 ++ .../docs/r/netapp_host_group.html.markdown | 6 ++ website/docs/r/netapp_kmsconfig.html.markdown | 6 ++ .../docs/r/netapp_storage_pool.html.markdown | 6 ++ website/docs/r/netapp_volume.html.markdown | 9 +- .../r/netapp_volume_quota_rule.html.markdown | 6 ++ .../r/netapp_volume_replication.html.markdown | 6 ++ .../r/netapp_volume_snapshot.html.markdown | 6 ++ ...ork_connectivity_destination.html.markdown | 6 ++ ...ity_gateway_advertised_route.html.markdown | 6 ++ .../network_connectivity_group.html.markdown | 6 ++ .../r/network_connectivity_hub.html.markdown | 6 ++ ..._connectivity_internal_range.html.markdown | 6 ++ ...ticloud_data_transfer_config.html.markdown | 6 ++ ...nectivity_policy_based_route.html.markdown | 6 ++ ...nnectivity_regional_endpoint.html.markdown | 6 ++ ...ty_service_connection_policy.html.markdown | 6 ++ .../network_connectivity_spoke.html.markdown | 6 ++ ...twork_connectivity_transport.html.markdown | 6 ++ ...management_connectivity_test.html.markdown | 6 ++ ...ization_vpc_flow_logs_config.html.markdown | 6 ++ ...agement_vpc_flow_logs_config.html.markdown | 6 ++ ...twork_security_address_group.html.markdown | 6 ++ ...ecurity_authorization_policy.html.markdown | 6 ++ ...etwork_security_authz_policy.html.markdown | 6 ++ ...ackend_authentication_config.html.markdown | 6 ++ ...k_security_client_tls_policy.html.markdown | 6 ++ ...security_dns_threat_detector.html.markdown | 6 ++ ...k_security_firewall_endpoint.html.markdown | 6 ++ ...irewall_endpoint_association.html.markdown | 6 ++ ...rity_gateway_security_policy.html.markdown | 6 ++ ...gateway_security_policy_rule.html.markdown | 6 ++ ...ecurity_intercept_deployment.html.markdown | 6 ++ ...y_intercept_deployment_group.html.markdown | 6 ++ ...ity_intercept_endpoint_group.html.markdown | 6 ++ ...t_endpoint_group_association.html.markdown | 6 ++ ...ecurity_mirroring_deployment.html.markdown | 6 ++ ...y_mirroring_deployment_group.html.markdown | 6 ++ ..._security_mirroring_endpoint.html.markdown | 6 ++ ...ity_mirroring_endpoint_group.html.markdown | 6 ++ ...g_endpoint_group_association.html.markdown | 6 ++ ...work_security_sac_attachment.html.markdown | 6 ++ .../network_security_sac_realm.html.markdown | 6 ++ ...rk_security_security_profile.html.markdown | 6 ++ ...urity_security_profile_group.html.markdown | 6 ++ ...k_security_server_tls_policy.html.markdown | 6 ++ ...curity_tls_inspection_policy.html.markdown | 6 ++ ...rity_ull_mirroring_collector.html.markdown | 6 ++ ...ull_mirroring_collector_rule.html.markdown | 6 ++ ...ecurity_ull_mirroring_engine.html.markdown | 6 ++ .../network_security_url_lists.html.markdown | 6 ++ ...twork_services_agent_gateway.html.markdown | 6 ++ ...ork_services_authz_extension.html.markdown | 6 ++ ...k_services_edge_cache_keyset.html.markdown | 6 ++ ...k_services_edge_cache_origin.html.markdown | 6 ++ ..._services_edge_cache_service.html.markdown | 6 ++ ...ork_services_endpoint_policy.html.markdown | 6 ++ .../r/network_services_gateway.html.markdown | 6 ++ .../network_services_grpc_route.html.markdown | 6 ++ .../network_services_http_route.html.markdown | 6 ++ ...k_services_lb_edge_extension.html.markdown | 6 ++ ..._services_lb_route_extension.html.markdown | 6 ++ ...ervices_lb_traffic_extension.html.markdown | 6 ++ .../r/network_services_mesh.html.markdown | 6 ++ ...lticast_consumer_association.html.markdown | 6 ++ ...rk_services_multicast_domain.html.markdown | 6 ++ ..._multicast_domain_activation.html.markdown | 6 ++ ...vices_multicast_domain_group.html.markdown | 6 ++ ...st_group_consumer_activation.html.markdown | 6 ++ ...st_group_producer_activation.html.markdown | 6 ++ ...rvices_multicast_group_range.html.markdown | 6 ++ ...icast_group_range_activation.html.markdown | 6 ++ ...lticast_producer_association.html.markdown | 6 ++ ...ork_services_service_binding.html.markdown | 6 ++ ...services_service_lb_policies.html.markdown | 6 ++ .../network_services_tcp_route.html.markdown | 6 ++ .../network_services_tls_route.html.markdown | 6 ++ ...network_services_wasm_plugin.html.markdown | 6 ++ .../r/notebooks_environment.html.markdown | 6 ++ .../docs/r/notebooks_instance.html.markdown | 6 ++ .../docs/r/notebooks_runtime.html.markdown | 6 ++ ...bservability_folder_settings.html.markdown | 6 ++ ...bility_organization_settings.html.markdown | 6 ++ ...servability_project_settings.html.markdown | 6 ++ .../r/observability_trace_scope.html.markdown | 6 ++ ...database_autonomous_database.html.markdown | 6 ++ ...cloud_exadata_infrastructure.html.markdown | 6 ++ ...le_database_cloud_vm_cluster.html.markdown | 6 ++ .../r/oracle_database_db_system.html.markdown | 6 ++ ...le_database_exadb_vm_cluster.html.markdown | 6 ++ ...se_exascale_db_storage_vault.html.markdown | 6 ++ .../oracle_database_odb_network.html.markdown | 6 ++ .../oracle_database_odb_subnet.html.markdown | 6 ++ ...org_policy_custom_constraint.html.markdown | 6 ++ .../docs/r/org_policy_policy.html.markdown | 6 ++ ...ion_access_approval_settings.html.markdown | 6 ++ .../r/os_config_guest_policies.html.markdown | 6 ++ ..._config_os_policy_assignment.html.markdown | 7 ++ .../os_config_patch_deployment.html.markdown | 6 ++ ...onfig_v2_policy_orchestrator.html.markdown | 6 ++ ...licy_orchestrator_for_folder.html.markdown | 6 ++ ...rchestrator_for_organization.html.markdown | 6 ++ .../r/os_login_ssh_public_key.html.markdown | 6 ++ .../r/parallelstore_instance.html.markdown | 6 ++ .../parameter_manager_parameter.html.markdown | 6 ++ ...er_manager_parameter_version.html.markdown | 6 ++ ...r_manager_regional_parameter.html.markdown | 6 ++ ...r_regional_parameter_version.html.markdown | 6 ++ .../docs/r/privateca_ca_pool.html.markdown | 6 ++ .../r/privateca_certificate.html.markdown | 6 ++ ...vateca_certificate_authority.html.markdown | 6 ++ ...ivateca_certificate_template.html.markdown | 6 ++ ...d_access_manager_entitlement.html.markdown | 6 ++ ...eged_access_manager_settings.html.markdown | 6 ++ ...ect_access_approval_settings.html.markdown | 6 ++ .../project_usage_export_bucket.html.markdown | 8 ++ ...blic_ca_external_account_key.html.markdown | 6 ++ .../r/pubsub_lite_reservation.html.markdown | 6 ++ .../r/pubsub_lite_subscription.html.markdown | 6 ++ .../docs/r/pubsub_lite_topic.html.markdown | 6 ++ website/docs/r/pubsub_schema.html.markdown | 6 ++ .../docs/r/pubsub_subscription.html.markdown | 6 ++ website/docs/r/pubsub_topic.html.markdown | 6 ++ .../r/recaptcha_enterprise_key.html.markdown | 8 +- website/docs/r/redis_cluster.html.markdown | 6 ++ ...ter_user_created_connections.html.markdown | 6 ++ website/docs/r/redis_instance.html.markdown | 6 ++ .../resource_manager_capability.html.markdown | 6 ++ .../r/resource_manager_lien.html.markdown | 6 ++ .../docs/r/runtimeconfig_config.html.markdown | 7 ++ .../r/runtimeconfig_variable.html.markdown | 7 ++ .../docs/r/saas_runtime_release.html.markdown | 6 ++ .../r/saas_runtime_rollout_kind.html.markdown | 6 ++ .../docs/r/saas_runtime_saas.html.markdown | 6 ++ .../docs/r/saas_runtime_tenant.html.markdown | 6 ++ .../docs/r/saas_runtime_unit.html.markdown | 6 ++ .../r/saas_runtime_unit_kind.html.markdown | 6 ++ .../saas_runtime_unit_operation.html.markdown | 6 ++ ...reat_detection_custom_module.html.markdown | 6 ++ .../r/scc_folder_custom_module.html.markdown | 6 ++ ...c_folder_notification_config.html.markdown | 6 ++ ..._folder_scc_big_query_export.html.markdown | 6 ++ ...alth_analytics_custom_module.html.markdown | 6 ++ ...reat_detection_custom_module.html.markdown | 6 ++ ...alth_analytics_custom_module.html.markdown | 6 ++ ...alth_analytics_custom_module.html.markdown | 6 ++ website/docs/r/scc_mute_config.html.markdown | 6 ++ .../r/scc_notification_config.html.markdown | 6 ++ ...c_organization_custom_module.html.markdown | 6 ++ ...ization_scc_big_query_export.html.markdown | 6 ++ .../r/scc_project_custom_module.html.markdown | 6 ++ ..._project_notification_config.html.markdown | 6 ++ ...project_scc_big_query_export.html.markdown | 6 ++ website/docs/r/scc_source.html.markdown | 6 ++ .../r/scc_v2_folder_mute_config.html.markdown | 6 ++ ...2_folder_notification_config.html.markdown | 6 ++ ..._folder_scc_big_query_export.html.markdown | 6 ++ ..._v2_organization_mute_config.html.markdown | 6 ++ ...nization_notification_config.html.markdown | 6 ++ ...ization_scc_big_query_export.html.markdown | 6 ++ ...zation_scc_big_query_exports.html.markdown | 6 ++ .../scc_v2_organization_source.html.markdown | 6 ++ .../scc_v2_project_mute_config.html.markdown | 6 ++ ..._project_notification_config.html.markdown | 6 ++ ...project_scc_big_query_export.html.markdown | 6 ++ ...cret_manager_regional_secret.html.markdown | 6 ++ ...ager_regional_secret_version.html.markdown | 10 +- .../r/secret_manager_secret.html.markdown | 6 ++ ...ecret_manager_secret_version.html.markdown | 8 +- ...e_source_manager_branch_rule.html.markdown | 6 ++ .../secure_source_manager_hook.html.markdown | 6 ++ ...cure_source_manager_instance.html.markdown | 15 ++- ...re_source_manager_repository.html.markdown | 15 ++- ...security_scanner_scan_config.html.markdown | 6 ++ .../r/securityposture_posture.html.markdown | 6 ++ ...typosture_posture_deployment.html.markdown | 6 ++ .../service_directory_endpoint.html.markdown | 6 ++ .../service_directory_namespace.html.markdown | 6 ++ .../r/service_directory_service.html.markdown | 6 ++ ...ervice_networking_connection.html.markdown | 8 +- ...working_vpc_service_controls.html.markdown | 6 ++ ...sage_consumer_quota_override.html.markdown | 6 ++ .../r/site_verification_owner.html.markdown | 7 ++ ...te_verification_web_resource.html.markdown | 6 ++ .../r/sourcerepo_repository.html.markdown | 6 ++ .../r/spanner_backup_schedule.html.markdown | 6 ++ website/docs/r/spanner_database.html.markdown | 6 ++ website/docs/r/spanner_instance.html.markdown | 6 ++ .../r/spanner_instance_config.html.markdown | 6 ++ .../spanner_instance_partition.html.markdown | 6 ++ website/docs/r/sql_database.html.markdown | 11 ++- .../r/sql_database_instance.html.markdown | 7 ++ ...urce_representation_instance.html.markdown | 6 ++ website/docs/r/sql_ssl_cert.html.markdown | 6 ++ website/docs/r/sql_user.html.markdown | 9 +- .../r/storage_anywhere_cache.html.markdown | 6 ++ ...storage_batch_operations_job.html.markdown | 6 ++ website/docs/r/storage_bucket.html.markdown | 7 ++ ...torage_bucket_access_control.html.markdown | 6 ++ .../docs/r/storage_bucket_acl.html.markdown | 7 ++ .../r/storage_bucket_object.html.markdown | 8 +- ...l_folder_intelligence_config.html.markdown | 6 ++ ...nization_intelligence_config.html.markdown | 6 ++ ..._project_intelligence_config.html.markdown | 6 ++ ...efault_object_access_control.html.markdown | 6 ++ .../storage_default_object_acl.html.markdown | 7 ++ website/docs/r/storage_folder.html.markdown | 6 ++ website/docs/r/storage_hmac_key.html.markdown | 6 ++ ...rage_insights_dataset_config.html.markdown | 6 ++ ...orage_insights_report_config.html.markdown | 6 ++ .../r/storage_managed_folder.html.markdown | 6 ++ ...torage_object_access_control.html.markdown | 6 ++ .../docs/r/storage_object_acl.html.markdown | 6 ++ .../storage_transfer_agent_pool.html.markdown | 6 ++ .../docs/r/storage_transfer_job.html.markdown | 7 ++ website/docs/r/tags_tag_binding.html.markdown | 6 ++ website/docs/r/tags_tag_key.html.markdown | 6 ++ website/docs/r/tags_tag_value.html.markdown | 6 ++ .../r/tpu_v2_queued_resource.html.markdown | 6 ++ website/docs/r/tpu_v2_vm.html.markdown | 6 ++ website/docs/r/transcoder_job.html.markdown | 6 ++ .../r/transcoder_job_template.html.markdown | 6 ++ .../r/vector_search_collection.html.markdown | 6 ++ .../r/vertex_ai_cache_config.html.markdown | 6 ++ .../docs/r/vertex_ai_dataset.html.markdown | 6 ++ ..._ai_deployment_resource_pool.html.markdown | 6 ++ .../docs/r/vertex_ai_endpoint.html.markdown | 6 ++ ...with_model_garden_deployment.html.markdown | 6 ++ .../r/vertex_ai_feature_group.html.markdown | 6 ++ ...tex_ai_feature_group_feature.html.markdown | 6 ++ ...rtex_ai_feature_online_store.html.markdown | 6 ++ ...ure_online_store_featureview.html.markdown | 6 ++ .../r/vertex_ai_featurestore.html.markdown | 6 ++ ...x_ai_featurestore_entitytype.html.markdown | 6 ++ ...turestore_entitytype_feature.html.markdown | 6 ++ website/docs/r/vertex_ai_index.html.markdown | 6 ++ .../r/vertex_ai_index_endpoint.html.markdown | 6 ++ ...ndex_endpoint_deployed_index.html.markdown | 6 ++ .../r/vertex_ai_metadata_store.html.markdown | 6 ++ .../vertex_ai_rag_engine_config.html.markdown | 6 ++ .../vertex_ai_reasoning_engine.html.markdown | 9 +- .../r/vertex_ai_tensorboard.html.markdown | 6 ++ .../docs/r/vmwareengine_cluster.html.markdown | 6 ++ .../r/vmwareengine_datastore.html.markdown | 6 ++ ...eengine_external_access_rule.html.markdown | 6 ++ ...mwareengine_external_address.html.markdown | 6 ++ .../docs/r/vmwareengine_network.html.markdown | 6 ++ ...vmwareengine_network_peering.html.markdown | 6 ++ .../vmwareengine_network_policy.html.markdown | 6 ++ .../vmwareengine_private_cloud.html.markdown | 6 ++ .../docs/r/vmwareengine_subnet.html.markdown | 6 ++ .../docs/r/vpc_access_connector.html.markdown | 6 ++ .../docs/r/workbench_instance.html.markdown | 6 ++ .../docs/r/workflows_workflow.html.markdown | 6 ++ ...kload_identity_service_agent.html.markdown | 6 ++ .../r/workstations_workstation.html.markdown | 6 ++ ...stations_workstation_cluster.html.markdown | 6 ++ ...kstations_workstation_config.html.markdown | 6 ++ 2529 files changed, 39930 insertions(+), 506 deletions(-) create mode 100644 .changelog/17380.txt diff --git a/.changelog/17380.txt b/.changelog/17380.txt new file mode 100644 index 00000000000..5f85f6d731d --- /dev/null +++ b/.changelog/17380.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +provider: support for a `deletion_policy` field has been added to almost all resources in the provider. Details on its usage can be found within individual resource documentation if supported. +``` \ No newline at end of file diff --git a/google/acctest/test_utils.go b/google/acctest/test_utils.go index b0168acd90f..c4e9f687bcf 100644 --- a/google/acctest/test_utils.go +++ b/google/acctest/test_utils.go @@ -79,7 +79,7 @@ func CheckDataSourceStateMatchesResourceStateWithIgnores(dataSourceName, resourc continue } - if strings.HasPrefix(k, "labels.") || strings.HasPrefix(k, "terraform_labels.") || strings.HasPrefix(k, "effective_labels.") { + if strings.HasPrefix(k, "labels.") || strings.HasPrefix(k, "terraform_labels.") || strings.HasPrefix(k, "effective_labels.") || strings.HasPrefix(k, "deletion_policy") { continue } if k == "%" { diff --git a/google/acctest/vcr_utils.go b/google/acctest/vcr_utils.go index 3807862397f..1ab451a037b 100644 --- a/google/acctest/vcr_utils.go +++ b/google/acctest/vcr_utils.go @@ -192,6 +192,11 @@ func VcrTest(t *testing.T, c resource.TestCase) { re := regexp.MustCompile(`create_duration = "\d+[sm]"`) s.Config = re.ReplaceAllString(s.Config, `create_duration = "1s"`) } + // deletion_policy is a universal virtual attribute for managing the behavior of resources when a delete is attempted + // in Terraform. Because it is a virtual attribute, it needs to be excluded from these ImportStateVerifys. + if s.ImportStateVerify && !slices.Contains(s.ImportStateVerifyIgnore, "deletion_policy") { + s.ImportStateVerifyIgnore = append(s.ImportStateVerifyIgnore, "deletion_policy") + } steps = append(steps, s) } c.Steps = steps diff --git a/google/fwmodels/provider_model.go b/google/fwmodels/provider_model.go index d62067cd7cf..1cc053221e9 100644 --- a/google/fwmodels/provider_model.go +++ b/google/fwmodels/provider_model.go @@ -47,6 +47,7 @@ type ProviderModel struct { RequestTimeout types.String `tfsdk:"request_timeout"` RequestReason types.String `tfsdk:"request_reason"` PollInterval types.String `tfsdk:"poll_interval"` + DeletionPolicy types.String `tfsdk:"deletion_policy"` UniverseDomain types.String `tfsdk:"universe_domain"` DefaultLabels types.Map `tfsdk:"default_labels"` AddTerraformAttributionLabel types.Bool `tfsdk:"add_terraform_attribution_label"` diff --git a/google/fwprovider/framework_provider.go b/google/fwprovider/framework_provider.go index ada27c89881..544988383aa 100644 --- a/google/fwprovider/framework_provider.go +++ b/google/fwprovider/framework_provider.go @@ -166,6 +166,9 @@ func (p *FrameworkProvider) Schema(_ context.Context, _ provider.SchemaRequest, fwvalidators.NonNegativeDurationValidator(), }, }, + "deletion_policy": schema.StringAttribute{ + Optional: true, + }, "request_reason": schema.StringAttribute{ Optional: true, }, diff --git a/google/provider/provider.go b/google/provider/provider.go index 724e26ccbcb..81cb11f89f1 100644 --- a/google/provider/provider.go +++ b/google/provider/provider.go @@ -160,6 +160,11 @@ func Provider() *schema.Provider { Optional: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + }, + "request_reason": { Type: schema.TypeString, Optional: true, @@ -292,6 +297,10 @@ func ProviderConfigure(ctx context.Context, d *schema.ResourceData, p *schema.Pr } } + if v, ok := d.GetOk("deletion_policy"); ok { + config.DeletionPolicy = v.(string) + } + if v, ok := d.GetOk("request_reason"); ok { config.RequestReason = v.(string) } diff --git a/google/services/accessapproval/resource_folder_access_approval_settings.go b/google/services/accessapproval/resource_folder_access_approval_settings.go index 25823e8cae4..8df413beeea 100644 --- a/google/services/accessapproval/resource_folder_access_approval_settings.go +++ b/google/services/accessapproval/resource_folder_access_approval_settings.go @@ -213,6 +213,19 @@ as key versions are inherited top-down.`, Computed: true, Description: `The resource name of the settings. Format is "folders/{folder_id}/accessApprovalSettings"`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -396,6 +409,20 @@ func resourceAccessApprovalFolderSettingsRead(d *schema.ResourceData, meta inter log.Printf("[DEBUG] Finished reading AccessApprovalFolderSettings %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceAccessApprovalFolderSettingsFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -417,6 +444,19 @@ func resourceAccessApprovalFolderSettingsRead(d *schema.ResourceData, meta inter } func resourceAccessApprovalFolderSettingsUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceAccessApprovalFolderSettings().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceAccessApprovalFolderSettingsRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -516,6 +556,13 @@ func resourceAccessApprovalFolderSettingsUpdate(d *schema.ResourceData, meta int } func resourceAccessApprovalFolderSettingsDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy AccessApprovalFolderSettings without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing FolderSettings %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/accessapproval/resource_folder_access_approval_settings_generated_meta.yaml b/google/services/accessapproval/resource_folder_access_approval_settings_generated_meta.yaml index 16414ec005a..12c5f9b7f90 100644 --- a/google/services/accessapproval/resource_folder_access_approval_settings_generated_meta.yaml +++ b/google/services/accessapproval/resource_folder_access_approval_settings_generated_meta.yaml @@ -19,3 +19,5 @@ fields: - api_field: invalidKeyVersion - api_field: name - api_field: notificationEmails + - field: deletion_policy + provider_only: true diff --git a/google/services/accessapproval/resource_organization_access_approval_settings.go b/google/services/accessapproval/resource_organization_access_approval_settings.go index b39e463214a..b0c362bcbb4 100644 --- a/google/services/accessapproval/resource_organization_access_approval_settings.go +++ b/google/services/accessapproval/resource_organization_access_approval_settings.go @@ -187,6 +187,19 @@ correct permissions on it, etc.).`, Computed: true, Description: `The resource name of the settings. Format is "organizations/{organization_id}/accessApprovalSettings"`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -357,6 +370,20 @@ func resourceAccessApprovalOrganizationSettingsRead(d *schema.ResourceData, meta log.Printf("[DEBUG] Finished reading AccessApprovalOrganizationSettings %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceAccessApprovalOrganizationSettingsFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -378,6 +405,19 @@ func resourceAccessApprovalOrganizationSettingsRead(d *schema.ResourceData, meta } func resourceAccessApprovalOrganizationSettingsUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceAccessApprovalOrganizationSettings().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceAccessApprovalOrganizationSettingsRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -477,6 +517,13 @@ func resourceAccessApprovalOrganizationSettingsUpdate(d *schema.ResourceData, me } func resourceAccessApprovalOrganizationSettingsDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy AccessApprovalOrganizationSettings without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing OrganizationSettings %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/accessapproval/resource_organization_access_approval_settings_generated_meta.yaml b/google/services/accessapproval/resource_organization_access_approval_settings_generated_meta.yaml index 2dbd3f19e10..3da7fed4c50 100644 --- a/google/services/accessapproval/resource_organization_access_approval_settings_generated_meta.yaml +++ b/google/services/accessapproval/resource_organization_access_approval_settings_generated_meta.yaml @@ -19,3 +19,5 @@ fields: - api_field: notificationEmails - field: organization_id provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/accessapproval/resource_project_access_approval_settings.go b/google/services/accessapproval/resource_project_access_approval_settings.go index 8167a82afd1..c7ab72f9f3a 100644 --- a/google/services/accessapproval/resource_project_access_approval_settings.go +++ b/google/services/accessapproval/resource_project_access_approval_settings.go @@ -195,6 +195,19 @@ as key versions are inherited top-down.`, Computed: true, Description: `The resource name of the settings. Format is "projects/{project_id}/accessApprovalSettings"`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -375,6 +388,20 @@ func resourceAccessApprovalProjectSettingsRead(d *schema.ResourceData, meta inte log.Printf("[DEBUG] Finished reading AccessApprovalProjectSettings %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceAccessApprovalProjectSettingsFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -396,6 +423,19 @@ func resourceAccessApprovalProjectSettingsRead(d *schema.ResourceData, meta inte } func resourceAccessApprovalProjectSettingsUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceAccessApprovalProjectSettings().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceAccessApprovalProjectSettingsRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -505,6 +545,13 @@ func resourceAccessApprovalProjectSettingsUpdate(d *schema.ResourceData, meta in } func resourceAccessApprovalProjectSettingsDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy AccessApprovalProjectSettings without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ProjectSettings %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/accessapproval/resource_project_access_approval_settings_generated_meta.yaml b/google/services/accessapproval/resource_project_access_approval_settings_generated_meta.yaml index f72d30415cf..7b6dbe6c3f7 100644 --- a/google/services/accessapproval/resource_project_access_approval_settings_generated_meta.yaml +++ b/google/services/accessapproval/resource_project_access_approval_settings_generated_meta.yaml @@ -20,3 +20,5 @@ fields: - api_field: project - field: project_id provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/accesscontextmanager/resource_access_context_manager_access_level.go b/google/services/accesscontextmanager/resource_access_context_manager_access_level.go index 6befbf97bc2..516f21bd801 100644 --- a/google/services/accesscontextmanager/resource_access_context_manager_access_level.go +++ b/google/services/accesscontextmanager/resource_access_context_manager_access_level.go @@ -399,6 +399,19 @@ custom access levels - https://cloud.google.com/access-context-manager/docs/cust Optional: true, Description: `Description of the AccessLevel and its use. Does not affect behavior.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -556,6 +569,20 @@ func resourceAccessContextManagerAccessLevelRead(d *schema.ResourceData, meta in log.Printf("[DEBUG] Finished reading AccessContextManagerAccessLevel %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceAccessContextManagerAccessLevelFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -577,6 +604,19 @@ func resourceAccessContextManagerAccessLevelRead(d *schema.ResourceData, meta in } func resourceAccessContextManagerAccessLevelUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceAccessContextManagerAccessLevel().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceAccessContextManagerAccessLevelRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -701,6 +741,13 @@ func resourceAccessContextManagerAccessLevelUpdate(d *schema.ResourceData, meta } func resourceAccessContextManagerAccessLevelDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy AccessContextManagerAccessLevel without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing AccessLevel %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/accesscontextmanager/resource_access_context_manager_access_level_condition.go b/google/services/accesscontextmanager/resource_access_context_manager_access_level_condition.go index a0a40fb0501..541703c2ba8 100644 --- a/google/services/accesscontextmanager/resource_access_context_manager_access_level_condition.go +++ b/google/services/accesscontextmanager/resource_access_context_manager_access_level_condition.go @@ -100,6 +100,7 @@ func ResourceAccessContextManagerAccessLevelCondition() *schema.Resource { return &schema.Resource{ Create: resourceAccessContextManagerAccessLevelConditionCreate, Read: resourceAccessContextManagerAccessLevelConditionRead, + Update: resourceAccessContextManagerAccessLevelConditionUpdate, Delete: resourceAccessContextManagerAccessLevelConditionDelete, Timeouts: &schema.ResourceTimeout{ @@ -317,6 +318,19 @@ Format: accessPolicies/{policy_id}/accessLevels/{short_name}`, Computed: true, Description: `The name of the Access Policy this resource belongs to.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -540,6 +554,20 @@ func resourceAccessContextManagerAccessLevelConditionRead(d *schema.ResourceData return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceAccessContextManagerAccessLevelConditionFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -560,7 +588,19 @@ func resourceAccessContextManagerAccessLevelConditionRead(d *schema.ResourceData return nil } +func resourceAccessContextManagerAccessLevelConditionUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceAccessContextManagerAccessLevelConditionRead(d, meta) +} + func resourceAccessContextManagerAccessLevelConditionDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy AccessContextManagerAccessLevelCondition without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing AccessLevelCondition %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/accesscontextmanager/resource_access_context_manager_access_level_condition_generated_meta.yaml b/google/services/accesscontextmanager/resource_access_context_manager_access_level_condition_generated_meta.yaml index e6f36a4156d..0a940719b19 100644 --- a/google/services/accesscontextmanager/resource_access_context_manager_access_level_condition_generated_meta.yaml +++ b/google/services/accesscontextmanager/resource_access_context_manager_access_level_condition_generated_meta.yaml @@ -39,3 +39,5 @@ fields: field: vpc_network_sources.vpc_subnetwork.network - api_field: basic.conditions.vpcNetworkSources.vpcSubnetwork.vpcIpSubnetworks field: vpc_network_sources.vpc_subnetwork.vpc_ip_subnetworks + - field: deletion_policy + provider_only: true diff --git a/google/services/accesscontextmanager/resource_access_context_manager_access_level_generated_meta.yaml b/google/services/accesscontextmanager/resource_access_context_manager_access_level_generated_meta.yaml index 0da0bf94533..32f876f87f2 100644 --- a/google/services/accesscontextmanager/resource_access_context_manager_access_level_generated_meta.yaml +++ b/google/services/accesscontextmanager/resource_access_context_manager_access_level_generated_meta.yaml @@ -32,3 +32,5 @@ fields: - api_field: name - api_field: parent - api_field: title + - field: deletion_policy + provider_only: true diff --git a/google/services/accesscontextmanager/resource_access_context_manager_access_levels.go b/google/services/accesscontextmanager/resource_access_context_manager_access_levels.go index a78c7eebf32..b38f2f7d3e1 100644 --- a/google/services/accesscontextmanager/resource_access_context_manager_access_levels.go +++ b/google/services/accesscontextmanager/resource_access_context_manager_access_levels.go @@ -143,6 +143,19 @@ Format: accessPolicies/{policy_id}`, Elem: accesscontextmanagerAccessLevelsAccessLevelsSchema(), // Default schema.HashSchema is used. }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -528,6 +541,20 @@ func resourceAccessContextManagerAccessLevelsRead(d *schema.ResourceData, meta i log.Printf("[DEBUG] Finished reading AccessContextManagerAccessLevels %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceAccessContextManagerAccessLevelsFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -549,6 +576,19 @@ func resourceAccessContextManagerAccessLevelsRead(d *schema.ResourceData, meta i } func resourceAccessContextManagerAccessLevelsUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceAccessContextManagerAccessLevels().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceAccessContextManagerAccessLevelsRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -624,6 +664,13 @@ func resourceAccessContextManagerAccessLevelsUpdate(d *schema.ResourceData, meta } func resourceAccessContextManagerAccessLevelsDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy AccessContextManagerAccessLevels without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing AccessLevels %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/accesscontextmanager/resource_access_context_manager_access_levels_generated_meta.yaml b/google/services/accesscontextmanager/resource_access_context_manager_access_levels_generated_meta.yaml index 6b040d75e8c..cde6043e40c 100644 --- a/google/services/accesscontextmanager/resource_access_context_manager_access_levels_generated_meta.yaml +++ b/google/services/accesscontextmanager/resource_access_context_manager_access_levels_generated_meta.yaml @@ -32,3 +32,5 @@ fields: - api_field: accessLevels.title - field: parent provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/accesscontextmanager/resource_access_context_manager_access_policy.go b/google/services/accesscontextmanager/resource_access_context_manager_access_policy.go index fe150ae9fd1..efdb0fad0f2 100644 --- a/google/services/accesscontextmanager/resource_access_context_manager_access_policy.go +++ b/google/services/accesscontextmanager/resource_access_context_manager_access_policy.go @@ -167,6 +167,19 @@ Format: 'folders/{{folder_id}}' or 'projects/{{project_number}}'`, Computed: true, Description: `Time the AccessPolicy was updated in UTC.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -315,6 +328,20 @@ func resourceAccessContextManagerAccessPolicyRead(d *schema.ResourceData, meta i log.Printf("[DEBUG] Finished reading AccessContextManagerAccessPolicy %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceAccessContextManagerAccessPolicyFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -336,6 +363,19 @@ func resourceAccessContextManagerAccessPolicyRead(d *schema.ResourceData, meta i } func resourceAccessContextManagerAccessPolicyUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceAccessContextManagerAccessPolicy().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceAccessContextManagerAccessPolicyRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -425,6 +465,13 @@ func resourceAccessContextManagerAccessPolicyUpdate(d *schema.ResourceData, meta } func resourceAccessContextManagerAccessPolicyDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy AccessContextManagerAccessPolicy without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing AccessPolicy %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/accesscontextmanager/resource_access_context_manager_access_policy_generated_meta.yaml b/google/services/accesscontextmanager/resource_access_context_manager_access_policy_generated_meta.yaml index d1c06975ff1..4f59e7f4266 100644 --- a/google/services/accesscontextmanager/resource_access_context_manager_access_policy_generated_meta.yaml +++ b/google/services/accesscontextmanager/resource_access_context_manager_access_policy_generated_meta.yaml @@ -15,3 +15,5 @@ fields: - api_field: scopes - api_field: title - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/accesscontextmanager/resource_access_context_manager_authorized_orgs_desc.go b/google/services/accesscontextmanager/resource_access_context_manager_authorized_orgs_desc.go index c72c4e91fa8..566ee75f8c3 100644 --- a/google/services/accesscontextmanager/resource_access_context_manager_authorized_orgs_desc.go +++ b/google/services/accesscontextmanager/resource_access_context_manager_authorized_orgs_desc.go @@ -204,6 +204,19 @@ Example: 'organizations/123456'`, Computed: true, Description: `Time the AuthorizedOrgsDesc was updated in UTC.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -366,6 +379,20 @@ func resourceAccessContextManagerAuthorizedOrgsDescRead(d *schema.ResourceData, log.Printf("[DEBUG] Finished reading AccessContextManagerAuthorizedOrgsDesc %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceAccessContextManagerAuthorizedOrgsDescFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -387,6 +414,19 @@ func resourceAccessContextManagerAuthorizedOrgsDescRead(d *schema.ResourceData, } func resourceAccessContextManagerAuthorizedOrgsDescUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceAccessContextManagerAuthorizedOrgsDesc().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceAccessContextManagerAuthorizedOrgsDescRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -478,6 +518,13 @@ func resourceAccessContextManagerAuthorizedOrgsDescUpdate(d *schema.ResourceData } func resourceAccessContextManagerAuthorizedOrgsDescDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy AccessContextManagerAuthorizedOrgsDesc without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing AuthorizedOrgsDesc %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/accesscontextmanager/resource_access_context_manager_authorized_orgs_desc_generated_meta.yaml b/google/services/accesscontextmanager/resource_access_context_manager_authorized_orgs_desc_generated_meta.yaml index 365e7a70b99..ac6f7e5e7f0 100644 --- a/google/services/accesscontextmanager/resource_access_context_manager_authorized_orgs_desc_generated_meta.yaml +++ b/google/services/accesscontextmanager/resource_access_context_manager_authorized_orgs_desc_generated_meta.yaml @@ -15,3 +15,5 @@ fields: - api_field: orgs - api_field: parent - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/accesscontextmanager/resource_access_context_manager_egress_policy.go b/google/services/accesscontextmanager/resource_access_context_manager_egress_policy.go index ff7f6b1b76c..47510423807 100644 --- a/google/services/accesscontextmanager/resource_access_context_manager_egress_policy.go +++ b/google/services/accesscontextmanager/resource_access_context_manager_egress_policy.go @@ -100,6 +100,7 @@ func ResourceAccessContextManagerEgressPolicy() *schema.Resource { return &schema.Resource{ Create: resourceAccessContextManagerEgressPolicyCreate, Read: resourceAccessContextManagerEgressPolicyRead, + Update: resourceAccessContextManagerEgressPolicyUpdate, Delete: resourceAccessContextManagerEgressPolicyDelete, Importer: &schema.ResourceImporter{ @@ -149,6 +150,19 @@ func ResourceAccessContextManagerEgressPolicy() *schema.Resource { Computed: true, Description: `The name of the Access Policy this resource belongs to.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -302,6 +316,20 @@ func resourceAccessContextManagerEgressPolicyRead(d *schema.ResourceData, meta i return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceAccessContextManagerEgressPolicyFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -328,7 +356,19 @@ func resourceAccessContextManagerEgressPolicyRead(d *schema.ResourceData, meta i return nil } +func resourceAccessContextManagerEgressPolicyUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceAccessContextManagerEgressPolicyRead(d, meta) +} + func resourceAccessContextManagerEgressPolicyDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy AccessContextManagerEgressPolicy without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing EgressPolicy %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/accesscontextmanager/resource_access_context_manager_egress_policy_generated_meta.yaml b/google/services/accesscontextmanager/resource_access_context_manager_egress_policy_generated_meta.yaml index d967eb69d15..4a9053a8e98 100644 --- a/google/services/accesscontextmanager/resource_access_context_manager_egress_policy_generated_meta.yaml +++ b/google/services/accesscontextmanager/resource_access_context_manager_egress_policy_generated_meta.yaml @@ -13,3 +13,5 @@ fields: provider_only: true - api_field: status.resources.resource field: resource + - field: deletion_policy + provider_only: true diff --git a/google/services/accesscontextmanager/resource_access_context_manager_gcp_user_access_binding.go b/google/services/accesscontextmanager/resource_access_context_manager_gcp_user_access_binding.go index b4158b0ee5b..85ae22ecb12 100644 --- a/google/services/accesscontextmanager/resource_access_context_manager_gcp_user_access_binding.go +++ b/google/services/accesscontextmanager/resource_access_context_manager_gcp_user_access_binding.go @@ -315,6 +315,19 @@ func ResourceAccessContextManagerGcpUserAccessBinding() *schema.Resource { Computed: true, Description: `Immutable. Assigned by the server during creation. The last segment has an arbitrary length and has only URI unreserved characters (as defined by RFC 3986 Section 2.3). Should not be specified by the client during creation. Example: "organizations/256/gcpUserAccessBindings/b3-BhcX_Ud5N"`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -462,6 +475,20 @@ func resourceAccessContextManagerGcpUserAccessBindingRead(d *schema.ResourceData log.Printf("[DEBUG] Finished reading AccessContextManagerGcpUserAccessBinding %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceAccessContextManagerGcpUserAccessBindingFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -483,6 +510,19 @@ func resourceAccessContextManagerGcpUserAccessBindingRead(d *schema.ResourceData } func resourceAccessContextManagerGcpUserAccessBindingUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceAccessContextManagerGcpUserAccessBinding().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceAccessContextManagerGcpUserAccessBindingRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -585,6 +625,13 @@ func resourceAccessContextManagerGcpUserAccessBindingUpdate(d *schema.ResourceDa } func resourceAccessContextManagerGcpUserAccessBindingDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy AccessContextManagerGcpUserAccessBinding without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing GcpUserAccessBinding %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/accesscontextmanager/resource_access_context_manager_gcp_user_access_binding_generated_meta.yaml b/google/services/accesscontextmanager/resource_access_context_manager_gcp_user_access_binding_generated_meta.yaml index 53d86f661c5..f92560bd865 100644 --- a/google/services/accesscontextmanager/resource_access_context_manager_gcp_user_access_binding_generated_meta.yaml +++ b/google/services/accesscontextmanager/resource_access_context_manager_gcp_user_access_binding_generated_meta.yaml @@ -26,3 +26,5 @@ fields: - api_field: sessionSettings.sessionLengthEnabled - api_field: sessionSettings.sessionReauthMethod - api_field: sessionSettings.useOidcMaxAge + - field: deletion_policy + provider_only: true diff --git a/google/services/accesscontextmanager/resource_access_context_manager_ingress_policy.go b/google/services/accesscontextmanager/resource_access_context_manager_ingress_policy.go index d0934f4686e..983f2b3f775 100644 --- a/google/services/accesscontextmanager/resource_access_context_manager_ingress_policy.go +++ b/google/services/accesscontextmanager/resource_access_context_manager_ingress_policy.go @@ -100,6 +100,7 @@ func ResourceAccessContextManagerIngressPolicy() *schema.Resource { return &schema.Resource{ Create: resourceAccessContextManagerIngressPolicyCreate, Read: resourceAccessContextManagerIngressPolicyRead, + Update: resourceAccessContextManagerIngressPolicyUpdate, Delete: resourceAccessContextManagerIngressPolicyDelete, Importer: &schema.ResourceImporter{ @@ -149,6 +150,19 @@ func ResourceAccessContextManagerIngressPolicy() *schema.Resource { Computed: true, Description: `The name of the Access Policy this resource belongs to.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -302,6 +316,20 @@ func resourceAccessContextManagerIngressPolicyRead(d *schema.ResourceData, meta return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceAccessContextManagerIngressPolicyFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -328,7 +356,19 @@ func resourceAccessContextManagerIngressPolicyRead(d *schema.ResourceData, meta return nil } +func resourceAccessContextManagerIngressPolicyUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceAccessContextManagerIngressPolicyRead(d, meta) +} + func resourceAccessContextManagerIngressPolicyDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy AccessContextManagerIngressPolicy without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing IngressPolicy %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/accesscontextmanager/resource_access_context_manager_ingress_policy_generated_meta.yaml b/google/services/accesscontextmanager/resource_access_context_manager_ingress_policy_generated_meta.yaml index ada397b4481..59c56e6572a 100644 --- a/google/services/accesscontextmanager/resource_access_context_manager_ingress_policy_generated_meta.yaml +++ b/google/services/accesscontextmanager/resource_access_context_manager_ingress_policy_generated_meta.yaml @@ -13,3 +13,5 @@ fields: provider_only: true - api_field: status.resources.resource field: resource + - field: deletion_policy + provider_only: true diff --git a/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter.go b/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter.go index c0eed1aad9c..80eaec1ed04 100644 --- a/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter.go +++ b/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter.go @@ -1133,6 +1133,19 @@ bet set to True if any of the fields in the spec are set to non-default values.` Computed: true, Description: `Time the AccessPolicy was updated in UTC.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -1302,6 +1315,20 @@ func resourceAccessContextManagerServicePerimeterRead(d *schema.ResourceData, me log.Printf("[DEBUG] Finished reading AccessContextManagerServicePerimeter %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceAccessContextManagerServicePerimeterFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -1323,6 +1350,19 @@ func resourceAccessContextManagerServicePerimeterRead(d *schema.ResourceData, me } func resourceAccessContextManagerServicePerimeterUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceAccessContextManagerServicePerimeter().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceAccessContextManagerServicePerimeterRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1457,6 +1497,13 @@ func resourceAccessContextManagerServicePerimeterUpdate(d *schema.ResourceData, } func resourceAccessContextManagerServicePerimeterDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy AccessContextManagerServicePerimeter without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ServicePerimeter %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_dry_run_egress_policy.go b/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_dry_run_egress_policy.go index c43b3900aa3..b5e8985cce0 100644 --- a/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_dry_run_egress_policy.go +++ b/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_dry_run_egress_policy.go @@ -212,6 +212,7 @@ func ResourceAccessContextManagerServicePerimeterDryRunEgressPolicy() *schema.Re return &schema.Resource{ Create: resourceAccessContextManagerServicePerimeterDryRunEgressPolicyCreate, Read: resourceAccessContextManagerServicePerimeterDryRunEgressPolicyRead, + Update: resourceAccessContextManagerServicePerimeterDryRunEgressPolicyUpdate, Delete: resourceAccessContextManagerServicePerimeterDryRunEgressPolicyDelete, Timeouts: &schema.ResourceTimeout{ @@ -422,6 +423,19 @@ are allowed to perform.`, Computed: true, Description: `The perimeter etag is internally used to prevent overwriting the list of policies on PATCH calls. It is retrieved from the same GET perimeter API call that's used to get the current list of policies. The policy defined in this resource is added or removed from that list, and then this etag is sent with the PATCH call along with the updated policies.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -602,6 +616,20 @@ func resourceAccessContextManagerServicePerimeterDryRunEgressPolicyRead(d *schem return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceAccessContextManagerServicePerimeterDryRunEgressPolicyFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -622,7 +650,19 @@ func resourceAccessContextManagerServicePerimeterDryRunEgressPolicyRead(d *schem return nil } +func resourceAccessContextManagerServicePerimeterDryRunEgressPolicyUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceAccessContextManagerServicePerimeterDryRunEgressPolicyRead(d, meta) +} + func resourceAccessContextManagerServicePerimeterDryRunEgressPolicyDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy AccessContextManagerServicePerimeterDryRunEgressPolicy without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ServicePerimeterDryRunEgressPolicy %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_dry_run_egress_policy_generated_meta.yaml b/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_dry_run_egress_policy_generated_meta.yaml index 89a61408ad5..68198856480 100644 --- a/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_dry_run_egress_policy_generated_meta.yaml +++ b/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_dry_run_egress_policy_generated_meta.yaml @@ -37,3 +37,5 @@ fields: provider_only: true - api_field: spec.egressPolicies.title field: title + - field: deletion_policy + provider_only: true diff --git a/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_dry_run_ingress_policy.go b/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_dry_run_ingress_policy.go index 11d89106054..15fd85faa47 100644 --- a/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_dry_run_ingress_policy.go +++ b/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_dry_run_ingress_policy.go @@ -212,6 +212,7 @@ func ResourceAccessContextManagerServicePerimeterDryRunIngressPolicy() *schema.R return &schema.Resource{ Create: resourceAccessContextManagerServicePerimeterDryRunIngressPolicyCreate, Read: resourceAccessContextManagerServicePerimeterDryRunIngressPolicyRead, + Update: resourceAccessContextManagerServicePerimeterDryRunIngressPolicyUpdate, Delete: resourceAccessContextManagerServicePerimeterDryRunIngressPolicyDelete, Timeouts: &schema.ResourceTimeout{ @@ -415,6 +416,19 @@ are allowed to perform.`, Computed: true, Description: `The perimeter etag is internally used to prevent overwriting the list of policies on PATCH calls. It is retrieved from the same GET perimeter API call that's used to get the current list of policies. The policy defined in this resource is added or removed from that list, and then this etag is sent with the PATCH call along with the updated policies.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -595,6 +609,20 @@ func resourceAccessContextManagerServicePerimeterDryRunIngressPolicyRead(d *sche return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceAccessContextManagerServicePerimeterDryRunIngressPolicyFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -615,7 +643,19 @@ func resourceAccessContextManagerServicePerimeterDryRunIngressPolicyRead(d *sche return nil } +func resourceAccessContextManagerServicePerimeterDryRunIngressPolicyUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceAccessContextManagerServicePerimeterDryRunIngressPolicyRead(d, meta) +} + func resourceAccessContextManagerServicePerimeterDryRunIngressPolicyDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy AccessContextManagerServicePerimeterDryRunIngressPolicy without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ServicePerimeterDryRunIngressPolicy %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_dry_run_ingress_policy_generated_meta.yaml b/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_dry_run_ingress_policy_generated_meta.yaml index 203bc1ee726..33fcae72e0c 100644 --- a/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_dry_run_ingress_policy_generated_meta.yaml +++ b/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_dry_run_ingress_policy_generated_meta.yaml @@ -33,3 +33,5 @@ fields: provider_only: true - api_field: spec.ingressPolicies.title field: title + - field: deletion_policy + provider_only: true diff --git a/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_dry_run_resource.go b/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_dry_run_resource.go index 345994efc54..8884b55986f 100644 --- a/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_dry_run_resource.go +++ b/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_dry_run_resource.go @@ -100,6 +100,7 @@ func ResourceAccessContextManagerServicePerimeterDryRunResource() *schema.Resour return &schema.Resource{ Create: resourceAccessContextManagerServicePerimeterDryRunResourceCreate, Read: resourceAccessContextManagerServicePerimeterDryRunResourceRead, + Update: resourceAccessContextManagerServicePerimeterDryRunResourceUpdate, Delete: resourceAccessContextManagerServicePerimeterDryRunResourceDelete, Importer: &schema.ResourceImporter{ @@ -156,6 +157,19 @@ Format: projects/{project_number}`, Computed: true, Description: `The perimeter etag is internally used to prevent overwriting the list of perimeter resources on PATCH calls. It is retrieved from the same GET perimeter API call that's used to get the current list of resources. The resource to add or remove is merged into that list and then this etag is sent with the PATCH call along with the updated resource list.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -329,6 +343,20 @@ func resourceAccessContextManagerServicePerimeterDryRunResourceRead(d *schema.Re return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceAccessContextManagerServicePerimeterDryRunResourceFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -355,7 +383,19 @@ func resourceAccessContextManagerServicePerimeterDryRunResourceRead(d *schema.Re return nil } +func resourceAccessContextManagerServicePerimeterDryRunResourceUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceAccessContextManagerServicePerimeterDryRunResourceRead(d, meta) +} + func resourceAccessContextManagerServicePerimeterDryRunResourceDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy AccessContextManagerServicePerimeterDryRunResource without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ServicePerimeterDryRunResource %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_dry_run_resource_generated_meta.yaml b/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_dry_run_resource_generated_meta.yaml index c2f5318a6d9..970f2dfb697 100644 --- a/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_dry_run_resource_generated_meta.yaml +++ b/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_dry_run_resource_generated_meta.yaml @@ -15,3 +15,5 @@ fields: provider_only: true - api_field: spec.resources.resource field: resource + - field: deletion_policy + provider_only: true diff --git a/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_egress_policy.go b/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_egress_policy.go index 492417d771e..83f6194a6be 100644 --- a/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_egress_policy.go +++ b/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_egress_policy.go @@ -212,6 +212,7 @@ func ResourceAccessContextManagerServicePerimeterEgressPolicy() *schema.Resource return &schema.Resource{ Create: resourceAccessContextManagerServicePerimeterEgressPolicyCreate, Read: resourceAccessContextManagerServicePerimeterEgressPolicyRead, + Update: resourceAccessContextManagerServicePerimeterEgressPolicyUpdate, Delete: resourceAccessContextManagerServicePerimeterEgressPolicyDelete, Timeouts: &schema.ResourceTimeout{ @@ -422,6 +423,19 @@ are allowed to perform.`, Computed: true, Description: `The perimeter etag is internally used to prevent overwriting the list of policies on PATCH calls. It is retrieved from the same GET perimeter API call that's used to get the current list of policies. The policy defined in this resource is added or removed from that list, and then this etag is sent with the PATCH call along with the updated policies.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -600,6 +614,20 @@ func resourceAccessContextManagerServicePerimeterEgressPolicyRead(d *schema.Reso return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceAccessContextManagerServicePerimeterEgressPolicyFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -620,7 +648,19 @@ func resourceAccessContextManagerServicePerimeterEgressPolicyRead(d *schema.Reso return nil } +func resourceAccessContextManagerServicePerimeterEgressPolicyUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceAccessContextManagerServicePerimeterEgressPolicyRead(d, meta) +} + func resourceAccessContextManagerServicePerimeterEgressPolicyDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy AccessContextManagerServicePerimeterEgressPolicy without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ServicePerimeterEgressPolicy %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_egress_policy_generated_meta.yaml b/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_egress_policy_generated_meta.yaml index ecd1eb341bc..79e852c5b70 100644 --- a/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_egress_policy_generated_meta.yaml +++ b/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_egress_policy_generated_meta.yaml @@ -37,3 +37,5 @@ fields: provider_only: true - api_field: status.egressPolicies.title field: title + - field: deletion_policy + provider_only: true diff --git a/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_generated_meta.yaml b/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_generated_meta.yaml index 50465e67f21..237b4a6c9db 100644 --- a/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_generated_meta.yaml +++ b/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_generated_meta.yaml @@ -69,3 +69,5 @@ fields: - api_field: title - api_field: updateTime - api_field: useExplicitDryRunSpec + - field: deletion_policy + provider_only: true diff --git a/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_ingress_policy.go b/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_ingress_policy.go index 8b2c234b23a..7853ed03adf 100644 --- a/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_ingress_policy.go +++ b/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_ingress_policy.go @@ -212,6 +212,7 @@ func ResourceAccessContextManagerServicePerimeterIngressPolicy() *schema.Resourc return &schema.Resource{ Create: resourceAccessContextManagerServicePerimeterIngressPolicyCreate, Read: resourceAccessContextManagerServicePerimeterIngressPolicyRead, + Update: resourceAccessContextManagerServicePerimeterIngressPolicyUpdate, Delete: resourceAccessContextManagerServicePerimeterIngressPolicyDelete, Timeouts: &schema.ResourceTimeout{ @@ -418,6 +419,19 @@ are allowed to perform.`, Computed: true, Description: `The perimeter etag is internally used to prevent overwriting the list of policies on PATCH calls. It is retrieved from the same GET perimeter API call that's used to get the current list of policies. The policy defined in this resource is added or removed from that list, and then this etag is sent with the PATCH call along with the updated policies.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -596,6 +610,20 @@ func resourceAccessContextManagerServicePerimeterIngressPolicyRead(d *schema.Res return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceAccessContextManagerServicePerimeterIngressPolicyFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -616,7 +644,19 @@ func resourceAccessContextManagerServicePerimeterIngressPolicyRead(d *schema.Res return nil } +func resourceAccessContextManagerServicePerimeterIngressPolicyUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceAccessContextManagerServicePerimeterIngressPolicyRead(d, meta) +} + func resourceAccessContextManagerServicePerimeterIngressPolicyDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy AccessContextManagerServicePerimeterIngressPolicy without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ServicePerimeterIngressPolicy %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_ingress_policy_generated_meta.yaml b/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_ingress_policy_generated_meta.yaml index 93b35a4779d..e87020f0e80 100644 --- a/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_ingress_policy_generated_meta.yaml +++ b/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_ingress_policy_generated_meta.yaml @@ -33,3 +33,5 @@ fields: provider_only: true - api_field: status.ingressPolicies.title field: title + - field: deletion_policy + provider_only: true diff --git a/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_resource.go b/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_resource.go index 22a0c651108..66f88b3ee3b 100644 --- a/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_resource.go +++ b/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_resource.go @@ -100,6 +100,7 @@ func ResourceAccessContextManagerServicePerimeterResource() *schema.Resource { return &schema.Resource{ Create: resourceAccessContextManagerServicePerimeterResourceCreate, Read: resourceAccessContextManagerServicePerimeterResourceRead, + Update: resourceAccessContextManagerServicePerimeterResourceUpdate, Delete: resourceAccessContextManagerServicePerimeterResourceDelete, Importer: &schema.ResourceImporter{ @@ -156,6 +157,19 @@ Format: projects/{project_number}`, Computed: true, Description: `The perimeter etag is internally used to prevent overwriting the list of perimeter resources on PATCH calls. It is retrieved from the same GET perimeter API call that's used to get the current list of resources. The resource to add or remove is merged into that list and then this etag is sent with the PATCH call along with the updated resource list.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -327,6 +341,20 @@ func resourceAccessContextManagerServicePerimeterResourceRead(d *schema.Resource return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceAccessContextManagerServicePerimeterResourceFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -353,7 +381,19 @@ func resourceAccessContextManagerServicePerimeterResourceRead(d *schema.Resource return nil } +func resourceAccessContextManagerServicePerimeterResourceUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceAccessContextManagerServicePerimeterResourceRead(d, meta) +} + func resourceAccessContextManagerServicePerimeterResourceDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy AccessContextManagerServicePerimeterResource without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ServicePerimeterResource %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_resource_generated_meta.yaml b/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_resource_generated_meta.yaml index 35fd6354bc6..99aa7b392be 100644 --- a/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_resource_generated_meta.yaml +++ b/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_resource_generated_meta.yaml @@ -15,3 +15,5 @@ fields: provider_only: true - api_field: status.resources.resource field: resource + - field: deletion_policy + provider_only: true diff --git a/google/services/accesscontextmanager/resource_access_context_manager_service_perimeters.go b/google/services/accesscontextmanager/resource_access_context_manager_service_perimeters.go index aa77e2803f2..1f077fda722 100644 --- a/google/services/accesscontextmanager/resource_access_context_manager_service_perimeters.go +++ b/google/services/accesscontextmanager/resource_access_context_manager_service_perimeters.go @@ -871,6 +871,19 @@ bet set to True if any of the fields in the spec are set to non-default values.` }, }, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -1152,6 +1165,20 @@ func resourceAccessContextManagerServicePerimetersRead(d *schema.ResourceData, m log.Printf("[DEBUG] Finished reading AccessContextManagerServicePerimeters %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceAccessContextManagerServicePerimetersFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -1173,6 +1200,19 @@ func resourceAccessContextManagerServicePerimetersRead(d *schema.ResourceData, m } func resourceAccessContextManagerServicePerimetersUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceAccessContextManagerServicePerimeters().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceAccessContextManagerServicePerimetersRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1254,6 +1294,13 @@ func resourceAccessContextManagerServicePerimetersUpdate(d *schema.ResourceData, } func resourceAccessContextManagerServicePerimetersDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy AccessContextManagerServicePerimeters without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ServicePerimeters %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/accesscontextmanager/resource_access_context_manager_service_perimeters_generated_meta.yaml b/google/services/accesscontextmanager/resource_access_context_manager_service_perimeters_generated_meta.yaml index 7ee1a2ee46b..1bc03f6c03e 100644 --- a/google/services/accesscontextmanager/resource_access_context_manager_service_perimeters_generated_meta.yaml +++ b/google/services/accesscontextmanager/resource_access_context_manager_service_perimeters_generated_meta.yaml @@ -69,3 +69,5 @@ fields: - api_field: servicePerimeters.title - api_field: servicePerimeters.updateTime - api_field: servicePerimeters.useExplicitDryRunSpec + - field: deletion_policy + provider_only: true diff --git a/google/services/activedirectory/resource_active_directory_domain.go b/google/services/activedirectory/resource_active_directory_domain.go index d80a7a62424..367a458c93d 100644 --- a/google/services/activedirectory/resource_active_directory_domain.go +++ b/google/services/activedirectory/resource_active_directory_domain.go @@ -116,6 +116,7 @@ func ResourceActiveDirectoryDomain() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -230,6 +231,18 @@ When the field is set to false, deleting the domain is allowed.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -408,6 +421,18 @@ func resourceActiveDirectoryDomainRead(d *schema.ResourceData, meta interface{}) return fmt.Errorf("Error setting deletion_protection: %s", err) } } + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Domain: %s", err) } @@ -439,6 +464,19 @@ func resourceActiveDirectoryDomainRead(d *schema.ResourceData, meta interface{}) } func resourceActiveDirectoryDomainUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceActiveDirectoryDomain().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceActiveDirectoryDomainRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -553,6 +591,13 @@ func resourceActiveDirectoryDomainUpdate(d *schema.ResourceData, meta interface{ } func resourceActiveDirectoryDomainDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ActiveDirectoryDomain without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Domain %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/activedirectory/resource_active_directory_domain_generated_meta.yaml b/google/services/activedirectory/resource_active_directory_domain_generated_meta.yaml index dff561f8c23..8221fa8fbc9 100644 --- a/google/services/activedirectory/resource_active_directory_domain_generated_meta.yaml +++ b/google/services/activedirectory/resource_active_directory_domain_generated_meta.yaml @@ -22,3 +22,5 @@ fields: - api_field: reservedIpRange - field: terraform_labels provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/activedirectory/resource_active_directory_domain_trust.go b/google/services/activedirectory/resource_active_directory_domain_trust.go index 7d4595f4a65..5dd2bde54f7 100644 --- a/google/services/activedirectory/resource_active_directory_domain_trust.go +++ b/google/services/activedirectory/resource_active_directory_domain_trust.go @@ -115,6 +115,7 @@ func ResourceActiveDirectoryDomainTrust() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -195,6 +196,18 @@ of https://cloud.google.com/managed-microsoft-ad/reference/rest/v1/projects.loca Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -391,6 +404,19 @@ func resourceActiveDirectoryDomainTrustRead(d *schema.ResourceData, meta interfa return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading DomainTrust: %s", err) } @@ -428,6 +454,19 @@ func resourceActiveDirectoryDomainTrustRead(d *schema.ResourceData, meta interfa } func resourceActiveDirectoryDomainTrustUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceActiveDirectoryDomainTrust().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceActiveDirectoryDomainTrustRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -547,6 +586,13 @@ func resourceActiveDirectoryDomainTrustUpdate(d *schema.ResourceData, meta inter } func resourceActiveDirectoryDomainTrustDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ActiveDirectoryDomainTrust without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing DomainTrust %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/activedirectory/resource_active_directory_domain_trust_generated_meta.yaml b/google/services/activedirectory/resource_active_directory_domain_trust_generated_meta.yaml index cd0c85b9580..2455dc943fb 100644 --- a/google/services/activedirectory/resource_active_directory_domain_trust_generated_meta.yaml +++ b/google/services/activedirectory/resource_active_directory_domain_trust_generated_meta.yaml @@ -21,3 +21,5 @@ fields: field: trust_handshake_secret - api_field: trusts.trustType field: trust_type + - field: deletion_policy + provider_only: true diff --git a/google/services/alloydb/resource_alloydb_backup.go b/google/services/alloydb/resource_alloydb_backup.go index 7d43db33676..71dfab7636e 100644 --- a/google/services/alloydb/resource_alloydb_backup.go +++ b/google/services/alloydb/resource_alloydb_backup.go @@ -117,6 +117,7 @@ func ResourceAlloydbBackup() *schema.Resource { tpgresource.SetLabelsDiff, tpgresource.SetAnnotationsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -343,6 +344,18 @@ Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -521,6 +534,19 @@ func resourceAlloydbBackupRead(d *schema.ResourceData, meta interface{}) error { log.Printf("[DEBUG] Finished reading AlloydbBackup %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Backup: %s", err) } @@ -558,6 +584,19 @@ func resourceAlloydbBackupRead(d *schema.ResourceData, meta interface{}) error { } func resourceAlloydbBackupUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceAlloydbBackup().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceAlloydbBackupRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -711,6 +750,13 @@ func resourceAlloydbBackupUpdate(d *schema.ResourceData, meta interface{}) error } func resourceAlloydbBackupDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy AlloydbBackup without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Backup %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/alloydb/resource_alloydb_backup_generated_meta.yaml b/google/services/alloydb/resource_alloydb_backup_generated_meta.yaml index 830817bc9f3..432b2a7c3ac 100644 --- a/google/services/alloydb/resource_alloydb_backup_generated_meta.yaml +++ b/google/services/alloydb/resource_alloydb_backup_generated_meta.yaml @@ -39,3 +39,5 @@ fields: - api_field: type - api_field: uid - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/alloydb/resource_alloydb_cluster.go b/google/services/alloydb/resource_alloydb_cluster.go index f35410b49ac..5cd33f9a36f 100644 --- a/google/services/alloydb/resource_alloydb_cluster.go +++ b/google/services/alloydb/resource_alloydb_cluster.go @@ -117,6 +117,7 @@ func ResourceAlloydbCluster() *schema.Resource { tpgresource.SetLabelsDiff, tpgresource.SetAnnotationsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DEFAULT"), ), Identity: &schema.ResourceIdentity{ @@ -850,15 +851,6 @@ This can happen due to user-triggered updates or system actions like failover or Computed: true, Description: `The system-generated UID of the resource.`, }, - "deletion_policy": { - Type: schema.TypeString, - Optional: true, - Description: `Policy to determine if the cluster should be deleted forcefully. -Deleting a cluster forcefully, deletes the cluster and all its associated instances within the cluster. -Deleting a Secondary cluster with a secondary instance REQUIRES setting deletion_policy = "FORCE" otherwise an error is returned. This is needed as there is no support to delete just the secondary instance, and the only way to delete secondary instance is to delete the associated secondary cluster forcefully which also deletes the secondary instance. -Possible values: DEFAULT, FORCE`, - Default: "DEFAULT", - }, "deletion_protection": { Type: schema.TypeBool, Optional: true, @@ -882,6 +874,12 @@ Default value: "true"`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `This field uses a custom implementation please refer to documentation under /hashicorp/terraform-provider-google-beta/website/docs/r/alloydb_cluster.html.markdown for specifics`, + }, }, UseJSONNumber: true, } @@ -1221,11 +1219,6 @@ func resourceAlloydbClusterRead(d *schema.ResourceData, meta interface{}) error log.Printf("[DEBUG] Finished reading AlloydbCluster %q: %#v", d.Id(), res) // Explicitly set virtual fields to default values if unset - if _, ok := d.GetOkExists("deletion_policy"); !ok { - if err := d.Set("deletion_policy", "DEFAULT"); err != nil { - return fmt.Errorf("Error setting deletion_policy: %s", err) - } - } 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) @@ -1236,6 +1229,18 @@ func resourceAlloydbClusterRead(d *schema.ResourceData, meta interface{}) error return fmt.Errorf("Error setting skip_await_major_version_upgrade: %s", err) } } + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DEFAULT"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Cluster: %s", err) } @@ -1273,6 +1278,19 @@ func resourceAlloydbClusterRead(d *schema.ResourceData, meta interface{}) error } func resourceAlloydbClusterUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceAlloydbCluster().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceAlloydbClusterRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1650,6 +1668,13 @@ func resourceAlloydbClusterUpdate(d *schema.ResourceData, meta interface{}) erro } func resourceAlloydbClusterDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy AlloydbCluster without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Cluster %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1738,9 +1763,6 @@ func resourceAlloydbClusterImport(d *schema.ResourceData, meta interface{}) ([]* d.SetId(id) // Explicitly set virtual fields to default values on import - if err := d.Set("deletion_policy", "DEFAULT"); err != nil { - return nil, fmt.Errorf("Error setting deletion_policy: %s", err) - } if err := d.Set("deletion_protection", true); err != nil { return nil, fmt.Errorf("Error setting deletion_protection: %s", err) } diff --git a/google/services/alloydb/resource_alloydb_cluster_generated_meta.yaml b/google/services/alloydb/resource_alloydb_cluster_generated_meta.yaml index e9415919aa1..02fdabe64ac 100644 --- a/google/services/alloydb/resource_alloydb_cluster_generated_meta.yaml +++ b/google/services/alloydb/resource_alloydb_cluster_generated_meta.yaml @@ -35,8 +35,6 @@ fields: - api_field: continuousBackupInfo.schedule - api_field: databaseVersion - api_field: dataplexConfig.enabled - - field: deletion_policy - provider_only: true - field: deletion_protection provider_only: true - api_field: displayName @@ -89,3 +87,5 @@ fields: - api_field: trialMetadata.startTime - api_field: trialMetadata.upgradeTime - api_field: uid + - field: deletion_policy + provider_only: true diff --git a/google/services/alloydb/resource_alloydb_instance.go b/google/services/alloydb/resource_alloydb_instance.go index 4e86a4d5fdb..cc0cf10a802 100644 --- a/google/services/alloydb/resource_alloydb_instance.go +++ b/google/services/alloydb/resource_alloydb_instance.go @@ -116,6 +116,7 @@ func ResourceAlloydbInstance() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.SetAnnotationsDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -556,6 +557,19 @@ endpoint for an end-user application.`, Computed: true, Description: `Time the Instance was updated in UTC.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -750,6 +764,20 @@ func resourceAlloydbInstanceRead(d *schema.ResourceData, meta interface{}) error log.Printf("[DEBUG] Finished reading AlloydbInstance %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceAlloydbInstanceFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -759,6 +787,18 @@ func resourceAlloydbInstanceRead(d *schema.ResourceData, meta interface{}) error } func resourceAlloydbInstanceUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceAlloydbInstance().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceAlloydbInstanceRead(d, meta) + } var project string config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) @@ -962,6 +1002,13 @@ func resourceAlloydbInstanceUpdate(d *schema.ResourceData, meta interface{}) err } func resourceAlloydbInstanceDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy AlloydbInstance without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Instance %q from Terraform state without deletion", d.Id()) + return nil + } var project string config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) diff --git a/google/services/alloydb/resource_alloydb_instance_generated_meta.yaml b/google/services/alloydb/resource_alloydb_instance_generated_meta.yaml index 665740c1ecb..0a9a01ffbfb 100644 --- a/google/services/alloydb/resource_alloydb_instance_generated_meta.yaml +++ b/google/services/alloydb/resource_alloydb_instance_generated_meta.yaml @@ -59,3 +59,5 @@ fields: provider_only: true - api_field: uid - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/alloydb/resource_alloydb_user.go b/google/services/alloydb/resource_alloydb_user.go index b2580817d1e..a5f1bcd6e62 100644 --- a/google/services/alloydb/resource_alloydb_user.go +++ b/google/services/alloydb/resource_alloydb_user.go @@ -169,6 +169,19 @@ func ResourceAlloydbUser() *schema.Resource { Computed: true, Description: `Name of the resource in the form of projects/{project}/locations/{location}/clusters/{cluster}/users/{user}.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -281,6 +294,20 @@ func resourceAlloydbUserRead(d *schema.ResourceData, meta interface{}) error { log.Printf("[DEBUG] Finished reading AlloydbUser %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceAlloydbUserFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -290,6 +317,19 @@ func resourceAlloydbUserRead(d *schema.ResourceData, meta interface{}) error { } func resourceAlloydbUserUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceAlloydbUser().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceAlloydbUserRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -392,6 +432,13 @@ func resourceAlloydbUserUpdate(d *schema.ResourceData, meta interface{}) error { } func resourceAlloydbUserDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy AlloydbUser without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing User %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/alloydb/resource_alloydb_user_generated_meta.yaml b/google/services/alloydb/resource_alloydb_user_generated_meta.yaml index d3ab3e5d293..ca33459c469 100644 --- a/google/services/alloydb/resource_alloydb_user_generated_meta.yaml +++ b/google/services/alloydb/resource_alloydb_user_generated_meta.yaml @@ -19,3 +19,5 @@ fields: - field: user_id provider_only: true - api_field: userType + - field: deletion_policy + provider_only: true diff --git a/google/services/apigee/resource_apigee_addons_config.go b/google/services/apigee/resource_apigee_addons_config.go index fa72fddd5d0..c096dfb8589 100644 --- a/google/services/apigee/resource_apigee_addons_config.go +++ b/google/services/apigee/resource_apigee_addons_config.go @@ -230,6 +230,19 @@ func ResourceApigeeAddonsConfig() *schema.Resource { }, }, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -345,6 +358,20 @@ func resourceApigeeAddonsConfigRead(d *schema.ResourceData, meta interface{}) er log.Printf("[DEBUG] Finished reading ApigeeAddonsConfig %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceApigeeAddonsConfigFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -366,6 +393,19 @@ func resourceApigeeAddonsConfigRead(d *schema.ResourceData, meta interface{}) er } func resourceApigeeAddonsConfigUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceApigeeAddonsConfig().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceApigeeAddonsConfigRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -434,6 +474,13 @@ func resourceApigeeAddonsConfigUpdate(d *schema.ResourceData, meta interface{}) } func resourceApigeeAddonsConfigDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ApigeeAddonsConfig without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing AddonsConfig %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/apigee/resource_apigee_addons_config_generated_meta.yaml b/google/services/apigee/resource_apigee_addons_config_generated_meta.yaml index eab36f647a5..3f82e81a958 100644 --- a/google/services/apigee/resource_apigee_addons_config_generated_meta.yaml +++ b/google/services/apigee/resource_apigee_addons_config_generated_meta.yaml @@ -16,3 +16,5 @@ fields: - api_field: addonsConfig.monetizationConfig.enabled - field: org provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/apigee/resource_apigee_api.go b/google/services/apigee/resource_apigee_api.go index f5a54bc08cc..e2f493c1da1 100644 --- a/google/services/apigee/resource_apigee_api.go +++ b/google/services/apigee/resource_apigee_api.go @@ -50,6 +50,7 @@ func ResourceApigeeApi() *schema.Resource { }, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), /* If any of the config_bundle, detect_md5hash or md5hash is changed, then an update is expected, so we tell Terraform core to expect update on meta_data, @@ -149,6 +150,9 @@ func ResourceApigeeApi() *schema.Resource { return true }, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, UseJSONNumber: true, } @@ -222,6 +226,11 @@ func resourceApigeeApiCreate(d *schema.ResourceData, meta interface{}) error { } func resourceApigeeApiUpdate(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceApigeeApi) { + return ResourceApigeeApi().Read(d, meta) + } + //For how API proxy api is implemented, just treat an update as create, when the name is same, it will create a new revision return resourceApigeeApiCreate(d, meta) } @@ -278,6 +287,11 @@ func resourceApigeeApiRead(d *schema.ResourceData, meta interface{}) error { d.Set("md5hash", "UNKNOWN") d.Set("detect_md5hash", "UNKNOWN") } + + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } @@ -300,6 +314,13 @@ func getApigeeApiLastModifiedAt(d *schema.ResourceData) string { } func resourceApigeeApiDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/apigee/resource_apigee_api_deployment.go b/google/services/apigee/resource_apigee_api_deployment.go index 365e50e5e4c..9fc7aca3e0b 100644 --- a/google/services/apigee/resource_apigee_api_deployment.go +++ b/google/services/apigee/resource_apigee_api_deployment.go @@ -100,6 +100,7 @@ func ResourceApigeeApiDeployment() *schema.Resource { return &schema.Resource{ Create: resourceApigeeApiDeploymentCreate, Read: resourceApigeeApiDeploymentRead, + Update: resourceApigeeApiDeploymentUpdate, Delete: resourceApigeeApiDeploymentDelete, Importer: &schema.ResourceImporter{ @@ -168,6 +169,19 @@ func ResourceApigeeApiDeployment() *schema.Resource { Computed: true, Description: `The ID of the API deployment in the format 'organizations/{{org_id}}/environments/{{environment}}/apis/{{proxy_id}}/revisions/{{revision}}/deployments'.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -282,6 +296,20 @@ func resourceApigeeApiDeploymentRead(d *schema.ResourceData, meta interface{}) e log.Printf("[DEBUG] Finished reading ApigeeApiDeployment %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceApigeeApiDeploymentFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -320,7 +348,19 @@ func resourceApigeeApiDeploymentRead(d *schema.ResourceData, meta interface{}) e return nil } +func resourceApigeeApiDeploymentUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceApigeeApiDeploymentRead(d, meta) +} + func resourceApigeeApiDeploymentDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ApigeeApiDeployment without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ApiDeployment %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/apigee/resource_apigee_api_deployment_generated_meta.yaml b/google/services/apigee/resource_apigee_api_deployment_generated_meta.yaml index fd954a83c64..ce1c25a7bd7 100644 --- a/google/services/apigee/resource_apigee_api_deployment_generated_meta.yaml +++ b/google/services/apigee/resource_apigee_api_deployment_generated_meta.yaml @@ -16,3 +16,5 @@ fields: provider_only: true - field: revision provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/apigee/resource_apigee_api_meta.yaml b/google/services/apigee/resource_apigee_api_meta.yaml index 41c17a12abb..a3c434303e9 100644 --- a/google/services/apigee/resource_apigee_api_meta.yaml +++ b/google/services/apigee/resource_apigee_api_meta.yaml @@ -16,3 +16,5 @@ fields: - api_field: 'name' - field: 'org_id' - api_field: 'revision' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/apigee/resource_apigee_api_product.go b/google/services/apigee/resource_apigee_api_product.go index 741aac537c5..a88000876d0 100644 --- a/google/services/apigee/resource_apigee_api_product.go +++ b/google/services/apigee/resource_apigee_api_product.go @@ -312,6 +312,19 @@ For example, a quota of 50, for a quotaInterval of 12 and a quotaTimeUnit of hou Computed: true, Description: `Response only. Modified time of this environment as milliseconds since epoch.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -791,6 +804,20 @@ func resourceApigeeApiProductRead(d *schema.ResourceData, meta interface{}) erro log.Printf("[DEBUG] Finished reading ApigeeApiProduct %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceApigeeApiProductFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -818,6 +845,19 @@ func resourceApigeeApiProductRead(d *schema.ResourceData, meta interface{}) erro } func resourceApigeeApiProductUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceApigeeApiProduct().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceApigeeApiProductRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -979,6 +1019,13 @@ func resourceApigeeApiProductUpdate(d *schema.ResourceData, meta interface{}) er } func resourceApigeeApiProductDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ApigeeApiProduct without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ApiProduct %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/apigee/resource_apigee_api_product_generated_meta.yaml b/google/services/apigee/resource_apigee_api_product_generated_meta.yaml index c24723d5e50..547fed03bad 100644 --- a/google/services/apigee/resource_apigee_api_product_generated_meta.yaml +++ b/google/services/apigee/resource_apigee_api_product_generated_meta.yaml @@ -52,3 +52,5 @@ fields: - api_field: quotaTimeUnit - api_field: scopes - api_field: space + - field: deletion_policy + provider_only: true diff --git a/google/services/apigee/resource_apigee_app_group.go b/google/services/apigee/resource_apigee_app_group.go index d160f5c6591..7fa7926284b 100644 --- a/google/services/apigee/resource_apigee_app_group.go +++ b/google/services/apigee/resource_apigee_app_group.go @@ -206,6 +206,19 @@ in the format 'organizations/{{org_name}}'.`, Computed: true, Description: `App group name displayed in the UI`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -346,6 +359,20 @@ func resourceApigeeAppGroupRead(d *schema.ResourceData, meta interface{}) error log.Printf("[DEBUG] Finished reading ApigeeAppGroup %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceApigeeAppGroupFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -373,6 +400,19 @@ func resourceApigeeAppGroupRead(d *schema.ResourceData, meta interface{}) error } func resourceApigeeAppGroupUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceApigeeAppGroup().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceApigeeAppGroupRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -468,6 +508,13 @@ func resourceApigeeAppGroupUpdate(d *schema.ResourceData, meta interface{}) erro } func resourceApigeeAppGroupDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ApigeeAppGroup without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing AppGroup %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/apigee/resource_apigee_app_group_generated_meta.yaml b/google/services/apigee/resource_apigee_app_group_generated_meta.yaml index ad60951bccc..141a56ed8fd 100644 --- a/google/services/apigee/resource_apigee_app_group_generated_meta.yaml +++ b/google/services/apigee/resource_apigee_app_group_generated_meta.yaml @@ -20,3 +20,5 @@ fields: provider_only: true - api_field: organization - api_field: status + - field: deletion_policy + provider_only: true diff --git a/google/services/apigee/resource_apigee_control_plane_access.go b/google/services/apigee/resource_apigee_control_plane_access.go index c1d7cf7a45f..ae2286f2f57 100644 --- a/google/services/apigee/resource_apigee_control_plane_access.go +++ b/google/services/apigee/resource_apigee_control_plane_access.go @@ -303,6 +303,7 @@ func resourceApigeeControlPlaneAccessRead(d *schema.ResourceData, meta interface } func resourceApigeeControlPlaneAccessUpdate(d *schema.ResourceData, meta interface{}) error { + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/apigee/resource_apigee_developer.go b/google/services/apigee/resource_apigee_developer.go index 8c585c6de01..cb51901f589 100644 --- a/google/services/apigee/resource_apigee_developer.go +++ b/google/services/apigee/resource_apigee_developer.go @@ -200,6 +200,19 @@ in the format 'organizations/{{org_name}}'.`, Computed: true, Description: `Status of the developer. Valid values are active and inactive.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -334,6 +347,20 @@ func resourceApigeeDeveloperRead(d *schema.ResourceData, meta interface{}) error log.Printf("[DEBUG] Finished reading ApigeeDeveloper %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceApigeeDeveloperFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -361,6 +388,19 @@ func resourceApigeeDeveloperRead(d *schema.ResourceData, meta interface{}) error } func resourceApigeeDeveloperUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceApigeeDeveloper().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceApigeeDeveloperRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -450,6 +490,13 @@ func resourceApigeeDeveloperUpdate(d *schema.ResourceData, meta interface{}) err } func resourceApigeeDeveloperDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ApigeeDeveloper without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Developer %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/apigee/resource_apigee_developer_app.go b/google/services/apigee/resource_apigee_developer_app.go index aba5c9a1389..b1861a842d5 100644 --- a/google/services/apigee/resource_apigee_developer_app.go +++ b/google/services/apigee/resource_apigee_developer_app.go @@ -330,6 +330,19 @@ you associate with the app.`, Computed: true, Description: `Time at which the developer was last modified in milliseconds since epoch.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -499,6 +512,20 @@ func resourceApigeeDeveloperAppRead(d *schema.ResourceData, meta interface{}) er return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceApigeeDeveloperAppFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -532,6 +559,19 @@ func resourceApigeeDeveloperAppRead(d *schema.ResourceData, meta interface{}) er } func resourceApigeeDeveloperAppUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceApigeeDeveloperApp().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceApigeeDeveloperAppRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -644,6 +684,13 @@ func resourceApigeeDeveloperAppUpdate(d *schema.ResourceData, meta interface{}) } func resourceApigeeDeveloperAppDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ApigeeDeveloperApp without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing DeveloperApp %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/apigee/resource_apigee_developer_app_generated_meta.yaml b/google/services/apigee/resource_apigee_developer_app_generated_meta.yaml index 89310ab3226..ef06dedfec3 100644 --- a/google/services/apigee/resource_apigee_developer_app_generated_meta.yaml +++ b/google/services/apigee/resource_apigee_developer_app_generated_meta.yaml @@ -34,3 +34,5 @@ fields: provider_only: true - api_field: scopes - api_field: status + - field: deletion_policy + provider_only: true diff --git a/google/services/apigee/resource_apigee_developer_generated_meta.yaml b/google/services/apigee/resource_apigee_developer_generated_meta.yaml index ab644cff8a8..bfaa16feb68 100644 --- a/google/services/apigee/resource_apigee_developer_generated_meta.yaml +++ b/google/services/apigee/resource_apigee_developer_generated_meta.yaml @@ -19,3 +19,5 @@ fields: - api_field: organizatioName - api_field: status - api_field: userName + - field: deletion_policy + provider_only: true diff --git a/google/services/apigee/resource_apigee_dns_zone.go b/google/services/apigee/resource_apigee_dns_zone.go index 190d6eaf4d0..c23b1150d9d 100644 --- a/google/services/apigee/resource_apigee_dns_zone.go +++ b/google/services/apigee/resource_apigee_dns_zone.go @@ -100,6 +100,7 @@ func ResourceApigeeDnsZone() *schema.Resource { return &schema.Resource{ Create: resourceApigeeDnsZoneCreate, Read: resourceApigeeDnsZoneRead, + Update: resourceApigeeDnsZoneUpdate, Delete: resourceApigeeDnsZoneDelete, Importer: &schema.ResourceImporter{ @@ -166,6 +167,19 @@ in the format 'organizations/{{org_name}}'.`, Description: `Name of the Dns Zone in the following format: organizations/{organization}/dnsZones/{dnsZone}.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -282,6 +296,20 @@ func resourceApigeeDnsZoneRead(d *schema.ResourceData, meta interface{}) error { log.Printf("[DEBUG] Finished reading ApigeeDnsZone %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceApigeeDnsZoneFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -290,7 +318,19 @@ func resourceApigeeDnsZoneRead(d *schema.ResourceData, meta interface{}) error { return nil } +func resourceApigeeDnsZoneUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceApigeeDnsZoneRead(d, meta) +} + func resourceApigeeDnsZoneDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ApigeeDnsZone without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing DnsZone %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/apigee/resource_apigee_dns_zone_generated_meta.yaml b/google/services/apigee/resource_apigee_dns_zone_generated_meta.yaml index 761721604a1..fb402351d62 100644 --- a/google/services/apigee/resource_apigee_dns_zone_generated_meta.yaml +++ b/google/services/apigee/resource_apigee_dns_zone_generated_meta.yaml @@ -16,3 +16,5 @@ fields: provider_only: true - api_field: peeringConfig.targetNetworkId - api_field: peeringConfig.targetProjectId + - field: deletion_policy + provider_only: true diff --git a/google/services/apigee/resource_apigee_endpoint_attachment.go b/google/services/apigee/resource_apigee_endpoint_attachment.go index 0dffc0c870f..a8eb6de1ab6 100644 --- a/google/services/apigee/resource_apigee_endpoint_attachment.go +++ b/google/services/apigee/resource_apigee_endpoint_attachment.go @@ -100,6 +100,7 @@ func ResourceApigeeEndpointAttachment() *schema.Resource { return &schema.Resource{ Create: resourceApigeeEndpointAttachmentCreate, Read: resourceApigeeEndpointAttachmentRead, + Update: resourceApigeeEndpointAttachmentUpdate, Delete: resourceApigeeEndpointAttachmentDelete, Importer: &schema.ResourceImporter{ @@ -172,6 +173,19 @@ in the format 'organizations/{{org_name}}'.`, Description: `Name of the Endpoint Attachment in the following format: organizations/{organization}/endpointAttachments/{endpointAttachment}.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -298,6 +312,20 @@ func resourceApigeeEndpointAttachmentRead(d *schema.ResourceData, meta interface log.Printf("[DEBUG] Finished reading ApigeeEndpointAttachment %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceApigeeEndpointAttachmentFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -324,7 +352,19 @@ func resourceApigeeEndpointAttachmentRead(d *schema.ResourceData, meta interface return nil } +func resourceApigeeEndpointAttachmentUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceApigeeEndpointAttachmentRead(d, meta) +} + func resourceApigeeEndpointAttachmentDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ApigeeEndpointAttachment without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing EndpointAttachment %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/apigee/resource_apigee_endpoint_attachment_generated_meta.yaml b/google/services/apigee/resource_apigee_endpoint_attachment_generated_meta.yaml index a7f1fa225c4..e6690ebdc35 100644 --- a/google/services/apigee/resource_apigee_endpoint_attachment_generated_meta.yaml +++ b/google/services/apigee/resource_apigee_endpoint_attachment_generated_meta.yaml @@ -16,3 +16,5 @@ fields: - field: org_id provider_only: true - api_field: serviceAttachment + - field: deletion_policy + provider_only: true diff --git a/google/services/apigee/resource_apigee_env_keystore.go b/google/services/apigee/resource_apigee_env_keystore.go index d2396852316..41c7804fc86 100644 --- a/google/services/apigee/resource_apigee_env_keystore.go +++ b/google/services/apigee/resource_apigee_env_keystore.go @@ -100,6 +100,7 @@ func ResourceApigeeEnvKeystore() *schema.Resource { return &schema.Resource{ Create: resourceApigeeEnvKeystoreCreate, Read: resourceApigeeEnvKeystoreRead, + Update: resourceApigeeEnvKeystoreUpdate, Delete: resourceApigeeEnvKeystoreDelete, Importer: &schema.ResourceImporter{ @@ -152,6 +153,19 @@ in the format 'organizations/{{org_name}}/environments/{{env_name}}'.`, Type: schema.TypeString, }, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -262,6 +276,20 @@ func resourceApigeeEnvKeystoreRead(d *schema.ResourceData, meta interface{}) err log.Printf("[DEBUG] Finished reading ApigeeEnvKeystore %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceApigeeEnvKeystoreFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -288,7 +316,19 @@ func resourceApigeeEnvKeystoreRead(d *schema.ResourceData, meta interface{}) err return nil } +func resourceApigeeEnvKeystoreUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceApigeeEnvKeystoreRead(d, meta) +} + func resourceApigeeEnvKeystoreDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ApigeeEnvKeystore without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing EnvKeystore %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/apigee/resource_apigee_env_keystore_generated_meta.yaml b/google/services/apigee/resource_apigee_env_keystore_generated_meta.yaml index ed961141c57..bf323ba4ce3 100644 --- a/google/services/apigee/resource_apigee_env_keystore_generated_meta.yaml +++ b/google/services/apigee/resource_apigee_env_keystore_generated_meta.yaml @@ -11,3 +11,5 @@ fields: - field: env_id provider_only: true - api_field: name + - field: deletion_policy + provider_only: true diff --git a/google/services/apigee/resource_apigee_env_references.go b/google/services/apigee/resource_apigee_env_references.go index 15ee50679f6..df68ed75d5e 100644 --- a/google/services/apigee/resource_apigee_env_references.go +++ b/google/services/apigee/resource_apigee_env_references.go @@ -163,6 +163,19 @@ in the format 'organizations/{{org_name}}/environments/{{env_name}}'.`, ForceNew: true, Description: `Optional. A human-readable description of this reference.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -291,6 +304,20 @@ func resourceApigeeEnvReferencesRead(d *schema.ResourceData, meta interface{}) e log.Printf("[DEBUG] Finished reading ApigeeEnvReferences %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceApigeeEnvReferencesFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -318,6 +345,19 @@ func resourceApigeeEnvReferencesRead(d *schema.ResourceData, meta interface{}) e } func resourceApigeeEnvReferencesUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceApigeeEnvReferences().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceApigeeEnvReferencesRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -401,6 +441,13 @@ func resourceApigeeEnvReferencesUpdate(d *schema.ResourceData, meta interface{}) } func resourceApigeeEnvReferencesDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ApigeeEnvReferences without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing EnvReferences %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/apigee/resource_apigee_env_references_generated_meta.yaml b/google/services/apigee/resource_apigee_env_references_generated_meta.yaml index 2cb7c85ddcf..5b77eca0797 100644 --- a/google/services/apigee/resource_apigee_env_references_generated_meta.yaml +++ b/google/services/apigee/resource_apigee_env_references_generated_meta.yaml @@ -13,3 +13,5 @@ fields: - api_field: name - api_field: refers - api_field: resourceType + - field: deletion_policy + provider_only: true diff --git a/google/services/apigee/resource_apigee_envgroup.go b/google/services/apigee/resource_apigee_envgroup.go index db9df29ebce..2ed2d7bfc1c 100644 --- a/google/services/apigee/resource_apigee_envgroup.go +++ b/google/services/apigee/resource_apigee_envgroup.go @@ -154,6 +154,19 @@ in the format 'organizations/{{org_name}}'.`, Type: schema.TypeString, }, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -280,6 +293,20 @@ func resourceApigeeEnvgroupRead(d *schema.ResourceData, meta interface{}) error log.Printf("[DEBUG] Finished reading ApigeeEnvgroup %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceApigeeEnvgroupFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -307,6 +334,19 @@ func resourceApigeeEnvgroupRead(d *schema.ResourceData, meta interface{}) error } func resourceApigeeEnvgroupUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceApigeeEnvgroup().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceApigeeEnvgroupRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -394,6 +434,13 @@ func resourceApigeeEnvgroupUpdate(d *schema.ResourceData, meta interface{}) erro } func resourceApigeeEnvgroupDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ApigeeEnvgroup without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Envgroup %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/apigee/resource_apigee_envgroup_attachment.go b/google/services/apigee/resource_apigee_envgroup_attachment.go index bb38ce4db7c..aac691a82cc 100644 --- a/google/services/apigee/resource_apigee_envgroup_attachment.go +++ b/google/services/apigee/resource_apigee_envgroup_attachment.go @@ -100,6 +100,7 @@ func ResourceApigeeEnvgroupAttachment() *schema.Resource { return &schema.Resource{ Create: resourceApigeeEnvgroupAttachmentCreate, Read: resourceApigeeEnvgroupAttachmentRead, + Update: resourceApigeeEnvgroupAttachmentUpdate, Delete: resourceApigeeEnvgroupAttachmentDelete, Importer: &schema.ResourceImporter{ @@ -149,6 +150,19 @@ in the format 'organizations/{{org_name}}/envgroups/{{envgroup_name}}'.`, Computed: true, Description: `The name of the newly created attachment (output parameter).`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -283,6 +297,20 @@ func resourceApigeeEnvgroupAttachmentRead(d *schema.ResourceData, meta interface log.Printf("[DEBUG] Finished reading ApigeeEnvgroupAttachment %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceApigeeEnvgroupAttachmentFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -309,7 +337,19 @@ func resourceApigeeEnvgroupAttachmentRead(d *schema.ResourceData, meta interface return nil } +func resourceApigeeEnvgroupAttachmentUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceApigeeEnvgroupAttachmentRead(d, meta) +} + func resourceApigeeEnvgroupAttachmentDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ApigeeEnvgroupAttachment without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing EnvgroupAttachment %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/apigee/resource_apigee_envgroup_attachment_generated_meta.yaml b/google/services/apigee/resource_apigee_envgroup_attachment_generated_meta.yaml index ee0e07e7243..1c3c3109d7f 100644 --- a/google/services/apigee/resource_apigee_envgroup_attachment_generated_meta.yaml +++ b/google/services/apigee/resource_apigee_envgroup_attachment_generated_meta.yaml @@ -11,3 +11,5 @@ fields: provider_only: true - api_field: environment - api_field: name + - field: deletion_policy + provider_only: true diff --git a/google/services/apigee/resource_apigee_envgroup_generated_meta.yaml b/google/services/apigee/resource_apigee_envgroup_generated_meta.yaml index 8c686d1d0bd..871494ddccc 100644 --- a/google/services/apigee/resource_apigee_envgroup_generated_meta.yaml +++ b/google/services/apigee/resource_apigee_envgroup_generated_meta.yaml @@ -11,3 +11,5 @@ fields: - api_field: name - field: org_id provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/apigee/resource_apigee_environment.go b/google/services/apigee/resource_apigee_environment.go index c2bcdb5a049..728f19589c8 100644 --- a/google/services/apigee/resource_apigee_environment.go +++ b/google/services/apigee/resource_apigee_environment.go @@ -285,6 +285,19 @@ limited by capability and capacity. Refer to Apigee's public documentation to understand about each of these types in details. An Apigee org can support heterogeneous Environments. Possible values: ["ENVIRONMENT_TYPE_UNSPECIFIED", "BASE", "INTERMEDIATE", "COMPREHENSIVE"]`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -459,6 +472,20 @@ func resourceApigeeEnvironmentRead(d *schema.ResourceData, meta interface{}) err log.Printf("[DEBUG] Finished reading ApigeeEnvironment %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceApigeeEnvironmentFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -486,6 +513,19 @@ func resourceApigeeEnvironmentRead(d *schema.ResourceData, meta interface{}) err } func resourceApigeeEnvironmentUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceApigeeEnvironment().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceApigeeEnvironmentRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -605,6 +645,13 @@ func resourceApigeeEnvironmentUpdate(d *schema.ResourceData, meta interface{}) e } func resourceApigeeEnvironmentDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ApigeeEnvironment without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Environment %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/apigee/resource_apigee_environment_addons_config.go b/google/services/apigee/resource_apigee_environment_addons_config.go index d654c849915..91ec2584b9e 100644 --- a/google/services/apigee/resource_apigee_environment_addons_config.go +++ b/google/services/apigee/resource_apigee_environment_addons_config.go @@ -289,6 +289,7 @@ func resourceApigeeEnvironmentAddonsConfigRead(d *schema.ResourceData, meta inte } func resourceApigeeEnvironmentAddonsConfigUpdate(d *schema.ResourceData, meta interface{}) error { + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/apigee/resource_apigee_environment_api_revision_deployment.go b/google/services/apigee/resource_apigee_environment_api_revision_deployment.go index cda82b0a34c..88f7ccf5699 100644 --- a/google/services/apigee/resource_apigee_environment_api_revision_deployment.go +++ b/google/services/apigee/resource_apigee_environment_api_revision_deployment.go @@ -100,6 +100,7 @@ func ResourceApigeeEnvironmentApiRevisionDeployment() *schema.Resource { return &schema.Resource{ Create: resourceApigeeEnvironmentApiRevisionDeploymentCreate, Read: resourceApigeeEnvironmentApiRevisionDeploymentRead, + Update: resourceApigeeEnvironmentApiRevisionDeploymentUpdate, Delete: resourceApigeeEnvironmentApiRevisionDeploymentDelete, Importer: &schema.ResourceImporter{ @@ -201,6 +202,19 @@ func ResourceApigeeEnvironmentApiRevisionDeployment() *schema.Resource { Computed: true, Description: `Deployment state reported by Apigee.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -316,6 +330,20 @@ func resourceApigeeEnvironmentApiRevisionDeploymentRead(d *schema.ResourceData, log.Printf("[DEBUG] Finished reading ApigeeEnvironmentApiRevisionDeployment %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceApigeeEnvironmentApiRevisionDeploymentFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -354,7 +382,19 @@ func resourceApigeeEnvironmentApiRevisionDeploymentRead(d *schema.ResourceData, return nil } +func resourceApigeeEnvironmentApiRevisionDeploymentUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceApigeeEnvironmentApiRevisionDeploymentRead(d, meta) +} + func resourceApigeeEnvironmentApiRevisionDeploymentDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ApigeeEnvironmentApiRevisionDeployment without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing EnvironmentApiRevisionDeployment %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/apigee/resource_apigee_environment_api_revision_deployment_generated_meta.yaml b/google/services/apigee/resource_apigee_environment_api_revision_deployment_generated_meta.yaml index 0317e8e2bf9..b3b5862e30e 100644 --- a/google/services/apigee/resource_apigee_environment_api_revision_deployment_generated_meta.yaml +++ b/google/services/apigee/resource_apigee_environment_api_revision_deployment_generated_meta.yaml @@ -25,3 +25,5 @@ fields: - field: service_account provider_only: true - api_field: state + - field: deletion_policy + provider_only: true diff --git a/google/services/apigee/resource_apigee_environment_generated_meta.yaml b/google/services/apigee/resource_apigee_environment_generated_meta.yaml index 84028f415a9..fc573211af7 100644 --- a/google/services/apigee/resource_apigee_environment_generated_meta.yaml +++ b/google/services/apigee/resource_apigee_environment_generated_meta.yaml @@ -23,3 +23,5 @@ fields: - api_field: properties.property.name - api_field: properties.property.value - api_field: type + - field: deletion_policy + provider_only: true diff --git a/google/services/apigee/resource_apigee_environment_keyvaluemaps.go b/google/services/apigee/resource_apigee_environment_keyvaluemaps.go index b774cf77492..afcea943a83 100644 --- a/google/services/apigee/resource_apigee_environment_keyvaluemaps.go +++ b/google/services/apigee/resource_apigee_environment_keyvaluemaps.go @@ -100,6 +100,7 @@ func ResourceApigeeEnvironmentKeyvaluemaps() *schema.Resource { return &schema.Resource{ Create: resourceApigeeEnvironmentKeyvaluemapsCreate, Read: resourceApigeeEnvironmentKeyvaluemapsRead, + Update: resourceApigeeEnvironmentKeyvaluemapsUpdate, Delete: resourceApigeeEnvironmentKeyvaluemapsDelete, Importer: &schema.ResourceImporter{ @@ -144,6 +145,19 @@ in the format 'organizations/{{org_name}}/environments/{{env_name}}'.`, ForceNew: true, Description: `Required. ID of the key value map.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -248,6 +262,20 @@ func resourceApigeeEnvironmentKeyvaluemapsRead(d *schema.ResourceData, meta inte return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceApigeeEnvironmentKeyvaluemapsFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -274,7 +302,19 @@ func resourceApigeeEnvironmentKeyvaluemapsRead(d *schema.ResourceData, meta inte return nil } +func resourceApigeeEnvironmentKeyvaluemapsUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceApigeeEnvironmentKeyvaluemapsRead(d, meta) +} + func resourceApigeeEnvironmentKeyvaluemapsDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ApigeeEnvironmentKeyvaluemaps without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing EnvironmentKeyvaluemaps %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/apigee/resource_apigee_environment_keyvaluemaps_entries.go b/google/services/apigee/resource_apigee_environment_keyvaluemaps_entries.go index 362e9dc0f0a..9d013be7bcf 100644 --- a/google/services/apigee/resource_apigee_environment_keyvaluemaps_entries.go +++ b/google/services/apigee/resource_apigee_environment_keyvaluemaps_entries.go @@ -100,6 +100,7 @@ func ResourceApigeeEnvironmentKeyvaluemapsEntries() *schema.Resource { return &schema.Resource{ Create: resourceApigeeEnvironmentKeyvaluemapsEntriesCreate, Read: resourceApigeeEnvironmentKeyvaluemapsEntriesRead, + Update: resourceApigeeEnvironmentKeyvaluemapsEntriesUpdate, Delete: resourceApigeeEnvironmentKeyvaluemapsEntriesDelete, Importer: &schema.ResourceImporter{ @@ -150,6 +151,19 @@ in the format 'organizations/{{org_name}}/environments/{{env_name}}/keyvaluemaps ForceNew: true, Description: `Required. Data or payload that is being retrieved and associated with the unique key.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -266,6 +280,20 @@ func resourceApigeeEnvironmentKeyvaluemapsEntriesRead(d *schema.ResourceData, me log.Printf("[DEBUG] Finished reading ApigeeEnvironmentKeyvaluemapsEntries %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceApigeeEnvironmentKeyvaluemapsEntriesFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -292,7 +320,19 @@ func resourceApigeeEnvironmentKeyvaluemapsEntriesRead(d *schema.ResourceData, me return nil } +func resourceApigeeEnvironmentKeyvaluemapsEntriesUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceApigeeEnvironmentKeyvaluemapsEntriesRead(d, meta) +} + func resourceApigeeEnvironmentKeyvaluemapsEntriesDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ApigeeEnvironmentKeyvaluemapsEntries without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing EnvironmentKeyvaluemapsEntries %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/apigee/resource_apigee_environment_keyvaluemaps_entries_generated_meta.yaml b/google/services/apigee/resource_apigee_environment_keyvaluemaps_entries_generated_meta.yaml index 9d82d6b2b47..1be894eb015 100644 --- a/google/services/apigee/resource_apigee_environment_keyvaluemaps_entries_generated_meta.yaml +++ b/google/services/apigee/resource_apigee_environment_keyvaluemaps_entries_generated_meta.yaml @@ -11,3 +11,5 @@ fields: provider_only: true - api_field: name - api_field: value + - field: deletion_policy + provider_only: true diff --git a/google/services/apigee/resource_apigee_environment_keyvaluemaps_generated_meta.yaml b/google/services/apigee/resource_apigee_environment_keyvaluemaps_generated_meta.yaml index 98ee045d98e..f37bd9501f1 100644 --- a/google/services/apigee/resource_apigee_environment_keyvaluemaps_generated_meta.yaml +++ b/google/services/apigee/resource_apigee_environment_keyvaluemaps_generated_meta.yaml @@ -10,3 +10,5 @@ fields: - field: env_id provider_only: true - api_field: name + - field: deletion_policy + provider_only: true diff --git a/google/services/apigee/resource_apigee_flowhook.go b/google/services/apigee/resource_apigee_flowhook.go index 7992b78a455..8c05b684962 100644 --- a/google/services/apigee/resource_apigee_flowhook.go +++ b/google/services/apigee/resource_apigee_flowhook.go @@ -22,6 +22,7 @@ import ( "reflect" "time" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-provider-google/google/registry" "github.com/hashicorp/terraform-provider-google/google/tpgresource" @@ -32,6 +33,7 @@ func ResourceApigeeFlowhook() *schema.Resource { return &schema.Resource{ Create: resourceApigeeFlowhookCreate, Read: resourceApigeeFlowhookRead, + Update: resourceApigeeFlowhookUpdate, Delete: resourceApigeeFlowhookDelete, Importer: &schema.ResourceImporter{ @@ -43,6 +45,10 @@ func ResourceApigeeFlowhook() *schema.Resource { Delete: schema.DefaultTimeout(20 * time.Minute), }, + CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), + ), + Schema: map[string]*schema.Schema{ "description": { Type: schema.TypeString, @@ -81,6 +87,9 @@ func ResourceApigeeFlowhook() *schema.Resource { Default: true, Description: `Flag that specifies whether execution should continue if the flow hook throws an exception. Set to true to continue execution. Set to false to stop execution if the flow hook throws an exception. Defaults to true.`, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, UseJSONNumber: true, } @@ -195,10 +204,29 @@ func resourceApigeeFlowhookRead(d *schema.ResourceData, meta interface{}) error return fmt.Errorf("Error reading Flowhook: %s", err) } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } +// UDP update start +func resourceApigeeFlowhookUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceApigeeFlowhookRead(d, meta) +} + +//UDP update end + func resourceApigeeFlowhookDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/apigee/resource_apigee_flowhook_meta.yaml b/google/services/apigee/resource_apigee_flowhook_meta.yaml index 56a4cb9b9de..b72de311f3a 100644 --- a/google/services/apigee/resource_apigee_flowhook_meta.yaml +++ b/google/services/apigee/resource_apigee_flowhook_meta.yaml @@ -12,3 +12,5 @@ fields: - api_field: 'flowHookPoint' - field: 'org_id' - field: 'sharedflow' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/apigee/resource_apigee_instance.go b/google/services/apigee/resource_apigee_instance.go index df25f86cda6..61ec90a0f0f 100644 --- a/google/services/apigee/resource_apigee_instance.go +++ b/google/services/apigee/resource_apigee_instance.go @@ -273,6 +273,19 @@ see [CidrRange](https://cloud.google.com/apigee/docs/reference/apis/apigee/rest/ the format: projects/*/regions/*/serviceAttachments/* Apigee customers can privately forward traffic to this service attachment using the PSC endpoints.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -450,6 +463,20 @@ func resourceApigeeInstanceRead(d *schema.ResourceData, meta interface{}) error log.Printf("[DEBUG] Finished reading ApigeeInstance %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceApigeeInstanceFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -477,6 +504,19 @@ func resourceApigeeInstanceRead(d *schema.ResourceData, meta interface{}) error } func resourceApigeeInstanceUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceApigeeInstance().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceApigeeInstanceRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -572,6 +612,13 @@ func resourceApigeeInstanceUpdate(d *schema.ResourceData, meta interface{}) erro } func resourceApigeeInstanceDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ApigeeInstance without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Instance %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/apigee/resource_apigee_instance_attachment.go b/google/services/apigee/resource_apigee_instance_attachment.go index c095d72c1be..581fe7aefcf 100644 --- a/google/services/apigee/resource_apigee_instance_attachment.go +++ b/google/services/apigee/resource_apigee_instance_attachment.go @@ -100,6 +100,7 @@ func ResourceApigeeInstanceAttachment() *schema.Resource { return &schema.Resource{ Create: resourceApigeeInstanceAttachmentCreate, Read: resourceApigeeInstanceAttachmentRead, + Update: resourceApigeeInstanceAttachmentUpdate, Delete: resourceApigeeInstanceAttachmentDelete, Importer: &schema.ResourceImporter{ @@ -149,6 +150,19 @@ in the format 'organizations/{{org_name}}/instances/{{instance_name}}'.`, Computed: true, Description: `The name of the newly created attachment (output parameter).`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -290,6 +304,20 @@ func resourceApigeeInstanceAttachmentRead(d *schema.ResourceData, meta interface log.Printf("[DEBUG] Finished reading ApigeeInstanceAttachment %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceApigeeInstanceAttachmentFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -316,7 +344,19 @@ func resourceApigeeInstanceAttachmentRead(d *schema.ResourceData, meta interface return nil } +func resourceApigeeInstanceAttachmentUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceApigeeInstanceAttachmentRead(d, meta) +} + func resourceApigeeInstanceAttachmentDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ApigeeInstanceAttachment without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing InstanceAttachment %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/apigee/resource_apigee_instance_attachment_generated_meta.yaml b/google/services/apigee/resource_apigee_instance_attachment_generated_meta.yaml index f0429e41b93..4f3a367ea81 100644 --- a/google/services/apigee/resource_apigee_instance_attachment_generated_meta.yaml +++ b/google/services/apigee/resource_apigee_instance_attachment_generated_meta.yaml @@ -11,3 +11,5 @@ fields: - field: instance_id provider_only: true - api_field: name + - field: deletion_policy + provider_only: true diff --git a/google/services/apigee/resource_apigee_instance_generated_meta.yaml b/google/services/apigee/resource_apigee_instance_generated_meta.yaml index 4bd173be83f..81aedb22c52 100644 --- a/google/services/apigee/resource_apigee_instance_generated_meta.yaml +++ b/google/services/apigee/resource_apigee_instance_generated_meta.yaml @@ -22,3 +22,5 @@ fields: - api_field: peeringCidrRange - api_field: port - api_field: serviceAttachment + - field: deletion_policy + provider_only: true diff --git a/google/services/apigee/resource_apigee_keystores_aliases_pkcs12.go b/google/services/apigee/resource_apigee_keystores_aliases_pkcs12.go index 2ba61dbdf6d..24d706ea90f 100644 --- a/google/services/apigee/resource_apigee_keystores_aliases_pkcs12.go +++ b/google/services/apigee/resource_apigee_keystores_aliases_pkcs12.go @@ -26,6 +26,7 @@ import ( "reflect" "time" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-provider-google/google/registry" "github.com/hashicorp/terraform-provider-google/google/tpgresource" @@ -36,6 +37,7 @@ func ResourceApigeeKeystoresAliasesPkcs12() *schema.Resource { return &schema.Resource{ Create: ResourceApigeeKeystoresAliasesPkcs12Create, Read: ResourceApigeeKeystoresAliasesPkcs12Read, + Update: ResourceApigeeKeystoresAliasesPkcs12Update, Delete: ResourceApigeeKeystoresAliasesPkcs12Delete, Importer: &schema.ResourceImporter{ @@ -47,6 +49,10 @@ func ResourceApigeeKeystoresAliasesPkcs12() *schema.Resource { Delete: schema.DefaultTimeout(20 * time.Minute), }, + CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), + ), + Schema: map[string]*schema.Schema{ "alias": { Type: schema.TypeString, @@ -172,6 +178,9 @@ Flag is set to Yes if the certificate is valid, No if expired, or Not yet if not Computed: true, Description: `Optional.Type of Alias`, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, UseJSONNumber: true, } @@ -271,10 +280,29 @@ func ResourceApigeeKeystoresAliasesPkcs12Read(d *schema.ResourceData, meta inter return fmt.Errorf("Error reading KeystoreAliasesPkcs: %s", err) } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } +// UDP update start +func ResourceApigeeKeystoresAliasesPkcs12Update(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return ResourceApigeeKeystoresAliasesPkcs12Read(d, meta) +} + +//UDP update end + func ResourceApigeeKeystoresAliasesPkcs12Delete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/apigee/resource_apigee_keystores_aliases_pkcs12_meta.yaml b/google/services/apigee/resource_apigee_keystores_aliases_pkcs12_meta.yaml index 7b293a84896..bee4ad4f9ee 100644 --- a/google/services/apigee/resource_apigee_keystores_aliases_pkcs12_meta.yaml +++ b/google/services/apigee/resource_apigee_keystores_aliases_pkcs12_meta.yaml @@ -25,3 +25,5 @@ fields: - field: 'org_id' - field: 'password' - api_field: 'type' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/apigee/resource_apigee_keystores_aliases_self_signed_cert.go b/google/services/apigee/resource_apigee_keystores_aliases_self_signed_cert.go index f58528e34f1..3549f2dc02f 100644 --- a/google/services/apigee/resource_apigee_keystores_aliases_self_signed_cert.go +++ b/google/services/apigee/resource_apigee_keystores_aliases_self_signed_cert.go @@ -100,6 +100,7 @@ func ResourceApigeeKeystoresAliasesSelfSignedCert() *schema.Resource { return &schema.Resource{ Create: resourceApigeeKeystoresAliasesSelfSignedCertCreate, Read: resourceApigeeKeystoresAliasesSelfSignedCertRead, + Update: resourceApigeeKeystoresAliasesSelfSignedCertUpdate, Delete: resourceApigeeKeystoresAliasesSelfSignedCertDelete, Importer: &schema.ResourceImporter{ @@ -335,6 +336,19 @@ Flag is set to Yes if the certificate is valid, No if expired, or Not yet if not Computed: true, Description: `Optional.Type of Alias`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -485,6 +499,20 @@ func resourceApigeeKeystoresAliasesSelfSignedCertRead(d *schema.ResourceData, me log.Printf("[DEBUG] Finished reading ApigeeKeystoresAliasesSelfSignedCert %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceApigeeKeystoresAliasesSelfSignedCertFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -523,7 +551,19 @@ func resourceApigeeKeystoresAliasesSelfSignedCertRead(d *schema.ResourceData, me return nil } +func resourceApigeeKeystoresAliasesSelfSignedCertUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceApigeeKeystoresAliasesSelfSignedCertRead(d, meta) +} + func resourceApigeeKeystoresAliasesSelfSignedCertDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ApigeeKeystoresAliasesSelfSignedCert without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing KeystoresAliasesSelfSignedCert %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/apigee/resource_apigee_keystores_aliases_self_signed_cert_generated_meta.yaml b/google/services/apigee/resource_apigee_keystores_aliases_self_signed_cert_generated_meta.yaml index d1d905ddf99..9d4602046b2 100644 --- a/google/services/apigee/resource_apigee_keystores_aliases_self_signed_cert_generated_meta.yaml +++ b/google/services/apigee/resource_apigee_keystores_aliases_self_signed_cert_generated_meta.yaml @@ -37,3 +37,5 @@ fields: - api_field: subject.state - api_field: subjectAlternativeDnsNames.subjectAlternativeName - api_field: type + - field: deletion_policy + provider_only: true diff --git a/google/services/apigee/resource_apigee_nat_address.go b/google/services/apigee/resource_apigee_nat_address.go index 15e22469146..a7e724ba01f 100644 --- a/google/services/apigee/resource_apigee_nat_address.go +++ b/google/services/apigee/resource_apigee_nat_address.go @@ -183,6 +183,19 @@ in the format 'organizations/{{org_name}}/instances/{{instance_name}}'.`, Computed: true, Description: `State of the NAT IP address.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -337,6 +350,20 @@ func resourceApigeeNatAddressRead(d *schema.ResourceData, meta interface{}) erro return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceApigeeNatAddressFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -364,6 +391,19 @@ func resourceApigeeNatAddressRead(d *schema.ResourceData, meta interface{}) erro } func resourceApigeeNatAddressUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceApigeeNatAddress().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceApigeeNatAddressRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -402,6 +442,13 @@ func resourceApigeeNatAddressUpdate(d *schema.ResourceData, meta interface{}) er } func resourceApigeeNatAddressDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ApigeeNatAddress without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing NatAddress %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/apigee/resource_apigee_nat_address_generated_meta.yaml b/google/services/apigee/resource_apigee_nat_address_generated_meta.yaml index 1d1868ce6f5..50e0a46c998 100644 --- a/google/services/apigee/resource_apigee_nat_address_generated_meta.yaml +++ b/google/services/apigee/resource_apigee_nat_address_generated_meta.yaml @@ -13,3 +13,5 @@ fields: - api_field: ipAddress - api_field: name - api_field: state + - field: deletion_policy + provider_only: true diff --git a/google/services/apigee/resource_apigee_organization.go b/google/services/apigee/resource_apigee_organization.go index c15b5b22597..1237bb4b407 100644 --- a/google/services/apigee/resource_apigee_organization.go +++ b/google/services/apigee/resource_apigee_organization.go @@ -274,6 +274,19 @@ Valid only when 'RuntimeType' is CLOUD. A base64-encoded string.`, Description: `Output only. Subscription type of the Apigee organization. Valid values include trial (free, limited, and for evaluation purposes only) or paid (full subscription has been purchased).`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -474,6 +487,20 @@ func resourceApigeeOrganizationRead(d *schema.ResourceData, meta interface{}) er log.Printf("[DEBUG] Finished reading ApigeeOrganization %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceApigeeOrganizationFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -495,6 +522,19 @@ func resourceApigeeOrganizationRead(d *schema.ResourceData, meta interface{}) er } func resourceApigeeOrganizationUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceApigeeOrganization().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceApigeeOrganizationRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -626,6 +666,13 @@ func resourceApigeeOrganizationUpdate(d *schema.ResourceData, meta interface{}) } func resourceApigeeOrganizationDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ApigeeOrganization without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Organization %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/apigee/resource_apigee_organization_generated_meta.yaml b/google/services/apigee/resource_apigee_organization_generated_meta.yaml index 05277cad850..399a63256af 100644 --- a/google/services/apigee/resource_apigee_organization_generated_meta.yaml +++ b/google/services/apigee/resource_apigee_organization_generated_meta.yaml @@ -28,3 +28,5 @@ fields: - api_field: runtimeDatabaseEncryptionKeyName - api_field: runtimeType - api_field: subscriptionType + - field: deletion_policy + provider_only: true diff --git a/google/services/apigee/resource_apigee_security_action.go b/google/services/apigee/resource_apigee_security_action.go index c463f77b024..40a975d845b 100644 --- a/google/services/apigee/resource_apigee_security_action.go +++ b/google/services/apigee/resource_apigee_security_action.go @@ -100,6 +100,7 @@ func ResourceApigeeSecurityAction() *schema.Resource { return &schema.Resource{ Create: resourceApigeeSecurityActionCreate, Read: resourceApigeeSecurityActionRead, + Update: resourceApigeeSecurityActionUpdate, Delete: resourceApigeeSecurityActionDelete, Importer: &schema.ResourceImporter{ @@ -391,6 +392,19 @@ Offsets other than "Z" are also accepted. Examples: "2014-10-02T15:01:23Z", "201 Uses RFC 3339, where generated output will always be Z-normalized and uses 0, 3, 6 or 9 fractional digits. Offsets other than "Z" are also accepted. Examples: "2014-10-02T15:01:23Z", "2014-10-02T15:01:23.045123456Z" or "2014-10-02T15:01:23+05:30".`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -554,6 +568,20 @@ func resourceApigeeSecurityActionRead(d *schema.ResourceData, meta interface{}) log.Printf("[DEBUG] Finished reading ApigeeSecurityAction %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceApigeeSecurityActionFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -586,7 +614,19 @@ func resourceApigeeSecurityActionRead(d *schema.ResourceData, meta interface{}) return nil } +func resourceApigeeSecurityActionUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceApigeeSecurityActionRead(d, meta) +} + func resourceApigeeSecurityActionDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ApigeeSecurityAction without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing SecurityAction %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/apigee/resource_apigee_security_action_generated_meta.yaml b/google/services/apigee/resource_apigee_security_action_generated_meta.yaml index e9b5e3370fa..773f22c53d7 100644 --- a/google/services/apigee/resource_apigee_security_action_generated_meta.yaml +++ b/google/services/apigee/resource_apigee_security_action_generated_meta.yaml @@ -35,3 +35,5 @@ fields: - api_field: state - api_field: ttl - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/apigee/resource_apigee_security_feedback.go b/google/services/apigee/resource_apigee_security_feedback.go index be2e32f3096..0e7d30972b5 100644 --- a/google/services/apigee/resource_apigee_security_feedback.go +++ b/google/services/apigee/resource_apigee_security_feedback.go @@ -188,6 +188,19 @@ in the format 'organizations/{{org_name}}/securityFeedback/{{feedback_id}}'.`, Computed: true, Description: `The time when this specific feedback id was updated.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -306,6 +319,20 @@ func resourceApigeeSecurityFeedbackRead(d *schema.ResourceData, meta interface{} log.Printf("[DEBUG] Finished reading ApigeeSecurityFeedback %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceApigeeSecurityFeedbackFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -315,6 +342,19 @@ func resourceApigeeSecurityFeedbackRead(d *schema.ResourceData, meta interface{} } func resourceApigeeSecurityFeedbackUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceApigeeSecurityFeedback().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceApigeeSecurityFeedbackRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -389,6 +429,13 @@ func resourceApigeeSecurityFeedbackUpdate(d *schema.ResourceData, meta interface } func resourceApigeeSecurityFeedbackDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ApigeeSecurityFeedback without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing SecurityFeedback %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/apigee/resource_apigee_security_feedback_generated_meta.yaml b/google/services/apigee/resource_apigee_security_feedback_generated_meta.yaml index bada62bba17..30ca4b364c7 100644 --- a/google/services/apigee/resource_apigee_security_feedback_generated_meta.yaml +++ b/google/services/apigee/resource_apigee_security_feedback_generated_meta.yaml @@ -20,3 +20,5 @@ fields: provider_only: true - api_field: reason - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/apigee/resource_apigee_security_monitoring_condition.go b/google/services/apigee/resource_apigee_security_monitoring_condition.go index 40bf5f45c2e..8da9c24e8fa 100644 --- a/google/services/apigee/resource_apigee_security_monitoring_condition.go +++ b/google/services/apigee/resource_apigee_security_monitoring_condition.go @@ -173,6 +173,19 @@ in the format 'organizations/{{org_name}}/securityMonitoringConditions/{{conditi Computed: true, Description: `The timestamp at which this profile was most recently updated.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -279,6 +292,20 @@ func resourceApigeeSecurityMonitoringConditionRead(d *schema.ResourceData, meta log.Printf("[DEBUG] Finished reading ApigeeSecurityMonitoringCondition %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceApigeeSecurityMonitoringConditionFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -288,6 +315,19 @@ func resourceApigeeSecurityMonitoringConditionRead(d *schema.ResourceData, meta } func resourceApigeeSecurityMonitoringConditionUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceApigeeSecurityMonitoringCondition().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceApigeeSecurityMonitoringConditionRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -350,6 +390,13 @@ func resourceApigeeSecurityMonitoringConditionUpdate(d *schema.ResourceData, met } func resourceApigeeSecurityMonitoringConditionDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ApigeeSecurityMonitoringCondition without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing SecurityMonitoringCondition %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/apigee/resource_apigee_security_monitoring_condition_generated_meta.yaml b/google/services/apigee/resource_apigee_security_monitoring_condition_generated_meta.yaml index e2ce4aad324..d5a21a1b3a6 100644 --- a/google/services/apigee/resource_apigee_security_monitoring_condition_generated_meta.yaml +++ b/google/services/apigee/resource_apigee_security_monitoring_condition_generated_meta.yaml @@ -19,3 +19,5 @@ fields: - api_field: totalDeployedResources - api_field: totalMonitoredResources - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/apigee/resource_apigee_security_profile_v2.go b/google/services/apigee/resource_apigee_security_profile_v2.go index 1b96bda03bb..f40637ecd84 100644 --- a/google/services/apigee/resource_apigee_security_profile_v2.go +++ b/google/services/apigee/resource_apigee_security_profile_v2.go @@ -167,6 +167,19 @@ in the format 'organizations/{{org_name}}/securityProfilesV2/{{profile_id}}'.`, Computed: true, Description: `The timestamp at which this profile was most recently updated.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -267,6 +280,20 @@ func resourceApigeeSecurityProfileV2Read(d *schema.ResourceData, meta interface{ log.Printf("[DEBUG] Finished reading ApigeeSecurityProfileV2 %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceApigeeSecurityProfileV2Flatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -276,6 +303,19 @@ func resourceApigeeSecurityProfileV2Read(d *schema.ResourceData, meta interface{ } func resourceApigeeSecurityProfileV2Update(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceApigeeSecurityProfileV2().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceApigeeSecurityProfileV2Read(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -351,6 +391,13 @@ func resourceApigeeSecurityProfileV2Update(d *schema.ResourceData, meta interfac } func resourceApigeeSecurityProfileV2Delete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ApigeeSecurityProfileV2 without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing SecurityProfileV2 %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/apigee/resource_apigee_security_profile_v2_generated_meta.yaml b/google/services/apigee/resource_apigee_security_profile_v2_generated_meta.yaml index 57a076a122e..e668c83ff7b 100644 --- a/google/services/apigee/resource_apigee_security_profile_v2_generated_meta.yaml +++ b/google/services/apigee/resource_apigee_security_profile_v2_generated_meta.yaml @@ -19,3 +19,5 @@ fields: - field: profile_id provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/apigee/resource_apigee_sharedflow.go b/google/services/apigee/resource_apigee_sharedflow.go index 2a596136f02..b450fa990bd 100644 --- a/google/services/apigee/resource_apigee_sharedflow.go +++ b/google/services/apigee/resource_apigee_sharedflow.go @@ -50,6 +50,7 @@ func ResourceApigeeSharedFlow() *schema.Resource { }, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), /* If any of the config_bundle, detect_md5hash or md5hash is changed, then an update is expected, so we tell Terraform core to expect update on meta_data, @@ -150,6 +151,9 @@ func ResourceApigeeSharedFlow() *schema.Resource { return true }, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, UseJSONNumber: true, } @@ -221,6 +225,11 @@ func resourceApigeeSharedFlowCreate(d *schema.ResourceData, meta interface{}) er } func resourceApigeeSharedFlowUpdate(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceApigeeSharedFlow) { + return ResourceApigeeSharedFlow().Read(d, meta) + } + //For how sharedflow api is implemented, just treat an update as create, when the name is same, it will create a new revision return resourceApigeeSharedFlowCreate(d, meta) } @@ -277,6 +286,11 @@ func resourceApigeeSharedFlowRead(d *schema.ResourceData, meta interface{}) erro d.Set("md5hash", "UNKNOWN") d.Set("detect_md5hash", "UNKNOWN") } + + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } @@ -300,6 +314,13 @@ func getApigeeSharedFlowLastModifiedAt(d *schema.ResourceData) string { func resourceApigeeSharedFlowDelete(d *schema.ResourceData, meta interface{}) error { log.Printf("[DEBUG] resourceApigeeSharedFlowDelete") + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/apigee/resource_apigee_sharedflow_deployment.go b/google/services/apigee/resource_apigee_sharedflow_deployment.go index 86584434c8e..5bf7e1aa842 100644 --- a/google/services/apigee/resource_apigee_sharedflow_deployment.go +++ b/google/services/apigee/resource_apigee_sharedflow_deployment.go @@ -21,6 +21,7 @@ import ( "log" "time" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-provider-google/google/registry" "github.com/hashicorp/terraform-provider-google/google/tpgresource" @@ -44,6 +45,10 @@ func ResourceApigeeSharedFlowDeployment() *schema.Resource { Delete: schema.DefaultTimeout(20 * time.Minute), }, + CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), + ), + Schema: map[string]*schema.Schema{ "environment": { Type: schema.TypeString, @@ -74,6 +79,9 @@ func ResourceApigeeSharedFlowDeployment() *schema.Resource { ForceNew: true, Description: `Id of the Sharedflow to be deployed.`, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, UseJSONNumber: true, } @@ -156,6 +164,10 @@ func resourceApigeeSharedflowDeploymentRead(d *schema.ResourceData, meta interfa } log.Printf("[DEBUG] ApigeeSharedflowDeployment deployStartTime %s", res["deployStartTime"]) + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } @@ -166,6 +178,10 @@ func resourceApigeeSharedflowDeploymentUpdate(d *schema.ResourceData, meta inter return err } + if tpgresource.DeletionPolicyPreUpdate(d, ResourceApigeeSharedFlowDeployment) { + return ResourceApigeeSharedFlowDeployment().Read(d, meta) + } + url, err := tpgresource.ReplaceVars(d, config, transport_tpg.BaseUrl(Product, config)+"organizations/{{org_id}}/environments/{{environment}}/sharedflows/{{sharedflow_id}}/revisions/{{revision}}/deployments?override=true&serviceAccount={{service_account}}") if err != nil { return err @@ -204,6 +220,13 @@ func resourceApigeeSharedflowDeploymentUpdate(d *schema.ResourceData, meta inter } func resourceApigeeSharedflowDeploymentDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/apigee/resource_apigee_sharedflow_deployment_meta.yaml b/google/services/apigee/resource_apigee_sharedflow_deployment_meta.yaml index 7b84ac919a8..6a6afd14f03 100644 --- a/google/services/apigee/resource_apigee_sharedflow_deployment_meta.yaml +++ b/google/services/apigee/resource_apigee_sharedflow_deployment_meta.yaml @@ -11,3 +11,5 @@ fields: - api_field: 'revision' - field: 'service_account' - field: 'sharedflow_id' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/apigee/resource_apigee_sharedflow_meta.yaml b/google/services/apigee/resource_apigee_sharedflow_meta.yaml index 5487bfd6e52..7c1fc9d6964 100644 --- a/google/services/apigee/resource_apigee_sharedflow_meta.yaml +++ b/google/services/apigee/resource_apigee_sharedflow_meta.yaml @@ -16,3 +16,5 @@ fields: - api_field: 'name' - field: 'org_id' - api_field: 'revision' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/apigee/resource_apigee_space.go b/google/services/apigee/resource_apigee_space.go index cd9789639a8..8e56eb82e76 100644 --- a/google/services/apigee/resource_apigee_space.go +++ b/google/services/apigee/resource_apigee_space.go @@ -146,6 +146,19 @@ func ResourceApigeeSpace() *schema.Resource { Computed: true, Description: `Last modified timestamp of the space.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -240,6 +253,20 @@ func resourceApigeeSpaceRead(d *schema.ResourceData, meta interface{}) error { log.Printf("[DEBUG] Finished reading ApigeeSpace %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceApigeeSpaceFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -249,6 +276,19 @@ func resourceApigeeSpaceRead(d *schema.ResourceData, meta interface{}) error { } func resourceApigeeSpaceUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceApigeeSpace().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceApigeeSpaceRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -314,6 +354,13 @@ func resourceApigeeSpaceUpdate(d *schema.ResourceData, meta interface{}) error { } func resourceApigeeSpaceDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ApigeeSpace without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Space %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/apigee/resource_apigee_space_generated_meta.yaml b/google/services/apigee/resource_apigee_space_generated_meta.yaml index b5d15f1d070..ffbf5900c9d 100644 --- a/google/services/apigee/resource_apigee_space_generated_meta.yaml +++ b/google/services/apigee/resource_apigee_space_generated_meta.yaml @@ -15,3 +15,5 @@ fields: - field: space_id provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/apigee/resource_apigee_sync_authorization.go b/google/services/apigee/resource_apigee_sync_authorization.go index 07840dbb753..7a746876ccb 100644 --- a/google/services/apigee/resource_apigee_sync_authorization.go +++ b/google/services/apigee/resource_apigee_sync_authorization.go @@ -287,6 +287,7 @@ func resourceApigeeSyncAuthorizationRead(d *schema.ResourceData, meta interface{ } func resourceApigeeSyncAuthorizationUpdate(d *schema.ResourceData, meta interface{}) error { + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/apigee/resource_apigee_target_server.go b/google/services/apigee/resource_apigee_target_server.go index ca33c36bc80..90193f02f26 100644 --- a/google/services/apigee/resource_apigee_target_server.go +++ b/google/services/apigee/resource_apigee_target_server.go @@ -256,6 +256,19 @@ in the format 'organizations/{{org_name}}/environments/{{env_name}}'.`, }, }, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -402,6 +415,20 @@ func resourceApigeeTargetServerRead(d *schema.ResourceData, meta interface{}) er log.Printf("[DEBUG] Finished reading ApigeeTargetServer %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceApigeeTargetServerFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -429,6 +456,19 @@ func resourceApigeeTargetServerRead(d *schema.ResourceData, meta interface{}) er } func resourceApigeeTargetServerUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceApigeeTargetServer().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceApigeeTargetServerRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -530,6 +570,13 @@ func resourceApigeeTargetServerUpdate(d *schema.ResourceData, meta interface{}) } func resourceApigeeTargetServerDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ApigeeTargetServer without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing TargetServer %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/apigee/resource_apigee_target_server_generated_meta.yaml b/google/services/apigee/resource_apigee_target_server_generated_meta.yaml index 06c2dc5eab5..03c23082108 100644 --- a/google/services/apigee/resource_apigee_target_server_generated_meta.yaml +++ b/google/services/apigee/resource_apigee_target_server_generated_meta.yaml @@ -26,3 +26,5 @@ fields: - api_field: sSLInfo.keyStore - api_field: sSLInfo.protocols - api_field: sSLInfo.trustStore + - field: deletion_policy + provider_only: true diff --git a/google/services/apihub/resource_apihub_api_hub_instance.go b/google/services/apihub/resource_apihub_api_hub_instance.go index 407d53c232c..b76bdd4e501 100644 --- a/google/services/apihub/resource_apihub_api_hub_instance.go +++ b/google/services/apihub/resource_apihub_api_hub_instance.go @@ -478,7 +478,7 @@ func resourceApihubApiHubInstanceRead(d *schema.ResourceData, meta interface{}) } func resourceApihubApiHubInstanceUpdate(d *schema.ResourceData, meta interface{}) error { - // Only the root field "labels", "terraform_labels", and virtual fields are mutable + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable return resourceApihubApiHubInstanceRead(d, meta) } diff --git a/google/services/apihub/resource_apihub_curation.go b/google/services/apihub/resource_apihub_curation.go index b540bf9af96..9668f0aec0b 100644 --- a/google/services/apihub/resource_apihub_curation.go +++ b/google/services/apihub/resource_apihub_curation.go @@ -115,6 +115,7 @@ func ResourceApihubCuration() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -290,6 +291,18 @@ Format is Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -429,6 +442,19 @@ func resourceApihubCurationRead(d *schema.ResourceData, meta interface{}) error log.Printf("[DEBUG] Finished reading ApihubCuration %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Curation: %s", err) } @@ -466,6 +492,19 @@ func resourceApihubCurationRead(d *schema.ResourceData, meta interface{}) error } func resourceApihubCurationUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceApihubCuration().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceApihubCurationRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -567,6 +606,13 @@ func resourceApihubCurationUpdate(d *schema.ResourceData, meta interface{}) erro } func resourceApihubCurationDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ApihubCuration without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Curation %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/apihub/resource_apihub_curation_generated_meta.yaml b/google/services/apihub/resource_apihub_curation_generated_meta.yaml index 0b7387eb7d6..cb6ee93ceba 100644 --- a/google/services/apihub/resource_apihub_curation_generated_meta.yaml +++ b/google/services/apihub/resource_apihub_curation_generated_meta.yaml @@ -24,3 +24,5 @@ fields: - api_field: pluginInstanceActions.actionId - api_field: pluginInstanceActions.pluginInstance - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/apihub/resource_apihub_plugin.go b/google/services/apihub/resource_apihub_plugin.go index b885384ade2..31df07323f1 100644 --- a/google/services/apihub/resource_apihub_plugin.go +++ b/google/services/apihub/resource_apihub_plugin.go @@ -100,6 +100,7 @@ func ResourceApihubPlugin() *schema.Resource { return &schema.Resource{ Create: resourceApihubPluginCreate, Read: resourceApihubPluginRead, + Update: resourceApihubPluginUpdate, Delete: resourceApihubPluginDelete, Importer: &schema.ResourceImporter{ @@ -113,6 +114,7 @@ func ResourceApihubPlugin() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -466,6 +468,18 @@ DISABLED`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -629,6 +643,19 @@ func resourceApihubPluginRead(d *schema.ResourceData, meta interface{}) error { log.Printf("[DEBUG] Finished reading ApihubPlugin %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Plugin: %s", err) } @@ -665,7 +692,19 @@ func resourceApihubPluginRead(d *schema.ResourceData, meta interface{}) error { return nil } +func resourceApihubPluginUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceApihubPluginRead(d, meta) +} + func resourceApihubPluginDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ApihubPlugin without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Plugin %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/apihub/resource_apihub_plugin_generated_meta.yaml b/google/services/apihub/resource_apihub_plugin_generated_meta.yaml index 463f32c0e84..6dfd93d75b7 100644 --- a/google/services/apihub/resource_apihub_plugin_generated_meta.yaml +++ b/google/services/apihub/resource_apihub_plugin_generated_meta.yaml @@ -39,3 +39,5 @@ fields: provider_only: true - api_field: state - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/apihub/resource_apihub_plugin_instance.go b/google/services/apihub/resource_apihub_plugin_instance.go index 08dda0a54af..a9c950a9c40 100644 --- a/google/services/apihub/resource_apihub_plugin_instance.go +++ b/google/services/apihub/resource_apihub_plugin_instance.go @@ -115,6 +115,7 @@ func ResourceApihubPluginInstance() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -532,6 +533,18 @@ DELETING`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -692,6 +705,19 @@ func resourceApihubPluginInstanceRead(d *schema.ResourceData, meta interface{}) log.Printf("[DEBUG] Finished reading ApihubPluginInstance %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading PluginInstance: %s", err) } @@ -735,6 +761,19 @@ func resourceApihubPluginInstanceRead(d *schema.ResourceData, meta interface{}) } func resourceApihubPluginInstanceUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceApihubPluginInstance().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceApihubPluginInstanceRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -828,6 +867,13 @@ func resourceApihubPluginInstanceUpdate(d *schema.ResourceData, meta interface{} } func resourceApihubPluginInstanceDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ApihubPluginInstance without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing PluginInstance %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/apihub/resource_apihub_plugin_instance_generated_meta.yaml b/google/services/apihub/resource_apihub_plugin_instance_generated_meta.yaml index 8444249568f..67c53dba1b1 100644 --- a/google/services/apihub/resource_apihub_plugin_instance_generated_meta.yaml +++ b/google/services/apihub/resource_apihub_plugin_instance_generated_meta.yaml @@ -41,3 +41,5 @@ fields: provider_only: true - api_field: state - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/apikeys/resource_apikeys_key.go b/google/services/apikeys/resource_apikeys_key.go index d9f60313412..7527eed6c69 100644 --- a/google/services/apikeys/resource_apikeys_key.go +++ b/google/services/apikeys/resource_apikeys_key.go @@ -49,6 +49,7 @@ func ResourceApikeysKey() *schema.Resource { }, CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -102,6 +103,10 @@ func ResourceApikeysKey() *schema.Resource { Computed: true, Description: "Output only. Unique id in UUID4 format.", }, + + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, } } @@ -351,9 +356,18 @@ func resourceApikeysKeyRead(d *schema.ResourceData, meta interface{}) error { return fmt.Errorf("error setting uid in state: %s", err) } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } func resourceApikeysKeyUpdate(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceApikeysKey) { + return ResourceApikeysKey().Read(d, meta) + } + config := meta.(*transport_tpg.Config) project, err := tpgresource.GetProject(d, config) if err != nil { @@ -401,6 +415,13 @@ func resourceApikeysKeyUpdate(d *schema.ResourceData, meta interface{}) error { } func resourceApikeysKeyDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) project, err := tpgresource.GetProject(d, config) if err != nil { diff --git a/google/services/apikeys/resource_apikeys_key_meta.yaml b/google/services/apikeys/resource_apikeys_key_meta.yaml index aa8ab119509..38ebc78a221 100644 --- a/google/services/apikeys/resource_apikeys_key_meta.yaml +++ b/google/services/apikeys/resource_apikeys_key_meta.yaml @@ -19,3 +19,5 @@ fields: - api_field: 'restrictions.serverKeyRestrictions.allowedIps' - api_field: 'uid' - api_field: 'serviceAccountEmail' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/appengine/resource_app_engine_application_url_dispatch_rules.go b/google/services/appengine/resource_app_engine_application_url_dispatch_rules.go index fab45aab02d..bdd7461cc58 100644 --- a/google/services/appengine/resource_app_engine_application_url_dispatch_rules.go +++ b/google/services/appengine/resource_app_engine_application_url_dispatch_rules.go @@ -115,6 +115,7 @@ func ResourceAppEngineApplicationUrlDispatchRules() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -167,6 +168,18 @@ Defaults to matching all domains: "*".`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -303,6 +316,19 @@ func resourceAppEngineApplicationUrlDispatchRulesRead(d *schema.ResourceData, me log.Printf("[DEBUG] Finished reading AppEngineApplicationUrlDispatchRules %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading ApplicationUrlDispatchRules: %s", err) } @@ -328,6 +354,19 @@ func resourceAppEngineApplicationUrlDispatchRulesRead(d *schema.ResourceData, me } func resourceAppEngineApplicationUrlDispatchRulesUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceAppEngineApplicationUrlDispatchRules().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceAppEngineApplicationUrlDispatchRulesRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -410,6 +449,13 @@ func resourceAppEngineApplicationUrlDispatchRulesUpdate(d *schema.ResourceData, } func resourceAppEngineApplicationUrlDispatchRulesDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy AppEngineApplicationUrlDispatchRules without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ApplicationUrlDispatchRules %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/appengine/resource_app_engine_application_url_dispatch_rules_generated_meta.yaml b/google/services/appengine/resource_app_engine_application_url_dispatch_rules_generated_meta.yaml index f4d748cce7b..3695e9ffb73 100644 --- a/google/services/appengine/resource_app_engine_application_url_dispatch_rules_generated_meta.yaml +++ b/google/services/appengine/resource_app_engine_application_url_dispatch_rules_generated_meta.yaml @@ -10,3 +10,5 @@ fields: - api_field: dispatchRules.domain - api_field: dispatchRules.path - api_field: dispatchRules.service + - field: deletion_policy + provider_only: true diff --git a/google/services/appengine/resource_app_engine_domain_mapping.go b/google/services/appengine/resource_app_engine_domain_mapping.go index b434ad078d6..c7fcc98566d 100644 --- a/google/services/appengine/resource_app_engine_domain_mapping.go +++ b/google/services/appengine/resource_app_engine_domain_mapping.go @@ -115,6 +115,7 @@ func ResourceAppEngineDomainMapping() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -226,6 +227,18 @@ configuration in order to serve the application via this domain mapping.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -383,6 +396,19 @@ func resourceAppEngineDomainMappingRead(d *schema.ResourceData, meta interface{} return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading DomainMapping: %s", err) } @@ -414,6 +440,19 @@ func resourceAppEngineDomainMappingRead(d *schema.ResourceData, meta interface{} } func resourceAppEngineDomainMappingUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceAppEngineDomainMapping().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceAppEngineDomainMappingRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -515,6 +554,13 @@ func resourceAppEngineDomainMappingUpdate(d *schema.ResourceData, meta interface } func resourceAppEngineDomainMappingDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy AppEngineDomainMapping without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing DomainMapping %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/appengine/resource_app_engine_domain_mapping_generated_meta.yaml b/google/services/appengine/resource_app_engine_domain_mapping_generated_meta.yaml index be634fa1cfd..d7468f29141 100644 --- a/google/services/appengine/resource_app_engine_domain_mapping_generated_meta.yaml +++ b/google/services/appengine/resource_app_engine_domain_mapping_generated_meta.yaml @@ -18,3 +18,5 @@ fields: - api_field: sslSettings.certificateId - api_field: sslSettings.pendingManagedCertificateId - api_field: sslSettings.sslManagementType + - field: deletion_policy + provider_only: true diff --git a/google/services/appengine/resource_app_engine_firewall_rule.go b/google/services/appengine/resource_app_engine_firewall_rule.go index 185ed4d8979..a2796522abc 100644 --- a/google/services/appengine/resource_app_engine_firewall_rule.go +++ b/google/services/appengine/resource_app_engine_firewall_rule.go @@ -115,6 +115,7 @@ func ResourceAppEngineFirewallRule() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -169,6 +170,18 @@ this rule can be modified by the user.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -363,6 +376,19 @@ func resourceAppEngineFirewallRuleRead(d *schema.ResourceData, meta interface{}) log.Printf("[DEBUG] Finished reading AppEngineFirewallRule %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading FirewallRule: %s", err) } @@ -394,6 +420,19 @@ func resourceAppEngineFirewallRuleRead(d *schema.ResourceData, meta interface{}) } func resourceAppEngineFirewallRuleUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceAppEngineFirewallRule().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceAppEngineFirewallRuleRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -518,6 +557,13 @@ func resourceAppEngineFirewallRuleUpdate(d *schema.ResourceData, meta interface{ } func resourceAppEngineFirewallRuleDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy AppEngineFirewallRule without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing FirewallRule %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/appengine/resource_app_engine_firewall_rule_generated_meta.yaml b/google/services/appengine/resource_app_engine_firewall_rule_generated_meta.yaml index bf5e8e50111..397b1d48d1a 100644 --- a/google/services/appengine/resource_app_engine_firewall_rule_generated_meta.yaml +++ b/google/services/appengine/resource_app_engine_firewall_rule_generated_meta.yaml @@ -11,3 +11,5 @@ fields: - api_field: description - api_field: priority - api_field: sourceRange + - field: deletion_policy + provider_only: true diff --git a/google/services/appengine/resource_app_engine_flexible_app_version.go b/google/services/appengine/resource_app_engine_flexible_app_version.go index 6176664fd4e..7b7928fe1ef 100644 --- a/google/services/appengine/resource_app_engine_flexible_app_version.go +++ b/google/services/appengine/resource_app_engine_flexible_app_version.go @@ -115,6 +115,7 @@ func ResourceAppEngineFlexibleAppVersion() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -980,6 +981,18 @@ Reserved names,"default", "latest", and any name with the prefix "ah-".`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -1292,6 +1305,18 @@ func resourceAppEngineFlexibleAppVersionRead(d *schema.ResourceData, meta interf return fmt.Errorf("Error setting delete_service_on_destroy: %s", err) } } + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading FlexibleAppVersion: %s", err) } @@ -1329,6 +1354,19 @@ func resourceAppEngineFlexibleAppVersionRead(d *schema.ResourceData, meta interf } func resourceAppEngineFlexibleAppVersionUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceAppEngineFlexibleAppVersion().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceAppEngineFlexibleAppVersionRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1576,6 +1614,13 @@ func resourceAppEngineFlexibleAppVersionUpdate(d *schema.ResourceData, meta inte } func resourceAppEngineFlexibleAppVersionDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy AppEngineFlexibleAppVersion without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing FlexibleAppVersion %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/appengine/resource_app_engine_flexible_app_version_generated_meta.yaml b/google/services/appengine/resource_app_engine_flexible_app_version_generated_meta.yaml index 8a735ba8b2f..a51602a41db 100644 --- a/google/services/appengine/resource_app_engine_flexible_app_version_generated_meta.yaml +++ b/google/services/appengine/resource_app_engine_flexible_app_version_generated_meta.yaml @@ -112,3 +112,5 @@ fields: - api_field: id field: version_id - api_field: vpcAccessConnector.name + - field: deletion_policy + provider_only: true diff --git a/google/services/appengine/resource_app_engine_service_network_settings.go b/google/services/appengine/resource_app_engine_service_network_settings.go index 450576ae2dd..f5568636d35 100644 --- a/google/services/appengine/resource_app_engine_service_network_settings.go +++ b/google/services/appengine/resource_app_engine_service_network_settings.go @@ -341,6 +341,7 @@ func resourceAppEngineServiceNetworkSettingsRead(d *schema.ResourceData, meta in } func resourceAppEngineServiceNetworkSettingsUpdate(d *schema.ResourceData, meta interface{}) error { + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/appengine/resource_app_engine_service_split_traffic.go b/google/services/appengine/resource_app_engine_service_split_traffic.go index 7bdbe5316a0..7535bdaff51 100644 --- a/google/services/appengine/resource_app_engine_service_split_traffic.go +++ b/google/services/appengine/resource_app_engine_service_split_traffic.go @@ -351,6 +351,7 @@ func resourceAppEngineServiceSplitTrafficRead(d *schema.ResourceData, meta inter } func resourceAppEngineServiceSplitTrafficUpdate(d *schema.ResourceData, meta interface{}) error { + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/appengine/resource_app_engine_standard_app_version.go b/google/services/appengine/resource_app_engine_standard_app_version.go index bf6925a990b..0397eb2d1b2 100644 --- a/google/services/appengine/resource_app_engine_standard_app_version.go +++ b/google/services/appengine/resource_app_engine_standard_app_version.go @@ -115,6 +115,7 @@ func ResourceAppEngineStandardAppVersion() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -562,6 +563,18 @@ Substitute '' with 'python', 'java', 'php', 'ruby', 'go' or 'nodejs'.` Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -815,6 +828,18 @@ func resourceAppEngineStandardAppVersionRead(d *schema.ResourceData, meta interf return fmt.Errorf("Error setting delete_service_on_destroy: %s", err) } } + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading StandardAppVersion: %s", err) } @@ -852,6 +877,19 @@ func resourceAppEngineStandardAppVersionRead(d *schema.ResourceData, meta interf } func resourceAppEngineStandardAppVersionUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceAppEngineStandardAppVersion().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceAppEngineStandardAppVersionRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1040,6 +1078,13 @@ func resourceAppEngineStandardAppVersionUpdate(d *schema.ResourceData, meta inte } func resourceAppEngineStandardAppVersionDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy AppEngineStandardAppVersion without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing StandardAppVersion %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/appengine/resource_app_engine_standard_app_version_generated_meta.yaml b/google/services/appengine/resource_app_engine_standard_app_version_generated_meta.yaml index 9cfe3ff2395..9b5770624fc 100644 --- a/google/services/appengine/resource_app_engine_standard_app_version_generated_meta.yaml +++ b/google/services/appengine/resource_app_engine_standard_app_version_generated_meta.yaml @@ -62,3 +62,5 @@ fields: field: version_id - api_field: vpcAccessConnector.egressSetting - api_field: vpcAccessConnector.name + - field: deletion_policy + provider_only: true diff --git a/google/services/apphub/resource_apphub_application.go b/google/services/apphub/resource_apphub_application.go index 646c7ce811a..c60f26d5a1e 100644 --- a/google/services/apphub/resource_apphub_application.go +++ b/google/services/apphub/resource_apphub_application.go @@ -134,6 +134,7 @@ func ResourceApphubApplication() *schema.Resource { CustomizeDiff: customdiff.All( apphubApplicationCustomizeDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -337,6 +338,18 @@ DELETING`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -492,6 +505,19 @@ func resourceApphubApplicationRead(d *schema.ResourceData, meta interface{}) err log.Printf("[DEBUG] Finished reading ApphubApplication %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Application: %s", err) } @@ -529,6 +555,19 @@ func resourceApphubApplicationRead(d *schema.ResourceData, meta interface{}) err } func resourceApphubApplicationUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceApphubApplication().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceApphubApplicationRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -657,6 +696,13 @@ func resourceApphubApplicationUpdate(d *schema.ResourceData, meta interface{}) e } func resourceApphubApplicationDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ApphubApplication without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Application %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/apphub/resource_apphub_application_generated_meta.yaml b/google/services/apphub/resource_apphub_application_generated_meta.yaml index adb1aee4918..8aecefb1fcf 100644 --- a/google/services/apphub/resource_apphub_application_generated_meta.yaml +++ b/google/services/apphub/resource_apphub_application_generated_meta.yaml @@ -28,3 +28,5 @@ fields: - api_field: state - api_field: uid - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/apphub/resource_apphub_boundary.go b/google/services/apphub/resource_apphub_boundary.go index 0865fdec79a..854236729f6 100644 --- a/google/services/apphub/resource_apphub_boundary.go +++ b/google/services/apphub/resource_apphub_boundary.go @@ -340,6 +340,7 @@ func resourceApphubBoundaryRead(d *schema.ResourceData, meta interface{}) error } func resourceApphubBoundaryUpdate(d *schema.ResourceData, meta interface{}) error { + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/apphub/resource_apphub_service.go b/google/services/apphub/resource_apphub_service.go index 09eaddb1e9c..5ded356fb3d 100644 --- a/google/services/apphub/resource_apphub_service.go +++ b/google/services/apphub/resource_apphub_service.go @@ -115,6 +115,7 @@ func ResourceApphubService() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -426,6 +427,18 @@ format.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -586,6 +599,19 @@ func resourceApphubServiceRead(d *schema.ResourceData, meta interface{}) error { log.Printf("[DEBUG] Finished reading ApphubService %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Service: %s", err) } @@ -629,6 +655,19 @@ func resourceApphubServiceRead(d *schema.ResourceData, meta interface{}) error { } func resourceApphubServiceUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceApphubService().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceApphubServiceRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -752,6 +791,13 @@ func resourceApphubServiceUpdate(d *schema.ResourceData, meta interface{}) error } func resourceApphubServiceDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ApphubService without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Service %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/apphub/resource_apphub_service_generated_meta.yaml b/google/services/apphub/resource_apphub_service_generated_meta.yaml index b4316f6a9fa..8e9c5e7dfaa 100644 --- a/google/services/apphub/resource_apphub_service_generated_meta.yaml +++ b/google/services/apphub/resource_apphub_service_generated_meta.yaml @@ -42,3 +42,5 @@ fields: - api_field: state - api_field: uid - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/apphub/resource_apphub_service_project_attachment.go b/google/services/apphub/resource_apphub_service_project_attachment.go index f3d65d13c52..2f6ca11e46d 100644 --- a/google/services/apphub/resource_apphub_service_project_attachment.go +++ b/google/services/apphub/resource_apphub_service_project_attachment.go @@ -105,6 +105,7 @@ func ResourceApphubServiceProjectAttachment() *schema.Resource { return &schema.Resource{ Create: resourceApphubServiceProjectAttachmentCreate, Read: resourceApphubServiceProjectAttachmentRead, + Update: resourceApphubServiceProjectAttachmentUpdate, Delete: resourceApphubServiceProjectAttachmentDelete, Importer: &schema.ResourceImporter{ @@ -118,6 +119,7 @@ func ResourceApphubServiceProjectAttachment() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -181,6 +183,18 @@ are accepted. As output, this field will contain project number."`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -313,6 +327,19 @@ func resourceApphubServiceProjectAttachmentRead(d *schema.ResourceData, meta int log.Printf("[DEBUG] Finished reading ApphubServiceProjectAttachment %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading ServiceProjectAttachment: %s", err) } @@ -343,7 +370,19 @@ func resourceApphubServiceProjectAttachmentRead(d *schema.ResourceData, meta int return nil } +func resourceApphubServiceProjectAttachmentUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceApphubServiceProjectAttachmentRead(d, meta) +} + func resourceApphubServiceProjectAttachmentDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ApphubServiceProjectAttachment without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ServiceProjectAttachment %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/apphub/resource_apphub_service_project_attachment_generated_meta.yaml b/google/services/apphub/resource_apphub_service_project_attachment_generated_meta.yaml index 720303fd92a..f26ff3f4564 100644 --- a/google/services/apphub/resource_apphub_service_project_attachment_generated_meta.yaml +++ b/google/services/apphub/resource_apphub_service_project_attachment_generated_meta.yaml @@ -15,3 +15,5 @@ fields: provider_only: true - api_field: state - api_field: uid + - field: deletion_policy + provider_only: true diff --git a/google/services/apphub/resource_apphub_workload.go b/google/services/apphub/resource_apphub_workload.go index e045c566990..2e08fdc2a8e 100644 --- a/google/services/apphub/resource_apphub_workload.go +++ b/google/services/apphub/resource_apphub_workload.go @@ -115,6 +115,7 @@ func ResourceApphubWorkload() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -409,6 +410,18 @@ func ResourceApphubWorkload() *schema.Resource { Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -569,6 +582,19 @@ func resourceApphubWorkloadRead(d *schema.ResourceData, meta interface{}) error log.Printf("[DEBUG] Finished reading ApphubWorkload %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Workload: %s", err) } @@ -612,6 +638,19 @@ func resourceApphubWorkloadRead(d *schema.ResourceData, meta interface{}) error } func resourceApphubWorkloadUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceApphubWorkload().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceApphubWorkloadRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -735,6 +774,13 @@ func resourceApphubWorkloadUpdate(d *schema.ResourceData, meta interface{}) erro } func resourceApphubWorkloadDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ApphubWorkload without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Workload %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/apphub/resource_apphub_workload_generated_meta.yaml b/google/services/apphub/resource_apphub_workload_generated_meta.yaml index 6ba262ef7a8..f10414b804e 100644 --- a/google/services/apphub/resource_apphub_workload_generated_meta.yaml +++ b/google/services/apphub/resource_apphub_workload_generated_meta.yaml @@ -41,3 +41,5 @@ fields: - api_field: workloadProperties.location - api_field: workloadProperties.zone - api_field: workloadReference.uri + - field: deletion_policy + provider_only: true diff --git a/google/services/artifactregistry/resource_artifact_registry_repository.go b/google/services/artifactregistry/resource_artifact_registry_repository.go index 00ec5541895..efc463422d7 100644 --- a/google/services/artifactregistry/resource_artifact_registry_repository.go +++ b/google/services/artifactregistry/resource_artifact_registry_repository.go @@ -273,6 +273,7 @@ func ResourceArtifactRegistryRepository() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -923,6 +924,18 @@ Repository. Upstream policies cannot be set on a standard repository.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -1139,6 +1152,19 @@ func resourceArtifactRegistryRepositoryRead(d *schema.ResourceData, meta interfa log.Printf("[DEBUG] Finished reading ArtifactRegistryRepository %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Repository: %s", err) } @@ -1176,6 +1202,19 @@ func resourceArtifactRegistryRepositoryRead(d *schema.ResourceData, meta interfa } func resourceArtifactRegistryRepositoryUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceArtifactRegistryRepository().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceArtifactRegistryRepositoryRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1345,6 +1384,13 @@ func resourceArtifactRegistryRepositoryUpdate(d *schema.ResourceData, meta inter } func resourceArtifactRegistryRepositoryDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ArtifactRegistryRepository without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Repository %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/artifactregistry/resource_artifact_registry_repository_generated_meta.yaml b/google/services/artifactregistry/resource_artifact_registry_repository_generated_meta.yaml index 44176c32234..de6329c326f 100644 --- a/google/services/artifactregistry/resource_artifact_registry_repository_generated_meta.yaml +++ b/google/services/artifactregistry/resource_artifact_registry_repository_generated_meta.yaml @@ -71,3 +71,5 @@ fields: - api_field: vulnerabilityScanningConfig.enablementConfig - api_field: vulnerabilityScanningConfig.enablementState - api_field: vulnerabilityScanningConfig.enablementStateReason + - field: deletion_policy + provider_only: true diff --git a/google/services/artifactregistry/resource_artifact_registry_rule.go b/google/services/artifactregistry/resource_artifact_registry_rule.go index 428051ed6a7..6ca826dd15b 100644 --- a/google/services/artifactregistry/resource_artifact_registry_rule.go +++ b/google/services/artifactregistry/resource_artifact_registry_rule.go @@ -115,6 +115,7 @@ func ResourceArtifactRegistryRule() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -233,6 +234,18 @@ packages inside the repository.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -389,6 +402,19 @@ func resourceArtifactRegistryRuleRead(d *schema.ResourceData, meta interface{}) log.Printf("[DEBUG] Finished reading ArtifactRegistryRule %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Rule: %s", err) } @@ -432,6 +458,19 @@ func resourceArtifactRegistryRuleRead(d *schema.ResourceData, meta interface{}) } func resourceArtifactRegistryRuleUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceArtifactRegistryRule().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceArtifactRegistryRuleRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -561,6 +600,13 @@ func resourceArtifactRegistryRuleUpdate(d *schema.ResourceData, meta interface{} } func resourceArtifactRegistryRuleDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ArtifactRegistryRule without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Rule %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/artifactregistry/resource_artifact_registry_rule_generated_meta.yaml b/google/services/artifactregistry/resource_artifact_registry_rule_generated_meta.yaml index 1b97b3add37..e1e453944e0 100644 --- a/google/services/artifactregistry/resource_artifact_registry_rule_generated_meta.yaml +++ b/google/services/artifactregistry/resource_artifact_registry_rule_generated_meta.yaml @@ -21,3 +21,5 @@ fields: provider_only: true - field: rule_id provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/assuredworkloads/resource_assured_workloads_workload.go b/google/services/assuredworkloads/resource_assured_workloads_workload.go index 130855872bb..b69043d1a6b 100644 --- a/google/services/assuredworkloads/resource_assured_workloads_workload.go +++ b/google/services/assuredworkloads/resource_assured_workloads_workload.go @@ -48,6 +48,7 @@ func ResourceAssuredWorkloadsWorkload() *schema.Resource { }, CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -229,6 +230,9 @@ func ResourceAssuredWorkloadsWorkload() *schema.Resource { Computed: true, Description: "The combination of labels configured directly on the resource and default labels configured on the provider.", }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, } } @@ -590,9 +594,18 @@ func resourceAssuredWorkloadsWorkloadRead(d *schema.ResourceData, meta interface return fmt.Errorf("error setting terraform_labels in state: %s", err) } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } func resourceAssuredWorkloadsWorkloadUpdate(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceAssuredWorkloadsWorkload) { + return ResourceAssuredWorkloadsWorkload().Read(d, meta) + } + config := meta.(*transport_tpg.Config) obj := &Workload{ @@ -667,6 +680,13 @@ func resourceAssuredWorkloadsWorkloadUpdate(d *schema.ResourceData, meta interfa } func resourceAssuredWorkloadsWorkloadDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) obj := &Workload{ diff --git a/google/services/assuredworkloads/resource_assured_workloads_workload_meta.yaml b/google/services/assuredworkloads/resource_assured_workloads_workload_meta.yaml index 40b297295e2..7a4a339e29f 100644 --- a/google/services/assuredworkloads/resource_assured_workloads_workload_meta.yaml +++ b/google/services/assuredworkloads/resource_assured_workloads_workload_meta.yaml @@ -45,3 +45,5 @@ fields: provider_only: true - api_field: 'violationNotificationsEnabled' - api_field: 'workloadOptions.kajEnrollmentType' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/backupdr/resource_backup_dr_backup_plan.go b/google/services/backupdr/resource_backup_dr_backup_plan.go index 5104699da52..bdc71a07e16 100644 --- a/google/services/backupdr/resource_backup_dr_backup_plan.go +++ b/google/services/backupdr/resource_backup_dr_backup_plan.go @@ -115,6 +115,7 @@ func ResourceBackupDRBackupPlan() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -351,6 +352,18 @@ create crash-consistent backups.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -524,6 +537,19 @@ func resourceBackupDRBackupPlanRead(d *schema.ResourceData, meta interface{}) er log.Printf("[DEBUG] Finished reading BackupDRBackupPlan %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading BackupPlan: %s", err) } @@ -561,6 +587,19 @@ func resourceBackupDRBackupPlanRead(d *schema.ResourceData, meta interface{}) er } func resourceBackupDRBackupPlanUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceBackupDRBackupPlan().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceBackupDRBackupPlanRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -699,6 +738,13 @@ func resourceBackupDRBackupPlanUpdate(d *schema.ResourceData, meta interface{}) } func resourceBackupDRBackupPlanDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy BackupDRBackupPlan without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing BackupPlan %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/backupdr/resource_backup_dr_backup_plan_association.go b/google/services/backupdr/resource_backup_dr_backup_plan_association.go index 27db30be22f..dcb4f554689 100644 --- a/google/services/backupdr/resource_backup_dr_backup_plan_association.go +++ b/google/services/backupdr/resource_backup_dr_backup_plan_association.go @@ -115,6 +115,7 @@ func ResourceBackupDRBackupPlanAssociation() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -241,6 +242,18 @@ Examples include, "compute.googleapis.com/Instance", "compute.googleapis.com/Dis Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -390,6 +403,19 @@ func resourceBackupDRBackupPlanAssociationRead(d *schema.ResourceData, meta inte log.Printf("[DEBUG] Finished reading BackupDRBackupPlanAssociation %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading BackupPlanAssociation: %s", err) } @@ -427,6 +453,19 @@ func resourceBackupDRBackupPlanAssociationRead(d *schema.ResourceData, meta inte } func resourceBackupDRBackupPlanAssociationUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceBackupDRBackupPlanAssociation().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceBackupDRBackupPlanAssociationRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -545,6 +584,13 @@ func resourceBackupDRBackupPlanAssociationUpdate(d *schema.ResourceData, meta in } func resourceBackupDRBackupPlanAssociationDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy BackupDRBackupPlanAssociation without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing BackupPlanAssociation %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/backupdr/resource_backup_dr_backup_plan_association_generated_meta.yaml b/google/services/backupdr/resource_backup_dr_backup_plan_association_generated_meta.yaml index f9c13730bd8..8aa03f15bba 100644 --- a/google/services/backupdr/resource_backup_dr_backup_plan_association_generated_meta.yaml +++ b/google/services/backupdr/resource_backup_dr_backup_plan_association_generated_meta.yaml @@ -23,3 +23,5 @@ fields: - api_field: rulesConfigInfo.lastSuccessfulBackupConsistencyTime - api_field: rulesConfigInfo.ruleId - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/backupdr/resource_backup_dr_backup_plan_generated_meta.yaml b/google/services/backupdr/resource_backup_dr_backup_plan_generated_meta.yaml index 2131f176cf9..3ceb09c4983 100644 --- a/google/services/backupdr/resource_backup_dr_backup_plan_generated_meta.yaml +++ b/google/services/backupdr/resource_backup_dr_backup_plan_generated_meta.yaml @@ -34,3 +34,5 @@ fields: - api_field: resourceType - api_field: supportedResourceTypes - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/backupdr/resource_backup_dr_backup_vault.go b/google/services/backupdr/resource_backup_dr_backup_vault.go index fe212ca500a..849f4b3e142 100644 --- a/google/services/backupdr/resource_backup_dr_backup_vault.go +++ b/google/services/backupdr/resource_backup_dr_backup_vault.go @@ -117,6 +117,7 @@ func ResourceBackupDRBackupVault() *schema.Resource { tpgresource.SetLabelsDiff, tpgresource.SetAnnotationsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -339,6 +340,18 @@ Please refer to the field 'effective_labels' for all of the labels present on th Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -518,6 +531,19 @@ func resourceBackupDRBackupVaultRead(d *schema.ResourceData, meta interface{}) e log.Printf("[DEBUG] Finished reading BackupDRBackupVault %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading BackupVault: %s", err) } @@ -555,6 +581,19 @@ func resourceBackupDRBackupVaultRead(d *schema.ResourceData, meta interface{}) e } func resourceBackupDRBackupVaultUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceBackupDRBackupVault().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceBackupDRBackupVaultRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -713,6 +752,13 @@ func resourceBackupDRBackupVaultUpdate(d *schema.ResourceData, meta interface{}) } func resourceBackupDRBackupVaultDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy BackupDRBackupVault without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing BackupVault %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/backupdr/resource_backup_dr_backup_vault_generated_meta.yaml b/google/services/backupdr/resource_backup_dr_backup_vault_generated_meta.yaml index fb45a675f2d..08eb7a86e55 100644 --- a/google/services/backupdr/resource_backup_dr_backup_vault_generated_meta.yaml +++ b/google/services/backupdr/resource_backup_dr_backup_vault_generated_meta.yaml @@ -45,3 +45,5 @@ fields: - api_field: totalStoredBytes - api_field: uid - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/backupdr/resource_backup_dr_management_server.go b/google/services/backupdr/resource_backup_dr_management_server.go index 16a5dcf5d35..a04560c0729 100644 --- a/google/services/backupdr/resource_backup_dr_management_server.go +++ b/google/services/backupdr/resource_backup_dr_management_server.go @@ -100,6 +100,7 @@ func ResourceBackupDRManagementServer() *schema.Resource { return &schema.Resource{ Create: resourceBackupDRManagementServerCreate, Read: resourceBackupDRManagementServerRead, + Update: resourceBackupDRManagementServerUpdate, Delete: resourceBackupDRManagementServerDelete, Importer: &schema.ResourceImporter{ @@ -113,6 +114,7 @@ func ResourceBackupDRManagementServer() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -213,6 +215,18 @@ func ResourceBackupDRManagementServer() *schema.Resource { Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -356,6 +370,19 @@ func resourceBackupDRManagementServerRead(d *schema.ResourceData, meta interface log.Printf("[DEBUG] Finished reading BackupDRManagementServer %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading ManagementServer: %s", err) } @@ -392,7 +419,19 @@ func resourceBackupDRManagementServerRead(d *schema.ResourceData, meta interface return nil } +func resourceBackupDRManagementServerUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceBackupDRManagementServerRead(d, meta) +} + func resourceBackupDRManagementServerDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy BackupDRManagementServer without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ManagementServer %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/backupdr/resource_backup_dr_management_server_generated_meta.yaml b/google/services/backupdr/resource_backup_dr_management_server_generated_meta.yaml index ab7448056ad..6718e61439c 100644 --- a/google/services/backupdr/resource_backup_dr_management_server_generated_meta.yaml +++ b/google/services/backupdr/resource_backup_dr_management_server_generated_meta.yaml @@ -17,3 +17,5 @@ fields: - api_field: networks.peeringMode - api_field: oauth2ClientId - api_field: type + - field: deletion_policy + provider_only: true diff --git a/google/services/backupdr/resource_backup_dr_restore_workload.go b/google/services/backupdr/resource_backup_dr_restore_workload.go index e0f347ebb3d..9bb52801dc5 100644 --- a/google/services/backupdr/resource_backup_dr_restore_workload.go +++ b/google/services/backupdr/resource_backup_dr_restore_workload.go @@ -100,6 +100,7 @@ func ResourceBackupDRRestoreWorkload() *schema.Resource { return &schema.Resource{ Create: resourceBackupDRRestoreWorkloadCreate, Read: resourceBackupDRRestoreWorkloadRead, + Update: resourceBackupDRRestoreWorkloadUpdate, Delete: resourceBackupDRRestoreWorkloadDelete, Importer: &schema.ResourceImporter{ @@ -1403,6 +1404,19 @@ the request if it has already been completed.`, }, }, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -2421,7 +2435,19 @@ func resourceBackupDRRestoreWorkloadRead(d *schema.ResourceData, meta interface{ return nil } +func resourceBackupDRRestoreWorkloadUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceBackupDRRestoreWorkloadRead(d, meta) +} + func resourceBackupDRRestoreWorkloadDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy BackupDRRestoreWorkload without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing RestoreWorkload %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/backupdr/resource_backup_dr_restore_workload_generated_meta.yaml b/google/services/backupdr/resource_backup_dr_restore_workload_generated_meta.yaml index 1dfd64aa697..5a8c5971606 100644 --- a/google/services/backupdr/resource_backup_dr_restore_workload_generated_meta.yaml +++ b/google/services/backupdr/resource_backup_dr_restore_workload_generated_meta.yaml @@ -155,3 +155,5 @@ fields: - api_field: targetResource.gcpResource.gcpResourcename - api_field: targetResource.gcpResource.location - api_field: targetResource.gcpResource.type + - field: deletion_policy + provider_only: true diff --git a/google/services/beyondcorp/resource_beyondcorp_app_connection.go b/google/services/beyondcorp/resource_beyondcorp_app_connection.go index c13f05a66db..5a0bfbc851a 100644 --- a/google/services/beyondcorp/resource_beyondcorp_app_connection.go +++ b/google/services/beyondcorp/resource_beyondcorp_app_connection.go @@ -116,6 +116,7 @@ func ResourceBeyondcorpAppConnection() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -257,6 +258,18 @@ for a list of possible values.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -424,6 +437,19 @@ func resourceBeyondcorpAppConnectionRead(d *schema.ResourceData, meta interface{ log.Printf("[DEBUG] Finished reading BeyondcorpAppConnection %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading AppConnection: %s", err) } @@ -461,6 +487,19 @@ func resourceBeyondcorpAppConnectionRead(d *schema.ResourceData, meta interface{ } func resourceBeyondcorpAppConnectionUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceBeyondcorpAppConnection().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceBeyondcorpAppConnectionRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -599,6 +638,13 @@ func resourceBeyondcorpAppConnectionUpdate(d *schema.ResourceData, meta interfac } func resourceBeyondcorpAppConnectionDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy BeyondcorpAppConnection without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing AppConnection %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/beyondcorp/resource_beyondcorp_app_connection_generated_meta.yaml b/google/services/beyondcorp/resource_beyondcorp_app_connection_generated_meta.yaml index 6ac9910e104..c07ada489f6 100644 --- a/google/services/beyondcorp/resource_beyondcorp_app_connection_generated_meta.yaml +++ b/google/services/beyondcorp/resource_beyondcorp_app_connection_generated_meta.yaml @@ -25,3 +25,5 @@ fields: - field: terraform_labels provider_only: true - api_field: type + - field: deletion_policy + provider_only: true diff --git a/google/services/beyondcorp/resource_beyondcorp_app_connector.go b/google/services/beyondcorp/resource_beyondcorp_app_connector.go index ae9ab1af498..18c031b6cf6 100644 --- a/google/services/beyondcorp/resource_beyondcorp_app_connector.go +++ b/google/services/beyondcorp/resource_beyondcorp_app_connector.go @@ -116,6 +116,7 @@ func ResourceBeyondcorpAppConnector() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -218,6 +219,18 @@ Please refer to the field 'effective_labels' for all of the labels present on th Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -367,6 +380,19 @@ func resourceBeyondcorpAppConnectorRead(d *schema.ResourceData, meta interface{} log.Printf("[DEBUG] Finished reading BeyondcorpAppConnector %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading AppConnector: %s", err) } @@ -404,6 +430,19 @@ func resourceBeyondcorpAppConnectorRead(d *schema.ResourceData, meta interface{} } func resourceBeyondcorpAppConnectorUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceBeyondcorpAppConnector().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceBeyondcorpAppConnectorRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -522,6 +561,13 @@ func resourceBeyondcorpAppConnectorUpdate(d *schema.ResourceData, meta interface } func resourceBeyondcorpAppConnectorDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy BeyondcorpAppConnector without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing AppConnector %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/beyondcorp/resource_beyondcorp_app_connector_generated_meta.yaml b/google/services/beyondcorp/resource_beyondcorp_app_connector_generated_meta.yaml index e7b4893202f..787259b47e7 100644 --- a/google/services/beyondcorp/resource_beyondcorp_app_connector_generated_meta.yaml +++ b/google/services/beyondcorp/resource_beyondcorp_app_connector_generated_meta.yaml @@ -19,3 +19,5 @@ fields: - api_field: state - field: terraform_labels provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/beyondcorp/resource_beyondcorp_app_gateway.go b/google/services/beyondcorp/resource_beyondcorp_app_gateway.go index f83180c9d09..ce243489ca4 100644 --- a/google/services/beyondcorp/resource_beyondcorp_app_gateway.go +++ b/google/services/beyondcorp/resource_beyondcorp_app_gateway.go @@ -125,6 +125,7 @@ func ResourceBeyondcorpAppGateway() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -244,6 +245,18 @@ Please refer to the field 'effective_labels' for all of the labels present on th Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -399,6 +412,19 @@ func resourceBeyondcorpAppGatewayRead(d *schema.ResourceData, meta interface{}) log.Printf("[DEBUG] Finished reading BeyondcorpAppGateway %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading AppGateway: %s", err) } @@ -436,11 +462,18 @@ func resourceBeyondcorpAppGatewayRead(d *schema.ResourceData, meta interface{}) } func resourceBeyondcorpAppGatewayUpdate(d *schema.ResourceData, meta interface{}) error { - // Only the root field "labels", "terraform_labels", and virtual fields are mutable + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable return resourceBeyondcorpAppGatewayRead(d, meta) } func resourceBeyondcorpAppGatewayDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy BeyondcorpAppGateway without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing AppGateway %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/beyondcorp/resource_beyondcorp_app_gateway_generated_meta.yaml b/google/services/beyondcorp/resource_beyondcorp_app_gateway_generated_meta.yaml index a08a24f186d..9cbf203fb7d 100644 --- a/google/services/beyondcorp/resource_beyondcorp_app_gateway_generated_meta.yaml +++ b/google/services/beyondcorp/resource_beyondcorp_app_gateway_generated_meta.yaml @@ -23,3 +23,5 @@ fields: provider_only: true - api_field: type - api_field: uri + - field: deletion_policy + provider_only: true diff --git a/google/services/beyondcorp/resource_beyondcorp_security_gateway.go b/google/services/beyondcorp/resource_beyondcorp_security_gateway.go index 9288be3563a..638fa66bd2c 100644 --- a/google/services/beyondcorp/resource_beyondcorp_security_gateway.go +++ b/google/services/beyondcorp/resource_beyondcorp_security_gateway.go @@ -128,6 +128,7 @@ func ResourceBeyondcorpSecurityGateway() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -407,6 +408,18 @@ ERROR`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -568,6 +581,19 @@ func resourceBeyondcorpSecurityGatewayRead(d *schema.ResourceData, meta interfac log.Printf("[DEBUG] Finished reading BeyondcorpSecurityGateway %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading SecurityGateway: %s", err) } @@ -605,6 +631,19 @@ func resourceBeyondcorpSecurityGatewayRead(d *schema.ResourceData, meta interfac } func resourceBeyondcorpSecurityGatewayUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceBeyondcorpSecurityGateway().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceBeyondcorpSecurityGatewayRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -743,6 +782,13 @@ func resourceBeyondcorpSecurityGatewayUpdate(d *schema.ResourceData, meta interf } func resourceBeyondcorpSecurityGatewayDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy BeyondcorpSecurityGateway without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing SecurityGateway %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/beyondcorp/resource_beyondcorp_security_gateway_application.go b/google/services/beyondcorp/resource_beyondcorp_security_gateway_application.go index ddf2e64767e..cc42f6a77d5 100644 --- a/google/services/beyondcorp/resource_beyondcorp_security_gateway_application.go +++ b/google/services/beyondcorp/resource_beyondcorp_security_gateway_application.go @@ -115,6 +115,7 @@ func ResourceBeyondcorpSecurityGatewayApplication() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -397,6 +398,18 @@ The names should conform to RFC 9110: Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -552,6 +565,19 @@ func resourceBeyondcorpSecurityGatewayApplicationRead(d *schema.ResourceData, me log.Printf("[DEBUG] Finished reading BeyondcorpSecurityGatewayApplication %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading SecurityGatewayApplication: %s", err) } @@ -589,6 +615,19 @@ func resourceBeyondcorpSecurityGatewayApplicationRead(d *schema.ResourceData, me } func resourceBeyondcorpSecurityGatewayApplicationUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceBeyondcorpSecurityGatewayApplication().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceBeyondcorpSecurityGatewayApplicationRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -717,6 +756,13 @@ func resourceBeyondcorpSecurityGatewayApplicationUpdate(d *schema.ResourceData, } func resourceBeyondcorpSecurityGatewayApplicationDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy BeyondcorpSecurityGatewayApplication without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing SecurityGatewayApplication %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/beyondcorp/resource_beyondcorp_security_gateway_application_generated_meta.yaml b/google/services/beyondcorp/resource_beyondcorp_security_gateway_application_generated_meta.yaml index b3064ad3ea0..dbf6218940e 100644 --- a/google/services/beyondcorp/resource_beyondcorp_security_gateway_application_generated_meta.yaml +++ b/google/services/beyondcorp/resource_beyondcorp_security_gateway_application_generated_meta.yaml @@ -31,3 +31,5 @@ fields: - api_field: upstreams.proxyProtocol.contextualHeaders.userInfo.outputType - api_field: upstreams.proxyProtocol.gatewayIdentity - api_field: upstreams.proxyProtocol.metadataHeaders + - field: deletion_policy + provider_only: true diff --git a/google/services/beyondcorp/resource_beyondcorp_security_gateway_generated_meta.yaml b/google/services/beyondcorp/resource_beyondcorp_security_gateway_generated_meta.yaml index eca7444960a..f5f91b030d3 100644 --- a/google/services/beyondcorp/resource_beyondcorp_security_gateway_generated_meta.yaml +++ b/google/services/beyondcorp/resource_beyondcorp_security_gateway_generated_meta.yaml @@ -33,3 +33,5 @@ fields: - api_field: serviceDiscovery.apiGateway.resourceOverride.path - api_field: state - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/biglake/resource_biglake_catalog.go b/google/services/biglake/resource_biglake_catalog.go index aa62e8b8364..8462017d563 100644 --- a/google/services/biglake/resource_biglake_catalog.go +++ b/google/services/biglake/resource_biglake_catalog.go @@ -100,6 +100,7 @@ func ResourceBiglakeCatalog() *schema.Resource { return &schema.Resource{ Create: resourceBiglakeCatalogCreate, Read: resourceBiglakeCatalogRead, + Update: resourceBiglakeCatalogUpdate, Delete: resourceBiglakeCatalogDelete, Importer: &schema.ResourceImporter{ @@ -113,6 +114,7 @@ func ResourceBiglakeCatalog() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -187,6 +189,18 @@ fractional digits.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -308,6 +322,19 @@ func resourceBiglakeCatalogRead(d *schema.ResourceData, meta interface{}) error log.Printf("[DEBUG] Finished reading BiglakeCatalog %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Catalog: %s", err) } @@ -344,7 +371,19 @@ func resourceBiglakeCatalogRead(d *schema.ResourceData, meta interface{}) error return nil } +func resourceBiglakeCatalogUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceBiglakeCatalogRead(d, meta) +} + func resourceBiglakeCatalogDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy BiglakeCatalog without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Catalog %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/biglake/resource_biglake_catalog_generated_meta.yaml b/google/services/biglake/resource_biglake_catalog_generated_meta.yaml index 57809297d15..4bad2a73fa0 100644 --- a/google/services/biglake/resource_biglake_catalog_generated_meta.yaml +++ b/google/services/biglake/resource_biglake_catalog_generated_meta.yaml @@ -15,3 +15,5 @@ fields: - field: name provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/biglake/resource_biglake_database.go b/google/services/biglake/resource_biglake_database.go index 59a83f7a5ab..0b018dadddb 100644 --- a/google/services/biglake/resource_biglake_database.go +++ b/google/services/biglake/resource_biglake_database.go @@ -205,6 +205,19 @@ RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -321,6 +334,20 @@ func resourceBiglakeDatabaseRead(d *schema.ResourceData, meta interface{}) error log.Printf("[DEBUG] Finished reading BiglakeDatabase %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceBiglakeDatabaseFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -348,6 +375,19 @@ func resourceBiglakeDatabaseRead(d *schema.ResourceData, meta interface{}) error } func resourceBiglakeDatabaseUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceBiglakeDatabase().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceBiglakeDatabaseRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -438,6 +478,13 @@ func resourceBiglakeDatabaseUpdate(d *schema.ResourceData, meta interface{}) err } func resourceBiglakeDatabaseDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy BiglakeDatabase without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Database %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/biglake/resource_biglake_database_generated_meta.yaml b/google/services/biglake/resource_biglake_database_generated_meta.yaml index 394ccc9d6db..e1aafe3c820 100644 --- a/google/services/biglake/resource_biglake_database_generated_meta.yaml +++ b/google/services/biglake/resource_biglake_database_generated_meta.yaml @@ -18,3 +18,5 @@ fields: provider_only: true - api_field: type - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/biglake/resource_biglake_table.go b/google/services/biglake/resource_biglake_table.go index ebd6436295a..d78f77f030c 100644 --- a/google/services/biglake/resource_biglake_table.go +++ b/google/services/biglake/resource_biglake_table.go @@ -240,6 +240,19 @@ RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -356,6 +369,20 @@ func resourceBiglakeTableRead(d *schema.ResourceData, meta interface{}) error { log.Printf("[DEBUG] Finished reading BiglakeTable %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceBiglakeTableFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -383,6 +410,19 @@ func resourceBiglakeTableRead(d *schema.ResourceData, meta interface{}) error { } func resourceBiglakeTableUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceBiglakeTable().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceBiglakeTableRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -473,6 +513,13 @@ func resourceBiglakeTableUpdate(d *schema.ResourceData, meta interface{}) error } func resourceBiglakeTableDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy BiglakeTable without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Table %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/biglake/resource_biglake_table_generated_meta.yaml b/google/services/biglake/resource_biglake_table_generated_meta.yaml index e1f3a490db4..abdc58b8807 100644 --- a/google/services/biglake/resource_biglake_table_generated_meta.yaml +++ b/google/services/biglake/resource_biglake_table_generated_meta.yaml @@ -22,3 +22,5 @@ fields: provider_only: true - api_field: type - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/biglakeiceberg/resource_biglake_iceberg_catalog.go b/google/services/biglakeiceberg/resource_biglake_iceberg_catalog.go index e4df27922e3..f45c6410dcb 100644 --- a/google/services/biglakeiceberg/resource_biglake_iceberg_catalog.go +++ b/google/services/biglakeiceberg/resource_biglake_iceberg_catalog.go @@ -115,6 +115,7 @@ func ResourceBiglakeIcebergIcebergCatalog() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -221,6 +222,18 @@ catalog's location.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -357,6 +370,19 @@ func resourceBiglakeIcebergIcebergCatalogRead(d *schema.ResourceData, meta inter log.Printf("[DEBUG] Finished reading BiglakeIcebergIcebergCatalog %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading IcebergCatalog: %s", err) } @@ -388,6 +414,19 @@ func resourceBiglakeIcebergIcebergCatalogRead(d *schema.ResourceData, meta inter } func resourceBiglakeIcebergIcebergCatalogUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceBiglakeIcebergIcebergCatalog().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceBiglakeIcebergIcebergCatalogRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -462,6 +501,13 @@ func resourceBiglakeIcebergIcebergCatalogUpdate(d *schema.ResourceData, meta int } func resourceBiglakeIcebergIcebergCatalogDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy BiglakeIcebergIcebergCatalog without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing IcebergCatalog %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/biglakeiceberg/resource_biglake_iceberg_catalog_generated_meta.yaml b/google/services/biglakeiceberg/resource_biglake_iceberg_catalog_generated_meta.yaml index bf93fe03c34..4a2ca3effe7 100644 --- a/google/services/biglakeiceberg/resource_biglake_iceberg_catalog_generated_meta.yaml +++ b/google/services/biglakeiceberg/resource_biglake_iceberg_catalog_generated_meta.yaml @@ -20,3 +20,5 @@ fields: - api_field: replicas.state - api_field: storage-regions - api_field: update-time + - field: deletion_policy + provider_only: true diff --git a/google/services/biglakeiceberg/resource_biglake_iceberg_namespace.go b/google/services/biglakeiceberg/resource_biglake_iceberg_namespace.go index 8e64a3b44f7..80b10b41e2e 100644 --- a/google/services/biglakeiceberg/resource_biglake_iceberg_namespace.go +++ b/google/services/biglakeiceberg/resource_biglake_iceberg_namespace.go @@ -128,6 +128,7 @@ func ResourceBiglakeIcebergIcebergNamespace() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -180,6 +181,18 @@ func ResourceBiglakeIcebergIcebergNamespace() *schema.Resource { Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -321,6 +334,19 @@ func resourceBiglakeIcebergIcebergNamespaceRead(d *schema.ResourceData, meta int log.Printf("[DEBUG] Finished reading BiglakeIcebergIcebergNamespace %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading IcebergNamespace: %s", err) } @@ -358,6 +384,19 @@ func resourceBiglakeIcebergIcebergNamespaceRead(d *schema.ResourceData, meta int } func resourceBiglakeIcebergIcebergNamespaceUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceBiglakeIcebergIcebergNamespace().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceBiglakeIcebergIcebergNamespaceRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -448,6 +487,13 @@ func resourceBiglakeIcebergIcebergNamespaceUpdate(d *schema.ResourceData, meta i } func resourceBiglakeIcebergIcebergNamespaceDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy BiglakeIcebergIcebergNamespace without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing IcebergNamespace %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/biglakeiceberg/resource_biglake_iceberg_namespace_generated_meta.yaml b/google/services/biglakeiceberg/resource_biglake_iceberg_namespace_generated_meta.yaml index c95c9da02a8..de5865c3941 100644 --- a/google/services/biglakeiceberg/resource_biglake_iceberg_namespace_generated_meta.yaml +++ b/google/services/biglakeiceberg/resource_biglake_iceberg_namespace_generated_meta.yaml @@ -12,3 +12,5 @@ fields: - api_field: namespace field: namespace_id - api_field: properties + - field: deletion_policy + provider_only: true diff --git a/google/services/biglakeiceberg/resource_biglake_iceberg_table.go b/google/services/biglakeiceberg/resource_biglake_iceberg_table.go index 7827ae0b516..396e66fd07e 100644 --- a/google/services/biglakeiceberg/resource_biglake_iceberg_table.go +++ b/google/services/biglakeiceberg/resource_biglake_iceberg_table.go @@ -131,6 +131,7 @@ func ResourceBiglakeIcebergIcebergTable() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -309,6 +310,18 @@ func ResourceBiglakeIcebergIcebergTable() *schema.Resource { Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -564,6 +577,19 @@ func resourceBiglakeIcebergIcebergTableRead(d *schema.ResourceData, meta interfa } } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading IcebergTable: %s", err) } @@ -607,6 +633,19 @@ func resourceBiglakeIcebergIcebergTableRead(d *schema.ResourceData, meta interfa } func resourceBiglakeIcebergIcebergTableUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceBiglakeIcebergIcebergTable().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceBiglakeIcebergIcebergTableRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -720,6 +759,13 @@ func resourceBiglakeIcebergIcebergTableUpdate(d *schema.ResourceData, meta inter } func resourceBiglakeIcebergIcebergTableDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy BiglakeIcebergIcebergTable without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing IcebergTable %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/biglakeiceberg/resource_biglake_iceberg_table_generated_meta.yaml b/google/services/biglakeiceberg/resource_biglake_iceberg_table_generated_meta.yaml index 04a263089ef..68e1b3bd1cd 100644 --- a/google/services/biglakeiceberg/resource_biglake_iceberg_table_generated_meta.yaml +++ b/google/services/biglakeiceberg/resource_biglake_iceberg_table_generated_meta.yaml @@ -27,3 +27,5 @@ fields: - api_field: schema.identifier-field-ids - api_field: schema.schema-id - api_field: schema.type + - field: deletion_policy + provider_only: true diff --git a/google/services/bigquery/resource_bigquery_dataset.go b/google/services/bigquery/resource_bigquery_dataset.go index 7b7ab43ab19..ee0bd560a71 100644 --- a/google/services/bigquery/resource_bigquery_dataset.go +++ b/google/services/bigquery/resource_bigquery_dataset.go @@ -204,6 +204,7 @@ func ResourceBigQueryDataset() *schema.Resource { customCollationDiff, tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -458,6 +459,18 @@ destroying the resource will fail if tables are present.`, Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -844,6 +857,18 @@ func resourceBigQueryDatasetRead(d *schema.ResourceData, meta interface{}) error return fmt.Errorf("Error setting delete_contents_on_destroy: %s", err) } } + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Dataset: %s", err) } @@ -857,6 +882,19 @@ func resourceBigQueryDatasetRead(d *schema.ResourceData, meta interface{}) error } func resourceBigQueryDatasetUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceBigQueryDataset().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceBigQueryDatasetRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1003,6 +1041,13 @@ func resourceBigQueryDatasetUpdate(d *schema.ResourceData, meta interface{}) err } func resourceBigQueryDatasetDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy BigQueryDataset without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Dataset %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/bigquery/resource_bigquery_dataset_access.go b/google/services/bigquery/resource_bigquery_dataset_access.go index 73207d82439..c3e0f3e3d6c 100644 --- a/google/services/bigquery/resource_bigquery_dataset_access.go +++ b/google/services/bigquery/resource_bigquery_dataset_access.go @@ -223,6 +223,7 @@ func ResourceBigQueryDatasetAccess() *schema.Resource { return &schema.Resource{ Create: resourceBigQueryDatasetAccessCreate, Read: resourceBigQueryDatasetAccessRead, + Update: resourceBigQueryDatasetAccessUpdate, Delete: resourceBigQueryDatasetAccessDelete, Timeouts: &schema.ResourceTimeout{ @@ -232,6 +233,7 @@ func ResourceBigQueryDatasetAccess() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -489,6 +491,18 @@ is 1,024 characters.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -725,6 +739,19 @@ func resourceBigQueryDatasetAccessRead(d *schema.ResourceData, meta interface{}) return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading DatasetAccess: %s", err) } @@ -755,7 +782,19 @@ func resourceBigQueryDatasetAccessRead(d *schema.ResourceData, meta interface{}) return nil } +func resourceBigQueryDatasetAccessUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceBigQueryDatasetAccessRead(d, meta) +} + func resourceBigQueryDatasetAccessDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy BigQueryDatasetAccess without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing DatasetAccess %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/bigquery/resource_bigquery_dataset_access_generated_meta.yaml b/google/services/bigquery/resource_bigquery_dataset_access_generated_meta.yaml index 14488014f96..ceddea13bc0 100644 --- a/google/services/bigquery/resource_bigquery_dataset_access_generated_meta.yaml +++ b/google/services/bigquery/resource_bigquery_dataset_access_generated_meta.yaml @@ -47,3 +47,5 @@ fields: field: view.project_id - api_field: access.view.tableId field: view.table_id + - field: deletion_policy + provider_only: true diff --git a/google/services/bigquery/resource_bigquery_dataset_generated_meta.yaml b/google/services/bigquery/resource_bigquery_dataset_generated_meta.yaml index eb728770782..062cd728692 100644 --- a/google/services/bigquery/resource_bigquery_dataset_generated_meta.yaml +++ b/google/services/bigquery/resource_bigquery_dataset_generated_meta.yaml @@ -54,3 +54,5 @@ fields: - field: terraform_labels provider_only: true - api_field: selfLink + - field: deletion_policy + provider_only: true diff --git a/google/services/bigquery/resource_bigquery_job.go b/google/services/bigquery/resource_bigquery_job.go index 87a9b8f37dc..8023f489f18 100644 --- a/google/services/bigquery/resource_bigquery_job.go +++ b/google/services/bigquery/resource_bigquery_job.go @@ -1273,7 +1273,7 @@ func resourceBigQueryJobRead(d *schema.ResourceData, meta interface{}) error { } func resourceBigQueryJobUpdate(d *schema.ResourceData, meta interface{}) error { - // Only the root field "labels", "terraform_labels", and virtual fields are mutable + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable return resourceBigQueryJobRead(d, meta) } diff --git a/google/services/bigquery/resource_bigquery_routine.go b/google/services/bigquery/resource_bigquery_routine.go index 8d5d6be3903..f7b76ad1baa 100644 --- a/google/services/bigquery/resource_bigquery_routine.go +++ b/google/services/bigquery/resource_bigquery_routine.go @@ -115,6 +115,7 @@ func ResourceBigQueryRoutine() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -391,6 +392,18 @@ epoch.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -575,6 +588,19 @@ func resourceBigQueryRoutineRead(d *schema.ResourceData, meta interface{}) error log.Printf("[DEBUG] Finished reading BigQueryRoutine %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Routine: %s", err) } @@ -588,6 +614,19 @@ func resourceBigQueryRoutineRead(d *schema.ResourceData, meta interface{}) error } func resourceBigQueryRoutineUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceBigQueryRoutine().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceBigQueryRoutineRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -722,6 +761,13 @@ func resourceBigQueryRoutineUpdate(d *schema.ResourceData, meta interface{}) err } func resourceBigQueryRoutineDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy BigQueryRoutine without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Routine %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/bigquery/resource_bigquery_routine_generated_meta.yaml b/google/services/bigquery/resource_bigquery_routine_generated_meta.yaml index b0eee0fef26..78e3570cd99 100644 --- a/google/services/bigquery/resource_bigquery_routine_generated_meta.yaml +++ b/google/services/bigquery/resource_bigquery_routine_generated_meta.yaml @@ -44,3 +44,5 @@ fields: - api_field: sparkOptions.properties - api_field: sparkOptions.pyFileUris - api_field: sparkOptions.runtimeVersion + - field: deletion_policy + provider_only: true diff --git a/google/services/bigquery/resource_bigquery_row_access_policy.go b/google/services/bigquery/resource_bigquery_row_access_policy.go index 07037964b71..f8a37958fb6 100644 --- a/google/services/bigquery/resource_bigquery_row_access_policy.go +++ b/google/services/bigquery/resource_bigquery_row_access_policy.go @@ -115,6 +115,7 @@ func ResourceBigQueryRowAccessPolicy() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -200,6 +201,18 @@ since the epoch.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -318,6 +331,19 @@ func resourceBigQueryRowAccessPolicyRead(d *schema.ResourceData, meta interface{ log.Printf("[DEBUG] Finished reading BigQueryRowAccessPolicy %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading RowAccessPolicy: %s", err) } @@ -331,6 +357,19 @@ func resourceBigQueryRowAccessPolicyRead(d *schema.ResourceData, meta interface{ } func resourceBigQueryRowAccessPolicyUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceBigQueryRowAccessPolicy().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceBigQueryRowAccessPolicyRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -399,6 +438,13 @@ func resourceBigQueryRowAccessPolicyUpdate(d *schema.ResourceData, meta interfac } func resourceBigQueryRowAccessPolicyDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy BigQueryRowAccessPolicy without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing RowAccessPolicy %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/bigquery/resource_bigquery_row_access_policy_generated_meta.yaml b/google/services/bigquery/resource_bigquery_row_access_policy_generated_meta.yaml index 1124623d130..b74f6800d04 100644 --- a/google/services/bigquery/resource_bigquery_row_access_policy_generated_meta.yaml +++ b/google/services/bigquery/resource_bigquery_row_access_policy_generated_meta.yaml @@ -17,3 +17,5 @@ fields: field: policy_id - api_field: rowAccessPolicyReference.tableId field: table_id + - field: deletion_policy + provider_only: true diff --git a/google/services/bigquery/resource_bigquery_table.go b/google/services/bigquery/resource_bigquery_table.go index 11fb0604eb3..482cc066426 100644 --- a/google/services/bigquery/resource_bigquery_table.go +++ b/google/services/bigquery/resource_bigquery_table.go @@ -702,6 +702,7 @@ func ResourceBigQueryTable() *schema.Resource { State: resourceBigQueryTableImport, }, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), tpgresource.DefaultProviderProject, resourceBigQueryTableSchemaCustomizeDiff, tpgresource.SetLabelsDiff, @@ -1853,6 +1854,9 @@ func ResourceBigQueryTable() *schema.Resource { }, }, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, UseJSONNumber: true, } @@ -2399,6 +2403,10 @@ func resourceBigQueryTableRead(d *schema.ResourceData, meta interface{}) error { } } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } @@ -2429,7 +2437,7 @@ func addAutoGenSchemaFields(d *schema.ResourceData, table *bigquery.Table) error func resourceBigQueryTableUpdate(d *schema.ResourceData, meta interface{}) error { // If only client-side fields were modified, short-circuit the Update function to avoid sending an update API request. - clientSideFields := map[string]bool{"deletion_protection": true, "ignore_schema_changes": true, "ignore_auto_generated_schema": true, "table_metadata_view": true} + clientSideFields := map[string]bool{"deletion_protection": true, "ignore_schema_changes": true, "ignore_auto_generated_schema": true, "table_metadata_view": true, "deletion_policy": true} clientSideOnly := true for field := range ResourceBigQueryTable().Schema { if d.HasChange(field) && !clientSideFields[field] { @@ -2569,6 +2577,13 @@ func resourceBigQueryTableColumnDrop(config *transport_tpg.Config, userAgent str } func resourceBigQueryTableDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + if d.Get("deletion_protection").(bool) { return fmt.Errorf("cannot destroy table %v without setting deletion_protection=false and running `terraform apply`", d.Id()) } diff --git a/google/services/bigquery/resource_bigquery_table_meta.yaml b/google/services/bigquery/resource_bigquery_table_meta.yaml index bdc43097c58..ccc6aedb5d6 100644 --- a/google/services/bigquery/resource_bigquery_table_meta.yaml +++ b/google/services/bigquery/resource_bigquery_table_meta.yaml @@ -136,3 +136,5 @@ fields: - api_field: 'type' - api_field: 'view.query' - api_field: 'view.useLegacySql' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/bigqueryanalyticshub/resource_bigquery_analytics_hub_data_exchange.go b/google/services/bigqueryanalyticshub/resource_bigquery_analytics_hub_data_exchange.go index 2edfa4e81fe..7eeed551643 100644 --- a/google/services/bigqueryanalyticshub/resource_bigquery_analytics_hub_data_exchange.go +++ b/google/services/bigqueryanalyticshub/resource_bigquery_analytics_hub_data_exchange.go @@ -115,6 +115,7 @@ func ResourceBigqueryAnalyticsHubDataExchange() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -242,6 +243,18 @@ This field is required for data clean room exchanges.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -411,6 +424,19 @@ func resourceBigqueryAnalyticsHubDataExchangeRead(d *schema.ResourceData, meta i log.Printf("[DEBUG] Finished reading BigqueryAnalyticsHubDataExchange %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading DataExchange: %s", err) } @@ -448,6 +474,19 @@ func resourceBigqueryAnalyticsHubDataExchangeRead(d *schema.ResourceData, meta i } func resourceBigqueryAnalyticsHubDataExchangeUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceBigqueryAnalyticsHubDataExchange().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceBigqueryAnalyticsHubDataExchangeRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -599,6 +638,13 @@ func resourceBigqueryAnalyticsHubDataExchangeUpdate(d *schema.ResourceData, meta } func resourceBigqueryAnalyticsHubDataExchangeDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy BigqueryAnalyticsHubDataExchange without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing DataExchange %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/bigqueryanalyticshub/resource_bigquery_analytics_hub_data_exchange_generated_meta.yaml b/google/services/bigqueryanalyticshub/resource_bigquery_analytics_hub_data_exchange_generated_meta.yaml index f8c10a48566..f436b8ef675 100644 --- a/google/services/bigqueryanalyticshub/resource_bigquery_analytics_hub_data_exchange_generated_meta.yaml +++ b/google/services/bigqueryanalyticshub/resource_bigquery_analytics_hub_data_exchange_generated_meta.yaml @@ -22,3 +22,5 @@ fields: - api_field: primaryContact - api_field: sharingEnvironmentConfig.dcrExchangeConfig - api_field: sharingEnvironmentConfig.defaultExchangeConfig + - field: deletion_policy + provider_only: true diff --git a/google/services/bigqueryanalyticshub/resource_bigquery_analytics_hub_listing.go b/google/services/bigqueryanalyticshub/resource_bigquery_analytics_hub_listing.go index 70451a4edc5..864fa2e762b 100644 --- a/google/services/bigqueryanalyticshub/resource_bigquery_analytics_hub_listing.go +++ b/google/services/bigqueryanalyticshub/resource_bigquery_analytics_hub_listing.go @@ -115,6 +115,7 @@ func ResourceBigqueryAnalyticsHubListing() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -443,6 +444,18 @@ Possible values: COMMERCIAL_STATE_UNSPECIFIED, ONBOARDING, ACTIVE`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -660,6 +673,18 @@ func resourceBigqueryAnalyticsHubListingRead(d *schema.ResourceData, meta interf log.Printf("[DEBUG] Finished reading BigqueryAnalyticsHubListing %q: %#v", d.Id(), res) // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Listing: %s", err) } @@ -703,6 +728,19 @@ func resourceBigqueryAnalyticsHubListingRead(d *schema.ResourceData, meta interf } func resourceBigqueryAnalyticsHubListingUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceBigqueryAnalyticsHubListing().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceBigqueryAnalyticsHubListingRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -968,6 +1006,13 @@ func resourceBigqueryAnalyticsHubListingUpdate(d *schema.ResourceData, meta inte } func resourceBigqueryAnalyticsHubListingDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy BigqueryAnalyticsHubListing without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Listing %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/bigqueryanalyticshub/resource_bigquery_analytics_hub_listing_generated_meta.yaml b/google/services/bigqueryanalyticshub/resource_bigquery_analytics_hub_listing_generated_meta.yaml index 965d2aad422..f834f728b50 100644 --- a/google/services/bigqueryanalyticshub/resource_bigquery_analytics_hub_listing_generated_meta.yaml +++ b/google/services/bigqueryanalyticshub/resource_bigquery_analytics_hub_listing_generated_meta.yaml @@ -45,3 +45,5 @@ fields: - api_field: restrictedExportConfig.restrictDirectTableAccess - api_field: restrictedExportConfig.restrictQueryResult - api_field: state + - field: deletion_policy + provider_only: true diff --git a/google/services/bigqueryanalyticshub/resource_bigquery_analytics_hub_listing_subscription.go b/google/services/bigqueryanalyticshub/resource_bigquery_analytics_hub_listing_subscription.go index 45699174475..d0db20a3d9f 100644 --- a/google/services/bigqueryanalyticshub/resource_bigquery_analytics_hub_listing_subscription.go +++ b/google/services/bigqueryanalyticshub/resource_bigquery_analytics_hub_listing_subscription.go @@ -106,6 +106,7 @@ func ResourceBigqueryAnalyticsHubListingSubscription() *schema.Resource { return &schema.Resource{ Create: resourceBigqueryAnalyticsHubListingSubscriptionCreate, Read: resourceBigqueryAnalyticsHubListingSubscriptionRead, + Update: resourceBigqueryAnalyticsHubListingSubscriptionUpdate, Delete: resourceBigqueryAnalyticsHubListingSubscriptionDelete, Importer: &schema.ResourceImporter{ @@ -119,6 +120,7 @@ func ResourceBigqueryAnalyticsHubListingSubscription() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -359,6 +361,18 @@ e.g. projects/123/locations/US/dataExchanges/456/listings/789 -> projects/123/da Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -531,6 +545,19 @@ func resourceBigqueryAnalyticsHubListingSubscriptionRead(d *schema.ResourceData, return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading ListingSubscription: %s", err) } @@ -567,7 +594,19 @@ func resourceBigqueryAnalyticsHubListingSubscriptionRead(d *schema.ResourceData, return nil } +func resourceBigqueryAnalyticsHubListingSubscriptionUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceBigqueryAnalyticsHubListingSubscriptionRead(d, meta) +} + func resourceBigqueryAnalyticsHubListingSubscriptionDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy BigqueryAnalyticsHubListingSubscription without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ListingSubscription %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/bigqueryanalyticshub/resource_bigquery_analytics_hub_listing_subscription_generated_meta.yaml b/google/services/bigqueryanalyticshub/resource_bigquery_analytics_hub_listing_subscription_generated_meta.yaml index 2ff273a82fd..04ff84c7c41 100644 --- a/google/services/bigqueryanalyticshub/resource_bigquery_analytics_hub_listing_subscription_generated_meta.yaml +++ b/google/services/bigqueryanalyticshub/resource_bigquery_analytics_hub_listing_subscription_generated_meta.yaml @@ -39,3 +39,5 @@ fields: - api_field: state - api_field: subscriberContact - api_field: subscriptionId + - field: deletion_policy + provider_only: true diff --git a/google/services/bigqueryconnection/resource_bigquery_connection.go b/google/services/bigqueryconnection/resource_bigquery_connection.go index d964580b8f4..72967475a48 100644 --- a/google/services/bigqueryconnection/resource_bigquery_connection.go +++ b/google/services/bigqueryconnection/resource_bigquery_connection.go @@ -115,6 +115,7 @@ func ResourceBigqueryConnectionConnection() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -565,6 +566,18 @@ Azure allowed regions are azure-eastus2`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -763,6 +776,19 @@ func resourceBigqueryConnectionConnectionRead(d *schema.ResourceData, meta inter log.Printf("[DEBUG] Finished reading BigqueryConnectionConnection %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Connection: %s", err) } @@ -800,6 +826,19 @@ func resourceBigqueryConnectionConnectionRead(d *schema.ResourceData, meta inter } func resourceBigqueryConnectionConnectionUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceBigqueryConnectionConnection().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceBigqueryConnectionConnectionRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -987,6 +1026,13 @@ func resourceBigqueryConnectionConnectionUpdate(d *schema.ResourceData, meta int } func resourceBigqueryConnectionConnectionDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy BigqueryConnectionConnection without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Connection %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/bigqueryconnection/resource_bigquery_connection_generated_meta.yaml b/google/services/bigqueryconnection/resource_bigquery_connection_generated_meta.yaml index 7871a93d364..4efacb6e827 100644 --- a/google/services/bigqueryconnection/resource_bigquery_connection_generated_meta.yaml +++ b/google/services/bigqueryconnection/resource_bigquery_connection_generated_meta.yaml @@ -49,3 +49,5 @@ fields: - api_field: spark.metastoreServiceConfig.metastoreService - api_field: spark.serviceAccountId - api_field: spark.sparkHistoryServerConfig.dataprocCluster + - field: deletion_policy + provider_only: true diff --git a/google/services/bigquerydatapolicy/resource_bigquery_datapolicy_data_policy.go b/google/services/bigquerydatapolicy/resource_bigquery_datapolicy_data_policy.go index cf473755038..5a17eca36c1 100644 --- a/google/services/bigquerydatapolicy/resource_bigquery_datapolicy_data_policy.go +++ b/google/services/bigquerydatapolicy/resource_bigquery_datapolicy_data_policy.go @@ -115,6 +115,7 @@ func ResourceBigqueryDatapolicyDataPolicy() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -200,6 +201,18 @@ func ResourceBigqueryDatapolicyDataPolicy() *schema.Resource { Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -345,6 +358,19 @@ func resourceBigqueryDatapolicyDataPolicyRead(d *schema.ResourceData, meta inter log.Printf("[DEBUG] Finished reading BigqueryDatapolicyDataPolicy %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading DataPolicy: %s", err) } @@ -382,6 +408,19 @@ func resourceBigqueryDatapolicyDataPolicyRead(d *schema.ResourceData, meta inter } func resourceBigqueryDatapolicyDataPolicyUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceBigqueryDatapolicyDataPolicy().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceBigqueryDatapolicyDataPolicyRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -493,6 +532,13 @@ func resourceBigqueryDatapolicyDataPolicyUpdate(d *schema.ResourceData, meta int } func resourceBigqueryDatapolicyDataPolicyDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy BigqueryDatapolicyDataPolicy without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing DataPolicy %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/bigquerydatapolicy/resource_bigquery_datapolicy_data_policy_generated_meta.yaml b/google/services/bigquerydatapolicy/resource_bigquery_datapolicy_data_policy_generated_meta.yaml index 25d43873590..868e1e24c41 100644 --- a/google/services/bigquerydatapolicy/resource_bigquery_datapolicy_data_policy_generated_meta.yaml +++ b/google/services/bigquerydatapolicy/resource_bigquery_datapolicy_data_policy_generated_meta.yaml @@ -15,3 +15,5 @@ fields: provider_only: true - api_field: name - api_field: policyTag + - field: deletion_policy + provider_only: true diff --git a/google/services/bigquerydatapolicyv2/resource_bigquery_datapolicyv2_data_policy.go b/google/services/bigquerydatapolicyv2/resource_bigquery_datapolicyv2_data_policy.go index 2400360c28b..2d036283093 100644 --- a/google/services/bigquerydatapolicyv2/resource_bigquery_datapolicyv2_data_policy.go +++ b/google/services/bigquerydatapolicyv2/resource_bigquery_datapolicyv2_data_policy.go @@ -115,6 +115,7 @@ func ResourceBigqueryDatapolicyv2DataPolicy() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -248,6 +249,18 @@ V2`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -404,6 +417,19 @@ func resourceBigqueryDatapolicyv2DataPolicyRead(d *schema.ResourceData, meta int log.Printf("[DEBUG] Finished reading BigqueryDatapolicyv2DataPolicy %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading DataPolicy: %s", err) } @@ -441,6 +467,19 @@ func resourceBigqueryDatapolicyv2DataPolicyRead(d *schema.ResourceData, meta int } func resourceBigqueryDatapolicyv2DataPolicyUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceBigqueryDatapolicyv2DataPolicy().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceBigqueryDatapolicyv2DataPolicyRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -577,6 +616,13 @@ func resourceBigqueryDatapolicyv2DataPolicyUpdate(d *schema.ResourceData, meta i } func resourceBigqueryDatapolicyv2DataPolicyDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy BigqueryDatapolicyv2DataPolicy without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing DataPolicy %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/bigquerydatapolicyv2/resource_bigquery_datapolicyv2_data_policy_generated_meta.yaml b/google/services/bigquerydatapolicyv2/resource_bigquery_datapolicyv2_data_policy_generated_meta.yaml index de4c149861a..3dc7aa51180 100644 --- a/google/services/bigquerydatapolicyv2/resource_bigquery_datapolicyv2_data_policy_generated_meta.yaml +++ b/google/services/bigquerydatapolicyv2/resource_bigquery_datapolicyv2_data_policy_generated_meta.yaml @@ -18,3 +18,5 @@ fields: - api_field: name - api_field: policyTag - api_field: version + - field: deletion_policy + provider_only: true diff --git a/google/services/bigquerydatatransfer/resource_bigquery_data_transfer_config.go b/google/services/bigquerydatatransfer/resource_bigquery_data_transfer_config.go index 4b78c9eaa67..c54c598be53 100644 --- a/google/services/bigquerydatatransfer/resource_bigquery_data_transfer_config.go +++ b/google/services/bigquerydatatransfer/resource_bigquery_data_transfer_config.go @@ -192,6 +192,7 @@ func ResourceBigqueryDataTransferConfig() *schema.Resource { sensitiveParamCustomizeDiff, paramsCustomizeDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -412,6 +413,18 @@ The name is ignored when creating a transfer config.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -619,6 +632,19 @@ func resourceBigqueryDataTransferConfigRead(d *schema.ResourceData, meta interfa return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Config: %s", err) } @@ -650,6 +676,19 @@ func resourceBigqueryDataTransferConfigRead(d *schema.ResourceData, meta interfa } func resourceBigqueryDataTransferConfigUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceBigqueryDataTransferConfig().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceBigqueryDataTransferConfigRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -830,6 +869,13 @@ func resourceBigqueryDataTransferConfigUpdate(d *schema.ResourceData, meta inter } func resourceBigqueryDataTransferConfigDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy BigqueryDataTransferConfig without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Config %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/bigquerydatatransfer/resource_bigquery_data_transfer_config_generated_meta.yaml b/google/services/bigquerydatatransfer/resource_bigquery_data_transfer_config_generated_meta.yaml index 84ea392650b..c63e640ce64 100644 --- a/google/services/bigquerydatatransfer/resource_bigquery_data_transfer_config_generated_meta.yaml +++ b/google/services/bigquerydatatransfer/resource_bigquery_data_transfer_config_generated_meta.yaml @@ -31,3 +31,5 @@ fields: provider_only: true - field: service_account_name provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/bigqueryreservation/resource_bigquery_bi_reservation.go b/google/services/bigqueryreservation/resource_bigquery_bi_reservation.go index db324293dc7..60426cd3bb5 100644 --- a/google/services/bigqueryreservation/resource_bigquery_bi_reservation.go +++ b/google/services/bigqueryreservation/resource_bigquery_bi_reservation.go @@ -115,6 +115,7 @@ func ResourceBigqueryReservationBiReservation() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -190,6 +191,18 @@ A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to n Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -333,6 +346,19 @@ func resourceBigqueryReservationBiReservationRead(d *schema.ResourceData, meta i log.Printf("[DEBUG] Finished reading BigqueryReservationBiReservation %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading BiReservation: %s", err) } @@ -364,6 +390,19 @@ func resourceBigqueryReservationBiReservationRead(d *schema.ResourceData, meta i } func resourceBigqueryReservationBiReservationUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceBigqueryReservationBiReservation().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceBigqueryReservationBiReservationRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -460,6 +499,13 @@ func resourceBigqueryReservationBiReservationUpdate(d *schema.ResourceData, meta } func resourceBigqueryReservationBiReservationDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy BigqueryReservationBiReservation without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing BiReservation %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/bigqueryreservation/resource_bigquery_bi_reservation_generated_meta.yaml b/google/services/bigqueryreservation/resource_bigquery_bi_reservation_generated_meta.yaml index 457fe234336..0a0a4fe4e6f 100644 --- a/google/services/bigqueryreservation/resource_bigquery_bi_reservation_generated_meta.yaml +++ b/google/services/bigqueryreservation/resource_bigquery_bi_reservation_generated_meta.yaml @@ -15,3 +15,5 @@ fields: - api_field: preferredTables.tableId - api_field: size - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/bigqueryreservation/resource_bigquery_capacity_commitment.go b/google/services/bigqueryreservation/resource_bigquery_capacity_commitment.go index c4edc33826e..fae382c95b9 100644 --- a/google/services/bigqueryreservation/resource_bigquery_capacity_commitment.go +++ b/google/services/bigqueryreservation/resource_bigquery_capacity_commitment.go @@ -122,6 +122,7 @@ func ResourceBigqueryReservationCapacityCommitment() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -221,6 +222,18 @@ Examples: US, EU, asia-northeast1. The default value is US.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -372,6 +385,19 @@ func resourceBigqueryReservationCapacityCommitmentRead(d *schema.ResourceData, m log.Printf("[DEBUG] Finished reading BigqueryReservationCapacityCommitment %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading CapacityCommitment: %s", err) } @@ -409,6 +435,19 @@ func resourceBigqueryReservationCapacityCommitmentRead(d *schema.ResourceData, m } func resourceBigqueryReservationCapacityCommitmentUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceBigqueryReservationCapacityCommitment().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceBigqueryReservationCapacityCommitmentRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -510,6 +549,13 @@ func resourceBigqueryReservationCapacityCommitmentUpdate(d *schema.ResourceData, } func resourceBigqueryReservationCapacityCommitmentDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy BigqueryReservationCapacityCommitment without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing CapacityCommitment %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/bigqueryreservation/resource_bigquery_capacity_commitment_generated_meta.yaml b/google/services/bigqueryreservation/resource_bigquery_capacity_commitment_generated_meta.yaml index d827ab267ab..02447bcd02b 100644 --- a/google/services/bigqueryreservation/resource_bigquery_capacity_commitment_generated_meta.yaml +++ b/google/services/bigqueryreservation/resource_bigquery_capacity_commitment_generated_meta.yaml @@ -21,3 +21,5 @@ fields: - api_field: renewalPlan - api_field: slotCount - api_field: state + - field: deletion_policy + provider_only: true diff --git a/google/services/bigqueryreservation/resource_bigquery_reservation.go b/google/services/bigqueryreservation/resource_bigquery_reservation.go index 0ae8a2ee90d..bddc2debb48 100644 --- a/google/services/bigqueryreservation/resource_bigquery_reservation.go +++ b/google/services/bigqueryreservation/resource_bigquery_reservation.go @@ -115,6 +115,7 @@ func ResourceBigqueryReservationReservation() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -282,6 +283,18 @@ replicated to the secondary.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -445,6 +458,19 @@ func resourceBigqueryReservationReservationRead(d *schema.ResourceData, meta int log.Printf("[DEBUG] Finished reading BigqueryReservationReservation %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Reservation: %s", err) } @@ -482,6 +508,19 @@ func resourceBigqueryReservationReservationRead(d *schema.ResourceData, meta int } func resourceBigqueryReservationReservationUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceBigqueryReservationReservation().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceBigqueryReservationReservationRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -623,6 +662,13 @@ func resourceBigqueryReservationReservationUpdate(d *schema.ResourceData, meta i } func resourceBigqueryReservationReservationDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy BigqueryReservationReservation without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Reservation %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/bigqueryreservation/resource_bigquery_reservation_assignment.go b/google/services/bigqueryreservation/resource_bigquery_reservation_assignment.go index 1690a530107..22dc4e13286 100644 --- a/google/services/bigqueryreservation/resource_bigquery_reservation_assignment.go +++ b/google/services/bigqueryreservation/resource_bigquery_reservation_assignment.go @@ -100,6 +100,7 @@ func ResourceBigqueryReservationReservationAssignment() *schema.Resource { return &schema.Resource{ Create: resourceBigqueryReservationReservationAssignmentCreate, Read: resourceBigqueryReservationReservationAssignmentRead, + Update: resourceBigqueryReservationReservationAssignmentUpdate, Delete: resourceBigqueryReservationReservationAssignmentDelete, Importer: &schema.ResourceImporter{ @@ -113,6 +114,7 @@ func ResourceBigqueryReservationReservationAssignment() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -187,6 +189,18 @@ Possible values: STATE_UNSPECIFIED, PENDING, ACTIVE`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -363,6 +377,19 @@ func resourceBigqueryReservationReservationAssignmentRead(d *schema.ResourceData return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading ReservationAssignment: %s", err) } @@ -405,7 +432,19 @@ func resourceBigqueryReservationReservationAssignmentRead(d *schema.ResourceData return nil } +func resourceBigqueryReservationReservationAssignmentUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceBigqueryReservationReservationAssignmentRead(d, meta) +} + func resourceBigqueryReservationReservationAssignmentDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy BigqueryReservationReservationAssignment without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ReservationAssignment %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/bigqueryreservation/resource_bigquery_reservation_assignment_generated_meta.yaml b/google/services/bigqueryreservation/resource_bigquery_reservation_assignment_generated_meta.yaml index 7bf964dff15..a30081032b0 100644 --- a/google/services/bigqueryreservation/resource_bigquery_reservation_assignment_generated_meta.yaml +++ b/google/services/bigqueryreservation/resource_bigquery_reservation_assignment_generated_meta.yaml @@ -15,3 +15,5 @@ fields: - field: reservation provider_only: true - api_field: state + - field: deletion_policy + provider_only: true diff --git a/google/services/bigqueryreservation/resource_bigquery_reservation_generated_meta.yaml b/google/services/bigqueryreservation/resource_bigquery_reservation_generated_meta.yaml index cf5c87c2265..db891017411 100644 --- a/google/services/bigqueryreservation/resource_bigquery_reservation_generated_meta.yaml +++ b/google/services/bigqueryreservation/resource_bigquery_reservation_generated_meta.yaml @@ -25,3 +25,5 @@ fields: - api_field: reservationGroup - api_field: secondaryLocation - api_field: slotCapacity + - field: deletion_policy + provider_only: true diff --git a/google/services/bigqueryreservation/resource_bigquery_reservation_group.go b/google/services/bigqueryreservation/resource_bigquery_reservation_group.go index 84fc1616913..480a9a85068 100644 --- a/google/services/bigqueryreservation/resource_bigquery_reservation_group.go +++ b/google/services/bigqueryreservation/resource_bigquery_reservation_group.go @@ -100,6 +100,7 @@ func ResourceBigqueryReservationReservationGroup() *schema.Resource { return &schema.Resource{ Create: resourceBigqueryReservationReservationGroupCreate, Read: resourceBigqueryReservationReservationGroupRead, + Update: resourceBigqueryReservationReservationGroupUpdate, Delete: resourceBigqueryReservationReservationGroupDelete, Importer: &schema.ResourceImporter{ @@ -113,6 +114,7 @@ func ResourceBigqueryReservationReservationGroup() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -160,6 +162,18 @@ Examples: US, EU, asia-northeast1. The default value is US.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -287,6 +301,19 @@ func resourceBigqueryReservationReservationGroupRead(d *schema.ResourceData, met log.Printf("[DEBUG] Finished reading BigqueryReservationReservationGroup %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading ReservationGroup: %s", err) } @@ -323,7 +350,19 @@ func resourceBigqueryReservationReservationGroupRead(d *schema.ResourceData, met return nil } +func resourceBigqueryReservationReservationGroupUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceBigqueryReservationReservationGroupRead(d, meta) +} + func resourceBigqueryReservationReservationGroupDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy BigqueryReservationReservationGroup without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ReservationGroup %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/bigqueryreservation/resource_bigquery_reservation_group_generated_meta.yaml b/google/services/bigqueryreservation/resource_bigquery_reservation_group_generated_meta.yaml index 6bfdaffd4a6..07da6ad4b06 100644 --- a/google/services/bigqueryreservation/resource_bigquery_reservation_group_generated_meta.yaml +++ b/google/services/bigqueryreservation/resource_bigquery_reservation_group_generated_meta.yaml @@ -10,3 +10,5 @@ fields: - field: location provider_only: true - api_field: name + - field: deletion_policy + provider_only: true diff --git a/google/services/bigtable/resource_bigtable_app_profile.go b/google/services/bigtable/resource_bigtable_app_profile.go index 93158e5151f..36d44fc8c9b 100644 --- a/google/services/bigtable/resource_bigtable_app_profile.go +++ b/google/services/bigtable/resource_bigtable_app_profile.go @@ -117,6 +117,7 @@ func ResourceBigtableAppProfile() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -258,6 +259,18 @@ It is unsafe to send these requests to the same table/row/column in multiple clu Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -414,6 +427,19 @@ func resourceBigtableAppProfileRead(d *schema.ResourceData, meta interface{}) er log.Printf("[DEBUG] Finished reading BigtableAppProfile %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading AppProfile: %s", err) } @@ -451,6 +477,19 @@ func resourceBigtableAppProfileRead(d *schema.ResourceData, meta interface{}) er } func resourceBigtableAppProfileUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceBigtableAppProfile().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceBigtableAppProfileRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -623,6 +662,13 @@ func resourceBigtableAppProfileUpdate(d *schema.ResourceData, meta interface{}) } func resourceBigtableAppProfileDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy BigtableAppProfile without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing AppProfile %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/bigtable/resource_bigtable_app_profile_generated_meta.yaml b/google/services/bigtable/resource_bigtable_app_profile_generated_meta.yaml index a8f00bd2dee..19411b8028c 100644 --- a/google/services/bigtable/resource_bigtable_app_profile_generated_meta.yaml +++ b/google/services/bigtable/resource_bigtable_app_profile_generated_meta.yaml @@ -22,3 +22,5 @@ fields: - api_field: singleClusterRouting.allowTransactionalWrites - api_field: singleClusterRouting.clusterId - api_field: standardIsolation.priority + - field: deletion_policy + provider_only: true diff --git a/google/services/bigtable/resource_bigtable_authorized_view.go b/google/services/bigtable/resource_bigtable_authorized_view.go index e85c54e3b67..88a8a824048 100644 --- a/google/services/bigtable/resource_bigtable_authorized_view.go +++ b/google/services/bigtable/resource_bigtable_authorized_view.go @@ -72,6 +72,7 @@ func ResourceBigtableAuthorizedView() *schema.Resource { }, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), tpgresource.DefaultProviderProject, ), @@ -138,6 +139,9 @@ If not provided, currently deletion protection will be set to UNPROTECTED as it }, }, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, UseJSONNumber: true, } @@ -269,10 +273,19 @@ func resourceBigtableAuthorizedViewRead(d *schema.ResourceData, meta interface{} return fmt.Errorf("Error parsing server returned subset_view since it's empty") } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } func resourceBigtableAuthorizedViewUpdate(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceBigtableAuthorizedView) { + return ResourceBigtableAuthorizedView().Read(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -336,6 +349,13 @@ func resourceBigtableAuthorizedViewUpdate(d *schema.ResourceData, meta interface } func resourceBigtableAuthorizedViewDestroy(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/bigtable/resource_bigtable_authorized_view_meta.yaml b/google/services/bigtable/resource_bigtable_authorized_view_meta.yaml index 48fbe3dbe76..4aa4dfd2ee8 100644 --- a/google/services/bigtable/resource_bigtable_authorized_view_meta.yaml +++ b/google/services/bigtable/resource_bigtable_authorized_view_meta.yaml @@ -15,3 +15,5 @@ fields: - field: 'subset_view.family_subsets.qualifiers' - api_field: 'subsetView.rowPrefixes' - field: 'table_name' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/bigtable/resource_bigtable_gc_policy.go b/google/services/bigtable/resource_bigtable_gc_policy.go index 9cd843e1a2a..baf1198c2b8 100644 --- a/google/services/bigtable/resource_bigtable_gc_policy.go +++ b/google/services/bigtable/resource_bigtable_gc_policy.go @@ -26,6 +26,7 @@ import ( "time" "cloud.google.com/go/bigtable" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/structure" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" @@ -111,12 +112,14 @@ func resourceBigtableGCPolicyCustomizeDiff(_ context.Context, d *schema.Resource func ResourceBigtableGCPolicy() *schema.Resource { return &schema.Resource{ - Create: resourceBigtableGCPolicyUpsert, - Read: resourceBigtableGCPolicyRead, - Delete: resourceBigtableGCPolicyDestroy, - Update: resourceBigtableGCPolicyUpsert, - CustomizeDiff: resourceBigtableGCPolicyCustomizeDiff, - + Create: resourceBigtableGCPolicyUpsert, + Read: resourceBigtableGCPolicyRead, + Delete: resourceBigtableGCPolicyDestroy, + Update: resourceBigtableGCPolicyUpsert, + CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), + resourceBigtableGCPolicyCustomizeDiff, + ), Timeouts: &schema.ResourceTimeout{ Create: schema.DefaultTimeout(20 * time.Minute), Delete: schema.DefaultTimeout(20 * time.Minute), @@ -225,14 +228,9 @@ func ResourceBigtableGCPolicy() *schema.Resource { Description: `The ID of the project in which the resource belongs. If it is not provided, the provider project is used.`, }, - "deletion_policy": { - Type: schema.TypeString, - Optional: true, - Description: `The deletion policy for the GC policy. Setting ABANDON allows the resource - to be abandoned rather than deleted. This is useful for GC policy as it cannot be deleted - in a replicated instance. Possible values are: "ABANDON".`, - ValidateFunc: validation.StringInSlice([]string{"ABANDON", ""}, false), - }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end "ignore_warnings": { Type: schema.TypeBool, @@ -249,6 +247,11 @@ func ResourceBigtableGCPolicy() *schema.Resource { } func resourceBigtableGCPolicyUpsert(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceBigtableGCPolicy) { + return ResourceBigtableGCPolicy().Read(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -386,6 +389,10 @@ func resourceBigtableGCPolicyRead(d *schema.ResourceData, meta interface{}) erro return fmt.Errorf("Error setting project: %s", err) } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } @@ -453,15 +460,15 @@ func GcPolicyToGCRuleString(gc bigtable.GCPolicy, topLevel bool) (map[string]int } func resourceBigtableGCPolicyDestroy(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - if deletionPolicy := d.Get("deletion_policy"); deletionPolicy == "ABANDON" { - // Allows for the GC policy to be abandoned without deletion to avoid possible - // deletion failure in a replicated instance. - log.Printf("[WARN] The GC policy is abandoned") + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { return nil } + config := meta.(*transport_tpg.Config) + userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { return err diff --git a/google/services/bigtable/resource_bigtable_gc_policy_meta.yaml b/google/services/bigtable/resource_bigtable_gc_policy_meta.yaml index 921d51aa2bd..de6697ead24 100644 --- a/google/services/bigtable/resource_bigtable_gc_policy_meta.yaml +++ b/google/services/bigtable/resource_bigtable_gc_policy_meta.yaml @@ -8,6 +8,7 @@ api_resource_type_kind: 'Table' fields: - field: 'column_family' - field: 'deletion_policy' + provider_only: true - field: 'gc_rules' - field: 'ignore_warnings' - field: 'instance_name' diff --git a/google/services/bigtable/resource_bigtable_instance.go b/google/services/bigtable/resource_bigtable_instance.go index bae5c288471..c4df45abc34 100644 --- a/google/services/bigtable/resource_bigtable_instance.go +++ b/google/services/bigtable/resource_bigtable_instance.go @@ -70,6 +70,7 @@ func ResourceBigtableInstance() *schema.Resource { }, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), tpgresource.DefaultProviderProject, resourceBigtableInstanceClusterReorderTypeList, resourceBigtableInstanceUniqueClusterID, @@ -240,7 +241,9 @@ func ResourceBigtableInstance() *schema.Resource { ForceNew: true, Description: `The ID of the project in which the resource belongs. If it is not provided, the provider project is used.`, }, - + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end "tags": { Type: schema.TypeMap, Optional: true, @@ -409,10 +412,19 @@ func resourceBigtableInstanceRead(d *schema.ResourceData, meta interface{}) erro } } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } func resourceBigtableInstanceUpdate(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceBigtableInstance) { + return ResourceBigtableInstance().Read(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -480,6 +492,13 @@ func resourceBigtableInstanceUpdate(d *schema.ResourceData, meta interface{}) er func resourceBigtableInstanceDestroy(d *schema.ResourceData, meta interface{}) error { log.Printf("[DEBUG] Deleting BigTable instance %q", d.Id()) + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + if d.Get("deletion_protection").(bool) { return fmt.Errorf("cannot destroy instance without setting deletion_protection=false and running `terraform apply`") } diff --git a/google/services/bigtable/resource_bigtable_instance_meta.yaml b/google/services/bigtable/resource_bigtable_instance_meta.yaml index 926f6e07b81..6350e1e3be7 100644 --- a/google/services/bigtable/resource_bigtable_instance_meta.yaml +++ b/google/services/bigtable/resource_bigtable_instance_meta.yaml @@ -31,3 +31,5 @@ fields: - api_field: 'tags' - field: 'terraform_labels' provider_only: true + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/bigtable/resource_bigtable_logical_view.go b/google/services/bigtable/resource_bigtable_logical_view.go index 4a1d6d385f2..a9136e7d1ab 100644 --- a/google/services/bigtable/resource_bigtable_logical_view.go +++ b/google/services/bigtable/resource_bigtable_logical_view.go @@ -115,6 +115,7 @@ func ResourceBigtableLogicalView() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -175,6 +176,18 @@ func ResourceBigtableLogicalView() *schema.Resource { Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -308,6 +321,19 @@ func resourceBigtableLogicalViewRead(d *schema.ResourceData, meta interface{}) e log.Printf("[DEBUG] Finished reading BigtableLogicalView %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading LogicalView: %s", err) } @@ -345,6 +371,19 @@ func resourceBigtableLogicalViewRead(d *schema.ResourceData, meta interface{}) e } func resourceBigtableLogicalViewUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceBigtableLogicalView().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceBigtableLogicalViewRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -446,6 +485,13 @@ func resourceBigtableLogicalViewUpdate(d *schema.ResourceData, meta interface{}) } func resourceBigtableLogicalViewDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy BigtableLogicalView without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing LogicalView %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/bigtable/resource_bigtable_logical_view_generated_meta.yaml b/google/services/bigtable/resource_bigtable_logical_view_generated_meta.yaml index 2f8107a7ba3..4f82e9706aa 100644 --- a/google/services/bigtable/resource_bigtable_logical_view_generated_meta.yaml +++ b/google/services/bigtable/resource_bigtable_logical_view_generated_meta.yaml @@ -16,3 +16,5 @@ fields: provider_only: true - api_field: name - api_field: query + - field: deletion_policy + provider_only: true diff --git a/google/services/bigtable/resource_bigtable_materialized_view.go b/google/services/bigtable/resource_bigtable_materialized_view.go index 8dfc106ad31..4b16a59d96f 100644 --- a/google/services/bigtable/resource_bigtable_materialized_view.go +++ b/google/services/bigtable/resource_bigtable_materialized_view.go @@ -115,6 +115,7 @@ func ResourceBigtableMaterializedView() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -176,6 +177,18 @@ func ResourceBigtableMaterializedView() *schema.Resource { Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -309,6 +322,19 @@ func resourceBigtableMaterializedViewRead(d *schema.ResourceData, meta interface log.Printf("[DEBUG] Finished reading BigtableMaterializedView %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading MaterializedView: %s", err) } @@ -346,6 +372,19 @@ func resourceBigtableMaterializedViewRead(d *schema.ResourceData, meta interface } func resourceBigtableMaterializedViewUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceBigtableMaterializedView().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceBigtableMaterializedViewRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -437,6 +476,13 @@ func resourceBigtableMaterializedViewUpdate(d *schema.ResourceData, meta interfa } func resourceBigtableMaterializedViewDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy BigtableMaterializedView without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing MaterializedView %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/bigtable/resource_bigtable_materialized_view_generated_meta.yaml b/google/services/bigtable/resource_bigtable_materialized_view_generated_meta.yaml index b94ab519fed..4b56de0117d 100644 --- a/google/services/bigtable/resource_bigtable_materialized_view_generated_meta.yaml +++ b/google/services/bigtable/resource_bigtable_materialized_view_generated_meta.yaml @@ -16,3 +16,5 @@ fields: provider_only: true - api_field: name - api_field: query + - field: deletion_policy + provider_only: true diff --git a/google/services/bigtable/resource_bigtable_schema_bundle.go b/google/services/bigtable/resource_bigtable_schema_bundle.go index 86a9ffdacc1..c46bc74677d 100644 --- a/google/services/bigtable/resource_bigtable_schema_bundle.go +++ b/google/services/bigtable/resource_bigtable_schema_bundle.go @@ -115,6 +115,7 @@ func ResourceBigtableSchemaBundle() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -209,6 +210,18 @@ an ABORTED error on a mismatched etag.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -341,6 +354,19 @@ func resourceBigtableSchemaBundleRead(d *schema.ResourceData, meta interface{}) log.Printf("[DEBUG] Finished reading BigtableSchemaBundle %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading SchemaBundle: %s", err) } @@ -384,6 +410,19 @@ func resourceBigtableSchemaBundleRead(d *schema.ResourceData, meta interface{}) } func resourceBigtableSchemaBundleUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceBigtableSchemaBundle().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceBigtableSchemaBundleRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -480,6 +519,13 @@ func resourceBigtableSchemaBundleUpdate(d *schema.ResourceData, meta interface{} } func resourceBigtableSchemaBundleDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy BigtableSchemaBundle without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing SchemaBundle %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/bigtable/resource_bigtable_schema_bundle_generated_meta.yaml b/google/services/bigtable/resource_bigtable_schema_bundle_generated_meta.yaml index 7170633dc72..cb99b17b7cc 100644 --- a/google/services/bigtable/resource_bigtable_schema_bundle_generated_meta.yaml +++ b/google/services/bigtable/resource_bigtable_schema_bundle_generated_meta.yaml @@ -20,3 +20,5 @@ fields: provider_only: true - field: table provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/bigtable/resource_bigtable_table.go b/google/services/bigtable/resource_bigtable_table.go index 7f545837a57..22a059828c4 100644 --- a/google/services/bigtable/resource_bigtable_table.go +++ b/google/services/bigtable/resource_bigtable_table.go @@ -70,6 +70,7 @@ func ResourceBigtableTable() *schema.Resource { }, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), tpgresource.DefaultProviderProject, abpDiffFunc, ), @@ -184,6 +185,9 @@ func ResourceBigtableTable() *schema.Resource { The schema must be a valid JSON encoded string representing a Type's struct protobuf message. Note that for bytes sequence (like delimited_bytes.delimiter) the delimiter must be base64 encoded. For example, if you want to set a delimiter to a single byte character "#", it should be set to "Iw==", which is the base64 encoding of the byte sequence "#".`, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, UseJSONNumber: true, } @@ -457,6 +461,10 @@ func resourceBigtableTableRead(d *schema.ResourceData, meta interface{}) error { d.Set("row_key_schema", nil) } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } @@ -503,6 +511,11 @@ func familyMapDiffValueTypes(a, b map[string]bigtable.Family) map[string]bigtabl } func resourceBigtableTableUpdate(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceBigtableTable) { + return ResourceBigtableTable().Read(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -648,6 +661,13 @@ func resourceBigtableTableUpdate(d *schema.ResourceData, meta interface{}) error } func resourceBigtableTableDestroy(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/bigtable/resource_bigtable_table_meta.yaml b/google/services/bigtable/resource_bigtable_table_meta.yaml index b73a3215dc7..61b9b774fdd 100644 --- a/google/services/bigtable/resource_bigtable_table_meta.yaml +++ b/google/services/bigtable/resource_bigtable_table_meta.yaml @@ -20,3 +20,5 @@ fields: - api_field: 'rowKeySchema' json: true - field: 'split_keys' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/billingbudgets/resource_billing_budget.go b/google/services/billingbudgets/resource_billing_budget.go index ee83c535e09..05707fd2eb2 100644 --- a/google/services/billingbudgets/resource_billing_budget.go +++ b/google/services/billingbudgets/resource_billing_budget.go @@ -500,6 +500,19 @@ the threshold. Default value: "CURRENT_SPEND" Possible values: ["CURRENT_SPEND", implies the scope of a budget. Values are of the form billingAccounts/{billingAccountId}/budgets/{budgetId}.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -646,6 +659,20 @@ func resourceBillingBudgetsBudgetRead(d *schema.ResourceData, meta interface{}) log.Printf("[DEBUG] Finished reading BillingBudgetsBudget %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceBillingBudgetsBudgetFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -673,6 +700,19 @@ func resourceBillingBudgetsBudgetRead(d *schema.ResourceData, meta interface{}) } func resourceBillingBudgetsBudgetUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceBillingBudgetsBudget().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceBillingBudgetsBudgetRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -817,6 +857,13 @@ func resourceBillingBudgetsBudgetUpdate(d *schema.ResourceData, meta interface{} } func resourceBillingBudgetsBudgetDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy BillingBudgetsBudget without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Budget %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/billingbudgets/resource_billing_budget_generated_meta.yaml b/google/services/billingbudgets/resource_billing_budget_generated_meta.yaml index e1689962e50..1172643a349 100644 --- a/google/services/billingbudgets/resource_billing_budget_generated_meta.yaml +++ b/google/services/billingbudgets/resource_billing_budget_generated_meta.yaml @@ -42,3 +42,5 @@ fields: - api_field: ownershipScope - api_field: thresholdRules.spendBasis - api_field: thresholdRules.thresholdPercent + - field: deletion_policy + provider_only: true diff --git a/google/services/binaryauthorization/resource_binary_authorization_attestor.go b/google/services/binaryauthorization/resource_binary_authorization_attestor.go index dacc038453a..0fa0bc6c778 100644 --- a/google/services/binaryauthorization/resource_binary_authorization_attestor.go +++ b/google/services/binaryauthorization/resource_binary_authorization_attestor.go @@ -143,6 +143,7 @@ func ResourceBinaryAuthorizationAttestor() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -294,6 +295,18 @@ displayed in chooser dialogs.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -428,6 +441,19 @@ func resourceBinaryAuthorizationAttestorRead(d *schema.ResourceData, meta interf log.Printf("[DEBUG] Finished reading BinaryAuthorizationAttestor %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Attestor: %s", err) } @@ -459,6 +485,19 @@ func resourceBinaryAuthorizationAttestorRead(d *schema.ResourceData, meta interf } func resourceBinaryAuthorizationAttestorUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceBinaryAuthorizationAttestor().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceBinaryAuthorizationAttestorRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -542,6 +581,13 @@ func resourceBinaryAuthorizationAttestorUpdate(d *schema.ResourceData, meta inte } func resourceBinaryAuthorizationAttestorDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy BinaryAuthorizationAttestor without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Attestor %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/binaryauthorization/resource_binary_authorization_attestor_generated_meta.yaml b/google/services/binaryauthorization/resource_binary_authorization_attestor_generated_meta.yaml index 3f7959f93d3..cdddb15b391 100644 --- a/google/services/binaryauthorization/resource_binary_authorization_attestor_generated_meta.yaml +++ b/google/services/binaryauthorization/resource_binary_authorization_attestor_generated_meta.yaml @@ -23,3 +23,5 @@ fields: field: attestation_authority_note.public_keys.pkix_public_key.signature_algorithm - api_field: description - api_field: name + - field: deletion_policy + provider_only: true diff --git a/google/services/binaryauthorization/resource_binary_authorization_policy.go b/google/services/binaryauthorization/resource_binary_authorization_policy.go index b9067cc4484..d9be40acacd 100644 --- a/google/services/binaryauthorization/resource_binary_authorization_policy.go +++ b/google/services/binaryauthorization/resource_binary_authorization_policy.go @@ -130,6 +130,7 @@ func ResourceBinaryAuthorizationPolicy() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -303,6 +304,18 @@ policy will be subject to the project admission policy. Possible values: ["ENABL Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -444,6 +457,19 @@ func resourceBinaryAuthorizationPolicyRead(d *schema.ResourceData, meta interfac log.Printf("[DEBUG] Finished reading BinaryAuthorizationPolicy %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Policy: %s", err) } @@ -469,6 +495,19 @@ func resourceBinaryAuthorizationPolicyRead(d *schema.ResourceData, meta interfac } func resourceBinaryAuthorizationPolicyUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceBinaryAuthorizationPolicy().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceBinaryAuthorizationPolicyRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -559,6 +598,13 @@ func resourceBinaryAuthorizationPolicyUpdate(d *schema.ResourceData, meta interf } func resourceBinaryAuthorizationPolicyDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy BinaryAuthorizationPolicy without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Policy %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/binaryauthorization/resource_binary_authorization_policy_generated_meta.yaml b/google/services/binaryauthorization/resource_binary_authorization_policy_generated_meta.yaml index 23e638222df..319bd1f6400 100644 --- a/google/services/binaryauthorization/resource_binary_authorization_policy_generated_meta.yaml +++ b/google/services/binaryauthorization/resource_binary_authorization_policy_generated_meta.yaml @@ -23,3 +23,5 @@ fields: - api_field: defaultAdmissionRule.requireAttestationsBy - api_field: description - api_field: globalPolicyEvaluationMode + - field: deletion_policy + provider_only: true diff --git a/google/services/blockchainnodeengine/resource_blockchain_node_engine_blockchain_nodes.go b/google/services/blockchainnodeengine/resource_blockchain_node_engine_blockchain_nodes.go index a8a26c13b40..0945169b733 100644 --- a/google/services/blockchainnodeengine/resource_blockchain_node_engine_blockchain_nodes.go +++ b/google/services/blockchainnodeengine/resource_blockchain_node_engine_blockchain_nodes.go @@ -116,6 +116,7 @@ func ResourceBlockchainNodeEngineBlockchainNodes() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -351,6 +352,18 @@ Please refer to the field 'effective_labels' for all of the labels present on th Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -500,6 +513,19 @@ func resourceBlockchainNodeEngineBlockchainNodesRead(d *schema.ResourceData, met log.Printf("[DEBUG] Finished reading BlockchainNodeEngineBlockchainNodes %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading BlockchainNodes: %s", err) } @@ -537,6 +563,19 @@ func resourceBlockchainNodeEngineBlockchainNodesRead(d *schema.ResourceData, met } func resourceBlockchainNodeEngineBlockchainNodesUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceBlockchainNodeEngineBlockchainNodes().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceBlockchainNodeEngineBlockchainNodesRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -633,6 +672,13 @@ func resourceBlockchainNodeEngineBlockchainNodesUpdate(d *schema.ResourceData, m } func resourceBlockchainNodeEngineBlockchainNodesDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy BlockchainNodeEngineBlockchainNodes without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing BlockchainNodes %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/blockchainnodeengine/resource_blockchain_node_engine_blockchain_nodes_generated_meta.yaml b/google/services/blockchainnodeengine/resource_blockchain_node_engine_blockchain_nodes_generated_meta.yaml index 8e780d371f5..ce744ee1c14 100644 --- a/google/services/blockchainnodeengine/resource_blockchain_node_engine_blockchain_nodes_generated_meta.yaml +++ b/google/services/blockchainnodeengine/resource_blockchain_node_engine_blockchain_nodes_generated_meta.yaml @@ -35,3 +35,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/certificatemanager/resource_certificate_manager_certificate.go b/google/services/certificatemanager/resource_certificate_manager_certificate.go index 38eef4dfc0d..e640bbb5010 100644 --- a/google/services/certificatemanager/resource_certificate_manager_certificate.go +++ b/google/services/certificatemanager/resource_certificate_manager_certificate.go @@ -132,6 +132,7 @@ func ResourceCertificateManagerCertificate() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -386,6 +387,18 @@ Leaf certificate comes first, followed by intermediate ones if any.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -547,6 +560,19 @@ func resourceCertificateManagerCertificateRead(d *schema.ResourceData, meta inte log.Printf("[DEBUG] Finished reading CertificateManagerCertificate %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Certificate: %s", err) } @@ -584,6 +610,19 @@ func resourceCertificateManagerCertificateRead(d *schema.ResourceData, meta inte } func resourceCertificateManagerCertificateUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceCertificateManagerCertificate().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceCertificateManagerCertificateRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -692,6 +731,13 @@ func resourceCertificateManagerCertificateUpdate(d *schema.ResourceData, meta in } func resourceCertificateManagerCertificateDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy CertificateManagerCertificate without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Certificate %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/certificatemanager/resource_certificate_manager_certificate_generated_meta.yaml b/google/services/certificatemanager/resource_certificate_manager_certificate_generated_meta.yaml index 4f28a0245f3..4cf0dc4d9e0 100644 --- a/google/services/certificatemanager/resource_certificate_manager_certificate_generated_meta.yaml +++ b/google/services/certificatemanager/resource_certificate_manager_certificate_generated_meta.yaml @@ -33,3 +33,5 @@ fields: - api_field: selfManaged.privateKeyPem - field: terraform_labels provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/certificatemanager/resource_certificate_manager_certificate_issuance_config.go b/google/services/certificatemanager/resource_certificate_manager_certificate_issuance_config.go index b7b2bd93b0b..0f4334726ee 100644 --- a/google/services/certificatemanager/resource_certificate_manager_certificate_issuance_config.go +++ b/google/services/certificatemanager/resource_certificate_manager_certificate_issuance_config.go @@ -125,6 +125,7 @@ func ResourceCertificateManagerCertificateIssuanceConfig() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -270,6 +271,18 @@ Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -437,6 +450,19 @@ func resourceCertificateManagerCertificateIssuanceConfigRead(d *schema.ResourceD log.Printf("[DEBUG] Finished reading CertificateManagerCertificateIssuanceConfig %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading CertificateIssuanceConfig: %s", err) } @@ -474,11 +500,18 @@ func resourceCertificateManagerCertificateIssuanceConfigRead(d *schema.ResourceD } func resourceCertificateManagerCertificateIssuanceConfigUpdate(d *schema.ResourceData, meta interface{}) error { - // Only the root field "labels", "terraform_labels", and virtual fields are mutable + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable return resourceCertificateManagerCertificateIssuanceConfigRead(d, meta) } func resourceCertificateManagerCertificateIssuanceConfigDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy CertificateManagerCertificateIssuanceConfig without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing CertificateIssuanceConfig %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/certificatemanager/resource_certificate_manager_certificate_issuance_config_generated_meta.yaml b/google/services/certificatemanager/resource_certificate_manager_certificate_issuance_config_generated_meta.yaml index 6e7b5011c8c..5cf60472233 100644 --- a/google/services/certificatemanager/resource_certificate_manager_certificate_issuance_config_generated_meta.yaml +++ b/google/services/certificatemanager/resource_certificate_manager_certificate_issuance_config_generated_meta.yaml @@ -23,3 +23,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/certificatemanager/resource_certificate_manager_certificate_map.go b/google/services/certificatemanager/resource_certificate_manager_certificate_map.go index 492ee4be306..ac06b036973 100644 --- a/google/services/certificatemanager/resource_certificate_manager_certificate_map.go +++ b/google/services/certificatemanager/resource_certificate_manager_certificate_map.go @@ -116,6 +116,7 @@ func ResourceCertificateManagerCertificateMap() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -238,6 +239,18 @@ Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -376,6 +389,19 @@ func resourceCertificateManagerCertificateMapRead(d *schema.ResourceData, meta i log.Printf("[DEBUG] Finished reading CertificateManagerCertificateMap %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading CertificateMap: %s", err) } @@ -407,6 +433,19 @@ func resourceCertificateManagerCertificateMapRead(d *schema.ResourceData, meta i } func resourceCertificateManagerCertificateMapUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceCertificateManagerCertificateMap().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceCertificateManagerCertificateMapRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -510,6 +549,13 @@ func resourceCertificateManagerCertificateMapUpdate(d *schema.ResourceData, meta } func resourceCertificateManagerCertificateMapDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy CertificateManagerCertificateMap without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing CertificateMap %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/certificatemanager/resource_certificate_manager_certificate_map_entry.go b/google/services/certificatemanager/resource_certificate_manager_certificate_map_entry.go index 2d529ad67f2..c1498322975 100644 --- a/google/services/certificatemanager/resource_certificate_manager_certificate_map_entry.go +++ b/google/services/certificatemanager/resource_certificate_manager_certificate_map_entry.go @@ -116,6 +116,7 @@ func ResourceCertificateManagerCertificateMapEntry() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -239,6 +240,18 @@ Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -406,6 +419,19 @@ func resourceCertificateManagerCertificateMapEntryRead(d *schema.ResourceData, m log.Printf("[DEBUG] Finished reading CertificateManagerCertificateMapEntry %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading CertificateMapEntry: %s", err) } @@ -443,6 +469,19 @@ func resourceCertificateManagerCertificateMapEntryRead(d *schema.ResourceData, m } func resourceCertificateManagerCertificateMapEntryUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceCertificateManagerCertificateMapEntry().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceCertificateManagerCertificateMapEntryRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -561,6 +600,13 @@ func resourceCertificateManagerCertificateMapEntryUpdate(d *schema.ResourceData, } func resourceCertificateManagerCertificateMapEntryDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy CertificateManagerCertificateMapEntry without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing CertificateMapEntry %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/certificatemanager/resource_certificate_manager_certificate_map_entry_generated_meta.yaml b/google/services/certificatemanager/resource_certificate_manager_certificate_map_entry_generated_meta.yaml index e5c2aa90ed3..0546a331b4c 100644 --- a/google/services/certificatemanager/resource_certificate_manager_certificate_map_entry_generated_meta.yaml +++ b/google/services/certificatemanager/resource_certificate_manager_certificate_map_entry_generated_meta.yaml @@ -22,3 +22,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/certificatemanager/resource_certificate_manager_certificate_map_generated_meta.yaml b/google/services/certificatemanager/resource_certificate_manager_certificate_map_generated_meta.yaml index cb6f49fe9eb..fd8d0f8752b 100644 --- a/google/services/certificatemanager/resource_certificate_manager_certificate_map_generated_meta.yaml +++ b/google/services/certificatemanager/resource_certificate_manager_certificate_map_generated_meta.yaml @@ -21,3 +21,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/certificatemanager/resource_certificate_manager_dns_authorization.go b/google/services/certificatemanager/resource_certificate_manager_dns_authorization.go index 0287caee982..c80217a6d64 100644 --- a/google/services/certificatemanager/resource_certificate_manager_dns_authorization.go +++ b/google/services/certificatemanager/resource_certificate_manager_dns_authorization.go @@ -125,6 +125,7 @@ func ResourceCertificateManagerDnsAuthorization() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -249,6 +250,18 @@ E.g. '_acme-challenge.example.com'.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -404,6 +417,19 @@ func resourceCertificateManagerDnsAuthorizationRead(d *schema.ResourceData, meta log.Printf("[DEBUG] Finished reading CertificateManagerDnsAuthorization %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading DnsAuthorization: %s", err) } @@ -441,6 +467,19 @@ func resourceCertificateManagerDnsAuthorizationRead(d *schema.ResourceData, meta } func resourceCertificateManagerDnsAuthorizationUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceCertificateManagerDnsAuthorization().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceCertificateManagerDnsAuthorizationRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -549,6 +588,13 @@ func resourceCertificateManagerDnsAuthorizationUpdate(d *schema.ResourceData, me } func resourceCertificateManagerDnsAuthorizationDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy CertificateManagerDnsAuthorization without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing DnsAuthorization %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/certificatemanager/resource_certificate_manager_dns_authorization_generated_meta.yaml b/google/services/certificatemanager/resource_certificate_manager_dns_authorization_generated_meta.yaml index 2c6d0fe1379..c4fcba91894 100644 --- a/google/services/certificatemanager/resource_certificate_manager_dns_authorization_generated_meta.yaml +++ b/google/services/certificatemanager/resource_certificate_manager_dns_authorization_generated_meta.yaml @@ -22,3 +22,5 @@ fields: - field: terraform_labels provider_only: true - api_field: type + - field: deletion_policy + provider_only: true diff --git a/google/services/certificatemanager/resource_certificate_manager_trust_config.go b/google/services/certificatemanager/resource_certificate_manager_trust_config.go index c6aac1c2e10..d4ee8f1b121 100644 --- a/google/services/certificatemanager/resource_certificate_manager_trust_config.go +++ b/google/services/certificatemanager/resource_certificate_manager_trust_config.go @@ -116,6 +116,7 @@ func ResourceCertificateManagerTrustConfig() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -261,6 +262,18 @@ Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -416,6 +429,19 @@ func resourceCertificateManagerTrustConfigRead(d *schema.ResourceData, meta inte log.Printf("[DEBUG] Finished reading CertificateManagerTrustConfig %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading TrustConfig: %s", err) } @@ -453,6 +479,19 @@ func resourceCertificateManagerTrustConfigRead(d *schema.ResourceData, meta inte } func resourceCertificateManagerTrustConfigUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceCertificateManagerTrustConfig().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceCertificateManagerTrustConfigRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -555,6 +594,13 @@ func resourceCertificateManagerTrustConfigUpdate(d *schema.ResourceData, meta in } func resourceCertificateManagerTrustConfigDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy CertificateManagerTrustConfig without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing TrustConfig %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/certificatemanager/resource_certificate_manager_trust_config_generated_meta.yaml b/google/services/certificatemanager/resource_certificate_manager_trust_config_generated_meta.yaml index cb9ad275a80..fd180273e1e 100644 --- a/google/services/certificatemanager/resource_certificate_manager_trust_config_generated_meta.yaml +++ b/google/services/certificatemanager/resource_certificate_manager_trust_config_generated_meta.yaml @@ -22,3 +22,5 @@ fields: - api_field: trustStores.intermediateCas.pemCertificate - api_field: trustStores.trustAnchors.pemCertificate - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/ces/resource_ces_agent.go b/google/services/ces/resource_ces_agent.go index 187371a6719..6c5c385acc3 100644 --- a/google/services/ces/resource_ces_agent.go +++ b/google/services/ces/resource_ces_agent.go @@ -115,6 +115,7 @@ func ResourceCESAgent() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -526,6 +527,18 @@ Format: 'projects/{project}/locations/{location}/apps/{app}/agents/{agent}'`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -754,6 +767,19 @@ func resourceCESAgentRead(d *schema.ResourceData, meta interface{}) error { log.Printf("[DEBUG] Finished reading CESAgent %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Agent: %s", err) } @@ -797,6 +823,19 @@ func resourceCESAgentRead(d *schema.ResourceData, meta interface{}) error { } func resourceCESAgentUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceCESAgent().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceCESAgentRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1043,6 +1082,13 @@ func resourceCESAgentUpdate(d *schema.ResourceData, meta interface{}) error { } func resourceCESAgentDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy CESAgent without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Agent %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/ces/resource_ces_agent_generated_meta.yaml b/google/services/ces/resource_ces_agent_generated_meta.yaml index ae91ec3b2a2..ed75e5a58d9 100644 --- a/google/services/ces/resource_ces_agent_generated_meta.yaml +++ b/google/services/ces/resource_ces_agent_generated_meta.yaml @@ -53,3 +53,5 @@ fields: - api_field: toolsets.toolIds - api_field: toolsets.toolset - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/ces/resource_ces_app.go b/google/services/ces/resource_ces_app.go index 28e630eb226..1285659e2d2 100644 --- a/google/services/ces/resource_ces_app.go +++ b/google/services/ces/resource_ces_app.go @@ -115,6 +115,7 @@ func ResourceCESApp() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -933,6 +934,18 @@ Format: 'projects/{project}/locations/{location}/apps/{app}'`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -1187,6 +1200,19 @@ func resourceCESAppRead(d *schema.ResourceData, meta interface{}) error { log.Printf("[DEBUG] Finished reading CESApp %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading App: %s", err) } @@ -1224,6 +1250,19 @@ func resourceCESAppRead(d *schema.ResourceData, meta interface{}) error { } func resourceCESAppUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceCESApp().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceCESAppRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1482,6 +1521,13 @@ func resourceCESAppUpdate(d *schema.ResourceData, meta interface{}) error { } func resourceCESAppDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy CESApp without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing App %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/ces/resource_ces_app_generated_meta.yaml b/google/services/ces/resource_ces_app_generated_meta.yaml index 1575e420cc8..5605a0dc1d6 100644 --- a/google/services/ces/resource_ces_app_generated_meta.yaml +++ b/google/services/ces/resource_ces_app_generated_meta.yaml @@ -92,3 +92,5 @@ fields: - api_field: variableDeclarations.schema.title - api_field: variableDeclarations.schema.type - api_field: variableDeclarations.schema.uniqueItems + - field: deletion_policy + provider_only: true diff --git a/google/services/ces/resource_ces_app_root_agent_association.go b/google/services/ces/resource_ces_app_root_agent_association.go index 08155cc4b29..78d404df0c0 100644 --- a/google/services/ces/resource_ces_app_root_agent_association.go +++ b/google/services/ces/resource_ces_app_root_agent_association.go @@ -115,6 +115,7 @@ func ResourceCESAppRootAgentAssociation() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -169,6 +170,18 @@ root agent of the app.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -310,6 +323,19 @@ func resourceCESAppRootAgentAssociationRead(d *schema.ResourceData, meta interfa return fmt.Errorf("Error setting agent_id: %s", err) } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading AppRootAgentAssociation: %s", err) } @@ -353,6 +379,19 @@ func resourceCESAppRootAgentAssociationRead(d *schema.ResourceData, meta interfa } func resourceCESAppRootAgentAssociationUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceCESAppRootAgentAssociation().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceCESAppRootAgentAssociationRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -423,6 +462,13 @@ func resourceCESAppRootAgentAssociationUpdate(d *schema.ResourceData, meta inter } func resourceCESAppRootAgentAssociationDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy CESAppRootAgentAssociation without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing AppRootAgentAssociation %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/ces/resource_ces_app_root_agent_association_generated_meta.yaml b/google/services/ces/resource_ces_app_root_agent_association_generated_meta.yaml index 44517f7d698..5d395cfaa31 100644 --- a/google/services/ces/resource_ces_app_root_agent_association_generated_meta.yaml +++ b/google/services/ces/resource_ces_app_root_agent_association_generated_meta.yaml @@ -12,3 +12,5 @@ fields: provider_only: true - field: location provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/ces/resource_ces_app_version.go b/google/services/ces/resource_ces_app_version.go index 9feb4309d53..b716644daa3 100644 --- a/google/services/ces/resource_ces_app_version.go +++ b/google/services/ces/resource_ces_app_version.go @@ -100,6 +100,7 @@ func ResourceCESAppVersion() *schema.Resource { return &schema.Resource{ Create: resourceCESAppVersionCreate, Read: resourceCESAppVersionRead, + Update: resourceCESAppVersionUpdate, Delete: resourceCESAppVersionDelete, Importer: &schema.ResourceImporter{ @@ -113,6 +114,7 @@ func ResourceCESAppVersion() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -3287,6 +3289,18 @@ it will replace the placeholder in the schema.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -3431,6 +3445,19 @@ func resourceCESAppVersionRead(d *schema.ResourceData, meta interface{}) error { log.Printf("[DEBUG] Finished reading CESAppVersion %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading AppVersion: %s", err) } @@ -3473,7 +3500,19 @@ func resourceCESAppVersionRead(d *schema.ResourceData, meta interface{}) error { return nil } +func resourceCESAppVersionUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceCESAppVersionRead(d, meta) +} + func resourceCESAppVersionDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy CESAppVersion without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing AppVersion %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/ces/resource_ces_app_version_generated_meta.yaml b/google/services/ces/resource_ces_app_version_generated_meta.yaml index 2e34c18a910..3d7de61deb6 100644 --- a/google/services/ces/resource_ces_app_version_generated_meta.yaml +++ b/google/services/ces/resource_ces_app_version_generated_meta.yaml @@ -341,3 +341,5 @@ fields: - api_field: snapshot.toolsets.openApiToolset.tlsConfig.caCerts.displayName - api_field: snapshot.toolsets.openApiToolset.url - api_field: snapshot.toolsets.updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/ces/resource_ces_deployment.go b/google/services/ces/resource_ces_deployment.go index e30dcb2e7ba..2e5f9b21644 100644 --- a/google/services/ces/resource_ces_deployment.go +++ b/google/services/ces/resource_ces_deployment.go @@ -115,6 +115,7 @@ func ResourceCESDeployment() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -293,6 +294,18 @@ projects/{project}/locations/{location}/apps/{app}/deployments/{deployment}`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -443,6 +456,19 @@ func resourceCESDeploymentRead(d *schema.ResourceData, meta interface{}) error { log.Printf("[DEBUG] Finished reading CESDeployment %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Deployment: %s", err) } @@ -486,6 +512,19 @@ func resourceCESDeploymentRead(d *schema.ResourceData, meta interface{}) error { } func resourceCESDeploymentUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceCESDeployment().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceCESDeploymentRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -602,6 +641,13 @@ func resourceCESDeploymentUpdate(d *schema.ResourceData, meta interface{}) error } func resourceCESDeploymentDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy CESDeployment without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Deployment %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/ces/resource_ces_deployment_generated_meta.yaml b/google/services/ces/resource_ces_deployment_generated_meta.yaml index c5721ba537e..89e75780341 100644 --- a/google/services/ces/resource_ces_deployment_generated_meta.yaml +++ b/google/services/ces/resource_ces_deployment_generated_meta.yaml @@ -26,3 +26,5 @@ fields: provider_only: true - api_field: name - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/ces/resource_ces_example.go b/google/services/ces/resource_ces_example.go index 277708d0d9f..4b6adbdfdce 100644 --- a/google/services/ces/resource_ces_example.go +++ b/google/services/ces/resource_ces_example.go @@ -115,6 +115,7 @@ func ResourceCESExample() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -412,6 +413,18 @@ Format: Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -574,6 +587,19 @@ func resourceCESExampleRead(d *schema.ResourceData, meta interface{}) error { log.Printf("[DEBUG] Finished reading CESExample %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Example: %s", err) } @@ -617,6 +643,19 @@ func resourceCESExampleRead(d *schema.ResourceData, meta interface{}) error { } func resourceCESExampleUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceCESExample().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceCESExampleRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -753,6 +792,13 @@ func resourceCESExampleUpdate(d *schema.ResourceData, meta interface{}) error { } func resourceCESExampleDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy CESExample without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Example %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/ces/resource_ces_example_generated_meta.yaml b/google/services/ces/resource_ces_example_generated_meta.yaml index b21318c4cde..d28f09e3ce5 100644 --- a/google/services/ces/resource_ces_example_generated_meta.yaml +++ b/google/services/ces/resource_ces_example_generated_meta.yaml @@ -44,3 +44,5 @@ fields: - api_field: messages.role - api_field: name - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/ces/resource_ces_guardrail.go b/google/services/ces/resource_ces_guardrail.go index b561bc5f5b1..fc0573dbb6c 100644 --- a/google/services/ces/resource_ces_guardrail.go +++ b/google/services/ces/resource_ces_guardrail.go @@ -115,6 +115,7 @@ func ResourceCESGuardrail() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -668,6 +669,18 @@ Format: Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -854,6 +867,19 @@ func resourceCESGuardrailRead(d *schema.ResourceData, meta interface{}) error { log.Printf("[DEBUG] Finished reading CESGuardrail %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Guardrail: %s", err) } @@ -897,6 +923,19 @@ func resourceCESGuardrailRead(d *schema.ResourceData, meta interface{}) error { } func resourceCESGuardrailUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceCESGuardrail().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceCESGuardrailRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1073,6 +1112,13 @@ func resourceCESGuardrailUpdate(d *schema.ResourceData, meta interface{}) error } func resourceCESGuardrailDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy CESGuardrail without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Guardrail %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/ces/resource_ces_guardrail_generated_meta.yaml b/google/services/ces/resource_ces_guardrail_generated_meta.yaml index 31a3d22f1f8..0cb175d24de 100644 --- a/google/services/ces/resource_ces_guardrail_generated_meta.yaml +++ b/google/services/ces/resource_ces_guardrail_generated_meta.yaml @@ -59,3 +59,5 @@ fields: - api_field: modelSafety.safetySettings.threshold - api_field: name - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/ces/resource_ces_tool.go b/google/services/ces/resource_ces_tool.go index 3feee29a684..5b160256b5e 100644 --- a/google/services/ces/resource_ces_tool.go +++ b/google/services/ces/resource_ces_tool.go @@ -115,6 +115,7 @@ func ResourceCESTool() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -1285,6 +1286,18 @@ placeholder in the schema.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -1447,6 +1460,19 @@ func resourceCESToolRead(d *schema.ResourceData, meta interface{}) error { log.Printf("[DEBUG] Finished reading CESTool %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Tool: %s", err) } @@ -1490,6 +1516,19 @@ func resourceCESToolRead(d *schema.ResourceData, meta interface{}) error { } func resourceCESToolUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceCESTool().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceCESToolRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1626,6 +1665,13 @@ func resourceCESToolUpdate(d *schema.ResourceData, meta interface{}) error { } func resourceCESToolDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy CESTool without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Tool %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/ces/resource_ces_tool_generated_meta.yaml b/google/services/ces/resource_ces_tool_generated_meta.yaml index a11dc51ea27..12ec004cc1b 100644 --- a/google/services/ces/resource_ces_tool_generated_meta.yaml +++ b/google/services/ces/resource_ces_tool_generated_meta.yaml @@ -135,3 +135,5 @@ fields: - field: tool_id provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/ces/resource_ces_toolset.go b/google/services/ces/resource_ces_toolset.go index 7d25232e26a..2bf9a78dc76 100644 --- a/google/services/ces/resource_ces_toolset.go +++ b/google/services/ces/resource_ces_toolset.go @@ -115,6 +115,7 @@ func ResourceCESToolset() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -690,6 +691,18 @@ Format: Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -846,6 +859,19 @@ func resourceCESToolsetRead(d *schema.ResourceData, meta interface{}) error { log.Printf("[DEBUG] Finished reading CESToolset %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Toolset: %s", err) } @@ -889,6 +915,19 @@ func resourceCESToolsetRead(d *schema.ResourceData, meta interface{}) error { } func resourceCESToolsetUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceCESToolset().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceCESToolsetRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1025,6 +1064,13 @@ func resourceCESToolsetUpdate(d *schema.ResourceData, meta interface{}) error { } func resourceCESToolsetDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy CESToolset without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Toolset %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/ces/resource_ces_toolset_generated_meta.yaml b/google/services/ces/resource_ces_toolset_generated_meta.yaml index ec55cb30bba..5828ae49f6d 100644 --- a/google/services/ces/resource_ces_toolset_generated_meta.yaml +++ b/google/services/ces/resource_ces_toolset_generated_meta.yaml @@ -56,3 +56,5 @@ fields: - field: toolset_id provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/chronicle/resource_chronicle_dashboard_chart.go b/google/services/chronicle/resource_chronicle_dashboard_chart.go index 36cd3bf42b9..9fda426d758 100644 --- a/google/services/chronicle/resource_chronicle_dashboard_chart.go +++ b/google/services/chronicle/resource_chronicle_dashboard_chart.go @@ -115,6 +115,7 @@ func ResourceChronicleDashboardChart() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -1447,6 +1448,18 @@ func ResourceChronicleDashboardChart() *schema.Resource { Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -1609,6 +1622,19 @@ func resourceChronicleDashboardChartRead(d *schema.ResourceData, meta interface{ return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading DashboardChart: %s", err) } @@ -1652,6 +1678,19 @@ func resourceChronicleDashboardChartRead(d *schema.ResourceData, meta interface{ } func resourceChronicleDashboardChartUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceChronicleDashboardChart().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceChronicleDashboardChartRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1795,6 +1834,13 @@ func resourceChronicleDashboardChartUpdate(d *schema.ResourceData, meta interfac } func resourceChronicleDashboardChartDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ChronicleDashboardChart without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing DashboardChart %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/chronicle/resource_chronicle_dashboard_chart_generated_meta.yaml b/google/services/chronicle/resource_chronicle_dashboard_chart_generated_meta.yaml index 03b1e4865a7..ac1c4aca73c 100644 --- a/google/services/chronicle/resource_chronicle_dashboard_chart_generated_meta.yaml +++ b/google/services/chronicle/resource_chronicle_dashboard_chart_generated_meta.yaml @@ -147,3 +147,5 @@ fields: - api_field: name - field: native_dashboard provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/chronicle/resource_chronicle_data_access_label.go b/google/services/chronicle/resource_chronicle_data_access_label.go index 90e12e820af..5c3a9fa24f1 100644 --- a/google/services/chronicle/resource_chronicle_data_access_label.go +++ b/google/services/chronicle/resource_chronicle_data_access_label.go @@ -115,6 +115,7 @@ func ResourceChronicleDataAccessLabel() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -214,6 +215,18 @@ projects/{project}/locations/{location}/instances/{instance}/dataAccessLabels/{d Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -352,6 +365,19 @@ func resourceChronicleDataAccessLabelRead(d *schema.ResourceData, meta interface log.Printf("[DEBUG] Finished reading ChronicleDataAccessLabel %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading DataAccessLabel: %s", err) } @@ -395,6 +421,19 @@ func resourceChronicleDataAccessLabelRead(d *schema.ResourceData, meta interface } func resourceChronicleDataAccessLabelUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceChronicleDataAccessLabel().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceChronicleDataAccessLabelRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -501,6 +540,13 @@ func resourceChronicleDataAccessLabelUpdate(d *schema.ResourceData, meta interfa } func resourceChronicleDataAccessLabelDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ChronicleDataAccessLabel without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing DataAccessLabel %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/chronicle/resource_chronicle_data_access_label_generated_meta.yaml b/google/services/chronicle/resource_chronicle_data_access_label_generated_meta.yaml index f7783c55113..2dc718ead3d 100644 --- a/google/services/chronicle/resource_chronicle_data_access_label_generated_meta.yaml +++ b/google/services/chronicle/resource_chronicle_data_access_label_generated_meta.yaml @@ -22,3 +22,5 @@ fields: - api_field: name - api_field: udmQuery - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/chronicle/resource_chronicle_data_access_scope.go b/google/services/chronicle/resource_chronicle_data_access_scope.go index b37c1d0f6bf..67ea13f49cc 100644 --- a/google/services/chronicle/resource_chronicle_data_access_scope.go +++ b/google/services/chronicle/resource_chronicle_data_access_scope.go @@ -115,6 +115,7 @@ func ResourceChronicleDataAccessScope() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -342,6 +343,18 @@ projects/{project}/locations/{location}/instances/{instance}/dataAccessScopes/{d Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -492,6 +505,19 @@ func resourceChronicleDataAccessScopeRead(d *schema.ResourceData, meta interface log.Printf("[DEBUG] Finished reading ChronicleDataAccessScope %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading DataAccessScope: %s", err) } @@ -535,6 +561,19 @@ func resourceChronicleDataAccessScopeRead(d *schema.ResourceData, meta interface } func resourceChronicleDataAccessScopeUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceChronicleDataAccessScope().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceChronicleDataAccessScopeRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -661,6 +700,13 @@ func resourceChronicleDataAccessScopeUpdate(d *schema.ResourceData, meta interfa } func resourceChronicleDataAccessScopeDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ChronicleDataAccessScope without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing DataAccessScope %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/chronicle/resource_chronicle_data_access_scope_generated_meta.yaml b/google/services/chronicle/resource_chronicle_data_access_scope_generated_meta.yaml index cd4626b9574..1934b1872c0 100644 --- a/google/services/chronicle/resource_chronicle_data_access_scope_generated_meta.yaml +++ b/google/services/chronicle/resource_chronicle_data_access_scope_generated_meta.yaml @@ -34,3 +34,5 @@ fields: provider_only: true - api_field: name - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/chronicle/resource_chronicle_data_table.go b/google/services/chronicle/resource_chronicle_data_table.go index 8d76a710d2c..4ae4f1d30de 100644 --- a/google/services/chronicle/resource_chronicle_data_table.go +++ b/google/services/chronicle/resource_chronicle_data_table.go @@ -115,6 +115,7 @@ func ResourceChronicleDataTable() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DEFAULT"), ), Identity: &schema.ResourceIdentity{ @@ -319,21 +320,18 @@ SEARCH`, Computed: true, Description: `Table update time`, }, - "deletion_policy": { - Type: schema.TypeString, - Optional: true, - Description: `The policy governing the deletion of the data table. -If set to 'FORCE', allows the deletion of the data table even if it contains rows. -If set to 'DEFAULT',or if the field is omitted, the data table must be empty before it can be deleted. -Possible values: DEFAULT, FORCE`, - Default: "DEFAULT", - }, "project": { Type: schema.TypeString, Optional: true, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `This field uses a custom implementation please refer to documentation under /hashicorp/terraform-provider-google-beta/website/docs/r/chronicle_data_table.html.markdown for specifics`, + }, }, UseJSONNumber: true, } @@ -486,8 +484,15 @@ func resourceChronicleDataTableRead(d *schema.ResourceData, meta interface{}) er // Explicitly set virtual fields to default values if unset if _, ok := d.GetOkExists("deletion_policy"); !ok { - if err := d.Set("deletion_policy", "DEFAULT"); err != nil { - return fmt.Errorf("Error setting deletion_policy: %s", err) + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DEFAULT"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } } } if err := d.Set("project", project); err != nil { @@ -533,6 +538,19 @@ func resourceChronicleDataTableRead(d *schema.ResourceData, meta interface{}) er } func resourceChronicleDataTableUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceChronicleDataTable().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceChronicleDataTableRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -649,6 +667,13 @@ func resourceChronicleDataTableUpdate(d *schema.ResourceData, meta interface{}) } func resourceChronicleDataTableDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ChronicleDataTable without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing DataTable %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -717,9 +742,6 @@ func resourceChronicleDataTableImport(d *schema.ResourceData, meta interface{}) d.SetId(id) // Explicitly set virtual fields to default values on import - if err := d.Set("deletion_policy", "DEFAULT"); err != nil { - return nil, fmt.Errorf("Error setting deletion_policy: %s", err) - } return []*schema.ResourceData{d}, nil } diff --git a/google/services/chronicle/resource_chronicle_data_table_generated_meta.yaml b/google/services/chronicle/resource_chronicle_data_table_generated_meta.yaml index 0d1d7311800..63604332ee1 100644 --- a/google/services/chronicle/resource_chronicle_data_table_generated_meta.yaml +++ b/google/services/chronicle/resource_chronicle_data_table_generated_meta.yaml @@ -19,8 +19,6 @@ fields: - field: data_table_id provider_only: true - api_field: dataTableUuid - - field: deletion_policy - provider_only: true - api_field: description - api_field: displayName - field: instance @@ -35,3 +33,5 @@ fields: - api_field: scopeInfo.dataAccessScopes - api_field: updateSource - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/chronicle/resource_chronicle_data_table_row.go b/google/services/chronicle/resource_chronicle_data_table_row.go index f0dbf098cfe..71ce14d4ac4 100644 --- a/google/services/chronicle/resource_chronicle_data_table_row.go +++ b/google/services/chronicle/resource_chronicle_data_table_row.go @@ -115,6 +115,7 @@ func ResourceChronicleDataTableRow() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -210,6 +211,18 @@ projects/{project}/locations/{location}/instances/{instance}/dataTables/{data_ta Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -359,6 +372,19 @@ func resourceChronicleDataTableRowRead(d *schema.ResourceData, meta interface{}) log.Printf("[DEBUG] Finished reading ChronicleDataTableRow %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading DataTableRow: %s", err) } @@ -408,6 +434,19 @@ func resourceChronicleDataTableRowRead(d *schema.ResourceData, meta interface{}) } func resourceChronicleDataTableRowUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceChronicleDataTableRow().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceChronicleDataTableRowRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -509,6 +548,13 @@ func resourceChronicleDataTableRowUpdate(d *schema.ResourceData, meta interface{ } func resourceChronicleDataTableRowDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ChronicleDataTableRow without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing DataTableRow %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/chronicle/resource_chronicle_data_table_row_generated_meta.yaml b/google/services/chronicle/resource_chronicle_data_table_row_generated_meta.yaml index 05112a3e140..fc3038252f3 100644 --- a/google/services/chronicle/resource_chronicle_data_table_row_generated_meta.yaml +++ b/google/services/chronicle/resource_chronicle_data_table_row_generated_meta.yaml @@ -20,3 +20,5 @@ fields: - api_field: rowTimeToLive - api_field: updateTime - api_field: values + - field: deletion_policy + provider_only: true diff --git a/google/services/chronicle/resource_chronicle_reference_list.go b/google/services/chronicle/resource_chronicle_reference_list.go index 93624540e1f..3a079257cf8 100644 --- a/google/services/chronicle/resource_chronicle_reference_list.go +++ b/google/services/chronicle/resource_chronicle_reference_list.go @@ -461,6 +461,7 @@ func resourceChronicleReferenceListRead(d *schema.ResourceData, meta interface{} } func resourceChronicleReferenceListUpdate(d *schema.ResourceData, meta interface{}) error { + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/chronicle/resource_chronicle_rule.go b/google/services/chronicle/resource_chronicle_rule.go index 4dae483ba8a..2c9c9e832ef 100644 --- a/google/services/chronicle/resource_chronicle_rule.go +++ b/google/services/chronicle/resource_chronicle_rule.go @@ -115,6 +115,7 @@ func ResourceChronicleRule() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DEFAULT"), ), Identity: &schema.ResourceIdentity{ @@ -364,24 +365,18 @@ RULE_TYPE_UNSPECIFIED SINGLE_EVENT MULTI_EVENT`, }, - "deletion_policy": { - Type: schema.TypeString, - Optional: true, - Description: `Policy to determine if the rule should be deleted forcefully. -If deletion_policy = "FORCE", any retrohunts and any detections associated with the rule -will also be deleted. If deletion_policy = "DEFAULT", the call will only succeed if the -rule has no associated retrohunts, including completed retrohunts, and no -associated detections. Regardless of this field's value, the rule -deployment associated with this rule will also be deleted. -Possible values: DEFAULT, FORCE`, - Default: "DEFAULT", - }, "project": { Type: schema.TypeString, Optional: true, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `This field uses a custom implementation please refer to documentation under /hashicorp/terraform-provider-google-beta/website/docs/r/chronicle_rule.html.markdown for specifics`, + }, }, UseJSONNumber: true, } @@ -534,8 +529,15 @@ func resourceChronicleRuleRead(d *schema.ResourceData, meta interface{}) error { // Explicitly set virtual fields to default values if unset if _, ok := d.GetOkExists("deletion_policy"); !ok { - if err := d.Set("deletion_policy", "DEFAULT"); err != nil { - return fmt.Errorf("Error setting deletion_policy: %s", err) + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DEFAULT"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } } } if err := d.Set("project", project); err != nil { @@ -581,6 +583,19 @@ func resourceChronicleRuleRead(d *schema.ResourceData, meta interface{}) error { } func resourceChronicleRuleUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceChronicleRule().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceChronicleRuleRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -697,6 +712,13 @@ func resourceChronicleRuleUpdate(d *schema.ResourceData, meta interface{}) error } func resourceChronicleRuleDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ChronicleRule without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Rule %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -765,9 +787,6 @@ func resourceChronicleRuleImport(d *schema.ResourceData, meta interface{}) ([]*s d.SetId(id) // Explicitly set virtual fields to default values on import - if err := d.Set("deletion_policy", "DEFAULT"); err != nil { - return nil, fmt.Errorf("Error setting deletion_policy: %s", err) - } return []*schema.ResourceData{d}, nil } diff --git a/google/services/chronicle/resource_chronicle_rule_deployment.go b/google/services/chronicle/resource_chronicle_rule_deployment.go index d8f97b54672..e199db722ed 100644 --- a/google/services/chronicle/resource_chronicle_rule_deployment.go +++ b/google/services/chronicle/resource_chronicle_rule_deployment.go @@ -525,6 +525,7 @@ func resourceChronicleRuleDeploymentRead(d *schema.ResourceData, meta interface{ } func resourceChronicleRuleDeploymentUpdate(d *schema.ResourceData, meta interface{}) error { + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/chronicle/resource_chronicle_rule_generated_meta.yaml b/google/services/chronicle/resource_chronicle_rule_generated_meta.yaml index e6c916efe9f..62a2df7fd46 100644 --- a/google/services/chronicle/resource_chronicle_rule_generated_meta.yaml +++ b/google/services/chronicle/resource_chronicle_rule_generated_meta.yaml @@ -20,8 +20,6 @@ fields: - api_field: compilationState - api_field: createTime - api_field: dataTables - - field: deletion_policy - provider_only: true - api_field: displayName - api_field: etag - field: instance @@ -39,3 +37,5 @@ fields: - api_field: severity.displayName - api_field: text - api_field: type + - field: deletion_policy + provider_only: true diff --git a/google/services/chronicle/resource_chronicle_watchlist.go b/google/services/chronicle/resource_chronicle_watchlist.go index a822bdb0b1d..7879ce0416e 100644 --- a/google/services/chronicle/resource_chronicle_watchlist.go +++ b/google/services/chronicle/resource_chronicle_watchlist.go @@ -115,6 +115,7 @@ func ResourceChronicleWatchlist() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -264,6 +265,18 @@ projects/{project}/locations/{location}/instances/{instance}/watchlists/{watchli Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -437,6 +450,19 @@ func resourceChronicleWatchlistRead(d *schema.ResourceData, meta interface{}) er log.Printf("[DEBUG] Finished reading ChronicleWatchlist %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Watchlist: %s", err) } @@ -480,6 +506,19 @@ func resourceChronicleWatchlistRead(d *schema.ResourceData, meta interface{}) er } func resourceChronicleWatchlistUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceChronicleWatchlist().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceChronicleWatchlistRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -621,6 +660,13 @@ func resourceChronicleWatchlistUpdate(d *schema.ResourceData, meta interface{}) } func resourceChronicleWatchlistDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ChronicleWatchlist without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Watchlist %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/chronicle/resource_chronicle_watchlist_generated_meta.yaml b/google/services/chronicle/resource_chronicle_watchlist_generated_meta.yaml index 5bc1783e627..83b3776df0a 100644 --- a/google/services/chronicle/resource_chronicle_watchlist_generated_meta.yaml +++ b/google/services/chronicle/resource_chronicle_watchlist_generated_meta.yaml @@ -23,3 +23,5 @@ fields: - api_field: updateTime - api_field: watchlistId - api_field: watchlistUserPreferences.pinned + - field: deletion_policy + provider_only: true diff --git a/google/services/cloudasset/resource_cloud_asset_folder_feed.go b/google/services/cloudasset/resource_cloud_asset_folder_feed.go index 85920649dc7..55a0717f288 100644 --- a/google/services/cloudasset/resource_cloud_asset_folder_feed.go +++ b/google/services/cloudasset/resource_cloud_asset_folder_feed.go @@ -255,6 +255,19 @@ and folders/[FOLDER_NUMBER] are accepted.`, Computed: true, Description: `The format will be folders/{folder_number}/feeds/{client-assigned_feed_identifier}.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -415,6 +428,20 @@ func resourceCloudAssetFolderFeedRead(d *schema.ResourceData, meta interface{}) log.Printf("[DEBUG] Finished reading CloudAssetFolderFeed %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceCloudAssetFolderFeedFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -442,6 +469,19 @@ func resourceCloudAssetFolderFeedRead(d *schema.ResourceData, meta interface{}) } func resourceCloudAssetFolderFeedUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceCloudAssetFolderFeed().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceCloudAssetFolderFeedRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -570,6 +610,13 @@ func resourceCloudAssetFolderFeedUpdate(d *schema.ResourceData, meta interface{} } func resourceCloudAssetFolderFeedDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy CloudAssetFolderFeed without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing FolderFeed %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/cloudasset/resource_cloud_asset_folder_feed_generated_meta.yaml b/google/services/cloudasset/resource_cloud_asset_folder_feed_generated_meta.yaml index b4055d63818..3c8cd1c8f0d 100644 --- a/google/services/cloudasset/resource_cloud_asset_folder_feed_generated_meta.yaml +++ b/google/services/cloudasset/resource_cloud_asset_folder_feed_generated_meta.yaml @@ -28,3 +28,5 @@ fields: - field: folder_id provider_only: true - api_field: name + - field: deletion_policy + provider_only: true diff --git a/google/services/cloudasset/resource_cloud_asset_organization_feed.go b/google/services/cloudasset/resource_cloud_asset_organization_feed.go index 79db9ab016d..c3015ef05ef 100644 --- a/google/services/cloudasset/resource_cloud_asset_organization_feed.go +++ b/google/services/cloudasset/resource_cloud_asset_organization_feed.go @@ -249,6 +249,19 @@ This can be used e.g. in UIs which allow to enter the expression.`, Computed: true, Description: `The format will be organizations/{organization_number}/feeds/{client-assigned_feed_identifier}.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -409,6 +422,20 @@ func resourceCloudAssetOrganizationFeedRead(d *schema.ResourceData, meta interfa log.Printf("[DEBUG] Finished reading CloudAssetOrganizationFeed %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceCloudAssetOrganizationFeedFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -436,6 +463,19 @@ func resourceCloudAssetOrganizationFeedRead(d *schema.ResourceData, meta interfa } func resourceCloudAssetOrganizationFeedUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceCloudAssetOrganizationFeed().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceCloudAssetOrganizationFeedRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -564,6 +604,13 @@ func resourceCloudAssetOrganizationFeedUpdate(d *schema.ResourceData, meta inter } func resourceCloudAssetOrganizationFeedDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy CloudAssetOrganizationFeed without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing OrganizationFeed %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/cloudasset/resource_cloud_asset_organization_feed_generated_meta.yaml b/google/services/cloudasset/resource_cloud_asset_organization_feed_generated_meta.yaml index fe3698dc3c1..44de2c86357 100644 --- a/google/services/cloudasset/resource_cloud_asset_organization_feed_generated_meta.yaml +++ b/google/services/cloudasset/resource_cloud_asset_organization_feed_generated_meta.yaml @@ -26,3 +26,5 @@ fields: - api_field: name - field: org_id provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/cloudasset/resource_cloud_asset_project_feed.go b/google/services/cloudasset/resource_cloud_asset_project_feed.go index 821b84c8643..51bc9a17dde 100644 --- a/google/services/cloudasset/resource_cloud_asset_project_feed.go +++ b/google/services/cloudasset/resource_cloud_asset_project_feed.go @@ -115,6 +115,7 @@ func ResourceCloudAssetProjectFeed() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -254,6 +255,18 @@ This can be used e.g. in UIs which allow to enter the expression.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -418,6 +431,19 @@ func resourceCloudAssetProjectFeedRead(d *schema.ResourceData, meta interface{}) log.Printf("[DEBUG] Finished reading CloudAssetProjectFeed %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading ProjectFeed: %s", err) } @@ -449,6 +475,19 @@ func resourceCloudAssetProjectFeedRead(d *schema.ResourceData, meta interface{}) } func resourceCloudAssetProjectFeedUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceCloudAssetProjectFeed().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceCloudAssetProjectFeedRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -580,6 +619,13 @@ func resourceCloudAssetProjectFeedUpdate(d *schema.ResourceData, meta interface{ } func resourceCloudAssetProjectFeedDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy CloudAssetProjectFeed without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ProjectFeed %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/cloudasset/resource_cloud_asset_project_feed_generated_meta.yaml b/google/services/cloudasset/resource_cloud_asset_project_feed_generated_meta.yaml index 7a6207fe509..a8a0ccffee3 100644 --- a/google/services/cloudasset/resource_cloud_asset_project_feed_generated_meta.yaml +++ b/google/services/cloudasset/resource_cloud_asset_project_feed_generated_meta.yaml @@ -24,3 +24,5 @@ fields: provider_only: true - api_field: feedOutputConfig.pubsubDestination.topic - api_field: name + - field: deletion_policy + provider_only: true diff --git a/google/services/cloudbilling/resource_billing_project_info.go b/google/services/cloudbilling/resource_billing_project_info.go index 4d6fe168781..eba6ace130c 100644 --- a/google/services/cloudbilling/resource_billing_project_info.go +++ b/google/services/cloudbilling/resource_billing_project_info.go @@ -115,6 +115,7 @@ func ResourceCloudBillingProjectInfo() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -146,6 +147,18 @@ For example, '"012345-567890-ABCDEF"' or '""'.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -280,6 +293,19 @@ func resourceCloudBillingProjectInfoRead(d *schema.ResourceData, meta interface{ return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading ProjectInfo: %s", err) } @@ -305,6 +331,19 @@ func resourceCloudBillingProjectInfoRead(d *schema.ResourceData, meta interface{ } func resourceCloudBillingProjectInfoUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceCloudBillingProjectInfo().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceCloudBillingProjectInfoRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -376,6 +415,13 @@ func resourceCloudBillingProjectInfoUpdate(d *schema.ResourceData, meta interfac } func resourceCloudBillingProjectInfoDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy CloudBillingProjectInfo without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ProjectInfo %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/cloudbilling/resource_billing_project_info_generated_meta.yaml b/google/services/cloudbilling/resource_billing_project_info_generated_meta.yaml index 9b2278b4c99..79e8c6cb032 100644 --- a/google/services/cloudbilling/resource_billing_project_info_generated_meta.yaml +++ b/google/services/cloudbilling/resource_billing_project_info_generated_meta.yaml @@ -10,3 +10,5 @@ cai_asset_name_formats: - //cloudbilling.googleapis.com/projects/{{project}}/billingInfo fields: - api_field: billing_account + - field: deletion_policy + provider_only: true diff --git a/google/services/cloudbuild/resource_cloudbuild_bitbucket_server_config.go b/google/services/cloudbuild/resource_cloudbuild_bitbucket_server_config.go index 7b16322048d..51b31606591 100644 --- a/google/services/cloudbuild/resource_cloudbuild_bitbucket_server_config.go +++ b/google/services/cloudbuild/resource_cloudbuild_bitbucket_server_config.go @@ -115,6 +115,7 @@ func ResourceCloudBuildBitbucketServerConfig() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -234,6 +235,18 @@ projects/{project}/global/networks/{network}, where {project} is a project numbe Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -480,6 +493,19 @@ func resourceCloudBuildBitbucketServerConfigRead(d *schema.ResourceData, meta in log.Printf("[DEBUG] Finished reading CloudBuildBitbucketServerConfig %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading BitbucketServerConfig: %s", err) } @@ -517,6 +543,19 @@ func resourceCloudBuildBitbucketServerConfigRead(d *schema.ResourceData, meta in } func resourceCloudBuildBitbucketServerConfigUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceCloudBuildBitbucketServerConfig().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceCloudBuildBitbucketServerConfigRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -772,6 +811,13 @@ func resourceCloudBuildBitbucketServerConfigUpdate(d *schema.ResourceData, meta } func resourceCloudBuildBitbucketServerConfigDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy CloudBuildBitbucketServerConfig without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing BitbucketServerConfig %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/cloudbuild/resource_cloudbuild_bitbucket_server_config_generated_meta.yaml b/google/services/cloudbuild/resource_cloudbuild_bitbucket_server_config_generated_meta.yaml index be825f5bdff..ff195c9032c 100644 --- a/google/services/cloudbuild/resource_cloudbuild_bitbucket_server_config_generated_meta.yaml +++ b/google/services/cloudbuild/resource_cloudbuild_bitbucket_server_config_generated_meta.yaml @@ -23,3 +23,5 @@ fields: - api_field: sslCa - api_field: username - api_field: webhookKey + - field: deletion_policy + provider_only: true diff --git a/google/services/cloudbuild/resource_cloudbuild_trigger.go b/google/services/cloudbuild/resource_cloudbuild_trigger.go index 3f3246c9c15..ee40a07ba73 100644 --- a/google/services/cloudbuild/resource_cloudbuild_trigger.go +++ b/google/services/cloudbuild/resource_cloudbuild_trigger.go @@ -167,6 +167,7 @@ func ResourceCloudBuildTrigger() *schema.Resource { CustomizeDiff: customdiff.All( stepTimeoutCustomizeDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -1564,6 +1565,18 @@ Only populated on get requests.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -1829,6 +1842,19 @@ func resourceCloudBuildTriggerRead(d *schema.ResourceData, meta interface{}) err log.Printf("[DEBUG] Finished reading CloudBuildTrigger %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Trigger: %s", err) } @@ -1866,6 +1892,19 @@ func resourceCloudBuildTriggerRead(d *schema.ResourceData, meta interface{}) err } func resourceCloudBuildTriggerUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceCloudBuildTrigger().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceCloudBuildTriggerRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -2069,6 +2108,13 @@ func resourceCloudBuildTriggerUpdate(d *schema.ResourceData, meta interface{}) e } func resourceCloudBuildTriggerDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy CloudBuildTrigger without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Trigger %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/cloudbuild/resource_cloudbuild_trigger_generated_meta.yaml b/google/services/cloudbuild/resource_cloudbuild_trigger_generated_meta.yaml index 7949de018ff..d1c6a9b9416 100644 --- a/google/services/cloudbuild/resource_cloudbuild_trigger_generated_meta.yaml +++ b/google/services/cloudbuild/resource_cloudbuild_trigger_generated_meta.yaml @@ -165,3 +165,5 @@ fields: - api_field: triggerTemplate.tagName - api_field: webhookConfig.secret - api_field: webhookConfig.state + - field: deletion_policy + provider_only: true diff --git a/google/services/cloudbuild/resource_cloudbuild_worker_pool.go b/google/services/cloudbuild/resource_cloudbuild_worker_pool.go index 4b79efd5586..3dc5d0c36d0 100644 --- a/google/services/cloudbuild/resource_cloudbuild_worker_pool.go +++ b/google/services/cloudbuild/resource_cloudbuild_worker_pool.go @@ -52,6 +52,7 @@ func ResourceCloudbuildWorkerPool() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, tpgresource.SetAnnotationsDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -155,6 +156,9 @@ func ResourceCloudbuildWorkerPool() *schema.Resource { Computed: true, Description: "Output only. Time at which the request to update the `WorkerPool` was received.", }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, } } @@ -370,9 +374,18 @@ func resourceCloudbuildWorkerPoolRead(d *schema.ResourceData, meta interface{}) return fmt.Errorf("error setting update_time in state: %s", err) } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } func resourceCloudbuildWorkerPoolUpdate(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceCloudbuildWorkerPool) { + return ResourceCloudbuildWorkerPool().Read(d, meta) + } + config := meta.(*transport_tpg.Config) project, err := tpgresource.GetProject(d, config) if err != nil { @@ -423,6 +436,13 @@ func resourceCloudbuildWorkerPoolUpdate(d *schema.ResourceData, meta interface{} } func resourceCloudbuildWorkerPoolDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) project, err := tpgresource.GetProject(d, config) if err != nil { diff --git a/google/services/cloudbuild/resource_cloudbuild_worker_pool_meta.yaml b/google/services/cloudbuild/resource_cloudbuild_worker_pool_meta.yaml index e3324c0e744..312c174c386 100644 --- a/google/services/cloudbuild/resource_cloudbuild_worker_pool_meta.yaml +++ b/google/services/cloudbuild/resource_cloudbuild_worker_pool_meta.yaml @@ -34,3 +34,5 @@ fields: field: 'worker_config.machine_type' - api_field: 'privatePoolV1Config.networkConfig.egressOption' field: 'worker_config.no_external_ip' + - field: 'deletion_policy' + provider_only: true \ No newline at end of file diff --git a/google/services/cloudbuildv2/resource_cloudbuildv2_connection.go b/google/services/cloudbuildv2/resource_cloudbuildv2_connection.go index 939ceec3b43..047dcd8435d 100644 --- a/google/services/cloudbuildv2/resource_cloudbuildv2_connection.go +++ b/google/services/cloudbuildv2/resource_cloudbuildv2_connection.go @@ -116,6 +116,7 @@ func ResourceCloudbuildv2Connection() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetAnnotationsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -573,6 +574,18 @@ Please refer to the field 'effective_annotations' for all of the annotations pre Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -752,6 +765,19 @@ func resourceCloudbuildv2ConnectionRead(d *schema.ResourceData, meta interface{} log.Printf("[DEBUG] Finished reading Cloudbuildv2Connection %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Connection: %s", err) } @@ -789,6 +815,19 @@ func resourceCloudbuildv2ConnectionRead(d *schema.ResourceData, meta interface{} } func resourceCloudbuildv2ConnectionUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceCloudbuildv2Connection().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceCloudbuildv2ConnectionRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -915,6 +954,13 @@ func resourceCloudbuildv2ConnectionUpdate(d *schema.ResourceData, meta interface } func resourceCloudbuildv2ConnectionDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy Cloudbuildv2Connection without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Connection %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/cloudbuildv2/resource_cloudbuildv2_connection_generated_meta.yaml b/google/services/cloudbuildv2/resource_cloudbuildv2_connection_generated_meta.yaml index 4687254d49b..4864a741a48 100644 --- a/google/services/cloudbuildv2/resource_cloudbuildv2_connection_generated_meta.yaml +++ b/google/services/cloudbuildv2/resource_cloudbuildv2_connection_generated_meta.yaml @@ -57,3 +57,5 @@ fields: provider_only: true - api_field: reconciling - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/cloudbuildv2/resource_cloudbuildv2_repository.go b/google/services/cloudbuildv2/resource_cloudbuildv2_repository.go index 626d77cce9d..8ca4b92a975 100644 --- a/google/services/cloudbuildv2/resource_cloudbuildv2_repository.go +++ b/google/services/cloudbuildv2/resource_cloudbuildv2_repository.go @@ -100,6 +100,7 @@ func ResourceCloudbuildv2Repository() *schema.Resource { return &schema.Resource{ Create: resourceCloudbuildv2RepositoryCreate, Read: resourceCloudbuildv2RepositoryRead, + Update: resourceCloudbuildv2RepositoryUpdate, Delete: resourceCloudbuildv2RepositoryDelete, Importer: &schema.ResourceImporter{ @@ -114,6 +115,7 @@ func ResourceCloudbuildv2Repository() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetAnnotationsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -208,6 +210,18 @@ Please refer to the field 'effective_annotations' for all of the annotations pre Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -367,6 +381,19 @@ func resourceCloudbuildv2RepositoryRead(d *schema.ResourceData, meta interface{} log.Printf("[DEBUG] Finished reading Cloudbuildv2Repository %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Repository: %s", err) } @@ -409,7 +436,19 @@ func resourceCloudbuildv2RepositoryRead(d *schema.ResourceData, meta interface{} return nil } +func resourceCloudbuildv2RepositoryUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceCloudbuildv2RepositoryRead(d, meta) +} + func resourceCloudbuildv2RepositoryDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy Cloudbuildv2Repository without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Repository %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/cloudbuildv2/resource_cloudbuildv2_repository_generated_meta.yaml b/google/services/cloudbuildv2/resource_cloudbuildv2_repository_generated_meta.yaml index 0a0cbdb9690..3e23cff684c 100644 --- a/google/services/cloudbuildv2/resource_cloudbuildv2_repository_generated_meta.yaml +++ b/google/services/cloudbuildv2/resource_cloudbuildv2_repository_generated_meta.yaml @@ -19,3 +19,5 @@ fields: provider_only: true - api_field: remoteUri - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/clouddeploy/resource_clouddeploy_automation.go b/google/services/clouddeploy/resource_clouddeploy_automation.go index aa3f1399ae6..3a4b6db0ab1 100644 --- a/google/services/clouddeploy/resource_clouddeploy_automation.go +++ b/google/services/clouddeploy/resource_clouddeploy_automation.go @@ -117,6 +117,7 @@ func ResourceClouddeployAutomation() *schema.Resource { tpgresource.SetAnnotationsDiff, tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -470,6 +471,18 @@ Please refer to the field 'effective_labels' for all of the labels present on th Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -648,6 +661,19 @@ func resourceClouddeployAutomationRead(d *schema.ResourceData, meta interface{}) log.Printf("[DEBUG] Finished reading ClouddeployAutomation %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Automation: %s", err) } @@ -691,6 +717,19 @@ func resourceClouddeployAutomationRead(d *schema.ResourceData, meta interface{}) } func resourceClouddeployAutomationUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceClouddeployAutomation().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceClouddeployAutomationRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -854,6 +893,13 @@ func resourceClouddeployAutomationUpdate(d *schema.ResourceData, meta interface{ } func resourceClouddeployAutomationDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ClouddeployAutomation without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Automation %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/clouddeploy/resource_clouddeploy_automation_generated_meta.yaml b/google/services/clouddeploy/resource_clouddeploy_automation_generated_meta.yaml index 0c8daaea149..1c1b671ff1c 100644 --- a/google/services/clouddeploy/resource_clouddeploy_automation_generated_meta.yaml +++ b/google/services/clouddeploy/resource_clouddeploy_automation_generated_meta.yaml @@ -50,3 +50,5 @@ fields: provider_only: true - api_field: uid - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/clouddeploy/resource_clouddeploy_custom_target_type.go b/google/services/clouddeploy/resource_clouddeploy_custom_target_type.go index 42e001f55aa..471b4593bde 100644 --- a/google/services/clouddeploy/resource_clouddeploy_custom_target_type.go +++ b/google/services/clouddeploy/resource_clouddeploy_custom_target_type.go @@ -117,6 +117,7 @@ func ResourceClouddeployCustomTargetType() *schema.Resource { tpgresource.SetAnnotationsDiff, tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -444,6 +445,18 @@ Please refer to the field 'effective_labels' for all of the labels present on th Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -605,6 +618,19 @@ func resourceClouddeployCustomTargetTypeRead(d *schema.ResourceData, meta interf log.Printf("[DEBUG] Finished reading ClouddeployCustomTargetType %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading CustomTargetType: %s", err) } @@ -642,6 +668,19 @@ func resourceClouddeployCustomTargetTypeRead(d *schema.ResourceData, meta interf } func resourceClouddeployCustomTargetTypeUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceClouddeployCustomTargetType().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceClouddeployCustomTargetTypeRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -780,6 +819,13 @@ func resourceClouddeployCustomTargetTypeUpdate(d *schema.ResourceData, meta inte } func resourceClouddeployCustomTargetTypeDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ClouddeployCustomTargetType without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing CustomTargetType %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/clouddeploy/resource_clouddeploy_custom_target_type_generated_meta.yaml b/google/services/clouddeploy/resource_clouddeploy_custom_target_type_generated_meta.yaml index efe74fdd4b4..7804a69eea7 100644 --- a/google/services/clouddeploy/resource_clouddeploy_custom_target_type_generated_meta.yaml +++ b/google/services/clouddeploy/resource_clouddeploy_custom_target_type_generated_meta.yaml @@ -44,3 +44,5 @@ fields: provider_only: true - api_field: uid - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/clouddeploy/resource_clouddeploy_delivery_pipeline.go b/google/services/clouddeploy/resource_clouddeploy_delivery_pipeline.go index 7050cb71e7d..5bf378431ea 100644 --- a/google/services/clouddeploy/resource_clouddeploy_delivery_pipeline.go +++ b/google/services/clouddeploy/resource_clouddeploy_delivery_pipeline.go @@ -53,6 +53,7 @@ func ResourceClouddeployDeliveryPipeline() *schema.Resource { tpgresource.DefaultProviderProject, tpgresource.SetLabelsDiff, tpgresource.SetAnnotationsDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -161,6 +162,9 @@ func ResourceClouddeployDeliveryPipeline() *schema.Resource { Computed: true, Description: "Output only. Most recent time at which the pipeline was updated.", }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, } } @@ -1105,9 +1109,18 @@ func resourceClouddeployDeliveryPipelineRead(d *schema.ResourceData, meta interf return fmt.Errorf("error setting update_time in state: %s", err) } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } func resourceClouddeployDeliveryPipelineUpdate(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceClouddeployDeliveryPipeline) { + return ResourceClouddeployDeliveryPipeline().Read(d, meta) + } + config := meta.(*transport_tpg.Config) project, err := tpgresource.GetProject(d, config) if err != nil { @@ -1158,6 +1171,13 @@ func resourceClouddeployDeliveryPipelineUpdate(d *schema.ResourceData, meta inte } func resourceClouddeployDeliveryPipelineDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) project, err := tpgresource.GetProject(d, config) if err != nil { diff --git a/google/services/clouddeploy/resource_clouddeploy_delivery_pipeline_meta.yaml b/google/services/clouddeploy/resource_clouddeploy_delivery_pipeline_meta.yaml index 06dde40cdec..a2f90ccab0d 100644 --- a/google/services/clouddeploy/resource_clouddeploy_delivery_pipeline_meta.yaml +++ b/google/services/clouddeploy/resource_clouddeploy_delivery_pipeline_meta.yaml @@ -113,3 +113,5 @@ fields: provider_only: true - api_field: 'uid' - api_field: 'updateTime' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/clouddeploy/resource_clouddeploy_deploy_policy.go b/google/services/clouddeploy/resource_clouddeploy_deploy_policy.go index 8751dfeed3e..c12ea92538d 100644 --- a/google/services/clouddeploy/resource_clouddeploy_deploy_policy.go +++ b/google/services/clouddeploy/resource_clouddeploy_deploy_policy.go @@ -117,6 +117,7 @@ func ResourceClouddeployDeployPolicy() *schema.Resource { tpgresource.SetAnnotationsDiff, tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -537,6 +538,18 @@ Please refer to the field 'effective_labels' for all of the labels present on th Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -704,6 +717,19 @@ func resourceClouddeployDeployPolicyRead(d *schema.ResourceData, meta interface{ log.Printf("[DEBUG] Finished reading ClouddeployDeployPolicy %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading DeployPolicy: %s", err) } @@ -741,6 +767,19 @@ func resourceClouddeployDeployPolicyRead(d *schema.ResourceData, meta interface{ } func resourceClouddeployDeployPolicyUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceClouddeployDeployPolicy().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceClouddeployDeployPolicyRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -889,6 +928,13 @@ func resourceClouddeployDeployPolicyUpdate(d *schema.ResourceData, meta interfac } func resourceClouddeployDeployPolicyDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ClouddeployDeployPolicy without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing DeployPolicy %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/clouddeploy/resource_clouddeploy_deploy_policy_generated_meta.yaml b/google/services/clouddeploy/resource_clouddeploy_deploy_policy_generated_meta.yaml index edeebfa7f51..3434a43bc33 100644 --- a/google/services/clouddeploy/resource_clouddeploy_deploy_policy_generated_meta.yaml +++ b/google/services/clouddeploy/resource_clouddeploy_deploy_policy_generated_meta.yaml @@ -56,3 +56,5 @@ fields: provider_only: true - api_field: uid - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/clouddeploy/resource_clouddeploy_target.go b/google/services/clouddeploy/resource_clouddeploy_target.go index 069c72a42db..c6f8313d883 100644 --- a/google/services/clouddeploy/resource_clouddeploy_target.go +++ b/google/services/clouddeploy/resource_clouddeploy_target.go @@ -53,6 +53,7 @@ func ResourceClouddeployTarget() *schema.Resource { tpgresource.DefaultProviderProject, tpgresource.SetLabelsDiff, tpgresource.SetAnnotationsDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -220,6 +221,9 @@ func ResourceClouddeployTarget() *schema.Resource { Computed: true, Description: "Output only. Most recent time at which the `Target` was updated.", }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, } } @@ -661,9 +665,18 @@ func resourceClouddeployTargetRead(d *schema.ResourceData, meta interface{}) err return fmt.Errorf("error setting update_time in state: %s", err) } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } func resourceClouddeployTargetUpdate(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceClouddeployTarget) { + return ResourceClouddeployTarget().Read(d, meta) + } + config := meta.(*transport_tpg.Config) project, err := tpgresource.GetProject(d, config) if err != nil { @@ -721,6 +734,13 @@ func resourceClouddeployTargetUpdate(d *schema.ResourceData, meta interface{}) e } func resourceClouddeployTargetDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) project, err := tpgresource.GetProject(d, config) if err != nil { diff --git a/google/services/clouddeploy/resource_clouddeploy_target_meta.yaml b/google/services/clouddeploy/resource_clouddeploy_target_meta.yaml index 7e9637c5fa8..675eeffd90f 100644 --- a/google/services/clouddeploy/resource_clouddeploy_target_meta.yaml +++ b/google/services/clouddeploy/resource_clouddeploy_target_meta.yaml @@ -49,3 +49,5 @@ fields: provider_only: true - api_field: 'uid' - api_field: 'updateTime' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/clouddomains/resource_clouddomains_registration.go b/google/services/clouddomains/resource_clouddomains_registration.go index b5eee999fa7..d8951e559c6 100644 --- a/google/services/clouddomains/resource_clouddomains_registration.go +++ b/google/services/clouddomains/resource_clouddomains_registration.go @@ -988,7 +988,7 @@ func resourceClouddomainsRegistrationRead(d *schema.ResourceData, meta interface } func resourceClouddomainsRegistrationUpdate(d *schema.ResourceData, meta interface{}) error { - // Only the root field "labels", "terraform_labels", and virtual fields are mutable + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable return resourceClouddomainsRegistrationRead(d, meta) } diff --git a/google/services/cloudfunctions/resource_cloudfunctions_function.go b/google/services/cloudfunctions/resource_cloudfunctions_function.go index eec12e70977..58f9b086800 100644 --- a/google/services/cloudfunctions/resource_cloudfunctions_function.go +++ b/google/services/cloudfunctions/resource_cloudfunctions_function.go @@ -160,6 +160,7 @@ func ResourceCloudFunctionsFunction() *schema.Resource { }, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), tpgresource.DefaultProviderProject, tpgresource.DefaultProviderRegion, tpgresource.SetLabelsDiff, @@ -550,6 +551,9 @@ func ResourceCloudFunctionsFunction() *schema.Resource { Computed: true, Description: `The version identifier of the Cloud Function. Each deployment attempt results in a new version of a function being created.`, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, UseJSONNumber: true, } @@ -884,11 +888,20 @@ func resourceCloudFunctionsRead(d *schema.ResourceData, meta interface{}) error d.Set("automatic_update_policy", nil) } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } func resourceCloudFunctionsUpdate(d *schema.ResourceData, meta interface{}) error { log.Printf("[DEBUG]: Updating google_cloudfunctions_function") + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceCloudFunctionsFunction) { + return ResourceCloudFunctionsFunction().Read(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1081,6 +1094,13 @@ func resourceCloudFunctionsUpdate(d *schema.ResourceData, meta interface{}) erro } func resourceCloudFunctionsDestroy(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/cloudfunctions/resource_cloudfunctions_function_meta.yaml b/google/services/cloudfunctions/resource_cloudfunctions_function_meta.yaml index b090370cbc9..4adaed2d235 100644 --- a/google/services/cloudfunctions/resource_cloudfunctions_function_meta.yaml +++ b/google/services/cloudfunctions/resource_cloudfunctions_function_meta.yaml @@ -55,3 +55,5 @@ fields: - api_field: 'vpcConnectorEgressSettings' - field: 'automatic_update_policy' - api_field: 'onDeployUpdatePolicy.runtimeVersion' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/cloudfunctions2/resource_cloudfunctions2_function.go b/google/services/cloudfunctions2/resource_cloudfunctions2_function.go index f63fd9fcdb9..a743a4b083b 100644 --- a/google/services/cloudfunctions2/resource_cloudfunctions2_function.go +++ b/google/services/cloudfunctions2/resource_cloudfunctions2_function.go @@ -131,6 +131,7 @@ func ResourceCloudfunctions2function() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -681,6 +682,18 @@ timeout period. Defaults to 60 seconds.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -887,6 +900,19 @@ func resourceCloudfunctions2functionRead(d *schema.ResourceData, meta interface{ log.Printf("[DEBUG] Finished reading Cloudfunctions2function %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading function: %s", err) } @@ -924,6 +950,19 @@ func resourceCloudfunctions2functionRead(d *schema.ResourceData, meta interface{ } func resourceCloudfunctions2functionUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceCloudfunctions2function().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceCloudfunctions2functionRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1077,6 +1116,13 @@ func resourceCloudfunctions2functionUpdate(d *schema.ResourceData, meta interfac } func resourceCloudfunctions2functionDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy Cloudfunctions2function without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing function %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/cloudfunctions2/resource_cloudfunctions2_function_generated_meta.yaml b/google/services/cloudfunctions2/resource_cloudfunctions2_function_generated_meta.yaml index 9bea5317d71..e690a4489c5 100644 --- a/google/services/cloudfunctions2/resource_cloudfunctions2_function_generated_meta.yaml +++ b/google/services/cloudfunctions2/resource_cloudfunctions2_function_generated_meta.yaml @@ -78,3 +78,5 @@ fields: provider_only: true - api_field: updateTime - api_field: url + - field: deletion_policy + provider_only: true diff --git a/google/services/cloudidentity/resource_cloud_identity_group.go b/google/services/cloudidentity/resource_cloud_identity_group.go index 508ba9fe62d..f043478ced9 100644 --- a/google/services/cloudidentity/resource_cloud_identity_group.go +++ b/google/services/cloudidentity/resource_cloud_identity_group.go @@ -264,6 +264,19 @@ is the unique ID assigned to the Group.`, Computed: true, Description: `The time when the Group was last updated.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -457,6 +470,20 @@ func resourceCloudIdentityGroupRead(d *schema.ResourceData, meta interface{}) er log.Printf("[DEBUG] Finished reading CloudIdentityGroup %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceCloudIdentityGroupFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -478,6 +505,19 @@ func resourceCloudIdentityGroupRead(d *schema.ResourceData, meta interface{}) er } func resourceCloudIdentityGroupUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceCloudIdentityGroup().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceCloudIdentityGroupRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -577,6 +617,13 @@ func resourceCloudIdentityGroupUpdate(d *schema.ResourceData, meta interface{}) } func resourceCloudIdentityGroupDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy CloudIdentityGroup without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Group %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/cloudidentity/resource_cloud_identity_group_generated_meta.yaml b/google/services/cloudidentity/resource_cloud_identity_group_generated_meta.yaml index a41f5f85c75..5c31321ee3f 100644 --- a/google/services/cloudidentity/resource_cloud_identity_group_generated_meta.yaml +++ b/google/services/cloudidentity/resource_cloud_identity_group_generated_meta.yaml @@ -20,3 +20,5 @@ fields: - api_field: name - api_field: parent - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/cloudidentity/resource_cloud_identity_group_membership.go b/google/services/cloudidentity/resource_cloud_identity_group_membership.go index 3da9f92dd36..56e0d05b062 100644 --- a/google/services/cloudidentity/resource_cloud_identity_group_membership.go +++ b/google/services/cloudidentity/resource_cloud_identity_group_membership.go @@ -210,6 +210,19 @@ and must be in the form of 'identitysources/{identity_source_id}'.`, Description: `If set to true, skip group member creation if a membership with the same name already exists. Defaults to false.`, Default: false, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -454,6 +467,18 @@ func resourceCloudIdentityGroupMembershipRead(d *schema.ResourceData, meta inter return fmt.Errorf("Error setting create_ignore_already_exists: %s", err) } } + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } err = ResourceCloudIdentityGroupMembershipFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { @@ -476,6 +501,19 @@ func resourceCloudIdentityGroupMembershipRead(d *schema.ResourceData, meta inter } func resourceCloudIdentityGroupMembershipUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceCloudIdentityGroupMembership().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceCloudIdentityGroupMembershipRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -605,6 +643,13 @@ func resourceCloudIdentityGroupMembershipUpdate(d *schema.ResourceData, meta int } func resourceCloudIdentityGroupMembershipDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy CloudIdentityGroupMembership without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing GroupMembership %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/cloudidentity/resource_cloud_identity_group_membership_generated_meta.yaml b/google/services/cloudidentity/resource_cloud_identity_group_membership_generated_meta.yaml index 39ca642b4f9..e99dc9df472 100644 --- a/google/services/cloudidentity/resource_cloud_identity_group_membership_generated_meta.yaml +++ b/google/services/cloudidentity/resource_cloud_identity_group_membership_generated_meta.yaml @@ -19,3 +19,5 @@ fields: - api_field: roles.name - api_field: type - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/cloudids/resource_cloud_ids_endpoint.go b/google/services/cloudids/resource_cloud_ids_endpoint.go index 4d325aeff33..9634ba0dfe3 100644 --- a/google/services/cloudids/resource_cloud_ids_endpoint.go +++ b/google/services/cloudids/resource_cloud_ids_endpoint.go @@ -115,6 +115,7 @@ func ResourceCloudIdsEndpoint() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -206,6 +207,18 @@ func ResourceCloudIdsEndpoint() *schema.Resource { Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -367,6 +380,19 @@ func resourceCloudIdsEndpointRead(d *schema.ResourceData, meta interface{}) erro log.Printf("[DEBUG] Finished reading CloudIdsEndpoint %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Endpoint: %s", err) } @@ -404,6 +430,19 @@ func resourceCloudIdsEndpointRead(d *schema.ResourceData, meta interface{}) erro } func resourceCloudIdsEndpointUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceCloudIdsEndpoint().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceCloudIdsEndpointRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -502,6 +541,13 @@ func resourceCloudIdsEndpointUpdate(d *schema.ResourceData, meta interface{}) er } func resourceCloudIdsEndpointDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy CloudIdsEndpoint without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Endpoint %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/cloudids/resource_cloud_ids_endpoint_generated_meta.yaml b/google/services/cloudids/resource_cloud_ids_endpoint_generated_meta.yaml index a709b2be756..1a6ea454981 100644 --- a/google/services/cloudids/resource_cloud_ids_endpoint_generated_meta.yaml +++ b/google/services/cloudids/resource_cloud_ids_endpoint_generated_meta.yaml @@ -18,3 +18,5 @@ fields: - api_field: severity - api_field: threatExceptions - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/cloudquotas/resource_cloud_quotas_quota_preference.go b/google/services/cloudquotas/resource_cloud_quotas_quota_preference.go index 81f8e06311f..c71cb204f32 100644 --- a/google/services/cloudquotas/resource_cloud_quotas_quota_preference.go +++ b/google/services/cloudquotas/resource_cloud_quotas_quota_preference.go @@ -444,6 +444,7 @@ func resourceCloudQuotasQuotaPreferenceRead(d *schema.ResourceData, meta interfa } func resourceCloudQuotasQuotaPreferenceUpdate(d *schema.ResourceData, meta interface{}) error { + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/cloudrun/resource_cloud_run_domain_mapping.go b/google/services/cloudrun/resource_cloud_run_domain_mapping.go index f4d965c656c..ba06054128e 100644 --- a/google/services/cloudrun/resource_cloud_run_domain_mapping.go +++ b/google/services/cloudrun/resource_cloud_run_domain_mapping.go @@ -110,6 +110,7 @@ func ResourceCloudRunDomainMapping() *schema.Resource { return &schema.Resource{ Create: resourceCloudRunDomainMappingCreate, Read: resourceCloudRunDomainMappingRead, + Update: resourceCloudRunDomainMappingUpdate, Delete: resourceCloudRunDomainMappingDelete, Importer: &schema.ResourceImporter{ @@ -135,6 +136,7 @@ func ResourceCloudRunDomainMapping() *schema.Resource { tpgresource.SetMetadataLabelsDiff, tpgresource.SetMetadataAnnotationsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -394,6 +396,18 @@ was last processed by the controller.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -601,6 +615,19 @@ func resourceCloudRunDomainMappingRead(d *schema.ResourceData, meta interface{}) return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading DomainMapping: %s", err) } @@ -637,7 +664,19 @@ func resourceCloudRunDomainMappingRead(d *schema.ResourceData, meta interface{}) return nil } +func resourceCloudRunDomainMappingUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceCloudRunDomainMappingRead(d, meta) +} + func resourceCloudRunDomainMappingDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy CloudRunDomainMapping without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing DomainMapping %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/cloudrun/resource_cloud_run_domain_mapping_generated_meta.yaml b/google/services/cloudrun/resource_cloud_run_domain_mapping_generated_meta.yaml index eb3100df325..dcdce7a4c2b 100644 --- a/google/services/cloudrun/resource_cloud_run_domain_mapping_generated_meta.yaml +++ b/google/services/cloudrun/resource_cloud_run_domain_mapping_generated_meta.yaml @@ -38,3 +38,5 @@ fields: - api_field: status.resourceRecords.name - api_field: status.resourceRecords.rrdata - api_field: status.resourceRecords.type + - field: deletion_policy + provider_only: true diff --git a/google/services/cloudrun/resource_cloud_run_service.go b/google/services/cloudrun/resource_cloud_run_service.go index 98a71401b71..f2bf1a23822 100644 --- a/google/services/cloudrun/resource_cloud_run_service.go +++ b/google/services/cloudrun/resource_cloud_run_service.go @@ -175,6 +175,7 @@ func ResourceCloudRunService() *schema.Resource { tpgresource.SetMetadataLabelsDiff, tpgresource.SetMetadataAnnotationsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -1384,6 +1385,18 @@ this field is set to false, the revision name will still autogenerate.)`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -1651,6 +1664,18 @@ func resourceCloudRunServiceRead(d *schema.ResourceData, meta interface{}) error return fmt.Errorf("Error setting autogenerate_revision_name: %s", err) } } + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Service: %s", err) } @@ -1688,6 +1713,19 @@ func resourceCloudRunServiceRead(d *schema.ResourceData, meta interface{}) error } func resourceCloudRunServiceUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceCloudRunService().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceCloudRunServiceRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1781,6 +1819,13 @@ func resourceCloudRunServiceUpdate(d *schema.ResourceData, meta interface{}) err } func resourceCloudRunServiceDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy CloudRunService without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Service %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/cloudrun/resource_cloud_run_service_generated_meta.yaml b/google/services/cloudrun/resource_cloud_run_service_generated_meta.yaml index 7d537ccb102..02a1e592b48 100644 --- a/google/services/cloudrun/resource_cloud_run_service_generated_meta.yaml +++ b/google/services/cloudrun/resource_cloud_run_service_generated_meta.yaml @@ -207,3 +207,5 @@ fields: field: traffic.tag - api_field: spec.traffic.url field: traffic.url + - field: deletion_policy + provider_only: true diff --git a/google/services/cloudrunv2/resource_cloud_run_v2_job.go b/google/services/cloudrunv2/resource_cloud_run_v2_job.go index 46b83c1499c..1679e20f555 100644 --- a/google/services/cloudrunv2/resource_cloud_run_v2_job.go +++ b/google/services/cloudrunv2/resource_cloud_run_v2_job.go @@ -117,6 +117,7 @@ func ResourceCloudRunV2Job() *schema.Resource { tpgresource.SetLabelsDiff, tpgresource.SetAnnotationsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -1024,6 +1025,18 @@ When the field is set to false, deleting the job is allowed.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -1250,6 +1263,18 @@ func resourceCloudRunV2JobRead(d *schema.ResourceData, meta interface{}) error { return fmt.Errorf("Error setting deletion_protection: %s", err) } } + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Job: %s", err) } @@ -1287,6 +1312,19 @@ func resourceCloudRunV2JobRead(d *schema.ResourceData, meta interface{}) error { } func resourceCloudRunV2JobUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceCloudRunV2Job().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceCloudRunV2JobRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1407,6 +1445,13 @@ func resourceCloudRunV2JobUpdate(d *schema.ResourceData, meta interface{}) error } func resourceCloudRunV2JobDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy CloudRunV2Job without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Job %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/cloudrunv2/resource_cloud_run_v2_job_generated_meta.yaml b/google/services/cloudrunv2/resource_cloud_run_v2_job_generated_meta.yaml index 299bb88197d..680cc91f9b9 100644 --- a/google/services/cloudrunv2/resource_cloud_run_v2_job_generated_meta.yaml +++ b/google/services/cloudrunv2/resource_cloud_run_v2_job_generated_meta.yaml @@ -116,3 +116,5 @@ fields: provider_only: true - api_field: uid - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/cloudrunv2/resource_cloud_run_v2_service.go b/google/services/cloudrunv2/resource_cloud_run_v2_service.go index 3b337b79df3..519eae60d4e 100644 --- a/google/services/cloudrunv2/resource_cloud_run_v2_service.go +++ b/google/services/cloudrunv2/resource_cloud_run_v2_service.go @@ -117,6 +117,7 @@ func ResourceCloudRunV2Service() *schema.Resource { tpgresource.SetLabelsDiff, tpgresource.SetAnnotationsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -1476,6 +1477,18 @@ When the field is set to false, deleting the service is allowed.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -1762,6 +1775,18 @@ func resourceCloudRunV2ServiceRead(d *schema.ResourceData, meta interface{}) err return fmt.Errorf("Error setting deletion_protection: %s", err) } } + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Service: %s", err) } @@ -1799,6 +1824,19 @@ func resourceCloudRunV2ServiceRead(d *schema.ResourceData, meta interface{}) err } func resourceCloudRunV2ServiceUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceCloudRunV2Service().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceCloudRunV2ServiceRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1979,6 +2017,13 @@ func resourceCloudRunV2ServiceUpdate(d *schema.ResourceData, meta interface{}) e } func resourceCloudRunV2ServiceDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy CloudRunV2Service without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Service %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/cloudrunv2/resource_cloud_run_v2_service_generated_meta.yaml b/google/services/cloudrunv2/resource_cloud_run_v2_service_generated_meta.yaml index bca8630b389..5b9ebf8273c 100644 --- a/google/services/cloudrunv2/resource_cloud_run_v2_service_generated_meta.yaml +++ b/google/services/cloudrunv2/resource_cloud_run_v2_service_generated_meta.yaml @@ -173,3 +173,5 @@ fields: - api_field: updateTime - api_field: uri - api_field: urls + - field: deletion_policy + provider_only: true diff --git a/google/services/cloudrunv2/resource_cloud_run_v2_worker_pool.go b/google/services/cloudrunv2/resource_cloud_run_v2_worker_pool.go index 6ac74acac6f..e71ddd65234 100644 --- a/google/services/cloudrunv2/resource_cloud_run_v2_worker_pool.go +++ b/google/services/cloudrunv2/resource_cloud_run_v2_worker_pool.go @@ -117,6 +117,7 @@ func ResourceCloudRunV2WorkerPool() *schema.Resource { tpgresource.SetLabelsDiff, tpgresource.SetAnnotationsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -1139,6 +1140,18 @@ When the field is set to false, deleting the WorkerPool is allowed.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -1389,6 +1402,18 @@ func resourceCloudRunV2WorkerPoolRead(d *schema.ResourceData, meta interface{}) return fmt.Errorf("Error setting deletion_protection: %s", err) } } + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading WorkerPool: %s", err) } @@ -1426,6 +1451,19 @@ func resourceCloudRunV2WorkerPoolRead(d *schema.ResourceData, meta interface{}) } func resourceCloudRunV2WorkerPoolUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceCloudRunV2WorkerPool().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceCloudRunV2WorkerPoolRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1570,6 +1608,13 @@ func resourceCloudRunV2WorkerPoolUpdate(d *schema.ResourceData, meta interface{} } func resourceCloudRunV2WorkerPoolDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy CloudRunV2WorkerPool without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing WorkerPool %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/cloudrunv2/resource_cloud_run_v2_worker_pool_generated_meta.yaml b/google/services/cloudrunv2/resource_cloud_run_v2_worker_pool_generated_meta.yaml index 7d8aa933c42..1425d123a5c 100644 --- a/google/services/cloudrunv2/resource_cloud_run_v2_worker_pool_generated_meta.yaml +++ b/google/services/cloudrunv2/resource_cloud_run_v2_worker_pool_generated_meta.yaml @@ -133,3 +133,5 @@ fields: provider_only: true - api_field: uid - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/cloudscheduler/resource_cloud_scheduler_job.go b/google/services/cloudscheduler/resource_cloud_scheduler_job.go index 3184aef769e..10d4e72c17b 100644 --- a/google/services/cloudscheduler/resource_cloud_scheduler_job.go +++ b/google/services/cloudscheduler/resource_cloud_scheduler_job.go @@ -207,6 +207,7 @@ func ResourceCloudSchedulerJob() *schema.Resource { validateAuthHeaders, tpgresource.DefaultProviderProject, tpgresource.DefaultProviderRegion, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -555,6 +556,18 @@ The value of this field must be a time zone name from the tz database.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -771,6 +784,19 @@ func resourceCloudSchedulerJobRead(d *schema.ResourceData, meta interface{}) err log.Printf("[DEBUG] Finished reading CloudSchedulerJob %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Job: %s", err) } @@ -816,6 +842,19 @@ func resourceCloudSchedulerJobRead(d *schema.ResourceData, meta interface{}) err } func resourceCloudSchedulerJobUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceCloudSchedulerJob().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceCloudSchedulerJobRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -978,6 +1017,13 @@ func resourceCloudSchedulerJobUpdate(d *schema.ResourceData, meta interface{}) e } func resourceCloudSchedulerJobDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy CloudSchedulerJob without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Job %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/cloudscheduler/resource_cloud_scheduler_job_generated_meta.yaml b/google/services/cloudscheduler/resource_cloud_scheduler_job_generated_meta.yaml index 36eaf5d7d36..4d119e1845a 100644 --- a/google/services/cloudscheduler/resource_cloud_scheduler_job_generated_meta.yaml +++ b/google/services/cloudscheduler/resource_cloud_scheduler_job_generated_meta.yaml @@ -39,3 +39,5 @@ fields: - api_field: schedule - api_field: state - api_field: timeZone + - field: deletion_policy + provider_only: true diff --git a/google/services/cloudsecuritycompliance/resource_cloud_security_compliance_cloud_control.go b/google/services/cloudsecuritycompliance/resource_cloud_security_compliance_cloud_control.go index 76c977696a8..7858d0d8cd2 100644 --- a/google/services/cloudsecuritycompliance/resource_cloud_security_compliance_cloud_control.go +++ b/google/services/cloudsecuritycompliance/resource_cloud_security_compliance_cloud_control.go @@ -980,6 +980,19 @@ organizations/{organization}/locations/{location}/cloudControls/{cloud_control_i Type: schema.TypeString, }, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -1148,6 +1161,20 @@ func resourceCloudSecurityComplianceCloudControlRead(d *schema.ResourceData, met log.Printf("[DEBUG] Finished reading CloudSecurityComplianceCloudControl %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceCloudSecurityComplianceCloudControlFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -1181,6 +1208,19 @@ func resourceCloudSecurityComplianceCloudControlRead(d *schema.ResourceData, met } func resourceCloudSecurityComplianceCloudControlUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceCloudSecurityComplianceCloudControl().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceCloudSecurityComplianceCloudControlRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1321,6 +1361,13 @@ func resourceCloudSecurityComplianceCloudControlUpdate(d *schema.ResourceData, m } func resourceCloudSecurityComplianceCloudControlDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy CloudSecurityComplianceCloudControl without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing CloudControl %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/cloudsecuritycompliance/resource_cloud_security_compliance_cloud_control_generated_meta.yaml b/google/services/cloudsecuritycompliance/resource_cloud_security_compliance_cloud_control_generated_meta.yaml index c70e049f44c..1ae5110f8af 100644 --- a/google/services/cloudsecuritycompliance/resource_cloud_security_compliance_cloud_control_generated_meta.yaml +++ b/google/services/cloudsecuritycompliance/resource_cloud_security_compliance_cloud_control_generated_meta.yaml @@ -87,3 +87,5 @@ fields: - api_field: supportedCloudProviders - api_field: supportedEnforcementModes - api_field: supportedTargetResourceTypes + - field: deletion_policy + provider_only: true diff --git a/google/services/cloudsecuritycompliance/resource_cloud_security_compliance_framework.go b/google/services/cloudsecuritycompliance/resource_cloud_security_compliance_framework.go index 77727833403..b2ec78b05b0 100644 --- a/google/services/cloudsecuritycompliance/resource_cloud_security_compliance_framework.go +++ b/google/services/cloudsecuritycompliance/resource_cloud_security_compliance_framework.go @@ -357,6 +357,19 @@ Possible values: BUILT_IN CUSTOM`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -489,6 +502,20 @@ func resourceCloudSecurityComplianceFrameworkRead(d *schema.ResourceData, meta i log.Printf("[DEBUG] Finished reading CloudSecurityComplianceFramework %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceCloudSecurityComplianceFrameworkFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -522,6 +549,19 @@ func resourceCloudSecurityComplianceFrameworkRead(d *schema.ResourceData, meta i } func resourceCloudSecurityComplianceFrameworkUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceCloudSecurityComplianceFramework().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceCloudSecurityComplianceFrameworkRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -632,6 +672,13 @@ func resourceCloudSecurityComplianceFrameworkUpdate(d *schema.ResourceData, meta } func resourceCloudSecurityComplianceFrameworkDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy CloudSecurityComplianceFramework without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Framework %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/cloudsecuritycompliance/resource_cloud_security_compliance_framework_deployment.go b/google/services/cloudsecuritycompliance/resource_cloud_security_compliance_framework_deployment.go index b1ff2e8e4eb..3b2a6041a7e 100644 --- a/google/services/cloudsecuritycompliance/resource_cloud_security_compliance_framework_deployment.go +++ b/google/services/cloudsecuritycompliance/resource_cloud_security_compliance_framework_deployment.go @@ -100,6 +100,7 @@ func ResourceCloudSecurityComplianceFrameworkDeployment() *schema.Resource { return &schema.Resource{ Create: resourceCloudSecurityComplianceFrameworkDeploymentCreate, Read: resourceCloudSecurityComplianceFrameworkDeploymentRead, + Update: resourceCloudSecurityComplianceFrameworkDeploymentUpdate, Delete: resourceCloudSecurityComplianceFrameworkDeploymentDelete, Importer: &schema.ResourceImporter{ @@ -533,6 +534,19 @@ organizations/{organization}/locations/{location}/frameworkDeployments/{framewor Computed: true, Description: `The time at which the resource last updated.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -676,6 +690,20 @@ func resourceCloudSecurityComplianceFrameworkDeploymentRead(d *schema.ResourceDa log.Printf("[DEBUG] Finished reading CloudSecurityComplianceFrameworkDeployment %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceCloudSecurityComplianceFrameworkDeploymentFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -708,7 +736,19 @@ func resourceCloudSecurityComplianceFrameworkDeploymentRead(d *schema.ResourceDa return nil } +func resourceCloudSecurityComplianceFrameworkDeploymentUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceCloudSecurityComplianceFrameworkDeploymentRead(d, meta) +} + func resourceCloudSecurityComplianceFrameworkDeploymentDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy CloudSecurityComplianceFrameworkDeployment without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing FrameworkDeployment %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/cloudsecuritycompliance/resource_cloud_security_compliance_framework_deployment_generated_meta.yaml b/google/services/cloudsecuritycompliance/resource_cloud_security_compliance_framework_deployment_generated_meta.yaml index a631a62192d..8edcc7943dd 100644 --- a/google/services/cloudsecuritycompliance/resource_cloud_security_compliance_framework_deployment_generated_meta.yaml +++ b/google/services/cloudsecuritycompliance/resource_cloud_security_compliance_framework_deployment_generated_meta.yaml @@ -44,3 +44,5 @@ fields: - api_field: targetResourceConfig.targetResourceCreationConfig.projectCreationConfig.projectDisplayName - api_field: targetResourceDisplayName - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/cloudsecuritycompliance/resource_cloud_security_compliance_framework_generated_meta.yaml b/google/services/cloudsecuritycompliance/resource_cloud_security_compliance_framework_generated_meta.yaml index 55b9193607c..ad1b404bebe 100644 --- a/google/services/cloudsecuritycompliance/resource_cloud_security_compliance_framework_generated_meta.yaml +++ b/google/services/cloudsecuritycompliance/resource_cloud_security_compliance_framework_generated_meta.yaml @@ -35,3 +35,5 @@ fields: - api_field: supportedEnforcementModes - api_field: supportedTargetResourceTypes - api_field: type + - field: deletion_policy + provider_only: true diff --git a/google/services/cloudtasks/resource_cloud_tasks_queue.go b/google/services/cloudtasks/resource_cloud_tasks_queue.go index e82a642698b..6ed94f30f6a 100644 --- a/google/services/cloudtasks/resource_cloud_tasks_queue.go +++ b/google/services/cloudtasks/resource_cloud_tasks_queue.go @@ -123,6 +123,7 @@ func ResourceCloudTasksQueue() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -551,6 +552,18 @@ default and means that no operations are logged.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -731,6 +744,18 @@ func resourceCloudTasksQueueRead(d *schema.ResourceData, meta interface{}) error return fmt.Errorf("Error setting desired_state: %s", err) } } + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Queue: %s", err) } @@ -768,6 +793,19 @@ func resourceCloudTasksQueueRead(d *schema.ResourceData, meta interface{}) error } func resourceCloudTasksQueueUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceCloudTasksQueue().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceCloudTasksQueueRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -934,6 +972,13 @@ func resourceCloudTasksQueueUpdate(d *schema.ResourceData, meta interface{}) err } func resourceCloudTasksQueueDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy CloudTasksQueue without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Queue %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/cloudtasks/resource_cloud_tasks_queue_generated_meta.yaml b/google/services/cloudtasks/resource_cloud_tasks_queue_generated_meta.yaml index be8cc518856..665d6292814 100644 --- a/google/services/cloudtasks/resource_cloud_tasks_queue_generated_meta.yaml +++ b/google/services/cloudtasks/resource_cloud_tasks_queue_generated_meta.yaml @@ -39,3 +39,5 @@ fields: - api_field: retryConfig.minBackoff - api_field: stackdriverLoggingConfig.samplingRatio - api_field: state + - field: deletion_policy + provider_only: true diff --git a/google/services/colab/resource_colab_notebook_execution.go b/google/services/colab/resource_colab_notebook_execution.go index 8e6419ae2e1..706e79d55b2 100644 --- a/google/services/colab/resource_colab_notebook_execution.go +++ b/google/services/colab/resource_colab_notebook_execution.go @@ -100,6 +100,7 @@ func ResourceColabNotebookExecution() *schema.Resource { return &schema.Resource{ Create: resourceColabNotebookExecutionCreate, Read: resourceColabNotebookExecutionRead, + Update: resourceColabNotebookExecutionUpdate, Delete: resourceColabNotebookExecutionDelete, Importer: &schema.ResourceImporter{ @@ -113,6 +114,7 @@ func ResourceColabNotebookExecution() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -359,6 +361,18 @@ func ResourceColabNotebookExecution() *schema.Resource { Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -567,6 +581,19 @@ func resourceColabNotebookExecutionRead(d *schema.ResourceData, meta interface{} log.Printf("[DEBUG] Finished reading ColabNotebookExecution %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading NotebookExecution: %s", err) } @@ -603,7 +630,19 @@ func resourceColabNotebookExecutionRead(d *schema.ResourceData, meta interface{} return nil } +func resourceColabNotebookExecutionUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceColabNotebookExecutionRead(d, meta) +} + func resourceColabNotebookExecutionDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ColabNotebookExecution without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing NotebookExecution %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/colab/resource_colab_notebook_execution_generated_meta.yaml b/google/services/colab/resource_colab_notebook_execution_generated_meta.yaml index 70bee2baa13..55d69dfe2e9 100644 --- a/google/services/colab/resource_colab_notebook_execution_generated_meta.yaml +++ b/google/services/colab/resource_colab_notebook_execution_generated_meta.yaml @@ -30,3 +30,5 @@ fields: provider_only: true - api_field: notebookRuntimeTemplateResourceName - api_field: serviceAccount + - field: deletion_policy + provider_only: true diff --git a/google/services/colab/resource_colab_runtime.go b/google/services/colab/resource_colab_runtime.go index 3117f3fe9c7..3f776f7e23e 100644 --- a/google/services/colab/resource_colab_runtime.go +++ b/google/services/colab/resource_colab_runtime.go @@ -155,6 +155,7 @@ func ResourceColabRuntime() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -265,6 +266,18 @@ func ResourceColabRuntime() *schema.Resource { Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -437,6 +450,18 @@ func resourceColabRuntimeRead(d *schema.ResourceData, meta interface{}) error { return fmt.Errorf("Error setting desired_state: %s", err) } } + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Runtime: %s", err) } @@ -474,6 +499,19 @@ func resourceColabRuntimeRead(d *schema.ResourceData, meta interface{}) error { } func resourceColabRuntimeUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceColabRuntime().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceColabRuntimeRead(d, meta) + } + config := meta.(*transport_tpg.Config) name := d.Get("name").(string) state := d.Get("state").(string) @@ -563,6 +601,13 @@ func resourceColabRuntimeUpdate(d *schema.ResourceData, meta interface{}) error } func resourceColabRuntimeDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ColabRuntime without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Runtime %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/colab/resource_colab_runtime_generated_meta.yaml b/google/services/colab/resource_colab_runtime_generated_meta.yaml index b52faad0c75..3400cacb4cb 100644 --- a/google/services/colab/resource_colab_runtime_generated_meta.yaml +++ b/google/services/colab/resource_colab_runtime_generated_meta.yaml @@ -23,3 +23,5 @@ fields: - api_field: notebookRuntimeType - api_field: runtimeUser - api_field: state + - field: deletion_policy + provider_only: true diff --git a/google/services/colab/resource_colab_runtime_template.go b/google/services/colab/resource_colab_runtime_template.go index 22f3c5623c1..ea0e937c089 100644 --- a/google/services/colab/resource_colab_runtime_template.go +++ b/google/services/colab/resource_colab_runtime_template.go @@ -116,6 +116,7 @@ func ResourceColabRuntimeTemplate() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -442,6 +443,18 @@ Please refer to the field 'effective_labels' for all of the labels present on th Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -668,6 +681,19 @@ func resourceColabRuntimeTemplateRead(d *schema.ResourceData, meta interface{}) log.Printf("[DEBUG] Finished reading ColabRuntimeTemplate %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading RuntimeTemplate: %s", err) } @@ -705,6 +731,19 @@ func resourceColabRuntimeTemplateRead(d *schema.ResourceData, meta interface{}) } func resourceColabRuntimeTemplateUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceColabRuntimeTemplate().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceColabRuntimeTemplateRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -820,6 +859,13 @@ func resourceColabRuntimeTemplateUpdate(d *schema.ResourceData, meta interface{} } func resourceColabRuntimeTemplateDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ColabRuntimeTemplate without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing RuntimeTemplate %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/colab/resource_colab_runtime_template_generated_meta.yaml b/google/services/colab/resource_colab_runtime_template_generated_meta.yaml index 6a34122becb..d90772b56a1 100644 --- a/google/services/colab/resource_colab_runtime_template_generated_meta.yaml +++ b/google/services/colab/resource_colab_runtime_template_generated_meta.yaml @@ -36,3 +36,5 @@ fields: - api_field: softwareConfig.postStartupScriptConfig.postStartupScriptUrl - field: terraform_labels provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/colab/resource_colab_schedule.go b/google/services/colab/resource_colab_schedule.go index 63379c60fcd..6fb53269fd9 100644 --- a/google/services/colab/resource_colab_schedule.go +++ b/google/services/colab/resource_colab_schedule.go @@ -134,6 +134,7 @@ func ResourceColabSchedule() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -319,6 +320,18 @@ func ResourceColabSchedule() *schema.Resource { Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -512,6 +525,18 @@ func resourceColabScheduleRead(d *schema.ResourceData, meta interface{}) error { return fmt.Errorf("Error setting desired_state: %s", err) } } + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Schedule: %s", err) } @@ -549,6 +574,19 @@ func resourceColabScheduleRead(d *schema.ResourceData, meta interface{}) error { } func resourceColabScheduleUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceColabSchedule().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceColabScheduleRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -729,6 +767,13 @@ func resourceColabScheduleUpdate(d *schema.ResourceData, meta interface{}) error } func resourceColabScheduleDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ColabSchedule without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Schedule %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/colab/resource_colab_schedule_generated_meta.yaml b/google/services/colab/resource_colab_schedule_generated_meta.yaml index d49e8e5a0ef..6d67ca26020 100644 --- a/google/services/colab/resource_colab_schedule_generated_meta.yaml +++ b/google/services/colab/resource_colab_schedule_generated_meta.yaml @@ -30,3 +30,5 @@ fields: - api_field: name - api_field: startTime - api_field: state + - field: deletion_policy + provider_only: true diff --git a/google/services/composer/resource_composer_environment.go b/google/services/composer/resource_composer_environment.go index 0feab67dd03..aee8074aaac 100644 --- a/google/services/composer/resource_composer_environment.go +++ b/google/services/composer/resource_composer_environment.go @@ -172,6 +172,7 @@ func ResourceComposerEnvironment() *schema.Resource { }, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), tpgresource.DefaultProviderProject, tpgresource.DefaultProviderRegion, tpgresource.SetLabelsDiff, @@ -1081,6 +1082,9 @@ func ResourceComposerEnvironment() *schema.Resource { }, }, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, UseJSONNumber: true, } @@ -1201,10 +1205,20 @@ func resourceComposerEnvironmentRead(d *schema.ResourceData, meta interface{}) e if err := d.Set("storage_config", flattenComposerStorageConfig(res.StorageConfig)); err != nil { return fmt.Errorf("Error setting Storage: %s", err) } + + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } func resourceComposerEnvironmentUpdate(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceComposerEnvironment) { + return ResourceComposerEnvironment().Read(d, meta) + } + tfConfig := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, tfConfig.UserAgent) if err != nil { @@ -1631,6 +1645,13 @@ func resourceComposerEnvironmentPatchField(updateMask, userAgent string, env *co } func resourceComposerEnvironmentDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/composer/resource_composer_environment_meta.yaml b/google/services/composer/resource_composer_environment_meta.yaml index 533ccd7baf9..6f205d3e038 100644 --- a/google/services/composer/resource_composer_environment_meta.yaml +++ b/google/services/composer/resource_composer_environment_meta.yaml @@ -93,3 +93,5 @@ fields: - api_field: 'storageConfig.bucket' - field: 'terraform_labels' provider_only: true + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/composer/resource_composer_user_workloads_config_map.go b/google/services/composer/resource_composer_user_workloads_config_map.go index 8906ac8434b..61f1d1cc79b 100644 --- a/google/services/composer/resource_composer_user_workloads_config_map.go +++ b/google/services/composer/resource_composer_user_workloads_config_map.go @@ -115,6 +115,7 @@ func ResourceComposerUserWorkloadsConfigMap() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -179,6 +180,18 @@ For details see: https://kubernetes.io/docs/concepts/configuration/configmap/`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -317,6 +330,19 @@ func resourceComposerUserWorkloadsConfigMapRead(d *schema.ResourceData, meta int log.Printf("[DEBUG] Finished reading ComposerUserWorkloadsConfigMap %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading UserWorkloadsConfigMap: %s", err) } @@ -360,6 +386,19 @@ func resourceComposerUserWorkloadsConfigMapRead(d *schema.ResourceData, meta int } func resourceComposerUserWorkloadsConfigMapUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComposerUserWorkloadsConfigMap().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComposerUserWorkloadsConfigMapRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -447,6 +486,13 @@ func resourceComposerUserWorkloadsConfigMapUpdate(d *schema.ResourceData, meta i } func resourceComposerUserWorkloadsConfigMapDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComposerUserWorkloadsConfigMap without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing UserWorkloadsConfigMap %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/composer/resource_composer_user_workloads_config_map_generated_meta.yaml b/google/services/composer/resource_composer_user_workloads_config_map_generated_meta.yaml index 92cf8d6e589..d83ca1d1b24 100644 --- a/google/services/composer/resource_composer_user_workloads_config_map_generated_meta.yaml +++ b/google/services/composer/resource_composer_user_workloads_config_map_generated_meta.yaml @@ -13,3 +13,5 @@ fields: - api_field: name - field: region provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/composer/resource_composer_user_workloads_secret.go b/google/services/composer/resource_composer_user_workloads_secret.go index 9f648147ecd..ef7573ed7d0 100644 --- a/google/services/composer/resource_composer_user_workloads_secret.go +++ b/google/services/composer/resource_composer_user_workloads_secret.go @@ -48,6 +48,7 @@ func ResourceComposerUserWorkloadsSecret() *schema.Resource { }, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), tpgresource.DefaultProviderProject, tpgresource.DefaultProviderRegion, ), @@ -88,6 +89,9 @@ func ResourceComposerUserWorkloadsSecret() *schema.Resource { Sensitive: true, Description: `A map of the secret data.`, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, } } @@ -156,10 +160,20 @@ func resourceComposerUserWorkloadsSecretRead(d *schema.ResourceData, meta interf if err := d.Set("name", tpgresource.GetResourceNameFromSelfLink(res.Name)); err != nil { return fmt.Errorf("Error setting UserWorkloadsSecret Name: %s", err) } + + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } func resourceComposerUserWorkloadsSecretUpdate(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceComposerUserWorkloadsSecret) { + return ResourceComposerUserWorkloadsSecret().Read(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -193,6 +207,13 @@ func resourceComposerUserWorkloadsSecretUpdate(d *schema.ResourceData, meta inte } func resourceComposerUserWorkloadsSecretDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/composer/resource_composer_user_workloads_secret_meta.yaml b/google/services/composer/resource_composer_user_workloads_secret_meta.yaml index 4a4d6d742ce..dd2deab8e3d 100644 --- a/google/services/composer/resource_composer_user_workloads_secret_meta.yaml +++ b/google/services/composer/resource_composer_user_workloads_secret_meta.yaml @@ -11,3 +11,5 @@ fields: - api_field: 'name' - field: 'project' - field: 'region' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/compute/data_source_google_compute_instance_group.go b/google/services/compute/data_source_google_compute_instance_group.go index c0627ce5042..989235aff8e 100644 --- a/google/services/compute/data_source_google_compute_instance_group.go +++ b/google/services/compute/data_source_google_compute_instance_group.go @@ -95,6 +95,11 @@ func DataSourceGoogleComputeInstanceGroup() *schema.Resource { Type: schema.TypeInt, Computed: true, }, + + "deletion_policy": { + Type: schema.TypeString, + Computed: true, + }, }, } } diff --git a/google/services/compute/resource_compute_address.go b/google/services/compute/resource_compute_address.go index c49ae6e97f7..748997fc3cc 100644 --- a/google/services/compute/resource_compute_address.go +++ b/google/services/compute/resource_compute_address.go @@ -143,6 +143,7 @@ func ResourceComputeAddress() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -364,6 +365,18 @@ internally during updates.`, Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -645,6 +658,19 @@ func resourceComputeAddressRead(d *schema.ResourceData, meta interface{}) error log.Printf("[DEBUG] Finished reading ComputeAddress %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Address: %s", err) } @@ -682,6 +708,19 @@ func resourceComputeAddressRead(d *schema.ResourceData, meta interface{}) error } func resourceComputeAddressUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeAddress().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeAddressRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -776,6 +815,13 @@ func resourceComputeAddressUpdate(d *schema.ResourceData, meta interface{}) erro } func resourceComputeAddressDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeAddress without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Address %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_address_generated_meta.yaml b/google/services/compute/resource_compute_address_generated_meta.yaml index f8991ee42f3..2e99c5c2e19 100644 --- a/google/services/compute/resource_compute_address_generated_meta.yaml +++ b/google/services/compute/resource_compute_address_generated_meta.yaml @@ -31,3 +31,5 @@ fields: provider_only: true - api_field: users - api_field: selfLink + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_attached_disk.go b/google/services/compute/resource_compute_attached_disk.go index 9a6849c036b..5a3d6340c83 100644 --- a/google/services/compute/resource_compute_attached_disk.go +++ b/google/services/compute/resource_compute_attached_disk.go @@ -37,6 +37,7 @@ func ResourceComputeAttachedDisk() *schema.Resource { return &schema.Resource{ Create: resourceAttachedDiskCreate, Read: resourceAttachedDiskRead, + Update: resourceAttachedDiskUpdate, Delete: resourceAttachedDiskDelete, Importer: &schema.ResourceImporter{ @@ -49,6 +50,7 @@ func ResourceComputeAttachedDisk() *schema.Resource { }, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), tpgresource.DefaultProviderProject, computeAttachedDiskDefaultProviderZone, ), @@ -104,6 +106,9 @@ func ResourceComputeAttachedDisk() *schema.Resource { Description: `The disk interface used for attaching this disk. One of SCSI or NVME. (This field is only used for specific cases, please don't specify this field without advice from Google.)`, ValidateFunc: validation.StringInSlice([]string{"SCSI", "NVME"}, false), }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, UseJSONNumber: true, } @@ -235,10 +240,29 @@ func resourceAttachedDiskRead(d *schema.ResourceData, meta interface{}) error { return fmt.Errorf("Error setting disk: %s", err) } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } +// UDP update start +func resourceAttachedDiskUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceAttachedDiskRead(d, meta) +} + +//UDP update end + func resourceAttachedDiskDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_attached_disk_meta.yaml b/google/services/compute/resource_compute_attached_disk_meta.yaml index 0947ad915cd..45c88de0876 100644 --- a/google/services/compute/resource_compute_attached_disk_meta.yaml +++ b/google/services/compute/resource_compute_attached_disk_meta.yaml @@ -17,3 +17,5 @@ fields: field: 'mode' - field: 'project' - api_field: 'zone' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/compute/resource_compute_autoscaler.go b/google/services/compute/resource_compute_autoscaler.go index ca26afd31dd..00f30f3805e 100644 --- a/google/services/compute/resource_compute_autoscaler.go +++ b/google/services/compute/resource_compute_autoscaler.go @@ -116,6 +116,7 @@ func ResourceComputeAutoscaler() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, tpgresource.DefaultProviderZone, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -478,6 +479,18 @@ character, which cannot be a dash.`, Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -639,6 +652,19 @@ func resourceComputeAutoscalerRead(d *schema.ResourceData, meta interface{}) err log.Printf("[DEBUG] Finished reading ComputeAutoscaler %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Autoscaler: %s", err) } @@ -683,6 +709,19 @@ func resourceComputeAutoscalerRead(d *schema.ResourceData, meta interface{}) err } func resourceComputeAutoscalerUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeAutoscaler().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeAutoscalerRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -791,6 +830,13 @@ func resourceComputeAutoscalerUpdate(d *schema.ResourceData, meta interface{}) e } func resourceComputeAutoscalerDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeAutoscaler without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Autoscaler %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_autoscaler_generated_meta.yaml b/google/services/compute/resource_compute_autoscaler_generated_meta.yaml index 790aee198f1..bd22065d5ae 100644 --- a/google/services/compute/resource_compute_autoscaler_generated_meta.yaml +++ b/google/services/compute/resource_compute_autoscaler_generated_meta.yaml @@ -54,3 +54,5 @@ fields: - api_field: target - api_field: zone - api_field: selfLink + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_backend_bucket.go b/google/services/compute/resource_compute_backend_bucket.go index 8d1ba778225..14a510be0f6 100644 --- a/google/services/compute/resource_compute_backend_bucket.go +++ b/google/services/compute/resource_compute_backend_bucket.go @@ -115,6 +115,7 @@ func ResourceComputeBackendBucket() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -368,6 +369,18 @@ and values are in the format tagValues/456.`, Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -595,6 +608,19 @@ func resourceComputeBackendBucketRead(d *schema.ResourceData, meta interface{}) log.Printf("[DEBUG] Finished reading ComputeBackendBucket %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading BackendBucket: %s", err) } @@ -626,6 +652,19 @@ func resourceComputeBackendBucketRead(d *schema.ResourceData, meta interface{}) } func resourceComputeBackendBucketUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeBackendBucket().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeBackendBucketRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -799,6 +838,13 @@ func resourceComputeBackendBucketUpdate(d *schema.ResourceData, meta interface{} } func resourceComputeBackendBucketDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeBackendBucket without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing BackendBucket %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_backend_bucket_generated_meta.yaml b/google/services/compute/resource_compute_backend_bucket_generated_meta.yaml index c69e4d571bf..98d3ebecd1b 100644 --- a/google/services/compute/resource_compute_backend_bucket_generated_meta.yaml +++ b/google/services/compute/resource_compute_backend_bucket_generated_meta.yaml @@ -31,3 +31,5 @@ fields: - api_field: name - api_field: params.resourceManagerTags - api_field: selfLink + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_backend_bucket_signed_url_key.go b/google/services/compute/resource_compute_backend_bucket_signed_url_key.go index e5d65a5c8b1..ff4e5ecdd7c 100644 --- a/google/services/compute/resource_compute_backend_bucket_signed_url_key.go +++ b/google/services/compute/resource_compute_backend_bucket_signed_url_key.go @@ -100,6 +100,7 @@ func ResourceComputeBackendBucketSignedUrlKey() *schema.Resource { return &schema.Resource{ Create: resourceComputeBackendBucketSignedUrlKeyCreate, Read: resourceComputeBackendBucketSignedUrlKeyRead, + Update: resourceComputeBackendBucketSignedUrlKeyUpdate, Delete: resourceComputeBackendBucketSignedUrlKeyDelete, Timeouts: &schema.ResourceTimeout{ @@ -109,6 +110,7 @@ func ResourceComputeBackendBucketSignedUrlKey() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -163,6 +165,18 @@ valid RFC 4648 Section 5 base64url encoded string.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -331,6 +345,19 @@ func resourceComputeBackendBucketSignedUrlKeyRead(d *schema.ResourceData, meta i return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading BackendBucketSignedUrlKey: %s", err) } @@ -367,7 +394,19 @@ func resourceComputeBackendBucketSignedUrlKeyRead(d *schema.ResourceData, meta i return nil } +func resourceComputeBackendBucketSignedUrlKeyUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceComputeBackendBucketSignedUrlKeyRead(d, meta) +} + func resourceComputeBackendBucketSignedUrlKeyDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeBackendBucketSignedUrlKey without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing BackendBucketSignedUrlKey %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_backend_bucket_signed_url_key_generated_meta.yaml b/google/services/compute/resource_compute_backend_bucket_signed_url_key_generated_meta.yaml index eecd006728e..4740a64bad8 100644 --- a/google/services/compute/resource_compute_backend_bucket_signed_url_key_generated_meta.yaml +++ b/google/services/compute/resource_compute_backend_bucket_signed_url_key_generated_meta.yaml @@ -13,3 +13,5 @@ fields: field: key_value - api_field: cdnPolicy.signedUrlKeyNames.keyName field: name + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_backend_service.go b/google/services/compute/resource_compute_backend_service.go index 0ffd39b2b4c..cc4333f2047 100644 --- a/google/services/compute/resource_compute_backend_service.go +++ b/google/services/compute/resource_compute_backend_service.go @@ -263,6 +263,7 @@ func ResourceComputeBackendService() *schema.Resource { SchemaVersion: 1, CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -1461,6 +1462,18 @@ object. This field is used in optimistic locking.`, Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -2072,6 +2085,19 @@ func resourceComputeBackendServiceRead(d *schema.ResourceData, meta interface{}) return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading BackendService: %s", err) } @@ -2103,6 +2129,19 @@ func resourceComputeBackendServiceRead(d *schema.ResourceData, meta interface{}) } func resourceComputeBackendServiceUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeBackendService().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeBackendServiceRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -2470,6 +2509,13 @@ func resourceComputeBackendServiceUpdate(d *schema.ResourceData, meta interface{ } func resourceComputeBackendServiceDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeBackendService without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing BackendService %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_backend_service_generated_meta.yaml b/google/services/compute/resource_compute_backend_service_generated_meta.yaml index cb862cb4c87..a065c24b8ff 100644 --- a/google/services/compute/resource_compute_backend_service_generated_meta.yaml +++ b/google/services/compute/resource_compute_backend_service_generated_meta.yaml @@ -136,3 +136,5 @@ fields: - api_field: tlsSettings.subjectAltNames.dnsName - api_field: tlsSettings.subjectAltNames.uniformResourceIdentifier - api_field: selfLink + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_backend_service_signed_url_key.go b/google/services/compute/resource_compute_backend_service_signed_url_key.go index 50e9007ab16..797da561fa8 100644 --- a/google/services/compute/resource_compute_backend_service_signed_url_key.go +++ b/google/services/compute/resource_compute_backend_service_signed_url_key.go @@ -100,6 +100,7 @@ func ResourceComputeBackendServiceSignedUrlKey() *schema.Resource { return &schema.Resource{ Create: resourceComputeBackendServiceSignedUrlKeyCreate, Read: resourceComputeBackendServiceSignedUrlKeyRead, + Update: resourceComputeBackendServiceSignedUrlKeyUpdate, Delete: resourceComputeBackendServiceSignedUrlKeyDelete, Timeouts: &schema.ResourceTimeout{ @@ -109,6 +110,7 @@ func ResourceComputeBackendServiceSignedUrlKey() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -163,6 +165,18 @@ valid RFC 4648 Section 5 base64url encoded string.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -331,6 +345,19 @@ func resourceComputeBackendServiceSignedUrlKeyRead(d *schema.ResourceData, meta return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading BackendServiceSignedUrlKey: %s", err) } @@ -367,7 +394,19 @@ func resourceComputeBackendServiceSignedUrlKeyRead(d *schema.ResourceData, meta return nil } +func resourceComputeBackendServiceSignedUrlKeyUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceComputeBackendServiceSignedUrlKeyRead(d, meta) +} + func resourceComputeBackendServiceSignedUrlKeyDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeBackendServiceSignedUrlKey without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing BackendServiceSignedUrlKey %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_backend_service_signed_url_key_generated_meta.yaml b/google/services/compute/resource_compute_backend_service_signed_url_key_generated_meta.yaml index 6139cdc5e17..5df10f405b6 100644 --- a/google/services/compute/resource_compute_backend_service_signed_url_key_generated_meta.yaml +++ b/google/services/compute/resource_compute_backend_service_signed_url_key_generated_meta.yaml @@ -13,3 +13,5 @@ fields: field: key_value - api_field: cdnPolicy.signedUrlKeyNames.keyName field: name + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_cross_site_network.go b/google/services/compute/resource_compute_cross_site_network.go index deaf11a5f98..1d0a8ffd87b 100644 --- a/google/services/compute/resource_compute_cross_site_network.go +++ b/google/services/compute/resource_compute_cross_site_network.go @@ -115,6 +115,7 @@ func ResourceComputeCrossSiteNetwork() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -159,6 +160,18 @@ lowercase letter, or digit, except the last character, which cannot be a dash.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -297,6 +310,19 @@ func resourceComputeCrossSiteNetworkRead(d *schema.ResourceData, meta interface{ log.Printf("[DEBUG] Finished reading ComputeCrossSiteNetwork %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading CrossSiteNetwork: %s", err) } @@ -328,6 +354,19 @@ func resourceComputeCrossSiteNetworkRead(d *schema.ResourceData, meta interface{ } func resourceComputeCrossSiteNetworkUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeCrossSiteNetwork().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeCrossSiteNetworkRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -407,6 +446,13 @@ func resourceComputeCrossSiteNetworkUpdate(d *schema.ResourceData, meta interfac } func resourceComputeCrossSiteNetworkDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeCrossSiteNetwork without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing CrossSiteNetwork %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_cross_site_network_generated_meta.yaml b/google/services/compute/resource_compute_cross_site_network_generated_meta.yaml index c7b9cbcd94e..086b5a5ad40 100644 --- a/google/services/compute/resource_compute_cross_site_network_generated_meta.yaml +++ b/google/services/compute/resource_compute_cross_site_network_generated_meta.yaml @@ -9,3 +9,5 @@ api_resource_type_kind: CrossSiteNetwork fields: - api_field: description - api_field: name + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_disk.go b/google/services/compute/resource_compute_disk.go index 23c9ea9dc44..135903ac2b2 100644 --- a/google/services/compute/resource_compute_disk.go +++ b/google/services/compute/resource_compute_disk.go @@ -457,6 +457,7 @@ func ResourceComputeDisk() *schema.Resource { hyperDiskIopsUpdateDiffSuppress, tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -996,6 +997,18 @@ The name of the snapshot by default will be '{{disk-name}}-YYYYMMDD-HHmm'`, Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -1319,6 +1332,18 @@ func resourceComputeDiskRead(d *schema.ResourceData, meta interface{}) error { return fmt.Errorf("Error setting create_snapshot_before_destroy: %s", err) } } + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Disk: %s", err) } @@ -1356,6 +1381,19 @@ func resourceComputeDiskRead(d *schema.ResourceData, meta interface{}) error { } func resourceComputeDiskUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeDisk().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeDiskRead(d, meta) + } + config := meta.(*transport_tpg.Config) // 'config' is provided by the boilerplate. @@ -1483,6 +1521,13 @@ func resourceComputeDiskUpdate(d *schema.ResourceData, meta interface{}) error { } func resourceComputeDiskDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeDisk without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Disk %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_disk_async_replication.go b/google/services/compute/resource_compute_disk_async_replication.go index e7459fabb7b..76b7d9fdbdf 100644 --- a/google/services/compute/resource_compute_disk_async_replication.go +++ b/google/services/compute/resource_compute_disk_async_replication.go @@ -26,6 +26,7 @@ import ( "github.com/hashicorp/terraform-provider-google/google/tpgresource" transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -34,12 +35,17 @@ func ResourceComputeDiskAsyncReplication() *schema.Resource { return &schema.Resource{ Create: resourceDiskAsyncReplicationCreate, Read: resourceDiskAsyncReplicationRead, + Update: resourceDiskAsyncReplicationUpdate, Delete: resourceDiskAsyncReplicationDelete, Importer: &schema.ResourceImporter{ State: schema.ImportStatePassthrough, }, + CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), + ), + Timeouts: &schema.ResourceTimeout{ Create: schema.DefaultTimeout(5 * time.Minute), Delete: schema.DefaultTimeout(5 * time.Minute), @@ -76,6 +82,9 @@ func ResourceComputeDiskAsyncReplication() *schema.Resource { }, }, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, UseJSONNumber: true, } @@ -288,10 +297,30 @@ func resourceDiskAsyncReplicationRead(d *schema.ResourceData, meta interface{}) return fmt.Errorf("Error setting secondary_disk: %s", err) } d.SetId(resourceId) + + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } +// UDP update start +func resourceDiskAsyncReplicationUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceDiskAsyncReplicationRead(d, meta) +} + +//UDP update end + func resourceDiskAsyncReplicationDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config, userAgent, err := asyncReplicationGetConfigAndUserAgent(d, meta) if err != nil { return err diff --git a/google/services/compute/resource_compute_disk_async_replication_meta.yaml b/google/services/compute/resource_compute_disk_async_replication_meta.yaml index 3b115b97fb0..1b36a8aabfc 100644 --- a/google/services/compute/resource_compute_disk_async_replication_meta.yaml +++ b/google/services/compute/resource_compute_disk_async_replication_meta.yaml @@ -11,3 +11,5 @@ fields: field: 'secondary_disk.disk' - api_field: 'resourceStatus.asyncSecondaryDisks' field: 'secondary_disk.state' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/compute/resource_compute_disk_generated_meta.yaml b/google/services/compute/resource_compute_disk_generated_meta.yaml index 3aaa57a981c..7888954ae03 100644 --- a/google/services/compute/resource_compute_disk_generated_meta.yaml +++ b/google/services/compute/resource_compute_disk_generated_meta.yaml @@ -68,3 +68,5 @@ fields: - api_field: users - api_field: zone - api_field: selfLink + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_disk_resource_policy_attachment.go b/google/services/compute/resource_compute_disk_resource_policy_attachment.go index 12f78e64431..c57d80f920e 100644 --- a/google/services/compute/resource_compute_disk_resource_policy_attachment.go +++ b/google/services/compute/resource_compute_disk_resource_policy_attachment.go @@ -100,6 +100,7 @@ func ResourceComputeDiskResourcePolicyAttachment() *schema.Resource { return &schema.Resource{ Create: resourceComputeDiskResourcePolicyAttachmentCreate, Read: resourceComputeDiskResourcePolicyAttachmentRead, + Update: resourceComputeDiskResourcePolicyAttachmentUpdate, Delete: resourceComputeDiskResourcePolicyAttachmentDelete, Importer: &schema.ResourceImporter{ @@ -114,6 +115,7 @@ func ResourceComputeDiskResourcePolicyAttachment() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, tpgresource.DefaultProviderZone, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -172,6 +174,18 @@ creation. Do not specify the self link.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -343,6 +357,19 @@ func resourceComputeDiskResourcePolicyAttachmentRead(d *schema.ResourceData, met return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading DiskResourcePolicyAttachment: %s", err) } @@ -392,7 +419,19 @@ func resourceComputeDiskResourcePolicyAttachmentRead(d *schema.ResourceData, met return nil } +func resourceComputeDiskResourcePolicyAttachmentUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceComputeDiskResourcePolicyAttachmentRead(d, meta) +} + func resourceComputeDiskResourcePolicyAttachmentDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeDiskResourcePolicyAttachment without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing DiskResourcePolicyAttachment %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_disk_resource_policy_attachment_generated_meta.yaml b/google/services/compute/resource_compute_disk_resource_policy_attachment_generated_meta.yaml index 7bbbffb3409..2088cce20aa 100644 --- a/google/services/compute/resource_compute_disk_resource_policy_attachment_generated_meta.yaml +++ b/google/services/compute/resource_compute_disk_resource_policy_attachment_generated_meta.yaml @@ -13,3 +13,5 @@ fields: field: name - field: zone provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_external_vpn_gateway.go b/google/services/compute/resource_compute_external_vpn_gateway.go index 9279aa50107..2bb9f05d566 100644 --- a/google/services/compute/resource_compute_external_vpn_gateway.go +++ b/google/services/compute/resource_compute_external_vpn_gateway.go @@ -116,6 +116,7 @@ func ResourceComputeExternalVpnGateway() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -261,6 +262,18 @@ internally during updates.`, Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -429,6 +442,19 @@ func resourceComputeExternalVpnGatewayRead(d *schema.ResourceData, meta interfac log.Printf("[DEBUG] Finished reading ComputeExternalVpnGateway %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading ExternalVpnGateway: %s", err) } @@ -460,6 +486,19 @@ func resourceComputeExternalVpnGatewayRead(d *schema.ResourceData, meta interfac } func resourceComputeExternalVpnGatewayUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeExternalVpnGateway().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeExternalVpnGatewayRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -549,6 +588,13 @@ func resourceComputeExternalVpnGatewayUpdate(d *schema.ResourceData, meta interf } func resourceComputeExternalVpnGatewayDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeExternalVpnGateway without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ExternalVpnGateway %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_external_vpn_gateway_generated_meta.yaml b/google/services/compute/resource_compute_external_vpn_gateway_generated_meta.yaml index b94cafd348b..d9958c75e3c 100644 --- a/google/services/compute/resource_compute_external_vpn_gateway_generated_meta.yaml +++ b/google/services/compute/resource_compute_external_vpn_gateway_generated_meta.yaml @@ -24,3 +24,5 @@ fields: - field: terraform_labels provider_only: true - api_field: selfLink + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_firewall.go b/google/services/compute/resource_compute_firewall.go index dabefc90d64..0d495a531d2 100644 --- a/google/services/compute/resource_compute_firewall.go +++ b/google/services/compute/resource_compute_firewall.go @@ -221,6 +221,7 @@ func ResourceComputeFirewall() *schema.Resource { resourceComputeFirewallEnableLoggingCustomizeDiff, resourceComputeFirewallSourceFieldsCustomizeDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -479,6 +480,18 @@ instances on the specified network.`, Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -761,6 +774,19 @@ func resourceComputeFirewallRead(d *schema.ResourceData, meta interface{}) error log.Printf("[DEBUG] Finished reading ComputeFirewall %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Firewall: %s", err) } @@ -792,6 +818,19 @@ func resourceComputeFirewallRead(d *schema.ResourceData, meta interface{}) error } func resourceComputeFirewallUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeFirewall().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeFirewallRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -943,6 +982,13 @@ func resourceComputeFirewallUpdate(d *schema.ResourceData, meta interface{}) err } func resourceComputeFirewallDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeFirewall without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Firewall %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_firewall_generated_meta.yaml b/google/services/compute/resource_compute_firewall_generated_meta.yaml index 9be5e272d58..c7f737c4e99 100644 --- a/google/services/compute/resource_compute_firewall_generated_meta.yaml +++ b/google/services/compute/resource_compute_firewall_generated_meta.yaml @@ -31,3 +31,5 @@ fields: - api_field: targetServiceAccounts - api_field: targetTags - api_field: selfLink + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_firewall_policy.go b/google/services/compute/resource_compute_firewall_policy.go index 46581fdf778..13652d13948 100644 --- a/google/services/compute/resource_compute_firewall_policy.go +++ b/google/services/compute/resource_compute_firewall_policy.go @@ -115,6 +115,7 @@ func ResourceComputeFirewallPolicy() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -173,6 +174,19 @@ Specifically, the name must be 1-63 characters long and match the regular expres Computed: true, Description: `Server-defined URL for this resource with the resource id.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -317,6 +331,20 @@ func resourceComputeFirewallPolicyRead(d *schema.ResourceData, meta interface{}) log.Printf("[DEBUG] Finished reading ComputeFirewallPolicy %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceComputeFirewallPolicyFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -326,6 +354,19 @@ func resourceComputeFirewallPolicyRead(d *schema.ResourceData, meta interface{}) } func resourceComputeFirewallPolicyUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeFirewallPolicy().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeFirewallPolicyRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -391,6 +432,13 @@ func resourceComputeFirewallPolicyUpdate(d *schema.ResourceData, meta interface{ } func resourceComputeFirewallPolicyDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeFirewallPolicy without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing FirewallPolicy %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_firewall_policy_association.go b/google/services/compute/resource_compute_firewall_policy_association.go index 20ce8a48b98..d0cf1925513 100644 --- a/google/services/compute/resource_compute_firewall_policy_association.go +++ b/google/services/compute/resource_compute_firewall_policy_association.go @@ -115,6 +115,7 @@ func ResourceComputeFirewallPolicyAssociation() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -167,6 +168,19 @@ on your exisiting firewall policy so as to prevent a situation where your attach Computed: true, Description: `The short name of the firewall policy of the association.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -306,6 +320,20 @@ func resourceComputeFirewallPolicyAssociationRead(d *schema.ResourceData, meta i log.Printf("[DEBUG] Finished reading ComputeFirewallPolicyAssociation %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceComputeFirewallPolicyAssociationFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -333,6 +361,19 @@ func resourceComputeFirewallPolicyAssociationRead(d *schema.ResourceData, meta i } func resourceComputeFirewallPolicyAssociationUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeFirewallPolicyAssociation().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeFirewallPolicyAssociationRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -411,6 +452,13 @@ func resourceComputeFirewallPolicyAssociationUpdate(d *schema.ResourceData, meta } func resourceComputeFirewallPolicyAssociationDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeFirewallPolicyAssociation without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing FirewallPolicyAssociation %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_firewall_policy_association_generated_meta.yaml b/google/services/compute/resource_compute_firewall_policy_association_generated_meta.yaml index fc84421a38b..2842de9c1d0 100644 --- a/google/services/compute/resource_compute_firewall_policy_association_generated_meta.yaml +++ b/google/services/compute/resource_compute_firewall_policy_association_generated_meta.yaml @@ -15,3 +15,5 @@ fields: field: name - api_field: associations.shortName field: short_name + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_firewall_policy_generated_meta.yaml b/google/services/compute/resource_compute_firewall_policy_generated_meta.yaml index 25082432726..310baded100 100644 --- a/google/services/compute/resource_compute_firewall_policy_generated_meta.yaml +++ b/google/services/compute/resource_compute_firewall_policy_generated_meta.yaml @@ -18,3 +18,5 @@ fields: - api_field: selfLink - api_field: selfLinkWithId - api_field: shortName + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_firewall_policy_rule.go b/google/services/compute/resource_compute_firewall_policy_rule.go index 9e9fa80116d..51c914ed5d8 100644 --- a/google/services/compute/resource_compute_firewall_policy_rule.go +++ b/google/services/compute/resource_compute_firewall_policy_rule.go @@ -115,6 +115,7 @@ func ResourceComputeFirewallPolicyRule() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -410,6 +411,19 @@ Can be set only if action = 'apply_security_profile_group' and cannot be set for Computed: true, Description: `Calculation of the complexity of a single firewall policy rule.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -605,6 +619,20 @@ func resourceComputeFirewallPolicyRuleRead(d *schema.ResourceData, meta interfac log.Printf("[DEBUG] Finished reading ComputeFirewallPolicyRule %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceComputeFirewallPolicyRuleFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -632,6 +660,19 @@ func resourceComputeFirewallPolicyRuleRead(d *schema.ResourceData, meta interfac } func resourceComputeFirewallPolicyRuleUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeFirewallPolicyRule().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeFirewallPolicyRuleRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -786,6 +827,13 @@ func resourceComputeFirewallPolicyRuleUpdate(d *schema.ResourceData, meta interf } func resourceComputeFirewallPolicyRuleDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeFirewallPolicyRule without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing FirewallPolicyRule %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_firewall_policy_rule_generated_meta.yaml b/google/services/compute/resource_compute_firewall_policy_rule_generated_meta.yaml index e44cc4c73d6..ec8a7df2fae 100644 --- a/google/services/compute/resource_compute_firewall_policy_rule_generated_meta.yaml +++ b/google/services/compute/resource_compute_firewall_policy_rule_generated_meta.yaml @@ -73,3 +73,5 @@ fields: field: target_service_accounts - api_field: rules.tlsInspect field: tls_inspect + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_firewall_policy_with_rules.go b/google/services/compute/resource_compute_firewall_policy_with_rules.go index 166dad756c1..0758102e505 100644 --- a/google/services/compute/resource_compute_firewall_policy_with_rules.go +++ b/google/services/compute/resource_compute_firewall_policy_with_rules.go @@ -789,6 +789,19 @@ It can be set only if action = 'apply_security_profile_group' and cannot be set Computed: true, Description: `Server-defined URL for this resource with the resource id.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -998,6 +1011,20 @@ func resourceComputeFirewallPolicyWithRulesRead(d *schema.ResourceData, meta int return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceComputeFirewallPolicyWithRulesFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -1019,6 +1046,19 @@ func resourceComputeFirewallPolicyWithRulesRead(d *schema.ResourceData, meta int } func resourceComputeFirewallPolicyWithRulesUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeFirewallPolicyWithRules().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeFirewallPolicyWithRulesRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1106,6 +1146,13 @@ func resourceComputeFirewallPolicyWithRulesUpdate(d *schema.ResourceData, meta i } func resourceComputeFirewallPolicyWithRulesDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeFirewallPolicyWithRules without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing FirewallPolicyWithRules %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_firewall_policy_with_rules_generated_meta.yaml b/google/services/compute/resource_compute_firewall_policy_with_rules_generated_meta.yaml index 3410add85c6..2573398de47 100644 --- a/google/services/compute/resource_compute_firewall_policy_with_rules_generated_meta.yaml +++ b/google/services/compute/resource_compute_firewall_policy_with_rules_generated_meta.yaml @@ -104,3 +104,5 @@ fields: - api_field: selfLink - api_field: selfLinkWithId - api_field: shortName + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_forwarding_rule.go b/google/services/compute/resource_compute_forwarding_rule.go index 708ee05cbde..a6b26fa6c9d 100644 --- a/google/services/compute/resource_compute_forwarding_rule.go +++ b/google/services/compute/resource_compute_forwarding_rule.go @@ -222,6 +222,7 @@ func ResourceComputeForwardingRule() *schema.Resource { forwardingRuleCustomizeDiff, tpgresource.SetLabelsDiffWithoutAttributionLabel, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -715,6 +716,18 @@ This field is only used for INTERNAL load balancing.`, Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -1068,6 +1081,18 @@ func resourceComputeForwardingRuleRead(d *schema.ResourceData, meta interface{}) return fmt.Errorf("Error setting recreate_closed_psc: %s", err) } } + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading ForwardingRule: %s", err) } @@ -1105,6 +1130,19 @@ func resourceComputeForwardingRuleRead(d *schema.ResourceData, meta interface{}) } func resourceComputeForwardingRuleUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeForwardingRule().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeForwardingRuleRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1357,6 +1395,13 @@ func resourceComputeForwardingRuleUpdate(d *schema.ResourceData, meta interface{ } func resourceComputeForwardingRuleDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeForwardingRule without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ForwardingRule %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_forwarding_rule_generated_meta.yaml b/google/services/compute/resource_compute_forwarding_rule_generated_meta.yaml index b5884e3d538..7e4977c1ffa 100644 --- a/google/services/compute/resource_compute_forwarding_rule_generated_meta.yaml +++ b/google/services/compute/resource_compute_forwarding_rule_generated_meta.yaml @@ -49,3 +49,5 @@ fields: - field: terraform_labels provider_only: true - api_field: selfLink + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_global_address.go b/google/services/compute/resource_compute_global_address.go index a71a8c9bedc..9eac93ce5a8 100644 --- a/google/services/compute/resource_compute_global_address.go +++ b/google/services/compute/resource_compute_global_address.go @@ -116,6 +116,7 @@ func ResourceComputeGlobalAddress() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -261,6 +262,18 @@ internally during updates.`, Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -512,6 +525,19 @@ func resourceComputeGlobalAddressRead(d *schema.ResourceData, meta interface{}) log.Printf("[DEBUG] Finished reading ComputeGlobalAddress %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading GlobalAddress: %s", err) } @@ -543,6 +569,19 @@ func resourceComputeGlobalAddressRead(d *schema.ResourceData, meta interface{}) } func resourceComputeGlobalAddressUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeGlobalAddress().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeGlobalAddressRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -632,6 +671,13 @@ func resourceComputeGlobalAddressUpdate(d *schema.ResourceData, meta interface{} } func resourceComputeGlobalAddressDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeGlobalAddress without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing GlobalAddress %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_global_address_generated_meta.yaml b/google/services/compute/resource_compute_global_address_generated_meta.yaml index 07ec1ce32a1..3ed965de07b 100644 --- a/google/services/compute/resource_compute_global_address_generated_meta.yaml +++ b/google/services/compute/resource_compute_global_address_generated_meta.yaml @@ -23,3 +23,5 @@ fields: - field: terraform_labels provider_only: true - api_field: selfLink + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_global_forwarding_rule.go b/google/services/compute/resource_compute_global_forwarding_rule.go index eb238544fdb..e701f52c3ed 100644 --- a/google/services/compute/resource_compute_global_forwarding_rule.go +++ b/google/services/compute/resource_compute_global_forwarding_rule.go @@ -116,6 +116,7 @@ func ResourceComputeGlobalForwardingRule() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiffWithoutAttributionLabel, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -537,6 +538,18 @@ internally during updates.`, Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -845,6 +858,19 @@ func resourceComputeGlobalForwardingRuleRead(d *schema.ResourceData, meta interf log.Printf("[DEBUG] Finished reading ComputeGlobalForwardingRule %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading GlobalForwardingRule: %s", err) } @@ -876,6 +902,19 @@ func resourceComputeGlobalForwardingRuleRead(d *schema.ResourceData, meta interf } func resourceComputeGlobalForwardingRuleUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeGlobalForwardingRule().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeGlobalForwardingRuleRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1067,6 +1106,13 @@ func resourceComputeGlobalForwardingRuleUpdate(d *schema.ResourceData, meta inte } func resourceComputeGlobalForwardingRuleDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeGlobalForwardingRule without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing GlobalForwardingRule %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_global_forwarding_rule_generated_meta.yaml b/google/services/compute/resource_compute_global_forwarding_rule_generated_meta.yaml index e22681fe117..1ed23d25ed2 100644 --- a/google/services/compute/resource_compute_global_forwarding_rule_generated_meta.yaml +++ b/google/services/compute/resource_compute_global_forwarding_rule_generated_meta.yaml @@ -41,3 +41,5 @@ fields: - field: terraform_labels provider_only: true - api_field: selfLink + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_global_network_endpoint.go b/google/services/compute/resource_compute_global_network_endpoint.go index 97df9ee5c35..157264599b6 100644 --- a/google/services/compute/resource_compute_global_network_endpoint.go +++ b/google/services/compute/resource_compute_global_network_endpoint.go @@ -100,6 +100,7 @@ func ResourceComputeGlobalNetworkEndpoint() *schema.Resource { return &schema.Resource{ Create: resourceComputeGlobalNetworkEndpointCreate, Read: resourceComputeGlobalNetworkEndpointRead, + Update: resourceComputeGlobalNetworkEndpointUpdate, Delete: resourceComputeGlobalNetworkEndpointDelete, Importer: &schema.ResourceImporter{ @@ -113,6 +114,7 @@ func ResourceComputeGlobalNetworkEndpoint() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -181,6 +183,18 @@ This can only be specified when network_endpoint_type of the NEG is INTERNET_FQD Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -377,6 +391,19 @@ func resourceComputeGlobalNetworkEndpointRead(d *schema.ResourceData, meta inter return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading GlobalNetworkEndpoint: %s", err) } @@ -425,7 +452,19 @@ func resourceComputeGlobalNetworkEndpointRead(d *schema.ResourceData, meta inter return nil } +func resourceComputeGlobalNetworkEndpointUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceComputeGlobalNetworkEndpointRead(d, meta) +} + func resourceComputeGlobalNetworkEndpointDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeGlobalNetworkEndpoint without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing GlobalNetworkEndpoint %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_global_network_endpoint_generated_meta.yaml b/google/services/compute/resource_compute_global_network_endpoint_generated_meta.yaml index 660e4bfa904..ecd89df44b0 100644 --- a/google/services/compute/resource_compute_global_network_endpoint_generated_meta.yaml +++ b/google/services/compute/resource_compute_global_network_endpoint_generated_meta.yaml @@ -12,3 +12,5 @@ fields: provider_only: true - api_field: ipAddress - api_field: port + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_global_network_endpoint_group.go b/google/services/compute/resource_compute_global_network_endpoint_group.go index df1f9b754e9..efa39fa9cd0 100644 --- a/google/services/compute/resource_compute_global_network_endpoint_group.go +++ b/google/services/compute/resource_compute_global_network_endpoint_group.go @@ -100,6 +100,7 @@ func ResourceComputeGlobalNetworkEndpointGroup() *schema.Resource { return &schema.Resource{ Create: resourceComputeGlobalNetworkEndpointGroupCreate, Read: resourceComputeGlobalNetworkEndpointGroupRead, + Update: resourceComputeGlobalNetworkEndpointGroupUpdate, Delete: resourceComputeGlobalNetworkEndpointGroupDelete, Importer: &schema.ResourceImporter{ @@ -113,6 +114,7 @@ func ResourceComputeGlobalNetworkEndpointGroup() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -179,6 +181,18 @@ you create the resource.`, Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -329,6 +343,19 @@ func resourceComputeGlobalNetworkEndpointGroupRead(d *schema.ResourceData, meta log.Printf("[DEBUG] Finished reading ComputeGlobalNetworkEndpointGroup %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading GlobalNetworkEndpointGroup: %s", err) } @@ -359,7 +386,19 @@ func resourceComputeGlobalNetworkEndpointGroupRead(d *schema.ResourceData, meta return nil } +func resourceComputeGlobalNetworkEndpointGroupUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceComputeGlobalNetworkEndpointGroupRead(d, meta) +} + func resourceComputeGlobalNetworkEndpointGroupDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeGlobalNetworkEndpointGroup without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing GlobalNetworkEndpointGroup %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_global_network_endpoint_group_generated_meta.yaml b/google/services/compute/resource_compute_global_network_endpoint_group_generated_meta.yaml index c98238d29fb..0f443a3fb4c 100644 --- a/google/services/compute/resource_compute_global_network_endpoint_group_generated_meta.yaml +++ b/google/services/compute/resource_compute_global_network_endpoint_group_generated_meta.yaml @@ -12,3 +12,5 @@ fields: - api_field: name - api_field: networkEndpointType - api_field: selfLink + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_ha_vpn_gateway.go b/google/services/compute/resource_compute_ha_vpn_gateway.go index b017d4882a1..67ebaae959e 100644 --- a/google/services/compute/resource_compute_ha_vpn_gateway.go +++ b/google/services/compute/resource_compute_ha_vpn_gateway.go @@ -125,6 +125,7 @@ func ResourceComputeHaVpnGateway() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -300,6 +301,18 @@ otherwise the request will fail with error 412 conditionNotMet.`, Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -491,6 +504,19 @@ func resourceComputeHaVpnGatewayRead(d *schema.ResourceData, meta interface{}) e log.Printf("[DEBUG] Finished reading ComputeHaVpnGateway %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading HaVpnGateway: %s", err) } @@ -528,6 +554,19 @@ func resourceComputeHaVpnGatewayRead(d *schema.ResourceData, meta interface{}) e } func resourceComputeHaVpnGatewayUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeHaVpnGateway().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeHaVpnGatewayRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -622,6 +661,13 @@ func resourceComputeHaVpnGatewayUpdate(d *schema.ResourceData, meta interface{}) } func resourceComputeHaVpnGatewayDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeHaVpnGateway without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing HaVpnGateway %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_ha_vpn_gateway_generated_meta.yaml b/google/services/compute/resource_compute_ha_vpn_gateway_generated_meta.yaml index 49b86ff6944..a8c12c4e7cf 100644 --- a/google/services/compute/resource_compute_ha_vpn_gateway_generated_meta.yaml +++ b/google/services/compute/resource_compute_ha_vpn_gateway_generated_meta.yaml @@ -24,3 +24,5 @@ fields: - api_field: vpnInterfaces.interconnectAttachment - api_field: vpnInterfaces.ipAddress - api_field: selfLink + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_health_check.go b/google/services/compute/resource_compute_health_check.go index 3f8051b4a44..d8f3843d453 100644 --- a/google/services/compute/resource_compute_health_check.go +++ b/google/services/compute/resource_compute_health_check.go @@ -199,6 +199,7 @@ func ResourceComputeHealthCheck() *schema.Resource { CustomizeDiff: customdiff.All( healthCheckCustomizeDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -818,6 +819,18 @@ consecutive failures. The default value is 2.`, Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -1039,6 +1052,19 @@ func resourceComputeHealthCheckRead(d *schema.ResourceData, meta interface{}) er log.Printf("[DEBUG] Finished reading ComputeHealthCheck %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading HealthCheck: %s", err) } @@ -1070,6 +1096,19 @@ func resourceComputeHealthCheckRead(d *schema.ResourceData, meta interface{}) er } func resourceComputeHealthCheckUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeHealthCheck().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeHealthCheckRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1238,6 +1277,13 @@ func resourceComputeHealthCheckUpdate(d *schema.ResourceData, meta interface{}) } func resourceComputeHealthCheckDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeHealthCheck without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing HealthCheck %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_health_check_generated_meta.yaml b/google/services/compute/resource_compute_health_check_generated_meta.yaml index c55dbbddcee..83bf91b018b 100644 --- a/google/services/compute/resource_compute_health_check_generated_meta.yaml +++ b/google/services/compute/resource_compute_health_check_generated_meta.yaml @@ -60,3 +60,5 @@ fields: - api_field: type - api_field: unhealthyThreshold - api_field: selfLink + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_http_health_check.go b/google/services/compute/resource_compute_http_health_check.go index a161dc78f53..bce7c381ba3 100644 --- a/google/services/compute/resource_compute_http_health_check.go +++ b/google/services/compute/resource_compute_http_health_check.go @@ -115,6 +115,7 @@ func ResourceComputeHttpHealthCheck() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -220,6 +221,18 @@ consecutive failures. The default value is 2.`, Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -400,6 +413,19 @@ func resourceComputeHttpHealthCheckRead(d *schema.ResourceData, meta interface{} log.Printf("[DEBUG] Finished reading ComputeHttpHealthCheck %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading HttpHealthCheck: %s", err) } @@ -431,6 +457,19 @@ func resourceComputeHttpHealthCheckRead(d *schema.ResourceData, meta interface{} } func resourceComputeHttpHealthCheckUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeHttpHealthCheck().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeHttpHealthCheckRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -558,6 +597,13 @@ func resourceComputeHttpHealthCheckUpdate(d *schema.ResourceData, meta interface } func resourceComputeHttpHealthCheckDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeHttpHealthCheck without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing HttpHealthCheck %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_http_health_check_generated_meta.yaml b/google/services/compute/resource_compute_http_health_check_generated_meta.yaml index 2cec3498d89..72ef6030cfc 100644 --- a/google/services/compute/resource_compute_http_health_check_generated_meta.yaml +++ b/google/services/compute/resource_compute_http_health_check_generated_meta.yaml @@ -18,3 +18,5 @@ fields: - api_field: timeoutSec - api_field: unhealthyThreshold - api_field: selfLink + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_https_health_check.go b/google/services/compute/resource_compute_https_health_check.go index 5ec6f26c946..e49a1b1cb59 100644 --- a/google/services/compute/resource_compute_https_health_check.go +++ b/google/services/compute/resource_compute_https_health_check.go @@ -115,6 +115,7 @@ func ResourceComputeHttpsHealthCheck() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -220,6 +221,18 @@ consecutive failures. The default value is 2.`, Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -400,6 +413,19 @@ func resourceComputeHttpsHealthCheckRead(d *schema.ResourceData, meta interface{ log.Printf("[DEBUG] Finished reading ComputeHttpsHealthCheck %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading HttpsHealthCheck: %s", err) } @@ -431,6 +457,19 @@ func resourceComputeHttpsHealthCheckRead(d *schema.ResourceData, meta interface{ } func resourceComputeHttpsHealthCheckUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeHttpsHealthCheck().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeHttpsHealthCheckRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -558,6 +597,13 @@ func resourceComputeHttpsHealthCheckUpdate(d *schema.ResourceData, meta interfac } func resourceComputeHttpsHealthCheckDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeHttpsHealthCheck without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing HttpsHealthCheck %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_https_health_check_generated_meta.yaml b/google/services/compute/resource_compute_https_health_check_generated_meta.yaml index 20506f67ffd..986b8f5ad3e 100644 --- a/google/services/compute/resource_compute_https_health_check_generated_meta.yaml +++ b/google/services/compute/resource_compute_https_health_check_generated_meta.yaml @@ -18,3 +18,5 @@ fields: - api_field: timeoutSec - api_field: unhealthyThreshold - api_field: selfLink + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_image.go b/google/services/compute/resource_compute_image.go index c514163b5ac..bc3009d1cac 100644 --- a/google/services/compute/resource_compute_image.go +++ b/google/services/compute/resource_compute_image.go @@ -116,6 +116,7 @@ func ResourceComputeImage() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -659,6 +660,18 @@ internally during updates.`, Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -913,6 +926,19 @@ func resourceComputeImageRead(d *schema.ResourceData, meta interface{}) error { log.Printf("[DEBUG] Finished reading ComputeImage %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Image: %s", err) } @@ -944,6 +970,19 @@ func resourceComputeImageRead(d *schema.ResourceData, meta interface{}) error { } func resourceComputeImageUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeImage().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeImageRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1033,6 +1072,13 @@ func resourceComputeImageUpdate(d *schema.ResourceData, meta interface{}) error } func resourceComputeImageDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeImage without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Image %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_image_generated_meta.yaml b/google/services/compute/resource_compute_image_generated_meta.yaml index bed4f9e4ab6..da5b19659d7 100644 --- a/google/services/compute/resource_compute_image_generated_meta.yaml +++ b/google/services/compute/resource_compute_image_generated_meta.yaml @@ -59,3 +59,5 @@ fields: - field: terraform_labels provider_only: true - api_field: selfLink + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_instance.go b/google/services/compute/resource_compute_instance.go index 9fe9567f610..2cbddd3dae2 100644 --- a/google/services/compute/resource_compute_instance.go +++ b/google/services/compute/resource_compute_instance.go @@ -1564,8 +1564,12 @@ be from 0 to 999,999,999 inclusive.`, }, }, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), tpgresource.DefaultProviderProject, tpgresource.DefaultProviderZone, customdiff.If( @@ -2173,10 +2177,19 @@ func resourceComputeInstanceRead(d *schema.ResourceData, meta interface{}) error d.SetId(fmt.Sprintf("projects/%s/zones/%s/instances/%s", project, zone, instance.Name)) + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } func resourceComputeInstanceUpdate(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceComputeInstance) { + return ResourceComputeInstance().Read(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -3332,6 +3345,13 @@ func isGracefulMetadataStartupSwitch(d *schema.ResourceDiff) bool { } func resourceComputeInstanceDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_instance_from_template_meta.yaml b/google/services/compute/resource_compute_instance_from_template_meta.yaml index c2d35358b15..b3d16de7c15 100644 --- a/google/services/compute/resource_compute_instance_from_template_meta.yaml +++ b/google/services/compute/resource_compute_instance_from_template_meta.yaml @@ -237,3 +237,5 @@ fields: - field: 'terraform_labels' provider_only: true - api_field: 'zone' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/compute/resource_compute_instance_group.go b/google/services/compute/resource_compute_instance_group.go index 06421f90ead..79cd73e9506 100644 --- a/google/services/compute/resource_compute_instance_group.go +++ b/google/services/compute/resource_compute_instance_group.go @@ -51,6 +51,7 @@ func ResourceComputeInstanceGroup() *schema.Resource { }, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), tpgresource.DefaultProviderProject, tpgresource.DefaultProviderZone, ), @@ -139,6 +140,9 @@ func ResourceComputeInstanceGroup() *schema.Resource { Computed: true, Description: `The number of instances in the group.`, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, UseJSONNumber: true, } @@ -418,9 +422,18 @@ func resourceComputeInstanceGroupRead(d *schema.ResourceData, meta interface{}) return fmt.Errorf("Error setting self_link: %s", err) } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } func resourceComputeInstanceGroupUpdate(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceComputeInstanceGroup) { + return ResourceComputeInstanceGroup().Read(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -559,6 +572,13 @@ func resourceComputeInstanceGroupUpdate(d *schema.ResourceData, meta interface{} } func resourceComputeInstanceGroupDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_instance_group_manager.go b/google/services/compute/resource_compute_instance_group_manager.go index ee2d45da6c9..94ba7e220da 100644 --- a/google/services/compute/resource_compute_instance_group_manager.go +++ b/google/services/compute/resource_compute_instance_group_manager.go @@ -50,6 +50,7 @@ func ResourceComputeInstanceGroupManager() *schema.Resource { Delete: schema.DefaultTimeout(15 * time.Minute), }, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), tpgresource.DefaultProviderProject, tpgresource.DefaultProviderZone, customdiff.ForceNewIfChange("resource_policies.0.workload_policy", ForceNewResourcePoliciesWorkloadPolicyIfNewIsEmpty), @@ -590,6 +591,9 @@ func ResourceComputeInstanceGroupManager() *schema.Resource { }, }, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, UseJSONNumber: true, } @@ -996,6 +1000,10 @@ func resourceComputeInstanceGroupManagerRead(d *schema.ResourceData, meta interf } } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } diff --git a/google/services/compute/resource_compute_instance_group_manager_meta.yaml b/google/services/compute/resource_compute_instance_group_manager_meta.yaml index e65a801b6d0..c4550054ff5 100644 --- a/google/services/compute/resource_compute_instance_group_manager_meta.yaml +++ b/google/services/compute/resource_compute_instance_group_manager_meta.yaml @@ -84,3 +84,5 @@ fields: - field: 'wait_for_instances_status' provider_only: true - api_field: 'zone' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/compute/resource_compute_instance_group_membership.go b/google/services/compute/resource_compute_instance_group_membership.go index 2eb9b4bc060..844852dfade 100644 --- a/google/services/compute/resource_compute_instance_group_membership.go +++ b/google/services/compute/resource_compute_instance_group_membership.go @@ -100,6 +100,7 @@ func ResourceComputeInstanceGroupMembership() *schema.Resource { return &schema.Resource{ Create: resourceComputeInstanceGroupMembershipCreate, Read: resourceComputeInstanceGroupMembershipRead, + Update: resourceComputeInstanceGroupMembershipUpdate, Delete: resourceComputeInstanceGroupMembershipDelete, Importer: &schema.ResourceImporter{ @@ -113,6 +114,7 @@ func ResourceComputeInstanceGroupMembership() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -170,6 +172,18 @@ func ResourceComputeInstanceGroupMembership() *schema.Resource { Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -336,6 +350,19 @@ func resourceComputeInstanceGroupMembershipRead(d *schema.ResourceData, meta int return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading InstanceGroupMembership: %s", err) } @@ -378,7 +405,19 @@ func resourceComputeInstanceGroupMembershipRead(d *schema.ResourceData, meta int return nil } +func resourceComputeInstanceGroupMembershipUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceComputeInstanceGroupMembershipRead(d, meta) +} + func resourceComputeInstanceGroupMembershipDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeInstanceGroupMembership without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing InstanceGroupMembership %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_instance_group_membership_generated_meta.yaml b/google/services/compute/resource_compute_instance_group_membership_generated_meta.yaml index 3bb31b61041..c6efff34c73 100644 --- a/google/services/compute/resource_compute_instance_group_membership_generated_meta.yaml +++ b/google/services/compute/resource_compute_instance_group_membership_generated_meta.yaml @@ -14,3 +14,5 @@ fields: provider_only: true - field: zone provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_instance_group_meta.yaml b/google/services/compute/resource_compute_instance_group_meta.yaml index 2a6c17cfe80..bdd1fc3a522 100644 --- a/google/services/compute/resource_compute_instance_group_meta.yaml +++ b/google/services/compute/resource_compute_instance_group_meta.yaml @@ -20,3 +20,5 @@ fields: - api_field: 'selfLink' - api_field: 'size' - api_field: 'zone' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/compute/resource_compute_instance_group_named_port.go b/google/services/compute/resource_compute_instance_group_named_port.go index 64e36251dbb..13c2df32cc6 100644 --- a/google/services/compute/resource_compute_instance_group_named_port.go +++ b/google/services/compute/resource_compute_instance_group_named_port.go @@ -100,6 +100,7 @@ func ResourceComputeInstanceGroupNamedPort() *schema.Resource { return &schema.Resource{ Create: resourceComputeInstanceGroupNamedPortCreate, Read: resourceComputeInstanceGroupNamedPortRead, + Update: resourceComputeInstanceGroupNamedPortUpdate, Delete: resourceComputeInstanceGroupNamedPortDelete, Importer: &schema.ResourceImporter{ @@ -114,6 +115,7 @@ func ResourceComputeInstanceGroupNamedPort() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, tpgresource.DefaultProviderZone, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -182,6 +184,18 @@ long, and comply with RFC1035.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -365,6 +379,19 @@ func resourceComputeInstanceGroupNamedPortRead(d *schema.ResourceData, meta inte return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading InstanceGroupNamedPort: %s", err) } @@ -420,7 +447,19 @@ func resourceComputeInstanceGroupNamedPortRead(d *schema.ResourceData, meta inte return nil } +func resourceComputeInstanceGroupNamedPortUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceComputeInstanceGroupNamedPortRead(d, meta) +} + func resourceComputeInstanceGroupNamedPortDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeInstanceGroupNamedPort without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing InstanceGroupNamedPort %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_instance_group_named_port_generated_meta.yaml b/google/services/compute/resource_compute_instance_group_named_port_generated_meta.yaml index d98c04836d5..9c1488b2bbd 100644 --- a/google/services/compute/resource_compute_instance_group_named_port_generated_meta.yaml +++ b/google/services/compute/resource_compute_instance_group_named_port_generated_meta.yaml @@ -17,3 +17,5 @@ fields: field: port - field: zone provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_instance_meta.yaml b/google/services/compute/resource_compute_instance_meta.yaml index 10605d4f642..fb67f77aba4 100644 --- a/google/services/compute/resource_compute_instance_meta.yaml +++ b/google/services/compute/resource_compute_instance_meta.yaml @@ -236,4 +236,6 @@ fields: field: 'tags_fingerprint' - field: 'terraform_labels' provider_only: true - - api_field: 'zone' \ No newline at end of file + - api_field: 'zone' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/compute/resource_compute_instance_settings.go b/google/services/compute/resource_compute_instance_settings.go index cb491a77af6..7a814f79a54 100644 --- a/google/services/compute/resource_compute_instance_settings.go +++ b/google/services/compute/resource_compute_instance_settings.go @@ -115,6 +115,7 @@ func ResourceComputeInstanceSettings() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -152,6 +153,18 @@ internally during updates.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -301,6 +314,19 @@ func resourceComputeInstanceSettingsRead(d *schema.ResourceData, meta interface{ log.Printf("[DEBUG] Finished reading ComputeInstanceSettings %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading InstanceSettings: %s", err) } @@ -314,6 +340,19 @@ func resourceComputeInstanceSettingsRead(d *schema.ResourceData, meta interface{ } func resourceComputeInstanceSettingsUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeInstanceSettings().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeInstanceSettingsRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -411,6 +450,13 @@ func resourceComputeInstanceSettingsUpdate(d *schema.ResourceData, meta interfac } func resourceComputeInstanceSettingsDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeInstanceSettings without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing InstanceSettings %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_instance_settings_generated_meta.yaml b/google/services/compute/resource_compute_instance_settings_generated_meta.yaml index ac98823526d..9a6802fef80 100644 --- a/google/services/compute/resource_compute_instance_settings_generated_meta.yaml +++ b/google/services/compute/resource_compute_instance_settings_generated_meta.yaml @@ -12,3 +12,5 @@ fields: - api_field: fingerprint - api_field: metadata.items - api_field: zone + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_instance_template.go b/google/services/compute/resource_compute_instance_template.go index b0b83302d92..651b6907c93 100644 --- a/google/services/compute/resource_compute_instance_template.go +++ b/google/services/compute/resource_compute_instance_template.go @@ -75,6 +75,7 @@ func ResourceComputeInstanceTemplate() *schema.Resource { }, SchemaVersion: 1, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), tpgresource.DefaultProviderProject, resourceComputeInstanceTemplateSourceImageCustomizeDiff, resourceComputeInstanceTemplateScratchDiskCustomizeDiff, diff --git a/google/services/compute/resource_compute_instant_snapshot.go b/google/services/compute/resource_compute_instant_snapshot.go index dbf0302616a..7bd91298f82 100644 --- a/google/services/compute/resource_compute_instant_snapshot.go +++ b/google/services/compute/resource_compute_instant_snapshot.go @@ -116,6 +116,7 @@ func ResourceComputeInstantSnapshot() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -248,6 +249,18 @@ internally during updates.`, Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -421,6 +434,19 @@ func resourceComputeInstantSnapshotRead(d *schema.ResourceData, meta interface{} log.Printf("[DEBUG] Finished reading ComputeInstantSnapshot %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading InstantSnapshot: %s", err) } @@ -458,6 +484,19 @@ func resourceComputeInstantSnapshotRead(d *schema.ResourceData, meta interface{} } func resourceComputeInstantSnapshotUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeInstantSnapshot().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeInstantSnapshotRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -552,6 +591,13 @@ func resourceComputeInstantSnapshotUpdate(d *schema.ResourceData, meta interface } func resourceComputeInstantSnapshotDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeInstantSnapshot without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing InstantSnapshot %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_instant_snapshot_generated_meta.yaml b/google/services/compute/resource_compute_instant_snapshot_generated_meta.yaml index 6e64f43b669..6e2f4c5c070 100644 --- a/google/services/compute/resource_compute_instant_snapshot_generated_meta.yaml +++ b/google/services/compute/resource_compute_instant_snapshot_generated_meta.yaml @@ -24,3 +24,5 @@ fields: provider_only: true - api_field: zone - api_field: selfLink + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_interconnect.go b/google/services/compute/resource_compute_interconnect.go index b4b44129c7a..80eba846819 100644 --- a/google/services/compute/resource_compute_interconnect.go +++ b/google/services/compute/resource_compute_interconnect.go @@ -120,6 +120,7 @@ func ResourceComputeInterconnect() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -552,6 +553,18 @@ This can be used only for ping tests.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -834,6 +847,19 @@ func resourceComputeInterconnectRead(d *schema.ResourceData, meta interface{}) e log.Printf("[DEBUG] Finished reading ComputeInterconnect %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Interconnect: %s", err) } @@ -865,6 +891,19 @@ func resourceComputeInterconnectRead(d *schema.ResourceData, meta interface{}) e } func resourceComputeInterconnectUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeInterconnect().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeInterconnectRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1029,6 +1068,13 @@ func resourceComputeInterconnectUpdate(d *schema.ResourceData, meta interface{}) } func resourceComputeInterconnectDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeInterconnect without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Interconnect %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_interconnect_attachment.go b/google/services/compute/resource_compute_interconnect_attachment.go index 7eed7bd6312..ea2ddfbf5ee 100644 --- a/google/services/compute/resource_compute_interconnect_attachment.go +++ b/google/services/compute/resource_compute_interconnect_attachment.go @@ -135,6 +135,7 @@ func ResourceComputeInterconnectAttachment() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -588,6 +589,18 @@ Google and the customer, going to and from this network and region.`, Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -927,6 +940,19 @@ func resourceComputeInterconnectAttachmentRead(d *schema.ResourceData, meta inte log.Printf("[DEBUG] Finished reading ComputeInterconnectAttachment %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading InterconnectAttachment: %s", err) } @@ -964,6 +990,19 @@ func resourceComputeInterconnectAttachmentRead(d *schema.ResourceData, meta inte } func resourceComputeInterconnectAttachmentUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeInterconnectAttachment().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeInterconnectAttachmentRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1139,6 +1178,13 @@ func resourceComputeInterconnectAttachmentUpdate(d *schema.ResourceData, meta in } func resourceComputeInterconnectAttachmentDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeInterconnectAttachment without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing InterconnectAttachment %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_interconnect_attachment_generated_meta.yaml b/google/services/compute/resource_compute_interconnect_attachment_generated_meta.yaml index 024123eae3d..62e0c5d9fa0 100644 --- a/google/services/compute/resource_compute_interconnect_attachment_generated_meta.yaml +++ b/google/services/compute/resource_compute_interconnect_attachment_generated_meta.yaml @@ -55,3 +55,5 @@ fields: - api_field: type - api_field: vlanTag8021q - api_field: selfLink + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_interconnect_attachment_group.go b/google/services/compute/resource_compute_interconnect_attachment_group.go index f83636544ff..3a3c2275dfb 100644 --- a/google/services/compute/resource_compute_interconnect_attachment_group.go +++ b/google/services/compute/resource_compute_interconnect_attachment_group.go @@ -115,6 +115,7 @@ func ResourceComputeInterconnectAttachmentGroup() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -399,6 +400,18 @@ Interconnect.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -555,6 +568,19 @@ func resourceComputeInterconnectAttachmentGroupRead(d *schema.ResourceData, meta log.Printf("[DEBUG] Finished reading ComputeInterconnectAttachmentGroup %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading InterconnectAttachmentGroup: %s", err) } @@ -586,6 +612,19 @@ func resourceComputeInterconnectAttachmentGroupRead(d *schema.ResourceData, meta } func resourceComputeInterconnectAttachmentGroupUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeInterconnectAttachmentGroup().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeInterconnectAttachmentGroupRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -683,6 +722,13 @@ func resourceComputeInterconnectAttachmentGroupUpdate(d *schema.ResourceData, me } func resourceComputeInterconnectAttachmentGroupDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeInterconnectAttachmentGroup without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing InterconnectAttachmentGroup %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_interconnect_attachment_group_generated_meta.yaml b/google/services/compute/resource_compute_interconnect_attachment_group_generated_meta.yaml index baac0813b6a..bc2e0751d11 100644 --- a/google/services/compute/resource_compute_interconnect_attachment_group_generated_meta.yaml +++ b/google/services/compute/resource_compute_interconnect_attachment_group_generated_meta.yaml @@ -30,3 +30,5 @@ fields: - api_field: logicalStructure.regions.metros.metro - api_field: logicalStructure.regions.region - api_field: name + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_interconnect_generated_meta.yaml b/google/services/compute/resource_compute_interconnect_generated_meta.yaml index ba816b14e7a..adfa7fb2c1b 100644 --- a/google/services/compute/resource_compute_interconnect_generated_meta.yaml +++ b/google/services/compute/resource_compute_interconnect_generated_meta.yaml @@ -53,3 +53,5 @@ fields: - field: terraform_labels provider_only: true - api_field: wireGroups + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_interconnect_group.go b/google/services/compute/resource_compute_interconnect_group.go index 876df9385fa..e73ee2f697c 100644 --- a/google/services/compute/resource_compute_interconnect_group.go +++ b/google/services/compute/resource_compute_interconnect_group.go @@ -115,6 +115,7 @@ func ResourceComputeInterconnectGroup() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -371,6 +372,18 @@ Interconnects underneath this.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -521,6 +534,19 @@ func resourceComputeInterconnectGroupRead(d *schema.ResourceData, meta interface log.Printf("[DEBUG] Finished reading ComputeInterconnectGroup %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading InterconnectGroup: %s", err) } @@ -552,6 +578,19 @@ func resourceComputeInterconnectGroupRead(d *schema.ResourceData, meta interface } func resourceComputeInterconnectGroupUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeInterconnectGroup().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeInterconnectGroupRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -643,6 +682,13 @@ func resourceComputeInterconnectGroupUpdate(d *schema.ResourceData, meta interfa } func resourceComputeInterconnectGroupDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeInterconnectGroup without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing InterconnectGroup %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_interconnect_group_generated_meta.yaml b/google/services/compute/resource_compute_interconnect_group_generated_meta.yaml index a0cc555e56f..8e3544e61ec 100644 --- a/google/services/compute/resource_compute_interconnect_group_generated_meta.yaml +++ b/google/services/compute/resource_compute_interconnect_group_generated_meta.yaml @@ -27,3 +27,5 @@ fields: - api_field: physicalStructure.metros.facilities.zones.interconnects - api_field: physicalStructure.metros.facilities.zones.zone - api_field: physicalStructure.metros.metro + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_managed_ssl_certificate.go b/google/services/compute/resource_compute_managed_ssl_certificate.go index 6c1727b8a39..d818907c30a 100644 --- a/google/services/compute/resource_compute_managed_ssl_certificate.go +++ b/google/services/compute/resource_compute_managed_ssl_certificate.go @@ -108,6 +108,7 @@ func ResourceComputeManagedSslCertificate() *schema.Resource { return &schema.Resource{ Create: resourceComputeManagedSslCertificateCreate, Read: resourceComputeManagedSslCertificateRead, + Update: resourceComputeManagedSslCertificateUpdate, Delete: resourceComputeManagedSslCertificateDelete, Importer: &schema.ResourceImporter{ @@ -121,6 +122,7 @@ func ResourceComputeManagedSslCertificate() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -229,6 +231,18 @@ which type this is. Default value: "MANAGED" Possible values: ["MANAGED"]`, Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -379,6 +393,19 @@ func resourceComputeManagedSslCertificateRead(d *schema.ResourceData, meta inter log.Printf("[DEBUG] Finished reading ComputeManagedSslCertificate %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading ManagedSslCertificate: %s", err) } @@ -409,7 +436,19 @@ func resourceComputeManagedSslCertificateRead(d *schema.ResourceData, meta inter return nil } +func resourceComputeManagedSslCertificateUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceComputeManagedSslCertificateRead(d, meta) +} + func resourceComputeManagedSslCertificateDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeManagedSslCertificate without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ManagedSslCertificate %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_managed_ssl_certificate_generated_meta.yaml b/google/services/compute/resource_compute_managed_ssl_certificate_generated_meta.yaml index fcbd08225e0..3c266edf53a 100644 --- a/google/services/compute/resource_compute_managed_ssl_certificate_generated_meta.yaml +++ b/google/services/compute/resource_compute_managed_ssl_certificate_generated_meta.yaml @@ -17,3 +17,5 @@ fields: - api_field: subjectAlternativeNames - api_field: type - api_field: selfLink + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_network.go b/google/services/compute/resource_compute_network.go index 8345986d22a..eb3d292ea73 100644 --- a/google/services/compute/resource_compute_network.go +++ b/google/services/compute/resource_compute_network.go @@ -115,6 +115,7 @@ func ResourceComputeNetwork() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -308,6 +309,18 @@ immediately after network creation. Defaults to 'false'.`, Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -549,6 +562,18 @@ func resourceComputeNetworkRead(d *schema.ResourceData, meta interface{}) error return fmt.Errorf("Error setting delete_default_routes_on_create: %s", err) } } + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Network: %s", err) } @@ -580,6 +605,19 @@ func resourceComputeNetworkRead(d *schema.ResourceData, meta interface{}) error } func resourceComputeNetworkUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeNetwork().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeNetworkRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -797,6 +835,13 @@ func resourceComputeNetworkUpdate(d *schema.ResourceData, meta interface{}) erro } func resourceComputeNetworkDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeNetwork without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Network %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_network_attachment.go b/google/services/compute/resource_compute_network_attachment.go index 672cd72f5c1..c618b75695c 100644 --- a/google/services/compute/resource_compute_network_attachment.go +++ b/google/services/compute/resource_compute_network_attachment.go @@ -115,6 +115,7 @@ func ResourceComputeNetworkAttachment() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -246,6 +247,18 @@ Because it is required that all the subnetworks must be from the same network, i Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -404,6 +417,19 @@ func resourceComputeNetworkAttachmentRead(d *schema.ResourceData, meta interface log.Printf("[DEBUG] Finished reading ComputeNetworkAttachment %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading NetworkAttachment: %s", err) } @@ -417,6 +443,19 @@ func resourceComputeNetworkAttachmentRead(d *schema.ResourceData, meta interface } func resourceComputeNetworkAttachmentUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeNetworkAttachment().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeNetworkAttachmentRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -505,6 +544,13 @@ func resourceComputeNetworkAttachmentUpdate(d *schema.ResourceData, meta interfa } func resourceComputeNetworkAttachmentDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeNetworkAttachment without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing NetworkAttachment %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_network_attachment_generated_meta.yaml b/google/services/compute/resource_compute_network_attachment_generated_meta.yaml index 7ae8d9018d2..35fc016ce5d 100644 --- a/google/services/compute/resource_compute_network_attachment_generated_meta.yaml +++ b/google/services/compute/resource_compute_network_attachment_generated_meta.yaml @@ -26,3 +26,5 @@ fields: - api_field: selfLink - api_field: selfLinkWithId - api_field: subnetworks + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_network_endpoint.go b/google/services/compute/resource_compute_network_endpoint.go index 9e7755f4153..97df87efd35 100644 --- a/google/services/compute/resource_compute_network_endpoint.go +++ b/google/services/compute/resource_compute_network_endpoint.go @@ -100,6 +100,7 @@ func ResourceComputeNetworkEndpoint() *schema.Resource { return &schema.Resource{ Create: resourceComputeNetworkEndpointCreate, Read: resourceComputeNetworkEndpointRead, + Update: resourceComputeNetworkEndpointUpdate, Delete: resourceComputeNetworkEndpointDelete, Importer: &schema.ResourceImporter{ @@ -114,6 +115,7 @@ func ResourceComputeNetworkEndpoint() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, tpgresource.DefaultProviderZone, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -198,6 +200,18 @@ with the type of 'GCE_VM_IP'`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -399,6 +413,19 @@ func resourceComputeNetworkEndpointRead(d *schema.ResourceData, meta interface{} return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading NetworkEndpoint: %s", err) } @@ -460,7 +487,19 @@ func resourceComputeNetworkEndpointRead(d *schema.ResourceData, meta interface{} return nil } +func resourceComputeNetworkEndpointUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceComputeNetworkEndpointRead(d, meta) +} + func resourceComputeNetworkEndpointDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeNetworkEndpoint without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing NetworkEndpoint %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_network_endpoint_generated_meta.yaml b/google/services/compute/resource_compute_network_endpoint_generated_meta.yaml index e3e86fb13d5..a198771a346 100644 --- a/google/services/compute/resource_compute_network_endpoint_generated_meta.yaml +++ b/google/services/compute/resource_compute_network_endpoint_generated_meta.yaml @@ -14,3 +14,5 @@ fields: - api_field: port - field: zone provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_network_endpoint_group.go b/google/services/compute/resource_compute_network_endpoint_group.go index b052a024abe..f2477aeada9 100644 --- a/google/services/compute/resource_compute_network_endpoint_group.go +++ b/google/services/compute/resource_compute_network_endpoint_group.go @@ -110,6 +110,7 @@ func ResourceComputeNetworkEndpointGroup() *schema.Resource { return &schema.Resource{ Create: resourceComputeNetworkEndpointGroupCreate, Read: resourceComputeNetworkEndpointGroupRead, + Update: resourceComputeNetworkEndpointGroupUpdate, Delete: resourceComputeNetworkEndpointGroupDelete, Importer: &schema.ResourceImporter{ @@ -124,6 +125,7 @@ func ResourceComputeNetworkEndpointGroup() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, tpgresource.DefaultProviderZone, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -236,6 +238,18 @@ Possible values include: GCE_VM_IP, GCE_VM_IP_PORT, NON_GCP_PRIVATE_IP_PORT, INT Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -409,6 +423,19 @@ func resourceComputeNetworkEndpointGroupRead(d *schema.ResourceData, meta interf log.Printf("[DEBUG] Finished reading ComputeNetworkEndpointGroup %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading NetworkEndpointGroup: %s", err) } @@ -452,7 +479,19 @@ func resourceComputeNetworkEndpointGroupRead(d *schema.ResourceData, meta interf return nil } +func resourceComputeNetworkEndpointGroupUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceComputeNetworkEndpointGroupRead(d, meta) +} + func resourceComputeNetworkEndpointGroupDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeNetworkEndpointGroup without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing NetworkEndpointGroup %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_network_endpoint_group_generated_meta.yaml b/google/services/compute/resource_compute_network_endpoint_group_generated_meta.yaml index 91f16b05b18..f8cf3b38a15 100644 --- a/google/services/compute/resource_compute_network_endpoint_group_generated_meta.yaml +++ b/google/services/compute/resource_compute_network_endpoint_group_generated_meta.yaml @@ -18,3 +18,5 @@ fields: - api_field: subnetwork - api_field: zone - api_field: selfLink + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_network_endpoints.go b/google/services/compute/resource_compute_network_endpoints.go index f45a0531be4..b468bcdadce 100644 --- a/google/services/compute/resource_compute_network_endpoints.go +++ b/google/services/compute/resource_compute_network_endpoints.go @@ -226,6 +226,7 @@ func ResourceComputeNetworkEndpoints() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, tpgresource.DefaultProviderZone, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -280,6 +281,18 @@ additional information depending on the NEG type.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -482,6 +495,19 @@ func resourceComputeNetworkEndpointsRead(d *schema.ResourceData, meta interface{ return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading NetworkEndpoints: %s", err) } @@ -526,6 +552,19 @@ func resourceComputeNetworkEndpointsRead(d *schema.ResourceData, meta interface{ } func resourceComputeNetworkEndpointsUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeNetworkEndpoints().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeNetworkEndpointsRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -687,6 +726,13 @@ func resourceComputeNetworkEndpointsUpdate(d *schema.ResourceData, meta interfac } func resourceComputeNetworkEndpointsDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeNetworkEndpoints without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing NetworkEndpoints %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_network_endpoints_generated_meta.yaml b/google/services/compute/resource_compute_network_endpoints_generated_meta.yaml index a278b8f83c1..37679cee275 100644 --- a/google/services/compute/resource_compute_network_endpoints_generated_meta.yaml +++ b/google/services/compute/resource_compute_network_endpoints_generated_meta.yaml @@ -14,3 +14,5 @@ fields: - api_field: networkEndpoints.port - field: zone provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_network_firewall_policy.go b/google/services/compute/resource_compute_network_firewall_policy.go index f24561b6201..651d876a3bd 100644 --- a/google/services/compute/resource_compute_network_firewall_policy.go +++ b/google/services/compute/resource_compute_network_firewall_policy.go @@ -115,6 +115,7 @@ func ResourceComputeNetworkFirewallPolicy() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -194,6 +195,18 @@ Different policy types may support some of the Firewall Rules features. Possible Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -344,6 +357,19 @@ func resourceComputeNetworkFirewallPolicyRead(d *schema.ResourceData, meta inter log.Printf("[DEBUG] Finished reading ComputeNetworkFirewallPolicy %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading NetworkFirewallPolicy: %s", err) } @@ -375,6 +401,19 @@ func resourceComputeNetworkFirewallPolicyRead(d *schema.ResourceData, meta inter } func resourceComputeNetworkFirewallPolicyUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeNetworkFirewallPolicy().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeNetworkFirewallPolicyRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -460,6 +499,13 @@ func resourceComputeNetworkFirewallPolicyUpdate(d *schema.ResourceData, meta int } func resourceComputeNetworkFirewallPolicyDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeNetworkFirewallPolicy without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing NetworkFirewallPolicy %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_network_firewall_policy_association.go b/google/services/compute/resource_compute_network_firewall_policy_association.go index 422be4847c5..4057558adac 100644 --- a/google/services/compute/resource_compute_network_firewall_policy_association.go +++ b/google/services/compute/resource_compute_network_firewall_policy_association.go @@ -100,6 +100,7 @@ func ResourceComputeNetworkFirewallPolicyAssociation() *schema.Resource { return &schema.Resource{ Create: resourceComputeNetworkFirewallPolicyAssociationCreate, Read: resourceComputeNetworkFirewallPolicyAssociationRead, + Update: resourceComputeNetworkFirewallPolicyAssociationUpdate, Delete: resourceComputeNetworkFirewallPolicyAssociationDelete, Importer: &schema.ResourceImporter{ @@ -113,6 +114,7 @@ func ResourceComputeNetworkFirewallPolicyAssociation() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -170,6 +172,18 @@ func ResourceComputeNetworkFirewallPolicyAssociation() *schema.Resource { Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -313,6 +327,19 @@ func resourceComputeNetworkFirewallPolicyAssociationRead(d *schema.ResourceData, log.Printf("[DEBUG] Finished reading ComputeNetworkFirewallPolicyAssociation %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading NetworkFirewallPolicyAssociation: %s", err) } @@ -349,7 +376,19 @@ func resourceComputeNetworkFirewallPolicyAssociationRead(d *schema.ResourceData, return nil } +func resourceComputeNetworkFirewallPolicyAssociationUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceComputeNetworkFirewallPolicyAssociationRead(d, meta) +} + func resourceComputeNetworkFirewallPolicyAssociationDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeNetworkFirewallPolicyAssociation without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing NetworkFirewallPolicyAssociation %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_network_firewall_policy_association_generated_meta.yaml b/google/services/compute/resource_compute_network_firewall_policy_association_generated_meta.yaml index ca2268d0e32..55ba390e3ea 100644 --- a/google/services/compute/resource_compute_network_firewall_policy_association_generated_meta.yaml +++ b/google/services/compute/resource_compute_network_firewall_policy_association_generated_meta.yaml @@ -15,3 +15,5 @@ fields: field: name - api_field: associations.shortName field: short_name + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_network_firewall_policy_generated_meta.yaml b/google/services/compute/resource_compute_network_firewall_policy_generated_meta.yaml index f1493ce2e70..cc0e027f6b2 100644 --- a/google/services/compute/resource_compute_network_firewall_policy_generated_meta.yaml +++ b/google/services/compute/resource_compute_network_firewall_policy_generated_meta.yaml @@ -17,3 +17,5 @@ fields: - api_field: ruleTupleCount - api_field: selfLink - api_field: selfLinkWithId + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_network_firewall_policy_rule.go b/google/services/compute/resource_compute_network_firewall_policy_rule.go index f2e0ceeb221..18da18a03e2 100644 --- a/google/services/compute/resource_compute_network_firewall_policy_rule.go +++ b/google/services/compute/resource_compute_network_firewall_policy_rule.go @@ -125,6 +125,7 @@ func ResourceComputeNetworkFirewallPolicyRule() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -425,6 +426,18 @@ Can be set only if action = 'apply_security_profile_group' and cannot be set for Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -629,6 +642,19 @@ func resourceComputeNetworkFirewallPolicyRuleRead(d *schema.ResourceData, meta i log.Printf("[DEBUG] Finished reading ComputeNetworkFirewallPolicyRule %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading NetworkFirewallPolicyRule: %s", err) } @@ -666,6 +692,19 @@ func resourceComputeNetworkFirewallPolicyRuleRead(d *schema.ResourceData, meta i } func resourceComputeNetworkFirewallPolicyRuleUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeNetworkFirewallPolicyRule().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeNetworkFirewallPolicyRuleRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -822,6 +861,13 @@ func resourceComputeNetworkFirewallPolicyRuleUpdate(d *schema.ResourceData, meta } func resourceComputeNetworkFirewallPolicyRuleDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeNetworkFirewallPolicyRule without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing NetworkFirewallPolicyRule %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_network_firewall_policy_rule_generated_meta.yaml b/google/services/compute/resource_compute_network_firewall_policy_rule_generated_meta.yaml index 463d1729f07..8f3db69c75f 100644 --- a/google/services/compute/resource_compute_network_firewall_policy_rule_generated_meta.yaml +++ b/google/services/compute/resource_compute_network_firewall_policy_rule_generated_meta.yaml @@ -73,3 +73,5 @@ fields: field: target_service_accounts - api_field: rules.tlsInspect field: tls_inspect + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_network_firewall_policy_with_rules.go b/google/services/compute/resource_compute_network_firewall_policy_with_rules.go index 74c8a585599..6b79eb7d794 100644 --- a/google/services/compute/resource_compute_network_firewall_policy_with_rules.go +++ b/google/services/compute/resource_compute_network_firewall_policy_with_rules.go @@ -169,6 +169,7 @@ func ResourceComputeNetworkFirewallPolicyWithRules() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -791,6 +792,18 @@ It can be set only if action = 'apply_security_profile_group' and cannot be set Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -996,6 +1009,19 @@ func resourceComputeNetworkFirewallPolicyWithRulesRead(d *schema.ResourceData, m return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading NetworkFirewallPolicyWithRules: %s", err) } @@ -1027,6 +1053,19 @@ func resourceComputeNetworkFirewallPolicyWithRulesRead(d *schema.ResourceData, m } func resourceComputeNetworkFirewallPolicyWithRulesUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeNetworkFirewallPolicyWithRules().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeNetworkFirewallPolicyWithRulesRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1123,6 +1162,13 @@ func resourceComputeNetworkFirewallPolicyWithRulesUpdate(d *schema.ResourceData, } func resourceComputeNetworkFirewallPolicyWithRulesDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeNetworkFirewallPolicyWithRules without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing NetworkFirewallPolicyWithRules %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_network_firewall_policy_with_rules_generated_meta.yaml b/google/services/compute/resource_compute_network_firewall_policy_with_rules_generated_meta.yaml index e03acf5fe3a..63a5a30596c 100644 --- a/google/services/compute/resource_compute_network_firewall_policy_with_rules_generated_meta.yaml +++ b/google/services/compute/resource_compute_network_firewall_policy_with_rules_generated_meta.yaml @@ -101,3 +101,5 @@ fields: - api_field: ruleTupleCount - api_field: selfLink - api_field: selfLinkWithId + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_network_generated_meta.yaml b/google/services/compute/resource_compute_network_generated_meta.yaml index 2d294d8774f..2c2bc0c7ead 100644 --- a/google/services/compute/resource_compute_network_generated_meta.yaml +++ b/google/services/compute/resource_compute_network_generated_meta.yaml @@ -34,3 +34,5 @@ fields: - api_field: routingConfig.routingMode field: routing_mode - api_field: selfLink + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_network_peering.go b/google/services/compute/resource_compute_network_peering.go index cafea2b1f7d..a88036eb192 100644 --- a/google/services/compute/resource_compute_network_peering.go +++ b/google/services/compute/resource_compute_network_peering.go @@ -24,6 +24,7 @@ import ( "strings" "time" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "google.golang.org/api/googleapi" @@ -53,6 +54,10 @@ func ResourceComputeNetworkPeering() *schema.Resource { Delete: schema.DefaultTimeout(4 * time.Minute), }, + CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), + ), + Schema: map[string]*schema.Schema{ "name": { Type: schema.TypeString, @@ -134,6 +139,9 @@ func ResourceComputeNetworkPeering() *schema.Resource { Description: `The update strategy determines the semantics for updates and deletes to the peering connection configuration. The default value is INDEPENDENT. Possible values: ["INDEPENDENT", "CONSENSUS"]`, Default: "INDEPENDENT", }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, UseJSONNumber: true, } @@ -238,10 +246,19 @@ func resourceComputeNetworkPeeringRead(d *schema.ResourceData, meta interface{}) return fmt.Errorf("Error setting update_strategy: %s", err) } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } func resourceComputeNetworkPeeringUpdate(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceComputeNetworkPeering) { + return ResourceComputeNetworkPeering().Read(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -282,6 +299,13 @@ func resourceComputeNetworkPeeringUpdate(d *schema.ResourceData, meta interface{ } func resourceComputeNetworkPeeringDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_network_peering_meta.yaml b/google/services/compute/resource_compute_network_peering_meta.yaml index 33b9e0d48b9..ec79ac140b7 100644 --- a/google/services/compute/resource_compute_network_peering_meta.yaml +++ b/google/services/compute/resource_compute_network_peering_meta.yaml @@ -27,3 +27,5 @@ fields: field: 'state_details' - api_field: 'peerings.updateStrategy' field: 'update_strategy' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/compute/resource_compute_network_peering_routes_config.go b/google/services/compute/resource_compute_network_peering_routes_config.go index aef1e9f29fe..604b8e96c98 100644 --- a/google/services/compute/resource_compute_network_peering_routes_config.go +++ b/google/services/compute/resource_compute_network_peering_routes_config.go @@ -406,6 +406,7 @@ func resourceComputeNetworkPeeringRoutesConfigRead(d *schema.ResourceData, meta } func resourceComputeNetworkPeeringRoutesConfigUpdate(d *schema.ResourceData, meta interface{}) error { + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_node_group.go b/google/services/compute/resource_compute_node_group.go index 15dc9b712af..568224d0611 100644 --- a/google/services/compute/resource_compute_node_group.go +++ b/google/services/compute/resource_compute_node_group.go @@ -119,6 +119,7 @@ func ResourceComputeNodeGroup() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -289,6 +290,18 @@ than or equal to max-nodes. The default value is 0.`, Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -480,6 +493,19 @@ func resourceComputeNodeGroupRead(d *schema.ResourceData, meta interface{}) erro log.Printf("[DEBUG] Finished reading ComputeNodeGroup %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading NodeGroup: %s", err) } @@ -517,6 +543,19 @@ func resourceComputeNodeGroupRead(d *schema.ResourceData, meta interface{}) erro } func resourceComputeNodeGroupUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeNodeGroup().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeNodeGroupRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -724,6 +763,13 @@ func resourceComputeNodeGroupUpdate(d *schema.ResourceData, meta interface{}) er } func resourceComputeNodeGroupDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeNodeGroup without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing NodeGroup %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_node_group_generated_meta.yaml b/google/services/compute/resource_compute_node_group_generated_meta.yaml index 0098893049c..e2e2f0b8844 100644 --- a/google/services/compute/resource_compute_node_group_generated_meta.yaml +++ b/google/services/compute/resource_compute_node_group_generated_meta.yaml @@ -26,3 +26,5 @@ fields: - api_field: size - api_field: zone - api_field: selfLink + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_node_template.go b/google/services/compute/resource_compute_node_template.go index b359fb2edea..22634cdcbc0 100644 --- a/google/services/compute/resource_compute_node_template.go +++ b/google/services/compute/resource_compute_node_template.go @@ -100,6 +100,7 @@ func ResourceComputeNodeTemplate() *schema.Resource { return &schema.Resource{ Create: resourceComputeNodeTemplateCreate, Read: resourceComputeNodeTemplateRead, + Update: resourceComputeNodeTemplateUpdate, Delete: resourceComputeNodeTemplateDelete, Importer: &schema.ResourceImporter{ @@ -113,6 +114,7 @@ func ResourceComputeNodeTemplate() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -318,6 +320,18 @@ nodes will experience outages while maintenance is applied. Possible values: ["R Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -509,6 +523,19 @@ func resourceComputeNodeTemplateRead(d *schema.ResourceData, meta interface{}) e log.Printf("[DEBUG] Finished reading ComputeNodeTemplate %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading NodeTemplate: %s", err) } @@ -545,7 +572,19 @@ func resourceComputeNodeTemplateRead(d *schema.ResourceData, meta interface{}) e return nil } +func resourceComputeNodeTemplateUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceComputeNodeTemplateRead(d, meta) +} + func resourceComputeNodeTemplateDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeNodeTemplate without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing NodeTemplate %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_node_template_generated_meta.yaml b/google/services/compute/resource_compute_node_template_generated_meta.yaml index e39027179b2..719f1a669b4 100644 --- a/google/services/compute/resource_compute_node_template_generated_meta.yaml +++ b/google/services/compute/resource_compute_node_template_generated_meta.yaml @@ -24,3 +24,5 @@ fields: - api_field: region - api_field: serverBinding.type - api_field: selfLink + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_organization_security_policy.go b/google/services/compute/resource_compute_organization_security_policy.go index 33eb531bda6..e59801d7f00 100644 --- a/google/services/compute/resource_compute_organization_security_policy.go +++ b/google/services/compute/resource_compute_organization_security_policy.go @@ -216,6 +216,19 @@ updates of this resource.`, Computed: true, Description: `The unique identifier for the resource. This identifier is defined by the server.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -379,6 +392,20 @@ func resourceComputeOrganizationSecurityPolicyRead(d *schema.ResourceData, meta log.Printf("[DEBUG] Finished reading ComputeOrganizationSecurityPolicy %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceComputeOrganizationSecurityPolicyFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -388,6 +415,19 @@ func resourceComputeOrganizationSecurityPolicyRead(d *schema.ResourceData, meta } func resourceComputeOrganizationSecurityPolicyUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeOrganizationSecurityPolicy().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeOrganizationSecurityPolicyRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -460,6 +500,13 @@ func resourceComputeOrganizationSecurityPolicyUpdate(d *schema.ResourceData, met } func resourceComputeOrganizationSecurityPolicyDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeOrganizationSecurityPolicy without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing OrganizationSecurityPolicy %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_organization_security_policy_association.go b/google/services/compute/resource_compute_organization_security_policy_association.go index e78a4f7f180..547404cd903 100644 --- a/google/services/compute/resource_compute_organization_security_policy_association.go +++ b/google/services/compute/resource_compute_organization_security_policy_association.go @@ -100,6 +100,7 @@ func ResourceComputeOrganizationSecurityPolicyAssociation() *schema.Resource { return &schema.Resource{ Create: resourceComputeOrganizationSecurityPolicyAssociationCreate, Read: resourceComputeOrganizationSecurityPolicyAssociationRead, + Update: resourceComputeOrganizationSecurityPolicyAssociationUpdate, Delete: resourceComputeOrganizationSecurityPolicyAssociationDelete, Importer: &schema.ResourceImporter{ @@ -172,6 +173,19 @@ func ResourceComputeOrganizationSecurityPolicyAssociation() *schema.Resource { Computed: true, Description: `The display name of the security policy of the association.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -330,6 +344,20 @@ func resourceComputeOrganizationSecurityPolicyAssociationRead(d *schema.Resource log.Printf("[DEBUG] Finished reading ComputeOrganizationSecurityPolicyAssociation %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceComputeOrganizationSecurityPolicyAssociationFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -356,7 +384,19 @@ func resourceComputeOrganizationSecurityPolicyAssociationRead(d *schema.Resource return nil } +func resourceComputeOrganizationSecurityPolicyAssociationUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceComputeOrganizationSecurityPolicyAssociationRead(d, meta) +} + func resourceComputeOrganizationSecurityPolicyAssociationDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeOrganizationSecurityPolicyAssociation without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing OrganizationSecurityPolicyAssociation %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_organization_security_policy_association_generated_meta.yaml b/google/services/compute/resource_compute_organization_security_policy_association_generated_meta.yaml index b8296cf3e1b..0e5b265e0fe 100644 --- a/google/services/compute/resource_compute_organization_security_policy_association_generated_meta.yaml +++ b/google/services/compute/resource_compute_organization_security_policy_association_generated_meta.yaml @@ -19,3 +19,5 @@ fields: field: name - field: policy_id provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_organization_security_policy_generated_meta.yaml b/google/services/compute/resource_compute_organization_security_policy_generated_meta.yaml index bf90af2062c..98980b5bb2c 100644 --- a/google/services/compute/resource_compute_organization_security_policy_generated_meta.yaml +++ b/google/services/compute/resource_compute_organization_security_policy_generated_meta.yaml @@ -20,3 +20,5 @@ fields: field: policy_id - api_field: shortName - api_field: type + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_organization_security_policy_rule.go b/google/services/compute/resource_compute_organization_security_policy_rule.go index 42a77322fa8..ae891ecaf75 100644 --- a/google/services/compute/resource_compute_organization_security_policy_rule.go +++ b/google/services/compute/resource_compute_organization_security_policy_rule.go @@ -418,6 +418,19 @@ Note: For organization security policies, only EXTERNAL_302 redirect type is sup }, }, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -613,6 +626,20 @@ func resourceComputeOrganizationSecurityPolicyRuleRead(d *schema.ResourceData, m return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceComputeOrganizationSecurityPolicyRuleFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -640,6 +667,19 @@ func resourceComputeOrganizationSecurityPolicyRuleRead(d *schema.ResourceData, m } func resourceComputeOrganizationSecurityPolicyRuleUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeOrganizationSecurityPolicyRule().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeOrganizationSecurityPolicyRuleRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -782,6 +822,13 @@ func resourceComputeOrganizationSecurityPolicyRuleUpdate(d *schema.ResourceData, } func resourceComputeOrganizationSecurityPolicyRuleDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeOrganizationSecurityPolicyRule without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing OrganizationSecurityPolicyRule %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_organization_security_policy_rule_generated_meta.yaml b/google/services/compute/resource_compute_organization_security_policy_rule_generated_meta.yaml index e3b410629bd..0521e6f6d75 100644 --- a/google/services/compute/resource_compute_organization_security_policy_rule_generated_meta.yaml +++ b/google/services/compute/resource_compute_organization_security_policy_rule_generated_meta.yaml @@ -53,3 +53,5 @@ fields: field: redirect_options.target - api_field: rules.redirectOptions.type field: redirect_options.type + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_packet_mirroring.go b/google/services/compute/resource_compute_packet_mirroring.go index 5e9e6bdc748..9ca2f5b9920 100644 --- a/google/services/compute/resource_compute_packet_mirroring.go +++ b/google/services/compute/resource_compute_packet_mirroring.go @@ -115,6 +115,7 @@ func ResourceComputePacketMirroring() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -290,6 +291,18 @@ If it is not provided, the provider region is used.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -501,6 +514,19 @@ func resourceComputePacketMirroringRead(d *schema.ResourceData, meta interface{} log.Printf("[DEBUG] Finished reading ComputePacketMirroring %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading PacketMirroring: %s", err) } @@ -538,6 +564,19 @@ func resourceComputePacketMirroringRead(d *schema.ResourceData, meta interface{} } func resourceComputePacketMirroringUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputePacketMirroring().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputePacketMirroringRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -658,6 +697,13 @@ func resourceComputePacketMirroringUpdate(d *schema.ResourceData, meta interface } func resourceComputePacketMirroringDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputePacketMirroring without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing PacketMirroring %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_packet_mirroring_generated_meta.yaml b/google/services/compute/resource_compute_packet_mirroring_generated_meta.yaml index 8d4515c4020..26dcf74362a 100644 --- a/google/services/compute/resource_compute_packet_mirroring_generated_meta.yaml +++ b/google/services/compute/resource_compute_packet_mirroring_generated_meta.yaml @@ -20,3 +20,5 @@ fields: - api_field: network.url - api_field: priority - api_field: region + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_per_instance_config.go b/google/services/compute/resource_compute_per_instance_config.go index 54a8229b69a..f057a167319 100644 --- a/google/services/compute/resource_compute_per_instance_config.go +++ b/google/services/compute/resource_compute_per_instance_config.go @@ -116,6 +116,7 @@ func ResourceComputePerInstanceConfig() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, tpgresource.DefaultProviderZone, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -305,6 +306,18 @@ State will be removed on the next instance recreation or update.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -534,6 +547,18 @@ func resourceComputePerInstanceConfigRead(d *schema.ResourceData, meta interface return fmt.Errorf("Error setting remove_instance_state_on_destroy: %s", err) } } + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading PerInstanceConfig: %s", err) } @@ -584,6 +609,19 @@ func resourceComputePerInstanceConfigRead(d *schema.ResourceData, meta interface } func resourceComputePerInstanceConfigUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputePerInstanceConfig().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputePerInstanceConfigRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -739,6 +777,13 @@ func resourceComputePerInstanceConfigUpdate(d *schema.ResourceData, meta interfa } func resourceComputePerInstanceConfigDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputePerInstanceConfig without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing PerInstanceConfig %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_per_instance_config_generated_meta.yaml b/google/services/compute/resource_compute_per_instance_config_generated_meta.yaml index c3473026936..96e238aeee8 100644 --- a/google/services/compute/resource_compute_per_instance_config_generated_meta.yaml +++ b/google/services/compute/resource_compute_per_instance_config_generated_meta.yaml @@ -43,3 +43,5 @@ fields: provider_only: true - field: zone provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_preview_feature.go b/google/services/compute/resource_compute_preview_feature.go index a9709379306..9f214f0e603 100644 --- a/google/services/compute/resource_compute_preview_feature.go +++ b/google/services/compute/resource_compute_preview_feature.go @@ -350,6 +350,7 @@ func resourceComputePreviewFeatureRead(d *schema.ResourceData, meta interface{}) } func resourceComputePreviewFeatureUpdate(d *schema.ResourceData, meta interface{}) error { + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_project_cloud_armor_tier.go b/google/services/compute/resource_compute_project_cloud_armor_tier.go index 14ad9af227c..5b475f92d7d 100644 --- a/google/services/compute/resource_compute_project_cloud_armor_tier.go +++ b/google/services/compute/resource_compute_project_cloud_armor_tier.go @@ -115,6 +115,7 @@ func ResourceComputeProjectCloudArmorTier() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -145,6 +146,18 @@ func ResourceComputeProjectCloudArmorTier() *schema.Resource { Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -272,6 +285,19 @@ func resourceComputeProjectCloudArmorTierRead(d *schema.ResourceData, meta inter log.Printf("[DEBUG] Finished reading ComputeProjectCloudArmorTier %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading ProjectCloudArmorTier: %s", err) } @@ -297,6 +323,19 @@ func resourceComputeProjectCloudArmorTierRead(d *schema.ResourceData, meta inter } func resourceComputeProjectCloudArmorTierUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeProjectCloudArmorTier().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeProjectCloudArmorTierRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -371,6 +410,13 @@ func resourceComputeProjectCloudArmorTierUpdate(d *schema.ResourceData, meta int } func resourceComputeProjectCloudArmorTierDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeProjectCloudArmorTier without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ProjectCloudArmorTier %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_project_cloud_armor_tier_generated_meta.yaml b/google/services/compute/resource_compute_project_cloud_armor_tier_generated_meta.yaml index 03078f5b905..c67f5080a83 100644 --- a/google/services/compute/resource_compute_project_cloud_armor_tier_generated_meta.yaml +++ b/google/services/compute/resource_compute_project_cloud_armor_tier_generated_meta.yaml @@ -8,3 +8,5 @@ api_version: v1 api_resource_type_kind: Project fields: - api_field: cloudArmorTier + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_project_default_network_tier.go b/google/services/compute/resource_compute_project_default_network_tier.go index 608a01c5b4d..dc98fff64b9 100644 --- a/google/services/compute/resource_compute_project_default_network_tier.go +++ b/google/services/compute/resource_compute_project_default_network_tier.go @@ -48,6 +48,7 @@ func ResourceComputeProjectDefaultNetworkTier() *schema.Resource { }, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), tpgresource.DefaultProviderProject, ), @@ -131,7 +132,6 @@ func resourceComputeProjectDefaultNetworkTierRead(d *schema.ResourceData, meta i } func resourceComputeProjectDefaultNetworkTierDelete(d *schema.ResourceData, meta interface{}) error { - log.Printf("[WARNING] Default Network Tier will be only removed from Terraform state, but will be left intact on GCP.") return schema.RemoveFromState(d, meta) diff --git a/google/services/compute/resource_compute_project_metadata.go b/google/services/compute/resource_compute_project_metadata.go index 1b47b8e7567..3120c7829a0 100644 --- a/google/services/compute/resource_compute_project_metadata.go +++ b/google/services/compute/resource_compute_project_metadata.go @@ -48,6 +48,7 @@ func ResourceComputeProjectMetadata() *schema.Resource { }, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), tpgresource.DefaultProviderProject, ), @@ -68,12 +69,20 @@ func ResourceComputeProjectMetadata() *schema.Resource { ForceNew: true, Description: `The ID of the project in which the resource belongs. If it is not provided, the provider project is used.`, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, UseJSONNumber: true, } } func resourceComputeProjectMetadataCreateOrUpdate(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceComputeProjectMetadata) { + return ResourceComputeProjectMetadata().Read(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -130,10 +139,21 @@ func resourceComputeProjectMetadataRead(d *schema.ResourceData, meta interface{} return fmt.Errorf("Error setting project: %s", err) } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } func resourceComputeProjectMetadataDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_project_metadata_item.go b/google/services/compute/resource_compute_project_metadata_item.go index 00c55a165d7..d060318002d 100644 --- a/google/services/compute/resource_compute_project_metadata_item.go +++ b/google/services/compute/resource_compute_project_metadata_item.go @@ -49,6 +49,7 @@ func ResourceComputeProjectMetadataItem() *schema.Resource { }, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), tpgresource.DefaultProviderProject, ), @@ -71,6 +72,9 @@ func ResourceComputeProjectMetadataItem() *schema.Resource { ForceNew: true, Description: `The ID of the project in which the resource belongs. If it is not provided, the provider project is used.`, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, Timeouts: &schema.ResourceTimeout{ @@ -142,10 +146,19 @@ func resourceComputeProjectMetadataItemRead(d *schema.ResourceData, meta interfa return fmt.Errorf("Error setting value: %s", err) } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } func resourceComputeProjectMetadataItemUpdate(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceComputeProjectMetadataItem) { + return ResourceComputeProjectMetadataItem().Read(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -170,6 +183,13 @@ func resourceComputeProjectMetadataItemUpdate(d *schema.ResourceData, meta inter } func resourceComputeProjectMetadataItemDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_project_metadata_item_meta.yaml b/google/services/compute/resource_compute_project_metadata_item_meta.yaml index aad67ab1c73..41bb69069e9 100644 --- a/google/services/compute/resource_compute_project_metadata_item_meta.yaml +++ b/google/services/compute/resource_compute_project_metadata_item_meta.yaml @@ -11,3 +11,5 @@ fields: - field: 'project' - api_field: 'commonInstanceMetadata.items' field: 'value' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/compute/resource_compute_project_metadata_meta.yaml b/google/services/compute/resource_compute_project_metadata_meta.yaml index d38c7b30001..81b8afba8b0 100644 --- a/google/services/compute/resource_compute_project_metadata_meta.yaml +++ b/google/services/compute/resource_compute_project_metadata_meta.yaml @@ -9,3 +9,5 @@ fields: - api_field: 'commonInstanceMetadata.items' field: 'metadata' - field: 'project' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/compute/resource_compute_public_advertised_prefix.go b/google/services/compute/resource_compute_public_advertised_prefix.go index 46245cff231..0403844db1c 100644 --- a/google/services/compute/resource_compute_public_advertised_prefix.go +++ b/google/services/compute/resource_compute_public_advertised_prefix.go @@ -100,6 +100,7 @@ func ResourceComputePublicAdvertisedPrefix() *schema.Resource { return &schema.Resource{ Create: resourceComputePublicAdvertisedPrefixCreate, Read: resourceComputePublicAdvertisedPrefixRead, + Update: resourceComputePublicAdvertisedPrefixUpdate, Delete: resourceComputePublicAdvertisedPrefixDelete, Importer: &schema.ResourceImporter{ @@ -113,6 +114,7 @@ func ResourceComputePublicAdvertisedPrefix() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -205,6 +207,18 @@ will take ~4 weeks. Possible values: ["GLOBAL", "REGIONAL"]`, Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -367,6 +381,19 @@ func resourceComputePublicAdvertisedPrefixRead(d *schema.ResourceData, meta inte log.Printf("[DEBUG] Finished reading ComputePublicAdvertisedPrefix %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading PublicAdvertisedPrefix: %s", err) } @@ -397,7 +424,19 @@ func resourceComputePublicAdvertisedPrefixRead(d *schema.ResourceData, meta inte return nil } +func resourceComputePublicAdvertisedPrefixUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceComputePublicAdvertisedPrefixRead(d, meta) +} + func resourceComputePublicAdvertisedPrefixDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputePublicAdvertisedPrefix without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing PublicAdvertisedPrefix %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_public_advertised_prefix_generated_meta.yaml b/google/services/compute/resource_compute_public_advertised_prefix_generated_meta.yaml index 87cedba3537..2da8af555b0 100644 --- a/google/services/compute/resource_compute_public_advertised_prefix_generated_meta.yaml +++ b/google/services/compute/resource_compute_public_advertised_prefix_generated_meta.yaml @@ -15,3 +15,5 @@ fields: - api_field: pdpScope - api_field: sharedSecret - api_field: selfLink + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_public_delegated_prefix.go b/google/services/compute/resource_compute_public_delegated_prefix.go index 7c63b2c4609..d425ec3e245 100644 --- a/google/services/compute/resource_compute_public_delegated_prefix.go +++ b/google/services/compute/resource_compute_public_delegated_prefix.go @@ -100,6 +100,7 @@ func ResourceComputePublicDelegatedPrefix() *schema.Resource { return &schema.Resource{ Create: resourceComputePublicDelegatedPrefixCreate, Read: resourceComputePublicDelegatedPrefixRead, + Update: resourceComputePublicDelegatedPrefixUpdate, Delete: resourceComputePublicDelegatedPrefixDelete, Importer: &schema.ResourceImporter{ @@ -113,6 +114,7 @@ func ResourceComputePublicDelegatedPrefix() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -301,6 +303,18 @@ from parent prefix and can be one of following: Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -474,6 +488,19 @@ func resourceComputePublicDelegatedPrefixRead(d *schema.ResourceData, meta inter log.Printf("[DEBUG] Finished reading ComputePublicDelegatedPrefix %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading PublicDelegatedPrefix: %s", err) } @@ -510,7 +537,19 @@ func resourceComputePublicDelegatedPrefixRead(d *schema.ResourceData, meta inter return nil } +func resourceComputePublicDelegatedPrefixUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceComputePublicDelegatedPrefixRead(d, meta) +} + func resourceComputePublicDelegatedPrefixDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputePublicDelegatedPrefix without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing PublicDelegatedPrefix %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_public_delegated_prefix_generated_meta.yaml b/google/services/compute/resource_compute_public_delegated_prefix_generated_meta.yaml index dc5009a5e7c..0d32ce9a476 100644 --- a/google/services/compute/resource_compute_public_delegated_prefix_generated_meta.yaml +++ b/google/services/compute/resource_compute_public_delegated_prefix_generated_meta.yaml @@ -30,3 +30,5 @@ fields: - field: region provider_only: true - api_field: selfLink + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_region_autoscaler.go b/google/services/compute/resource_compute_region_autoscaler.go index c787d6edf3f..8808cbc0b4f 100644 --- a/google/services/compute/resource_compute_region_autoscaler.go +++ b/google/services/compute/resource_compute_region_autoscaler.go @@ -116,6 +116,7 @@ func ResourceComputeRegionAutoscaler() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, tpgresource.DefaultProviderRegion, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -477,6 +478,18 @@ character, which cannot be a dash.`, Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -638,6 +651,19 @@ func resourceComputeRegionAutoscalerRead(d *schema.ResourceData, meta interface{ log.Printf("[DEBUG] Finished reading ComputeRegionAutoscaler %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading RegionAutoscaler: %s", err) } @@ -683,6 +709,19 @@ func resourceComputeRegionAutoscalerRead(d *schema.ResourceData, meta interface{ } func resourceComputeRegionAutoscalerUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeRegionAutoscaler().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeRegionAutoscalerRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -791,6 +830,13 @@ func resourceComputeRegionAutoscalerUpdate(d *schema.ResourceData, meta interfac } func resourceComputeRegionAutoscalerDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeRegionAutoscaler without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing RegionAutoscaler %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_region_autoscaler_generated_meta.yaml b/google/services/compute/resource_compute_region_autoscaler_generated_meta.yaml index 28b9c70c6c8..749d79726e3 100644 --- a/google/services/compute/resource_compute_region_autoscaler_generated_meta.yaml +++ b/google/services/compute/resource_compute_region_autoscaler_generated_meta.yaml @@ -54,3 +54,5 @@ fields: - api_field: region - api_field: target - api_field: selfLink + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_region_backend_service.go b/google/services/compute/resource_compute_region_backend_service.go index 97eb44cb73d..def17b799d6 100644 --- a/google/services/compute/resource_compute_region_backend_service.go +++ b/google/services/compute/resource_compute_region_backend_service.go @@ -207,6 +207,7 @@ func ResourceComputeRegionBackendService() *schema.Resource { CustomizeDiff: customdiff.All( customDiffRegionBackendService, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -1351,6 +1352,18 @@ object. This field is used in optimistic locking.`, Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -1866,6 +1879,19 @@ func resourceComputeRegionBackendServiceRead(d *schema.ResourceData, meta interf return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading RegionBackendService: %s", err) } @@ -1903,6 +1929,19 @@ func resourceComputeRegionBackendServiceRead(d *schema.ResourceData, meta interf } func resourceComputeRegionBackendServiceUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeRegionBackendService().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeRegionBackendServiceRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -2221,6 +2260,13 @@ func resourceComputeRegionBackendServiceUpdate(d *schema.ResourceData, meta inte } func resourceComputeRegionBackendServiceDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeRegionBackendService without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing RegionBackendService %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_region_backend_service_generated_meta.yaml b/google/services/compute/resource_compute_region_backend_service_generated_meta.yaml index ee4ba2b6ce9..ebd8578426c 100644 --- a/google/services/compute/resource_compute_region_backend_service_generated_meta.yaml +++ b/google/services/compute/resource_compute_region_backend_service_generated_meta.yaml @@ -128,3 +128,5 @@ fields: - api_field: tlsSettings.subjectAltNames.dnsName - api_field: tlsSettings.subjectAltNames.uniformResourceIdentifier - api_field: selfLink + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_region_composite_health_check.go b/google/services/compute/resource_compute_region_composite_health_check.go index 63b3ac4b006..a268466f363 100644 --- a/google/services/compute/resource_compute_region_composite_health_check.go +++ b/google/services/compute/resource_compute_region_composite_health_check.go @@ -115,6 +115,7 @@ func ResourceComputeRegionCompositeHealthCheck() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -223,6 +224,18 @@ CompositeHealthCheck.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -384,6 +397,19 @@ func resourceComputeRegionCompositeHealthCheckRead(d *schema.ResourceData, meta log.Printf("[DEBUG] Finished reading ComputeRegionCompositeHealthCheck %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading RegionCompositeHealthCheck: %s", err) } @@ -421,6 +447,19 @@ func resourceComputeRegionCompositeHealthCheckRead(d *schema.ResourceData, meta } func resourceComputeRegionCompositeHealthCheckUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeRegionCompositeHealthCheck().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeRegionCompositeHealthCheckRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -549,6 +588,13 @@ func resourceComputeRegionCompositeHealthCheckUpdate(d *schema.ResourceData, met } func resourceComputeRegionCompositeHealthCheckDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeRegionCompositeHealthCheck without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing RegionCompositeHealthCheck %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_region_composite_health_check_generated_meta.yaml b/google/services/compute/resource_compute_region_composite_health_check_generated_meta.yaml index de73a86889a..6cb831e866a 100644 --- a/google/services/compute/resource_compute_region_composite_health_check_generated_meta.yaml +++ b/google/services/compute/resource_compute_region_composite_health_check_generated_meta.yaml @@ -17,3 +17,5 @@ fields: - field: region provider_only: true - api_field: selfLinkWithId + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_region_disk.go b/google/services/compute/resource_compute_region_disk.go index 5df39cee771..fb695360a5b 100644 --- a/google/services/compute/resource_compute_region_disk.go +++ b/google/services/compute/resource_compute_region_disk.go @@ -122,6 +122,7 @@ func ResourceComputeRegionDisk() *schema.Resource { hyperDiskIopsUpdateDiffSuppress, tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -562,6 +563,18 @@ The name of the snapshot by default will be '{{disk-name}}-YYYYMMDD-HHmm'`, Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -856,6 +869,18 @@ func resourceComputeRegionDiskRead(d *schema.ResourceData, meta interface{}) err return fmt.Errorf("Error setting create_snapshot_before_destroy: %s", err) } } + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading RegionDisk: %s", err) } @@ -893,6 +918,19 @@ func resourceComputeRegionDiskRead(d *schema.ResourceData, meta interface{}) err } func resourceComputeRegionDiskUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeRegionDisk().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeRegionDiskRead(d, meta) + } + config := meta.(*transport_tpg.Config) // 'config' is provided by the boilerplate. @@ -1077,6 +1115,13 @@ func resourceComputeRegionDiskUpdate(d *schema.ResourceData, meta interface{}) e } func resourceComputeRegionDiskDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeRegionDisk without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing RegionDisk %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_region_disk_generated_meta.yaml b/google/services/compute/resource_compute_region_disk_generated_meta.yaml index 3f8b2cd6176..7c6c1bef74d 100644 --- a/google/services/compute/resource_compute_region_disk_generated_meta.yaml +++ b/google/services/compute/resource_compute_region_disk_generated_meta.yaml @@ -57,3 +57,5 @@ fields: - api_field: type - api_field: users - api_field: selfLink + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_region_disk_resource_policy_attachment.go b/google/services/compute/resource_compute_region_disk_resource_policy_attachment.go index 74b5f96d566..d3e9fa01f5a 100644 --- a/google/services/compute/resource_compute_region_disk_resource_policy_attachment.go +++ b/google/services/compute/resource_compute_region_disk_resource_policy_attachment.go @@ -100,6 +100,7 @@ func ResourceComputeRegionDiskResourcePolicyAttachment() *schema.Resource { return &schema.Resource{ Create: resourceComputeRegionDiskResourcePolicyAttachmentCreate, Read: resourceComputeRegionDiskResourcePolicyAttachmentRead, + Update: resourceComputeRegionDiskResourcePolicyAttachmentUpdate, Delete: resourceComputeRegionDiskResourcePolicyAttachmentDelete, Importer: &schema.ResourceImporter{ @@ -113,6 +114,7 @@ func ResourceComputeRegionDiskResourcePolicyAttachment() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -171,6 +173,18 @@ creation. Do not specify the self link.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -342,6 +356,19 @@ func resourceComputeRegionDiskResourcePolicyAttachmentRead(d *schema.ResourceDat return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading RegionDiskResourcePolicyAttachment: %s", err) } @@ -384,7 +411,19 @@ func resourceComputeRegionDiskResourcePolicyAttachmentRead(d *schema.ResourceDat return nil } +func resourceComputeRegionDiskResourcePolicyAttachmentUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceComputeRegionDiskResourcePolicyAttachmentRead(d, meta) +} + func resourceComputeRegionDiskResourcePolicyAttachmentDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeRegionDiskResourcePolicyAttachment without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing RegionDiskResourcePolicyAttachment %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_region_disk_resource_policy_attachment_generated_meta.yaml b/google/services/compute/resource_compute_region_disk_resource_policy_attachment_generated_meta.yaml index ca6bb5bb3cc..92d50572803 100644 --- a/google/services/compute/resource_compute_region_disk_resource_policy_attachment_generated_meta.yaml +++ b/google/services/compute/resource_compute_region_disk_resource_policy_attachment_generated_meta.yaml @@ -13,3 +13,5 @@ fields: field: name - field: region provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_region_health_aggregation_policy.go b/google/services/compute/resource_compute_region_health_aggregation_policy.go index 45630ee0c5c..6db60727449 100644 --- a/google/services/compute/resource_compute_region_health_aggregation_policy.go +++ b/google/services/compute/resource_compute_region_health_aggregation_policy.go @@ -115,6 +115,7 @@ func ResourceComputeRegionHealthAggregationPolicy() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -240,6 +241,18 @@ RegionHealthAggregationPolicy.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -407,6 +420,19 @@ func resourceComputeRegionHealthAggregationPolicyRead(d *schema.ResourceData, me log.Printf("[DEBUG] Finished reading ComputeRegionHealthAggregationPolicy %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading RegionHealthAggregationPolicy: %s", err) } @@ -444,6 +470,19 @@ func resourceComputeRegionHealthAggregationPolicyRead(d *schema.ResourceData, me } func resourceComputeRegionHealthAggregationPolicyUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeRegionHealthAggregationPolicy().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeRegionHealthAggregationPolicyRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -582,6 +621,13 @@ func resourceComputeRegionHealthAggregationPolicyUpdate(d *schema.ResourceData, } func resourceComputeRegionHealthAggregationPolicyDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeRegionHealthAggregationPolicy without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing RegionHealthAggregationPolicy %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_region_health_aggregation_policy_generated_meta.yaml b/google/services/compute/resource_compute_region_health_aggregation_policy_generated_meta.yaml index 6761bf90cd8..e393ffa76b6 100644 --- a/google/services/compute/resource_compute_region_health_aggregation_policy_generated_meta.yaml +++ b/google/services/compute/resource_compute_region_health_aggregation_policy_generated_meta.yaml @@ -18,3 +18,5 @@ fields: - field: region provider_only: true - api_field: selfLinkWithId + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_region_health_check.go b/google/services/compute/resource_compute_region_health_check.go index 8debe744284..40655739b1f 100644 --- a/google/services/compute/resource_compute_region_health_check.go +++ b/google/services/compute/resource_compute_region_health_check.go @@ -116,6 +116,7 @@ func ResourceComputeRegionHealthCheck() *schema.Resource { CustomizeDiff: customdiff.All( healthCheckCustomizeDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -731,6 +732,18 @@ consecutive failures. The default value is 2.`, Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -957,6 +970,19 @@ func resourceComputeRegionHealthCheckRead(d *schema.ResourceData, meta interface log.Printf("[DEBUG] Finished reading ComputeRegionHealthCheck %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading RegionHealthCheck: %s", err) } @@ -994,6 +1020,19 @@ func resourceComputeRegionHealthCheckRead(d *schema.ResourceData, meta interface } func resourceComputeRegionHealthCheckUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeRegionHealthCheck().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeRegionHealthCheckRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1167,6 +1206,13 @@ func resourceComputeRegionHealthCheckUpdate(d *schema.ResourceData, meta interfa } func resourceComputeRegionHealthCheckDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeRegionHealthCheck without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing RegionHealthCheck %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_region_health_check_generated_meta.yaml b/google/services/compute/resource_compute_region_health_check_generated_meta.yaml index 20861563bf2..362faff6b0c 100644 --- a/google/services/compute/resource_compute_region_health_check_generated_meta.yaml +++ b/google/services/compute/resource_compute_region_health_check_generated_meta.yaml @@ -62,3 +62,5 @@ fields: - api_field: type - api_field: unhealthyThreshold - api_field: selfLink + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_region_health_source.go b/google/services/compute/resource_compute_region_health_source.go index 85a8ca1956b..da7b397bdc0 100644 --- a/google/services/compute/resource_compute_region_health_source.go +++ b/google/services/compute/resource_compute_region_health_source.go @@ -115,6 +115,7 @@ func ResourceComputeRegionHealthSource() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -229,6 +230,18 @@ This field is used in optimistic locking.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -396,6 +409,19 @@ func resourceComputeRegionHealthSourceRead(d *schema.ResourceData, meta interfac log.Printf("[DEBUG] Finished reading ComputeRegionHealthSource %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading RegionHealthSource: %s", err) } @@ -433,6 +459,19 @@ func resourceComputeRegionHealthSourceRead(d *schema.ResourceData, meta interfac } func resourceComputeRegionHealthSourceUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeRegionHealthSource().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeRegionHealthSourceRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -561,6 +600,13 @@ func resourceComputeRegionHealthSourceUpdate(d *schema.ResourceData, meta interf } func resourceComputeRegionHealthSourceDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeRegionHealthSource without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing RegionHealthSource %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_region_health_source_generated_meta.yaml b/google/services/compute/resource_compute_region_health_source_generated_meta.yaml index 72e4c90496e..44a053e58b8 100644 --- a/google/services/compute/resource_compute_region_health_source_generated_meta.yaml +++ b/google/services/compute/resource_compute_region_health_source_generated_meta.yaml @@ -18,3 +18,5 @@ fields: - api_field: selfLinkWithId - api_field: sourceType - api_field: sources + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_region_instance_group_manager.go b/google/services/compute/resource_compute_region_instance_group_manager.go index cb3c1352e71..1536ad6e20f 100644 --- a/google/services/compute/resource_compute_region_instance_group_manager.go +++ b/google/services/compute/resource_compute_region_instance_group_manager.go @@ -50,6 +50,7 @@ func ResourceComputeRegionInstanceGroupManager() *schema.Resource { }, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), tpgresource.DefaultProviderProject, tpgresource.DefaultProviderRegion, customdiff.ForceNewIfChange("resource_policies.0.workload_policy", ForceNewResourcePoliciesWorkloadPolicyIfNewIsEmpty), @@ -657,6 +658,9 @@ func ResourceComputeRegionInstanceGroupManager() *schema.Resource { }, }, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, UseJSONNumber: true, } @@ -948,10 +952,19 @@ func resourceComputeRegionInstanceGroupManagerRead(d *schema.ResourceData, meta } } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } func resourceComputeRegionInstanceGroupManagerUpdate(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceComputeRegionInstanceGroupManager) { + return ResourceComputeRegionInstanceGroupManager().Read(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) @@ -1130,6 +1143,13 @@ func resourceComputeRegionInstanceGroupManagerUpdate(d *schema.ResourceData, met } func resourceComputeRegionInstanceGroupManagerDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) diff --git a/google/services/compute/resource_compute_region_instance_group_manager_meta.yaml b/google/services/compute/resource_compute_region_instance_group_manager_meta.yaml index 1c13ee26e68..e34118003fa 100644 --- a/google/services/compute/resource_compute_region_instance_group_manager_meta.yaml +++ b/google/services/compute/resource_compute_region_instance_group_manager_meta.yaml @@ -93,3 +93,5 @@ fields: provider_only: true - field: 'wait_for_instances_status' provider_only: true + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/compute/resource_compute_region_instance_template.go b/google/services/compute/resource_compute_region_instance_template.go index 1a568091113..2b5710adeb8 100644 --- a/google/services/compute/resource_compute_region_instance_template.go +++ b/google/services/compute/resource_compute_region_instance_template.go @@ -46,6 +46,7 @@ func ResourceComputeRegionInstanceTemplate() *schema.Resource { }, SchemaVersion: 1, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), tpgresource.DefaultProviderProject, tpgresource.DefaultProviderRegion, resourceComputeInstanceTemplateSourceImageCustomizeDiff, @@ -1176,6 +1177,9 @@ be from 0 to 999,999,999 inclusive.`, ValidateFunc: validation.StringInSlice([]string{"NONE", "STOP", ""}, false), Description: `Action to be taken when a customer's encryption key is revoked. Supports "STOP" and "NONE", with "NONE" being the default.`, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, UseJSONNumber: true, } @@ -1305,7 +1309,7 @@ func resourceComputeRegionInstanceTemplateCreate(d *schema.ResourceData, meta in } func resourceComputeRegionInstanceTemplateUpdate(d *schema.ResourceData, meta interface{}) error { - // Only the field "labels" and "terraform_labels" is mutable + // Only the field "deletion_policy", "labels" and "terraform_labels" is mutable return resourceComputeRegionInstanceTemplateRead(d, meta) } @@ -1517,10 +1521,21 @@ func resourceComputeRegionInstanceTemplateRead(d *schema.ResourceData, meta inte } } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } func resourceComputeRegionInstanceTemplateDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_region_instance_template_meta.yaml b/google/services/compute/resource_compute_region_instance_template_meta.yaml index 5dca3346a29..9be77200a77 100644 --- a/google/services/compute/resource_compute_region_instance_template_meta.yaml +++ b/google/services/compute/resource_compute_region_instance_template_meta.yaml @@ -228,3 +228,5 @@ fields: api_field: 'properties.tags.fingerprint' - field: 'terraform_labels' provider_only: true + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/compute/resource_compute_region_instant_snapshot.go b/google/services/compute/resource_compute_region_instant_snapshot.go index a8f8903de6b..6fad08be84f 100644 --- a/google/services/compute/resource_compute_region_instant_snapshot.go +++ b/google/services/compute/resource_compute_region_instant_snapshot.go @@ -116,6 +116,7 @@ func ResourceComputeRegionInstantSnapshot() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -282,6 +283,18 @@ internally during updates.`, Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -455,6 +468,19 @@ func resourceComputeRegionInstantSnapshotRead(d *schema.ResourceData, meta inter log.Printf("[DEBUG] Finished reading ComputeRegionInstantSnapshot %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading RegionInstantSnapshot: %s", err) } @@ -492,6 +518,19 @@ func resourceComputeRegionInstantSnapshotRead(d *schema.ResourceData, meta inter } func resourceComputeRegionInstantSnapshotUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeRegionInstantSnapshot().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeRegionInstantSnapshotRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -586,6 +625,13 @@ func resourceComputeRegionInstantSnapshotUpdate(d *schema.ResourceData, meta int } func resourceComputeRegionInstantSnapshotDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeRegionInstantSnapshot without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing RegionInstantSnapshot %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_region_instant_snapshot_generated_meta.yaml b/google/services/compute/resource_compute_region_instant_snapshot_generated_meta.yaml index 98cef79c522..715c1b06114 100644 --- a/google/services/compute/resource_compute_region_instant_snapshot_generated_meta.yaml +++ b/google/services/compute/resource_compute_region_instant_snapshot_generated_meta.yaml @@ -29,3 +29,5 @@ fields: - field: terraform_labels provider_only: true - api_field: selfLink + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_region_network_endpoint.go b/google/services/compute/resource_compute_region_network_endpoint.go index 4f2c3c397d7..1435f40282c 100644 --- a/google/services/compute/resource_compute_region_network_endpoint.go +++ b/google/services/compute/resource_compute_region_network_endpoint.go @@ -100,6 +100,7 @@ func ResourceComputeRegionNetworkEndpoint() *schema.Resource { return &schema.Resource{ Create: resourceComputeRegionNetworkEndpointCreate, Read: resourceComputeRegionNetworkEndpointRead, + Update: resourceComputeRegionNetworkEndpointUpdate, Delete: resourceComputeRegionNetworkEndpointDelete, Importer: &schema.ResourceImporter{ @@ -114,6 +115,7 @@ func ResourceComputeRegionNetworkEndpoint() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, tpgresource.DefaultProviderRegion, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -216,6 +218,18 @@ This can only be specified when network_endpoint_type of the NEG is INTERNET_IP_ Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -429,6 +443,19 @@ func resourceComputeRegionNetworkEndpointRead(d *schema.ResourceData, meta inter return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading RegionNetworkEndpoint: %s", err) } @@ -491,7 +518,19 @@ func resourceComputeRegionNetworkEndpointRead(d *schema.ResourceData, meta inter return nil } +func resourceComputeRegionNetworkEndpointUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceComputeRegionNetworkEndpointRead(d, meta) +} + func resourceComputeRegionNetworkEndpointDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeRegionNetworkEndpoint without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing RegionNetworkEndpoint %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_region_network_endpoint_generated_meta.yaml b/google/services/compute/resource_compute_region_network_endpoint_generated_meta.yaml index dd4b739a370..1f50f5ed2e8 100644 --- a/google/services/compute/resource_compute_region_network_endpoint_generated_meta.yaml +++ b/google/services/compute/resource_compute_region_network_endpoint_generated_meta.yaml @@ -18,3 +18,5 @@ fields: provider_only: true - field: region_network_endpoint_group provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_region_network_endpoint_group.go b/google/services/compute/resource_compute_region_network_endpoint_group.go index 96ce661977a..2d93ca83a0f 100644 --- a/google/services/compute/resource_compute_region_network_endpoint_group.go +++ b/google/services/compute/resource_compute_region_network_endpoint_group.go @@ -100,6 +100,7 @@ func ResourceComputeRegionNetworkEndpointGroup() *schema.Resource { return &schema.Resource{ Create: resourceComputeRegionNetworkEndpointGroupCreate, Read: resourceComputeRegionNetworkEndpointGroupRead, + Update: resourceComputeRegionNetworkEndpointGroupUpdate, Delete: resourceComputeRegionNetworkEndpointGroupDelete, Importer: &schema.ResourceImporter{ @@ -113,6 +114,7 @@ func ResourceComputeRegionNetworkEndpointGroup() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -359,6 +361,18 @@ Optional URL of the subnetwork to which all network endpoints in the NEG belong. Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -556,6 +570,19 @@ func resourceComputeRegionNetworkEndpointGroupRead(d *schema.ResourceData, meta log.Printf("[DEBUG] Finished reading ComputeRegionNetworkEndpointGroup %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading RegionNetworkEndpointGroup: %s", err) } @@ -592,7 +619,19 @@ func resourceComputeRegionNetworkEndpointGroupRead(d *schema.ResourceData, meta return nil } +func resourceComputeRegionNetworkEndpointGroupUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceComputeRegionNetworkEndpointGroupRead(d, meta) +} + func resourceComputeRegionNetworkEndpointGroupDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeRegionNetworkEndpointGroup without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing RegionNetworkEndpointGroup %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_region_network_endpoint_group_generated_meta.yaml b/google/services/compute/resource_compute_region_network_endpoint_group_generated_meta.yaml index 1e3e25f2840..a66239f86fc 100644 --- a/google/services/compute/resource_compute_region_network_endpoint_group_generated_meta.yaml +++ b/google/services/compute/resource_compute_region_network_endpoint_group_generated_meta.yaml @@ -24,3 +24,5 @@ fields: - api_field: region - api_field: subnetwork - api_field: selfLink + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_region_network_firewall_policy.go b/google/services/compute/resource_compute_region_network_firewall_policy.go index 959e679c9af..bace38268a1 100644 --- a/google/services/compute/resource_compute_region_network_firewall_policy.go +++ b/google/services/compute/resource_compute_region_network_firewall_policy.go @@ -115,6 +115,7 @@ func ResourceComputeRegionNetworkFirewallPolicy() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -205,6 +206,18 @@ Different policy types may support some of the Firewall Rules features. Possible Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -360,6 +373,19 @@ func resourceComputeRegionNetworkFirewallPolicyRead(d *schema.ResourceData, meta log.Printf("[DEBUG] Finished reading ComputeRegionNetworkFirewallPolicy %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading RegionNetworkFirewallPolicy: %s", err) } @@ -397,6 +423,19 @@ func resourceComputeRegionNetworkFirewallPolicyRead(d *schema.ResourceData, meta } func resourceComputeRegionNetworkFirewallPolicyUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeRegionNetworkFirewallPolicy().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeRegionNetworkFirewallPolicyRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -487,6 +526,13 @@ func resourceComputeRegionNetworkFirewallPolicyUpdate(d *schema.ResourceData, me } func resourceComputeRegionNetworkFirewallPolicyDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeRegionNetworkFirewallPolicy without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing RegionNetworkFirewallPolicy %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_region_network_firewall_policy_association.go b/google/services/compute/resource_compute_region_network_firewall_policy_association.go index 9dfb9fe041e..f08a9856fb7 100644 --- a/google/services/compute/resource_compute_region_network_firewall_policy_association.go +++ b/google/services/compute/resource_compute_region_network_firewall_policy_association.go @@ -100,6 +100,7 @@ func ResourceComputeRegionNetworkFirewallPolicyAssociation() *schema.Resource { return &schema.Resource{ Create: resourceComputeRegionNetworkFirewallPolicyAssociationCreate, Read: resourceComputeRegionNetworkFirewallPolicyAssociationRead, + Update: resourceComputeRegionNetworkFirewallPolicyAssociationUpdate, Delete: resourceComputeRegionNetworkFirewallPolicyAssociationDelete, Importer: &schema.ResourceImporter{ @@ -113,6 +114,7 @@ func ResourceComputeRegionNetworkFirewallPolicyAssociation() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -181,6 +183,18 @@ func ResourceComputeRegionNetworkFirewallPolicyAssociation() *schema.Resource { Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -329,6 +343,19 @@ func resourceComputeRegionNetworkFirewallPolicyAssociationRead(d *schema.Resourc log.Printf("[DEBUG] Finished reading ComputeRegionNetworkFirewallPolicyAssociation %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading RegionNetworkFirewallPolicyAssociation: %s", err) } @@ -371,7 +398,19 @@ func resourceComputeRegionNetworkFirewallPolicyAssociationRead(d *schema.Resourc return nil } +func resourceComputeRegionNetworkFirewallPolicyAssociationUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceComputeRegionNetworkFirewallPolicyAssociationRead(d, meta) +} + func resourceComputeRegionNetworkFirewallPolicyAssociationDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeRegionNetworkFirewallPolicyAssociation without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing RegionNetworkFirewallPolicyAssociation %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_region_network_firewall_policy_association_generated_meta.yaml b/google/services/compute/resource_compute_region_network_firewall_policy_association_generated_meta.yaml index 5fe6f639d2c..536445486f2 100644 --- a/google/services/compute/resource_compute_region_network_firewall_policy_association_generated_meta.yaml +++ b/google/services/compute/resource_compute_region_network_firewall_policy_association_generated_meta.yaml @@ -17,3 +17,5 @@ fields: provider_only: true - api_field: associations.shortName field: short_name + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_region_network_firewall_policy_generated_meta.yaml b/google/services/compute/resource_compute_region_network_firewall_policy_generated_meta.yaml index 65fc5d6afc2..dfaa9dcf08b 100644 --- a/google/services/compute/resource_compute_region_network_firewall_policy_generated_meta.yaml +++ b/google/services/compute/resource_compute_region_network_firewall_policy_generated_meta.yaml @@ -19,3 +19,5 @@ fields: - api_field: ruleTupleCount - api_field: selfLink - api_field: selfLinkWithId + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_region_network_firewall_policy_rule.go b/google/services/compute/resource_compute_region_network_firewall_policy_rule.go index a18cf59be57..c53ad235848 100644 --- a/google/services/compute/resource_compute_region_network_firewall_policy_rule.go +++ b/google/services/compute/resource_compute_region_network_firewall_policy_rule.go @@ -116,6 +116,7 @@ func ResourceComputeRegionNetworkFirewallPolicyRule() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderRegion, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -452,6 +453,18 @@ Can be set only if action = 'apply_security_profile_group' and cannot be set for Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -673,6 +686,19 @@ func resourceComputeRegionNetworkFirewallPolicyRuleRead(d *schema.ResourceData, log.Printf("[DEBUG] Finished reading ComputeRegionNetworkFirewallPolicyRule %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading RegionNetworkFirewallPolicyRule: %s", err) } @@ -716,6 +742,19 @@ func resourceComputeRegionNetworkFirewallPolicyRuleRead(d *schema.ResourceData, } func resourceComputeRegionNetworkFirewallPolicyRuleUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeRegionNetworkFirewallPolicyRule().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeRegionNetworkFirewallPolicyRuleRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -889,6 +928,13 @@ func resourceComputeRegionNetworkFirewallPolicyRuleUpdate(d *schema.ResourceData } func resourceComputeRegionNetworkFirewallPolicyRuleDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeRegionNetworkFirewallPolicyRule without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing RegionNetworkFirewallPolicyRule %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_region_network_firewall_policy_rule_generated_meta.yaml b/google/services/compute/resource_compute_region_network_firewall_policy_rule_generated_meta.yaml index 4630f320b2c..a784456dc97 100644 --- a/google/services/compute/resource_compute_region_network_firewall_policy_rule_generated_meta.yaml +++ b/google/services/compute/resource_compute_region_network_firewall_policy_rule_generated_meta.yaml @@ -79,3 +79,5 @@ fields: field: target_type - api_field: rules.tlsInspect field: tls_inspect + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_region_network_firewall_policy_with_rules.go b/google/services/compute/resource_compute_region_network_firewall_policy_with_rules.go index f3fc7c6ac69..b75fcb1bcba 100644 --- a/google/services/compute/resource_compute_region_network_firewall_policy_with_rules.go +++ b/google/services/compute/resource_compute_region_network_firewall_policy_with_rules.go @@ -167,6 +167,7 @@ func ResourceComputeRegionNetworkFirewallPolicyWithRules() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -800,6 +801,18 @@ It can be set only if action = 'apply_security_profile_group' and cannot be set Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -1010,6 +1023,19 @@ func resourceComputeRegionNetworkFirewallPolicyWithRulesRead(d *schema.ResourceD return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading RegionNetworkFirewallPolicyWithRules: %s", err) } @@ -1047,6 +1073,19 @@ func resourceComputeRegionNetworkFirewallPolicyWithRulesRead(d *schema.ResourceD } func resourceComputeRegionNetworkFirewallPolicyWithRulesUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeRegionNetworkFirewallPolicyWithRules().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeRegionNetworkFirewallPolicyWithRulesRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1148,6 +1187,13 @@ func resourceComputeRegionNetworkFirewallPolicyWithRulesUpdate(d *schema.Resourc } func resourceComputeRegionNetworkFirewallPolicyWithRulesDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeRegionNetworkFirewallPolicyWithRules without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing RegionNetworkFirewallPolicyWithRules %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_region_network_firewall_policy_with_rules_generated_meta.yaml b/google/services/compute/resource_compute_region_network_firewall_policy_with_rules_generated_meta.yaml index 7a819945220..95f0ef0aadc 100644 --- a/google/services/compute/resource_compute_region_network_firewall_policy_with_rules_generated_meta.yaml +++ b/google/services/compute/resource_compute_region_network_firewall_policy_with_rules_generated_meta.yaml @@ -103,3 +103,5 @@ fields: - api_field: ruleTupleCount - api_field: selfLink - api_field: selfLinkWithId + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_region_per_instance_config.go b/google/services/compute/resource_compute_region_per_instance_config.go index 17486bba977..3de4154c213 100644 --- a/google/services/compute/resource_compute_region_per_instance_config.go +++ b/google/services/compute/resource_compute_region_per_instance_config.go @@ -116,6 +116,7 @@ func ResourceComputeRegionPerInstanceConfig() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, tpgresource.DefaultProviderRegion, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -305,6 +306,18 @@ State will be removed on the next instance recreation or update.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -534,6 +547,18 @@ func resourceComputeRegionPerInstanceConfigRead(d *schema.ResourceData, meta int return fmt.Errorf("Error setting remove_instance_state_on_destroy: %s", err) } } + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading RegionPerInstanceConfig: %s", err) } @@ -585,6 +610,19 @@ func resourceComputeRegionPerInstanceConfigRead(d *schema.ResourceData, meta int } func resourceComputeRegionPerInstanceConfigUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeRegionPerInstanceConfig().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeRegionPerInstanceConfigRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -740,6 +778,13 @@ func resourceComputeRegionPerInstanceConfigUpdate(d *schema.ResourceData, meta i } func resourceComputeRegionPerInstanceConfigDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeRegionPerInstanceConfig without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing RegionPerInstanceConfig %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_region_per_instance_config_generated_meta.yaml b/google/services/compute/resource_compute_region_per_instance_config_generated_meta.yaml index 9f027538a9d..87d7aaa118d 100644 --- a/google/services/compute/resource_compute_region_per_instance_config_generated_meta.yaml +++ b/google/services/compute/resource_compute_region_per_instance_config_generated_meta.yaml @@ -43,3 +43,5 @@ fields: provider_only: true - field: remove_instance_state_on_destroy provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_region_security_policy.go b/google/services/compute/resource_compute_region_security_policy.go index c646189336a..eef317ec35d 100644 --- a/google/services/compute/resource_compute_region_security_policy.go +++ b/google/services/compute/resource_compute_region_security_policy.go @@ -144,6 +144,7 @@ func ResourceComputeRegionSecurityPolicy() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -781,6 +782,18 @@ updates of this resource.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -945,6 +958,19 @@ func resourceComputeRegionSecurityPolicyRead(d *schema.ResourceData, meta interf log.Printf("[DEBUG] Finished reading ComputeRegionSecurityPolicy %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading RegionSecurityPolicy: %s", err) } @@ -958,6 +984,19 @@ func resourceComputeRegionSecurityPolicyRead(d *schema.ResourceData, meta interf } func resourceComputeRegionSecurityPolicyUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeRegionSecurityPolicy().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeRegionSecurityPolicyRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1086,6 +1125,13 @@ func resourceComputeRegionSecurityPolicyUpdate(d *schema.ResourceData, meta inte } func resourceComputeRegionSecurityPolicyDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeRegionSecurityPolicy without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing RegionSecurityPolicy %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_region_security_policy_generated_meta.yaml b/google/services/compute/resource_compute_region_security_policy_generated_meta.yaml index 70c324439ac..fc8ff97036e 100644 --- a/google/services/compute/resource_compute_region_security_policy_generated_meta.yaml +++ b/google/services/compute/resource_compute_region_security_policy_generated_meta.yaml @@ -74,3 +74,5 @@ fields: - api_field: userDefinedFields.name - api_field: userDefinedFields.offset - api_field: userDefinedFields.size + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_region_security_policy_rule.go b/google/services/compute/resource_compute_region_security_policy_rule.go index eb12a8a6b36..ad04f696690 100644 --- a/google/services/compute/resource_compute_region_security_policy_rule.go +++ b/google/services/compute/resource_compute_region_security_policy_rule.go @@ -115,6 +115,7 @@ func ResourceComputeRegionSecurityPolicyRule() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -588,6 +589,18 @@ Valid options are deny(STATUS), where valid values for STATUS are 403, 404, 429, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -757,6 +770,19 @@ func resourceComputeRegionSecurityPolicyRuleRead(d *schema.ResourceData, meta in log.Printf("[DEBUG] Finished reading ComputeRegionSecurityPolicyRule %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading RegionSecurityPolicyRule: %s", err) } @@ -770,6 +796,19 @@ func resourceComputeRegionSecurityPolicyRuleRead(d *schema.ResourceData, meta in } func resourceComputeRegionSecurityPolicyRuleUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeRegionSecurityPolicyRule().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeRegionSecurityPolicyRuleRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -933,6 +972,13 @@ func resourceComputeRegionSecurityPolicyRuleUpdate(d *schema.ResourceData, meta } func resourceComputeRegionSecurityPolicyRuleDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeRegionSecurityPolicyRule without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing RegionSecurityPolicyRule %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_region_security_policy_rule_generated_meta.yaml b/google/services/compute/resource_compute_region_security_policy_rule_generated_meta.yaml index 380d7c4fec6..5f1cedac3eb 100644 --- a/google/services/compute/resource_compute_region_security_policy_rule_generated_meta.yaml +++ b/google/services/compute/resource_compute_region_security_policy_rule_generated_meta.yaml @@ -85,3 +85,5 @@ fields: provider_only: true - field: security_policy provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_region_ssl_certificate.go b/google/services/compute/resource_compute_region_ssl_certificate.go index 936009d5151..5fc3355c542 100644 --- a/google/services/compute/resource_compute_region_ssl_certificate.go +++ b/google/services/compute/resource_compute_region_ssl_certificate.go @@ -111,6 +111,7 @@ func ResourceComputeRegionSslCertificate() *schema.Resource { return &schema.Resource{ Create: resourceComputeRegionSslCertificateCreate, Read: resourceComputeRegionSslCertificateRead, + Update: resourceComputeRegionSslCertificateUpdate, Delete: resourceComputeRegionSslCertificateDelete, Importer: &schema.ResourceImporter{ @@ -124,6 +125,7 @@ func ResourceComputeRegionSslCertificate() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -257,6 +259,18 @@ If it is not provided, the provider region is used.`, Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -424,6 +438,19 @@ func resourceComputeRegionSslCertificateRead(d *schema.ResourceData, meta interf log.Printf("[DEBUG] Finished reading ComputeRegionSslCertificate %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading RegionSslCertificate: %s", err) } @@ -460,7 +487,19 @@ func resourceComputeRegionSslCertificateRead(d *schema.ResourceData, meta interf return nil } +func resourceComputeRegionSslCertificateUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceComputeRegionSslCertificateRead(d, meta) +} + func resourceComputeRegionSslCertificateDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeRegionSslCertificate without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing RegionSslCertificate %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_region_ssl_certificate_generated_meta.yaml b/google/services/compute/resource_compute_region_ssl_certificate_generated_meta.yaml index 9f752dfd750..686619c1e18 100644 --- a/google/services/compute/resource_compute_region_ssl_certificate_generated_meta.yaml +++ b/google/services/compute/resource_compute_region_ssl_certificate_generated_meta.yaml @@ -21,3 +21,5 @@ fields: provider_only: true - api_field: region - api_field: selfLink + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_region_ssl_policy.go b/google/services/compute/resource_compute_region_ssl_policy.go index c4bd533e4d3..812cb8b761f 100644 --- a/google/services/compute/resource_compute_region_ssl_policy.go +++ b/google/services/compute/resource_compute_region_ssl_policy.go @@ -133,6 +133,7 @@ func ResourceComputeRegionSslPolicy() *schema.Resource { CustomizeDiff: customdiff.All( regionSslPolicyCustomizeDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -256,6 +257,18 @@ object. This field is used in optimistic locking.`, Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -429,6 +442,19 @@ func resourceComputeRegionSslPolicyRead(d *schema.ResourceData, meta interface{} log.Printf("[DEBUG] Finished reading ComputeRegionSslPolicy %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading RegionSslPolicy: %s", err) } @@ -466,6 +492,19 @@ func resourceComputeRegionSslPolicyRead(d *schema.ResourceData, meta interface{} } func resourceComputeRegionSslPolicyUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeRegionSslPolicy().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeRegionSslPolicyRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -568,6 +607,13 @@ func resourceComputeRegionSslPolicyUpdate(d *schema.ResourceData, meta interface } func resourceComputeRegionSslPolicyDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeRegionSslPolicy without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing RegionSslPolicy %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_region_ssl_policy_generated_meta.yaml b/google/services/compute/resource_compute_region_ssl_policy_generated_meta.yaml index a354a40983f..71da71de152 100644 --- a/google/services/compute/resource_compute_region_ssl_policy_generated_meta.yaml +++ b/google/services/compute/resource_compute_region_ssl_policy_generated_meta.yaml @@ -17,3 +17,5 @@ fields: - api_field: profile - api_field: region - api_field: selfLink + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_region_target_http_proxy.go b/google/services/compute/resource_compute_region_target_http_proxy.go index 454c7726142..cc6926e4820 100644 --- a/google/services/compute/resource_compute_region_target_http_proxy.go +++ b/google/services/compute/resource_compute_region_target_http_proxy.go @@ -115,6 +115,7 @@ func ResourceComputeRegionTargetHttpProxy() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -205,6 +206,18 @@ If it is not provided, the provider region is used.`, Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -366,6 +379,19 @@ func resourceComputeRegionTargetHttpProxyRead(d *schema.ResourceData, meta inter log.Printf("[DEBUG] Finished reading ComputeRegionTargetHttpProxy %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading RegionTargetHttpProxy: %s", err) } @@ -403,6 +429,19 @@ func resourceComputeRegionTargetHttpProxyRead(d *schema.ResourceData, meta inter } func resourceComputeRegionTargetHttpProxyUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeRegionTargetHttpProxy().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeRegionTargetHttpProxyRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -491,6 +530,13 @@ func resourceComputeRegionTargetHttpProxyUpdate(d *schema.ResourceData, meta int } func resourceComputeRegionTargetHttpProxyDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeRegionTargetHttpProxy without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing RegionTargetHttpProxy %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_region_target_http_proxy_generated_meta.yaml b/google/services/compute/resource_compute_region_target_http_proxy_generated_meta.yaml index 55249099df4..20fa92a4896 100644 --- a/google/services/compute/resource_compute_region_target_http_proxy_generated_meta.yaml +++ b/google/services/compute/resource_compute_region_target_http_proxy_generated_meta.yaml @@ -16,3 +16,5 @@ fields: - api_field: region - api_field: urlMap - api_field: selfLink + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_region_target_https_proxy.go b/google/services/compute/resource_compute_region_target_https_proxy.go index 1f95fbb5313..eac00f2fcee 100644 --- a/google/services/compute/resource_compute_region_target_https_proxy.go +++ b/google/services/compute/resource_compute_region_target_https_proxy.go @@ -115,6 +115,7 @@ func ResourceComputeRegionTargetHttpsProxy() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -256,6 +257,18 @@ resource will not have any SSL policy configured.`, Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -458,6 +471,19 @@ func resourceComputeRegionTargetHttpsProxyRead(d *schema.ResourceData, meta inte return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading RegionTargetHttpsProxy: %s", err) } @@ -495,6 +521,19 @@ func resourceComputeRegionTargetHttpsProxyRead(d *schema.ResourceData, meta inte } func resourceComputeRegionTargetHttpsProxyUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeRegionTargetHttpsProxy().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeRegionTargetHttpsProxyRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -790,6 +829,13 @@ func resourceComputeRegionTargetHttpsProxyUpdate(d *schema.ResourceData, meta in } func resourceComputeRegionTargetHttpsProxyDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeRegionTargetHttpsProxy without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing RegionTargetHttpsProxy %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_region_target_https_proxy_generated_meta.yaml b/google/services/compute/resource_compute_region_target_https_proxy_generated_meta.yaml index db18556affa..38bd78f981c 100644 --- a/google/services/compute/resource_compute_region_target_https_proxy_generated_meta.yaml +++ b/google/services/compute/resource_compute_region_target_https_proxy_generated_meta.yaml @@ -20,3 +20,5 @@ fields: - api_field: sslPolicy - api_field: urlMap - api_field: selfLink + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_region_target_tcp_proxy.go b/google/services/compute/resource_compute_region_target_tcp_proxy.go index b3773247227..9674f5f2f06 100644 --- a/google/services/compute/resource_compute_region_target_tcp_proxy.go +++ b/google/services/compute/resource_compute_region_target_tcp_proxy.go @@ -100,6 +100,7 @@ func ResourceComputeRegionTargetTcpProxy() *schema.Resource { return &schema.Resource{ Create: resourceComputeRegionTargetTcpProxyCreate, Read: resourceComputeRegionTargetTcpProxyRead, + Update: resourceComputeRegionTargetTcpProxyUpdate, Delete: resourceComputeRegionTargetTcpProxyDelete, Importer: &schema.ResourceImporter{ @@ -113,6 +114,7 @@ func ResourceComputeRegionTargetTcpProxy() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -212,6 +214,18 @@ If it is not provided, the provider region is used.`, Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -379,6 +393,19 @@ func resourceComputeRegionTargetTcpProxyRead(d *schema.ResourceData, meta interf log.Printf("[DEBUG] Finished reading ComputeRegionTargetTcpProxy %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading RegionTargetTcpProxy: %s", err) } @@ -415,7 +442,19 @@ func resourceComputeRegionTargetTcpProxyRead(d *schema.ResourceData, meta interf return nil } +func resourceComputeRegionTargetTcpProxyUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceComputeRegionTargetTcpProxyRead(d, meta) +} + func resourceComputeRegionTargetTcpProxyDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeRegionTargetTcpProxy without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing RegionTargetTcpProxy %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_region_target_tcp_proxy_generated_meta.yaml b/google/services/compute/resource_compute_region_target_tcp_proxy_generated_meta.yaml index d653c379fc4..7253dccf31d 100644 --- a/google/services/compute/resource_compute_region_target_tcp_proxy_generated_meta.yaml +++ b/google/services/compute/resource_compute_region_target_tcp_proxy_generated_meta.yaml @@ -18,3 +18,5 @@ fields: field: proxy_id - api_field: region - api_field: selfLink + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_region_url_map.go b/google/services/compute/resource_compute_region_url_map.go index 36184e54ea5..59df3b93434 100644 --- a/google/services/compute/resource_compute_region_url_map.go +++ b/google/services/compute/resource_compute_region_url_map.go @@ -115,6 +115,7 @@ func ResourceComputeRegionUrlMap() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -2902,6 +2903,18 @@ updates of this resource.`, Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -3130,6 +3143,19 @@ func resourceComputeRegionUrlMapRead(d *schema.ResourceData, meta interface{}) e log.Printf("[DEBUG] Finished reading ComputeRegionUrlMap %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading RegionUrlMap: %s", err) } @@ -3167,6 +3193,19 @@ func resourceComputeRegionUrlMapRead(d *schema.ResourceData, meta interface{}) e } func resourceComputeRegionUrlMapUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeRegionUrlMap().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeRegionUrlMapRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -3311,6 +3350,13 @@ func resourceComputeRegionUrlMapUpdate(d *schema.ResourceData, meta interface{}) } func resourceComputeRegionUrlMapDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeRegionUrlMap without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing RegionUrlMap %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_region_url_map_generated_meta.yaml b/google/services/compute/resource_compute_region_url_map_generated_meta.yaml index 1e1540c5bfa..45984bcf908 100644 --- a/google/services/compute/resource_compute_region_url_map_generated_meta.yaml +++ b/google/services/compute/resource_compute_region_url_map_generated_meta.yaml @@ -400,3 +400,5 @@ fields: - api_field: tests.service field: test.service - api_field: selfLink + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_reservation.go b/google/services/compute/resource_compute_reservation.go index 5d955b47d86..649e9dcfc66 100644 --- a/google/services/compute/resource_compute_reservation.go +++ b/google/services/compute/resource_compute_reservation.go @@ -126,6 +126,7 @@ func ResourceComputeReservation() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -587,6 +588,18 @@ reservations that are tied to a commitment.`, Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -789,6 +802,18 @@ func resourceComputeReservationRead(d *schema.ResourceData, meta interface{}) er } // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Reservation: %s", err) } @@ -802,6 +827,19 @@ func resourceComputeReservationRead(d *schema.ResourceData, meta interface{}) er } func resourceComputeReservationUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeReservation().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeReservationRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -981,6 +1019,13 @@ func resourceComputeReservationUpdate(d *schema.ResourceData, meta interface{}) } func resourceComputeReservationDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeReservation without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Reservation %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_reservation_generated_meta.yaml b/google/services/compute/resource_compute_reservation_generated_meta.yaml index e76d46228cd..755e32607e1 100644 --- a/google/services/compute/resource_compute_reservation_generated_meta.yaml +++ b/google/services/compute/resource_compute_reservation_generated_meta.yaml @@ -63,3 +63,5 @@ fields: - api_field: status - api_field: zone - api_field: selfLink + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_resize_request.go b/google/services/compute/resource_compute_resize_request.go index 4154e525472..2c7ae9860c3 100644 --- a/google/services/compute/resource_compute_resize_request.go +++ b/google/services/compute/resource_compute_resize_request.go @@ -100,6 +100,7 @@ func ResourceComputeResizeRequest() *schema.Resource { return &schema.Resource{ Create: resourceComputeResizeRequestCreate, Read: resourceComputeResizeRequestRead, + Update: resourceComputeResizeRequestUpdate, Delete: resourceComputeResizeRequestDelete, Importer: &schema.ResourceImporter{ @@ -113,6 +114,7 @@ func ResourceComputeResizeRequest() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -541,6 +543,18 @@ func ResourceComputeResizeRequest() *schema.Resource { Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -707,6 +721,19 @@ func resourceComputeResizeRequestRead(d *schema.ResourceData, meta interface{}) log.Printf("[DEBUG] Finished reading ComputeResizeRequest %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading ResizeRequest: %s", err) } @@ -749,7 +776,19 @@ func resourceComputeResizeRequestRead(d *schema.ResourceData, meta interface{}) return nil } +func resourceComputeResizeRequestUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceComputeResizeRequestRead(d, meta) +} + func resourceComputeResizeRequestDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeResizeRequest without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ResizeRequest %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_resize_request_generated_meta.yaml b/google/services/compute/resource_compute_resize_request_generated_meta.yaml index 10240f4ba33..7c47f26c827 100644 --- a/google/services/compute/resource_compute_resize_request_generated_meta.yaml +++ b/google/services/compute/resource_compute_resize_request_generated_meta.yaml @@ -49,3 +49,5 @@ fields: - api_field: status.lastAttempt.error.errors.location - api_field: status.lastAttempt.error.errors.message - api_field: zone + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_resource_policy.go b/google/services/compute/resource_compute_resource_policy.go index e6d6f2b67fa..328546c4c28 100644 --- a/google/services/compute/resource_compute_resource_policy.go +++ b/google/services/compute/resource_compute_resource_policy.go @@ -122,6 +122,7 @@ func ResourceComputeResourcePolicy() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, tpgresource.DefaultProviderRegion, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -488,6 +489,18 @@ and cannot be set if accelerator topology or accelerator topology mode is set. P Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -686,6 +699,19 @@ func resourceComputeResourcePolicyRead(d *schema.ResourceData, meta interface{}) log.Printf("[DEBUG] Finished reading ComputeResourcePolicy %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading ResourcePolicy: %s", err) } @@ -731,6 +757,19 @@ func resourceComputeResourcePolicyRead(d *schema.ResourceData, meta interface{}) } func resourceComputeResourcePolicyUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeResourcePolicy().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeResourcePolicyRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -851,6 +890,13 @@ func resourceComputeResourcePolicyUpdate(d *schema.ResourceData, meta interface{ } func resourceComputeResourcePolicyDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeResourcePolicy without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ResourcePolicy %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_resource_policy_attachment.go b/google/services/compute/resource_compute_resource_policy_attachment.go index 6c268c0a768..e787fb8c959 100644 --- a/google/services/compute/resource_compute_resource_policy_attachment.go +++ b/google/services/compute/resource_compute_resource_policy_attachment.go @@ -100,6 +100,7 @@ func ResourceComputeResourcePolicyAttachment() *schema.Resource { return &schema.Resource{ Create: resourceComputeResourcePolicyAttachmentCreate, Read: resourceComputeResourcePolicyAttachmentRead, + Update: resourceComputeResourcePolicyAttachmentUpdate, Delete: resourceComputeResourcePolicyAttachmentDelete, Importer: &schema.ResourceImporter{ @@ -114,6 +115,7 @@ func ResourceComputeResourcePolicyAttachment() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, tpgresource.DefaultProviderZone, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -172,6 +174,18 @@ operations. Do not specify the self link.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -343,6 +357,19 @@ func resourceComputeResourcePolicyAttachmentRead(d *schema.ResourceData, meta in return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading ResourcePolicyAttachment: %s", err) } @@ -392,7 +419,19 @@ func resourceComputeResourcePolicyAttachmentRead(d *schema.ResourceData, meta in return nil } +func resourceComputeResourcePolicyAttachmentUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceComputeResourcePolicyAttachmentRead(d, meta) +} + func resourceComputeResourcePolicyAttachmentDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeResourcePolicyAttachment without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ResourcePolicyAttachment %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_resource_policy_attachment_generated_meta.yaml b/google/services/compute/resource_compute_resource_policy_attachment_generated_meta.yaml index 5621638b85f..3a998161f8f 100644 --- a/google/services/compute/resource_compute_resource_policy_attachment_generated_meta.yaml +++ b/google/services/compute/resource_compute_resource_policy_attachment_generated_meta.yaml @@ -13,3 +13,5 @@ fields: field: name - field: zone provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_resource_policy_generated_meta.yaml b/google/services/compute/resource_compute_resource_policy_generated_meta.yaml index 648d6709698..0c97351ee7d 100644 --- a/google/services/compute/resource_compute_resource_policy_generated_meta.yaml +++ b/google/services/compute/resource_compute_resource_policy_generated_meta.yaml @@ -36,3 +36,5 @@ fields: - api_field: workloadPolicy.maxTopologyDistance - api_field: workloadPolicy.type - api_field: selfLink + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_route.go b/google/services/compute/resource_compute_route.go index c6d162094ce..a3f8193ed44 100644 --- a/google/services/compute/resource_compute_route.go +++ b/google/services/compute/resource_compute_route.go @@ -115,6 +115,7 @@ func ResourceComputeRoute() *schema.Resource { return &schema.Resource{ Create: resourceComputeRouteCreate, Read: resourceComputeRouteRead, + Update: resourceComputeRouteUpdate, Delete: resourceComputeRouteDelete, Importer: &schema.ResourceImporter{ @@ -128,6 +129,7 @@ func ResourceComputeRoute() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -430,6 +432,18 @@ NO_RESULTS_ON_PAGE if there are no results in the response.`, Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -649,6 +663,19 @@ func resourceComputeRouteRead(d *schema.ResourceData, meta interface{}) error { return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Route: %s", err) } @@ -679,7 +706,19 @@ func resourceComputeRouteRead(d *schema.ResourceData, meta interface{}) error { return nil } +func resourceComputeRouteUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceComputeRouteRead(d, meta) +} + func resourceComputeRouteDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeRoute without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Route %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_route_generated_meta.yaml b/google/services/compute/resource_compute_route_generated_meta.yaml index ce2c70761b9..920030c49f1 100644 --- a/google/services/compute/resource_compute_route_generated_meta.yaml +++ b/google/services/compute/resource_compute_route_generated_meta.yaml @@ -35,3 +35,5 @@ fields: - api_field: warnings.data.value - api_field: warnings.message - api_field: selfLink + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_router.go b/google/services/compute/resource_compute_router.go index 2ea28239f0f..9147f057b4a 100644 --- a/google/services/compute/resource_compute_router.go +++ b/google/services/compute/resource_compute_router.go @@ -134,6 +134,7 @@ func ResourceComputeRouter() *schema.Resource { CustomizeDiff: customdiff.All( resourceComputeRouterCustomDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -331,6 +332,18 @@ and values are in the format tagValues/456.`, Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -535,6 +548,19 @@ func resourceComputeRouterRead(d *schema.ResourceData, meta interface{}) error { log.Printf("[DEBUG] Finished reading ComputeRouter %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Router: %s", err) } @@ -572,6 +598,19 @@ func resourceComputeRouterRead(d *schema.ResourceData, meta interface{}) error { } func resourceComputeRouterUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeRouter().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeRouterRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -675,6 +714,13 @@ func resourceComputeRouterUpdate(d *schema.ResourceData, meta interface{}) error } func resourceComputeRouterDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeRouter without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Router %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_router_generated_meta.yaml b/google/services/compute/resource_compute_router_generated_meta.yaml index a080b9c0635..8ddef1ea44e 100644 --- a/google/services/compute/resource_compute_router_generated_meta.yaml +++ b/google/services/compute/resource_compute_router_generated_meta.yaml @@ -24,3 +24,5 @@ fields: - api_field: params.resourceManagerTags - api_field: region - api_field: selfLink + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_router_interface.go b/google/services/compute/resource_compute_router_interface.go index cae30c9f2e0..a712243b6be 100644 --- a/google/services/compute/resource_compute_router_interface.go +++ b/google/services/compute/resource_compute_router_interface.go @@ -39,6 +39,7 @@ func ResourceComputeRouterInterface() *schema.Resource { return &schema.Resource{ Create: resourceComputeRouterInterfaceCreate, Read: resourceComputeRouterInterfaceRead, + Update: resourceComputeRouterInterfaceUpdate, Delete: resourceComputeRouterInterfaceDelete, Importer: &schema.ResourceImporter{ State: resourceComputeRouterInterfaceImportState, @@ -50,6 +51,7 @@ func ResourceComputeRouterInterface() *schema.Resource { }, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), tpgresource.DefaultProviderProject, tpgresource.DefaultProviderRegion, ), @@ -138,6 +140,9 @@ func ResourceComputeRouterInterface() *schema.Resource { ForceNew: true, Description: `The name of the interface that is redundant to this interface. Changing this forces a new interface to be created.`, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, UseJSONNumber: true, } @@ -312,6 +317,11 @@ func resourceComputeRouterInterfaceRead(d *schema.ResourceData, meta interface{} if err := d.Set("redundant_interface", iface.RedundantInterface); err != nil { return fmt.Errorf("Error setting redundant interface: %s", err) } + + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } } @@ -321,7 +331,22 @@ func resourceComputeRouterInterfaceRead(d *schema.ResourceData, meta interface{} return nil } +// UDP update start +func resourceComputeRouterInterfaceUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceComputeRouterInterfaceRead(d, meta) +} + +//UDP update end + func resourceComputeRouterInterfaceDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_router_interface_meta.yaml b/google/services/compute/resource_compute_router_interface_meta.yaml index fbb2520a080..ba89efe00f2 100644 --- a/google/services/compute/resource_compute_router_interface_meta.yaml +++ b/google/services/compute/resource_compute_router_interface_meta.yaml @@ -24,3 +24,5 @@ fields: field: 'subnetwork' - api_field: 'interfaces.linkedVpnTunnel' field: 'vpn_tunnel' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/compute/resource_compute_router_nat.go b/google/services/compute/resource_compute_router_nat.go index 4ca5cd13e79..2e42466aadd 100644 --- a/google/services/compute/resource_compute_router_nat.go +++ b/google/services/compute/resource_compute_router_nat.go @@ -271,6 +271,7 @@ func ResourceComputeRouterNat() *schema.Resource { CustomizeDiff: customdiff.All( resourceComputeRouterNatDrainNatIpsCustomDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -545,6 +546,18 @@ If 'PRIVATE' NAT used for private IP translation. Default value: "PUBLIC" Possib Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -1020,6 +1033,19 @@ func resourceComputeRouterNatRead(d *schema.ResourceData, meta interface{}) erro return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading RouterNat: %s", err) } @@ -1063,6 +1089,19 @@ func resourceComputeRouterNatRead(d *schema.ResourceData, meta interface{}) erro } func resourceComputeRouterNatUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeRouterNat().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeRouterNatRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1303,6 +1342,13 @@ func resourceComputeRouterNatUpdate(d *schema.ResourceData, meta interface{}) er } func resourceComputeRouterNatDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeRouterNat without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing RouterNat %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_router_nat_address.go b/google/services/compute/resource_compute_router_nat_address.go index 45bdef7c231..122009ea443 100644 --- a/google/services/compute/resource_compute_router_nat_address.go +++ b/google/services/compute/resource_compute_router_nat_address.go @@ -196,6 +196,7 @@ func ResourceComputeRouterNatAddress() *schema.Resource { CustomizeDiff: customdiff.All( resourceComputeRouterNatAddressDrainNatIpsCustomDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -276,6 +277,18 @@ valid static external IPs that have been assigned to the NAT.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -430,6 +443,19 @@ func resourceComputeRouterNatAddressRead(d *schema.ResourceData, meta interface{ return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading RouterNatAddress: %s", err) } @@ -473,6 +499,19 @@ func resourceComputeRouterNatAddressRead(d *schema.ResourceData, meta interface{ } func resourceComputeRouterNatAddressUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeRouterNatAddress().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeRouterNatAddressRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -585,6 +624,13 @@ func resourceComputeRouterNatAddressUpdate(d *schema.ResourceData, meta interfac } func resourceComputeRouterNatAddressDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeRouterNatAddress without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing RouterNatAddress %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_router_nat_address_generated_meta.yaml b/google/services/compute/resource_compute_router_nat_address_generated_meta.yaml index bb6ff44750e..3cf0aecfab0 100644 --- a/google/services/compute/resource_compute_router_nat_address_generated_meta.yaml +++ b/google/services/compute/resource_compute_router_nat_address_generated_meta.yaml @@ -17,3 +17,5 @@ fields: provider_only: true - api_field: nats.name field: router_nat + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_router_nat_generated_meta.yaml b/google/services/compute/resource_compute_router_nat_generated_meta.yaml index d5e993dfd08..d1396188df1 100644 --- a/google/services/compute/resource_compute_router_nat_generated_meta.yaml +++ b/google/services/compute/resource_compute_router_nat_generated_meta.yaml @@ -75,3 +75,5 @@ fields: field: type - api_field: nats.udpIdleTimeoutSec field: udp_idle_timeout_sec + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_router_peer.go b/google/services/compute/resource_compute_router_peer.go index c80ca4e44cd..f58cab87e0d 100644 --- a/google/services/compute/resource_compute_router_peer.go +++ b/google/services/compute/resource_compute_router_peer.go @@ -66,6 +66,7 @@ func ResourceComputeRouterBgpPeer() *schema.Resource { }, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), tpgresource.DefaultProviderProject, ), @@ -388,6 +389,9 @@ Must be unique within a router. Must be referenced by exactly one bgpPeer. Must }, }, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, UseJSONNumber: true, } @@ -785,10 +789,19 @@ func resourceComputeRouterBgpPeerRead(d *schema.ResourceData, meta interface{}) return fmt.Errorf("Error reading RouterBgpPeer: %s", err) } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } func resourceComputeRouterBgpPeerUpdate(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceComputeRouterBgpPeer) { + return ResourceComputeRouterBgpPeer().Read(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1019,6 +1032,13 @@ func resourceComputeRouterBgpPeerUpdate(d *schema.ResourceData, meta interface{} } func resourceComputeRouterBgpPeerDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_router_peer_meta.yaml b/google/services/compute/resource_compute_router_peer_meta.yaml index 728d80be0c6..849732de48f 100644 --- a/google/services/compute/resource_compute_router_peer_meta.yaml +++ b/google/services/compute/resource_compute_router_peer_meta.yaml @@ -74,3 +74,5 @@ fields: provider_only: true - field: 'zero_custom_learned_route_priority' provider_only: true + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/compute/resource_compute_router_route_policy.go b/google/services/compute/resource_compute_router_route_policy.go index 8a210d22040..7dbc9db71c5 100644 --- a/google/services/compute/resource_compute_router_route_policy.go +++ b/google/services/compute/resource_compute_router_route_policy.go @@ -115,6 +115,7 @@ func ResourceComputeRouterRoutePolicy() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -260,6 +261,18 @@ internally during updates.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -432,6 +445,19 @@ func resourceComputeRouterRoutePolicyRead(d *schema.ResourceData, meta interface return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading RouterRoutePolicy: %s", err) } @@ -475,6 +501,19 @@ func resourceComputeRouterRoutePolicyRead(d *schema.ResourceData, meta interface } func resourceComputeRouterRoutePolicyUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeRouterRoutePolicy().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeRouterRoutePolicyRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -608,6 +647,13 @@ func resourceComputeRouterRoutePolicyUpdate(d *schema.ResourceData, meta interfa } func resourceComputeRouterRoutePolicyDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeRouterRoutePolicy without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing RouterRoutePolicy %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_router_route_policy_generated_meta.yaml b/google/services/compute/resource_compute_router_route_policy_generated_meta.yaml index dff87c29796..2fb43a02a7d 100644 --- a/google/services/compute/resource_compute_router_route_policy_generated_meta.yaml +++ b/google/services/compute/resource_compute_router_route_policy_generated_meta.yaml @@ -23,3 +23,5 @@ fields: - api_field: terms.match.title - api_field: terms.priority - api_field: type + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_security_policy.go b/google/services/compute/resource_compute_security_policy.go index 324506a6a04..7c2db0de419 100644 --- a/google/services/compute/resource_compute_security_policy.go +++ b/google/services/compute/resource_compute_security_policy.go @@ -77,6 +77,7 @@ func ResourceComputeSecurityPolicy() *schema.Resource { State: resourceSecurityPolicyStateImporter, }, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), tpgresource.DefaultProviderProject, tpgresource.SetLabelsDiff, rulesCustomizeDiff, @@ -711,6 +712,9 @@ Please refer to the field 'effective_labels' for all of the labels present on th Computed: true, Description: `The unique fingerprint of the labels.`, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, UseJSONNumber: true, } @@ -929,10 +933,19 @@ func resourceComputeSecurityPolicyRead(d *schema.ResourceData, meta interface{}) return fmt.Errorf("Error setting label_fingerprint: %s", err) } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } func resourceComputeSecurityPolicyUpdate(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceComputeSecurityPolicy) { + return ResourceComputeSecurityPolicy().Read(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1130,6 +1143,13 @@ func resourceComputeSecurityPolicyUpdate(d *schema.ResourceData, meta interface{ } func resourceComputeSecurityPolicyDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_security_policy_meta.yaml b/google/services/compute/resource_compute_security_policy_meta.yaml index 36592790473..cb353028f45 100644 --- a/google/services/compute/resource_compute_security_policy_meta.yaml +++ b/google/services/compute/resource_compute_security_policy_meta.yaml @@ -121,4 +121,6 @@ fields: - api_field: 'selfLink' - field: 'terraform_labels' provider_only: true - - api_field: 'type' \ No newline at end of file + - api_field: 'type' + - field: 'deletion_policy' + provider_only: true \ No newline at end of file diff --git a/google/services/compute/resource_compute_security_policy_rule.go b/google/services/compute/resource_compute_security_policy_rule.go index 9cfa694cbaa..c82840ceb69 100644 --- a/google/services/compute/resource_compute_security_policy_rule.go +++ b/google/services/compute/resource_compute_security_policy_rule.go @@ -115,6 +115,7 @@ func ResourceComputeSecurityPolicyRule() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -615,6 +616,18 @@ Valid options are deny(STATUS), where valid values for STATUS are 403, 404, 429, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -812,6 +825,19 @@ func resourceComputeSecurityPolicyRuleRead(d *schema.ResourceData, meta interfac log.Printf("[DEBUG] Finished reading ComputeSecurityPolicyRule %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading SecurityPolicyRule: %s", err) } @@ -849,6 +875,19 @@ func resourceComputeSecurityPolicyRuleRead(d *schema.ResourceData, meta interfac } func resourceComputeSecurityPolicyRuleUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeSecurityPolicyRule().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeSecurityPolicyRuleRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1037,6 +1076,13 @@ func resourceComputeSecurityPolicyRuleUpdate(d *schema.ResourceData, meta interf } func resourceComputeSecurityPolicyRuleDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeSecurityPolicyRule without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing SecurityPolicyRule %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_security_policy_rule_generated_meta.yaml b/google/services/compute/resource_compute_security_policy_rule_generated_meta.yaml index 9ecb615458e..0aa119dbb2a 100644 --- a/google/services/compute/resource_compute_security_policy_rule_generated_meta.yaml +++ b/google/services/compute/resource_compute_security_policy_rule_generated_meta.yaml @@ -81,3 +81,5 @@ fields: field: redirect_options.type - field: security_policy provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_service_attachment.go b/google/services/compute/resource_compute_service_attachment.go index 4fa207f34ef..2b634acf030 100644 --- a/google/services/compute/resource_compute_service_attachment.go +++ b/google/services/compute/resource_compute_service_attachment.go @@ -152,6 +152,7 @@ func ResourceComputeServiceAttachment() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, tpgresource.DefaultProviderRegion, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -377,6 +378,18 @@ Defaults to false.`, Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -630,6 +643,18 @@ func resourceComputeServiceAttachmentRead(d *schema.ResourceData, meta interface return fmt.Errorf("Error setting send_propagated_connection_limit_if_zero: %s", err) } } + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading ServiceAttachment: %s", err) } @@ -675,6 +700,19 @@ func resourceComputeServiceAttachmentRead(d *schema.ResourceData, meta interface } func resourceComputeServiceAttachmentUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeServiceAttachment().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeServiceAttachmentRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -818,6 +856,13 @@ func resourceComputeServiceAttachmentUpdate(d *schema.ResourceData, meta interfa } func resourceComputeServiceAttachmentDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeServiceAttachment without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ServiceAttachment %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_service_attachment_generated_meta.yaml b/google/services/compute/resource_compute_service_attachment_generated_meta.yaml index 76f948ab3bb..e31698fb0d0 100644 --- a/google/services/compute/resource_compute_service_attachment_generated_meta.yaml +++ b/google/services/compute/resource_compute_service_attachment_generated_meta.yaml @@ -36,3 +36,5 @@ fields: provider_only: true - api_field: targetService - api_field: selfLink + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_shared_vpc_host_project.go b/google/services/compute/resource_compute_shared_vpc_host_project.go index 1c945c5d785..355252c98e0 100644 --- a/google/services/compute/resource_compute_shared_vpc_host_project.go +++ b/google/services/compute/resource_compute_shared_vpc_host_project.go @@ -21,6 +21,7 @@ import ( "log" "time" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-provider-google/google/registry" "github.com/hashicorp/terraform-provider-google/google/tpgresource" @@ -31,6 +32,7 @@ func ResourceComputeSharedVpcHostProject() *schema.Resource { return &schema.Resource{ Create: resourceComputeSharedVpcHostProjectCreate, Read: resourceComputeSharedVpcHostProjectRead, + Update: resourceComputeSharedVpcHostProjectUpdate, Delete: resourceComputeSharedVpcHostProjectDelete, Importer: &schema.ResourceImporter{ State: schema.ImportStatePassthrough, @@ -41,6 +43,10 @@ func ResourceComputeSharedVpcHostProject() *schema.Resource { Delete: schema.DefaultTimeout(4 * time.Minute), }, + CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), + ), + Schema: map[string]*schema.Schema{ "project": { Type: schema.TypeString, @@ -48,6 +54,9 @@ func ResourceComputeSharedVpcHostProject() *schema.Resource { ForceNew: true, Description: `The ID of the project that will serve as a Shared VPC host project`, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, UseJSONNumber: true, } @@ -100,10 +109,29 @@ func resourceComputeSharedVpcHostProjectRead(d *schema.ResourceData, meta interf return fmt.Errorf("Error setting project: %s", err) } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } +// UDP update start +func resourceComputeSharedVpcHostProjectUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceComputeSharedVpcHostProjectRead(d, meta) +} + +//UDP update end + func resourceComputeSharedVpcHostProjectDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_shared_vpc_host_project_meta.yaml b/google/services/compute/resource_compute_shared_vpc_host_project_meta.yaml index 307abf48e17..6dc3b65f52b 100644 --- a/google/services/compute/resource_compute_shared_vpc_host_project_meta.yaml +++ b/google/services/compute/resource_compute_shared_vpc_host_project_meta.yaml @@ -7,3 +7,5 @@ api_version: 'v1' api_resource_type_kind: 'Project' fields: - field: 'project' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/compute/resource_compute_snapshot.go b/google/services/compute/resource_compute_snapshot.go index b7a207a4987..4ad6cd528f7 100644 --- a/google/services/compute/resource_compute_snapshot.go +++ b/google/services/compute/resource_compute_snapshot.go @@ -116,6 +116,7 @@ func ResourceComputeSnapshot() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -380,6 +381,18 @@ creation/deletion.`, Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -599,6 +612,19 @@ func resourceComputeSnapshotRead(d *schema.ResourceData, meta interface{}) error return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Snapshot: %s", err) } @@ -630,6 +656,19 @@ func resourceComputeSnapshotRead(d *schema.ResourceData, meta interface{}) error } func resourceComputeSnapshotUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeSnapshot().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeSnapshotRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -719,6 +758,13 @@ func resourceComputeSnapshotUpdate(d *schema.ResourceData, meta interface{}) err } func resourceComputeSnapshotDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeSnapshot without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Snapshot %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_snapshot_generated_meta.yaml b/google/services/compute/resource_compute_snapshot_generated_meta.yaml index 69a7a642299..cb31bdd6d2a 100644 --- a/google/services/compute/resource_compute_snapshot_generated_meta.yaml +++ b/google/services/compute/resource_compute_snapshot_generated_meta.yaml @@ -39,3 +39,5 @@ fields: provider_only: true - api_field: zone - api_field: selfLink + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_snapshot_settings.go b/google/services/compute/resource_compute_snapshot_settings.go index d26797364be..24f0aa3ffbd 100644 --- a/google/services/compute/resource_compute_snapshot_settings.go +++ b/google/services/compute/resource_compute_snapshot_settings.go @@ -334,6 +334,7 @@ func resourceComputeSnapshotSettingsRead(d *schema.ResourceData, meta interface{ } func resourceComputeSnapshotSettingsUpdate(d *schema.ResourceData, meta interface{}) error { + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_ssl_certificate.go b/google/services/compute/resource_compute_ssl_certificate.go index 3de73f1bbe3..25c78319dad 100644 --- a/google/services/compute/resource_compute_ssl_certificate.go +++ b/google/services/compute/resource_compute_ssl_certificate.go @@ -100,6 +100,7 @@ func ResourceComputeSslCertificate() *schema.Resource { return &schema.Resource{ Create: resourceComputeSslCertificateCreate, Read: resourceComputeSslCertificateRead, + Update: resourceComputeSslCertificateUpdate, Delete: resourceComputeSslCertificateDelete, Importer: &schema.ResourceImporter{ @@ -113,6 +114,7 @@ func ResourceComputeSslCertificate() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -233,6 +235,18 @@ These are in the same namespace as the managed SSL certificates.`, Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -389,6 +403,19 @@ func resourceComputeSslCertificateRead(d *schema.ResourceData, meta interface{}) log.Printf("[DEBUG] Finished reading ComputeSslCertificate %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading SslCertificate: %s", err) } @@ -419,7 +446,19 @@ func resourceComputeSslCertificateRead(d *schema.ResourceData, meta interface{}) return nil } +func resourceComputeSslCertificateUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceComputeSslCertificateRead(d, meta) +} + func resourceComputeSslCertificateDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeSslCertificate without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing SslCertificate %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_ssl_certificate_generated_meta.yaml b/google/services/compute/resource_compute_ssl_certificate_generated_meta.yaml index bc4e27808ec..f94991111fd 100644 --- a/google/services/compute/resource_compute_ssl_certificate_generated_meta.yaml +++ b/google/services/compute/resource_compute_ssl_certificate_generated_meta.yaml @@ -20,3 +20,5 @@ fields: - field: private_key_wo_version provider_only: true - api_field: selfLink + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_ssl_policy.go b/google/services/compute/resource_compute_ssl_policy.go index 3baf53a09b5..4119af7e931 100644 --- a/google/services/compute/resource_compute_ssl_policy.go +++ b/google/services/compute/resource_compute_ssl_policy.go @@ -137,6 +137,7 @@ func ResourceComputeSslPolicy() *schema.Resource { CustomizeDiff: customdiff.All( sslPolicyCustomizeDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -250,6 +251,18 @@ object. This field is used in optimistic locking.`, Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -406,6 +419,19 @@ func resourceComputeSslPolicyRead(d *schema.ResourceData, meta interface{}) erro log.Printf("[DEBUG] Finished reading ComputeSslPolicy %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading SslPolicy: %s", err) } @@ -437,6 +463,19 @@ func resourceComputeSslPolicyRead(d *schema.ResourceData, meta interface{}) erro } func resourceComputeSslPolicyUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeSslPolicy().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeSslPolicyRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -533,6 +572,13 @@ func resourceComputeSslPolicyUpdate(d *schema.ResourceData, meta interface{}) er } func resourceComputeSslPolicyDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeSslPolicy without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing SslPolicy %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_ssl_policy_generated_meta.yaml b/google/services/compute/resource_compute_ssl_policy_generated_meta.yaml index 62a08973869..7eb84053857 100644 --- a/google/services/compute/resource_compute_ssl_policy_generated_meta.yaml +++ b/google/services/compute/resource_compute_ssl_policy_generated_meta.yaml @@ -16,3 +16,5 @@ fields: - api_field: name - api_field: profile - api_field: selfLink + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_storage_pool.go b/google/services/compute/resource_compute_storage_pool.go index 2657534d9af..ab7908ad50f 100644 --- a/google/services/compute/resource_compute_storage_pool.go +++ b/google/services/compute/resource_compute_storage_pool.go @@ -116,6 +116,7 @@ func ResourceComputeStoragePool() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -422,6 +423,18 @@ When the field is set to false, deleting the StoragePool is allowed.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -631,6 +644,18 @@ func resourceComputeStoragePoolRead(d *schema.ResourceData, meta interface{}) er return fmt.Errorf("Error setting deletion_protection: %s", err) } } + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading StoragePool: %s", err) } @@ -668,6 +693,19 @@ func resourceComputeStoragePoolRead(d *schema.ResourceData, meta interface{}) er } func resourceComputeStoragePoolUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeStoragePool().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeStoragePoolRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -782,6 +820,13 @@ func resourceComputeStoragePoolUpdate(d *schema.ResourceData, meta interface{}) } func resourceComputeStoragePoolDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeStoragePool without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing StoragePool %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_storage_pool_generated_meta.yaml b/google/services/compute/resource_compute_storage_pool_generated_meta.yaml index 5ea6517e6c9..44e90a47c1b 100644 --- a/google/services/compute/resource_compute_storage_pool_generated_meta.yaml +++ b/google/services/compute/resource_compute_storage_pool_generated_meta.yaml @@ -48,3 +48,5 @@ fields: - field: terraform_labels provider_only: true - api_field: zone + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_subnetwork.go b/google/services/compute/resource_compute_subnetwork.go index a7488c48585..9230fd0ec0f 100644 --- a/google/services/compute/resource_compute_subnetwork.go +++ b/google/services/compute/resource_compute_subnetwork.go @@ -206,6 +206,7 @@ func ResourceComputeSubnetwork() *schema.Resource { customdiff.ForceNewIfChange("ip_cidr_range", IsShrinkageIpCidr), sendSecondaryIpRangeIfEmptyDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -581,6 +582,18 @@ Defaults to false.`, Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -875,6 +888,18 @@ func resourceComputeSubnetworkRead(d *schema.ResourceData, meta interface{}) err log.Printf("[DEBUG] Finished reading ComputeSubnetwork %q: %#v", d.Id(), res) // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Subnetwork: %s", err) } @@ -912,6 +937,19 @@ func resourceComputeSubnetworkRead(d *schema.ResourceData, meta interface{}) err } func resourceComputeSubnetworkUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeSubnetwork().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeSubnetworkRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1536,6 +1574,13 @@ func resourceComputeSubnetworkUpdate(d *schema.ResourceData, meta interface{}) e } func resourceComputeSubnetworkDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeSubnetwork without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Subnetwork %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_subnetwork_generated_meta.yaml b/google/services/compute/resource_compute_subnetwork_generated_meta.yaml index f852c13e5ea..55b2e054722 100644 --- a/google/services/compute/resource_compute_subnetwork_generated_meta.yaml +++ b/google/services/compute/resource_compute_subnetwork_generated_meta.yaml @@ -46,3 +46,5 @@ fields: - api_field: id field: subnetwork_id - api_field: selfLink + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_target_grpc_proxy.go b/google/services/compute/resource_compute_target_grpc_proxy.go index 3068086233c..48c0487e92b 100644 --- a/google/services/compute/resource_compute_target_grpc_proxy.go +++ b/google/services/compute/resource_compute_target_grpc_proxy.go @@ -115,6 +115,7 @@ func ResourceComputeTargetGrpcProxy() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -209,6 +210,18 @@ request to retrieve the TargetGrpcProxy. A base64-encoded string.`, Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -365,6 +378,19 @@ func resourceComputeTargetGrpcProxyRead(d *schema.ResourceData, meta interface{} log.Printf("[DEBUG] Finished reading ComputeTargetGrpcProxy %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading TargetGrpcProxy: %s", err) } @@ -396,6 +422,19 @@ func resourceComputeTargetGrpcProxyRead(d *schema.ResourceData, meta interface{} } func resourceComputeTargetGrpcProxyUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeTargetGrpcProxy().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeTargetGrpcProxyRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -481,6 +520,13 @@ func resourceComputeTargetGrpcProxyUpdate(d *schema.ResourceData, meta interface } func resourceComputeTargetGrpcProxyDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeTargetGrpcProxy without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing TargetGrpcProxy %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_target_grpc_proxy_generated_meta.yaml b/google/services/compute/resource_compute_target_grpc_proxy_generated_meta.yaml index 1922f338f66..a590d23d283 100644 --- a/google/services/compute/resource_compute_target_grpc_proxy_generated_meta.yaml +++ b/google/services/compute/resource_compute_target_grpc_proxy_generated_meta.yaml @@ -15,3 +15,5 @@ fields: - api_field: urlMap - api_field: validateForProxyless - api_field: selfLink + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_target_http_proxy.go b/google/services/compute/resource_compute_target_http_proxy.go index 58c75ebe6ba..1c6e0eb2100 100644 --- a/google/services/compute/resource_compute_target_http_proxy.go +++ b/google/services/compute/resource_compute_target_http_proxy.go @@ -115,6 +115,7 @@ func ResourceComputeTargetHttpProxy() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -213,6 +214,18 @@ A base64-encoded string.`, Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -375,6 +388,19 @@ func resourceComputeTargetHttpProxyRead(d *schema.ResourceData, meta interface{} log.Printf("[DEBUG] Finished reading ComputeTargetHttpProxy %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading TargetHttpProxy: %s", err) } @@ -406,6 +432,19 @@ func resourceComputeTargetHttpProxyRead(d *schema.ResourceData, meta interface{} } func resourceComputeTargetHttpProxyUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeTargetHttpProxy().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeTargetHttpProxyRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -489,6 +528,13 @@ func resourceComputeTargetHttpProxyUpdate(d *schema.ResourceData, meta interface } func resourceComputeTargetHttpProxyDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeTargetHttpProxy without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing TargetHttpProxy %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_target_http_proxy_generated_meta.yaml b/google/services/compute/resource_compute_target_http_proxy_generated_meta.yaml index 8d624240c3d..7442e01e8b4 100644 --- a/google/services/compute/resource_compute_target_http_proxy_generated_meta.yaml +++ b/google/services/compute/resource_compute_target_http_proxy_generated_meta.yaml @@ -17,3 +17,5 @@ fields: field: proxy_id - api_field: urlMap - api_field: selfLink + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_target_https_proxy.go b/google/services/compute/resource_compute_target_https_proxy.go index d25038604a3..7baeab5676f 100644 --- a/google/services/compute/resource_compute_target_https_proxy.go +++ b/google/services/compute/resource_compute_target_https_proxy.go @@ -115,6 +115,7 @@ func ResourceComputeTargetHttpsProxy() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -295,6 +296,18 @@ A base64-encoded string.`, Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -516,6 +529,19 @@ func resourceComputeTargetHttpsProxyRead(d *schema.ResourceData, meta interface{ return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading TargetHttpsProxy: %s", err) } @@ -547,6 +573,19 @@ func resourceComputeTargetHttpsProxyRead(d *schema.ResourceData, meta interface{ } func resourceComputeTargetHttpsProxyUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeTargetHttpsProxy().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeTargetHttpsProxyRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -914,6 +953,13 @@ func resourceComputeTargetHttpsProxyUpdate(d *schema.ResourceData, meta interfac } func resourceComputeTargetHttpsProxyDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeTargetHttpsProxy without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing TargetHttpsProxy %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_target_https_proxy_generated_meta.yaml b/google/services/compute/resource_compute_target_https_proxy_generated_meta.yaml index d86ec4e13fa..bcaf2baacb5 100644 --- a/google/services/compute/resource_compute_target_https_proxy_generated_meta.yaml +++ b/google/services/compute/resource_compute_target_https_proxy_generated_meta.yaml @@ -24,3 +24,5 @@ fields: - api_field: tlsEarlyData - api_field: urlMap - api_field: selfLink + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_target_instance.go b/google/services/compute/resource_compute_target_instance.go index 96ab2ea29b0..b099a669d20 100644 --- a/google/services/compute/resource_compute_target_instance.go +++ b/google/services/compute/resource_compute_target_instance.go @@ -100,6 +100,7 @@ func ResourceComputeTargetInstance() *schema.Resource { return &schema.Resource{ Create: resourceComputeTargetInstanceCreate, Read: resourceComputeTargetInstanceRead, + Update: resourceComputeTargetInstanceUpdate, Delete: resourceComputeTargetInstanceDelete, Importer: &schema.ResourceImporter{ @@ -113,6 +114,7 @@ func ResourceComputeTargetInstance() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -178,6 +180,18 @@ Currently only NO_NAT (default value) is supported. Default value: "NO_NAT" Poss Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -318,6 +332,19 @@ func resourceComputeTargetInstanceRead(d *schema.ResourceData, meta interface{}) log.Printf("[DEBUG] Finished reading ComputeTargetInstance %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading TargetInstance: %s", err) } @@ -330,7 +357,19 @@ func resourceComputeTargetInstanceRead(d *schema.ResourceData, meta interface{}) return nil } +func resourceComputeTargetInstanceUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceComputeTargetInstanceRead(d, meta) +} + func resourceComputeTargetInstanceDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeTargetInstance without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing TargetInstance %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_target_instance_generated_meta.yaml b/google/services/compute/resource_compute_target_instance_generated_meta.yaml index afc1c4706d0..b2448618597 100644 --- a/google/services/compute/resource_compute_target_instance_generated_meta.yaml +++ b/google/services/compute/resource_compute_target_instance_generated_meta.yaml @@ -14,3 +14,5 @@ fields: - api_field: natPolicy - api_field: zone - api_field: selfLink + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_target_pool.go b/google/services/compute/resource_compute_target_pool.go index 4b3f4706360..978eaf0e83f 100644 --- a/google/services/compute/resource_compute_target_pool.go +++ b/google/services/compute/resource_compute_target_pool.go @@ -53,6 +53,7 @@ func ResourceComputeTargetPool() *schema.Resource { }, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), tpgresource.DefaultProviderProject, tpgresource.DefaultProviderRegion, ), @@ -144,6 +145,10 @@ func ResourceComputeTargetPool() *schema.Resource { Default: "NONE", Description: `How to distribute load. Options are "NONE" (no affinity). "CLIENT_IP" (hash of the source/dest addresses / ports), and "CLIENT_IP_PROTO" also includes the protocol (default "NONE").`, }, + + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, UseJSONNumber: true, } @@ -271,6 +276,11 @@ func resourceComputeTargetPoolCreate(d *schema.ResourceData, meta interface{}) e } func resourceComputeTargetPoolUpdate(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceComputeTargetPool) { + return ResourceComputeTargetPool().Read(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -477,10 +487,22 @@ func resourceComputeTargetPoolRead(d *schema.ResourceData, meta interface{}) err if err := d.Set("project", project); err != nil { return fmt.Errorf("Error setting project: %s", err) } + + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } func resourceComputeTargetPoolDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_target_pool_meta.yaml b/google/services/compute/resource_compute_target_pool_meta.yaml index 0a691477fe8..c6a736e678c 100644 --- a/google/services/compute/resource_compute_target_pool_meta.yaml +++ b/google/services/compute/resource_compute_target_pool_meta.yaml @@ -16,3 +16,5 @@ fields: - api_field: 'region' - api_field: 'selfLink' - api_field: 'sessionAffinity' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/compute/resource_compute_target_ssl_proxy.go b/google/services/compute/resource_compute_target_ssl_proxy.go index a3db468862d..51c106b9aa1 100644 --- a/google/services/compute/resource_compute_target_ssl_proxy.go +++ b/google/services/compute/resource_compute_target_ssl_proxy.go @@ -115,6 +115,7 @@ func ResourceComputeTargetSslProxy() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -215,6 +216,18 @@ resource will not have any SSL policy configured.`, Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -383,6 +396,19 @@ func resourceComputeTargetSslProxyRead(d *schema.ResourceData, meta interface{}) log.Printf("[DEBUG] Finished reading ComputeTargetSslProxy %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading TargetSslProxy: %s", err) } @@ -414,6 +440,19 @@ func resourceComputeTargetSslProxyRead(d *schema.ResourceData, meta interface{}) } func resourceComputeTargetSslProxyUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeTargetSslProxy().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeTargetSslProxyRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -677,6 +716,13 @@ func resourceComputeTargetSslProxyUpdate(d *schema.ResourceData, meta interface{ } func resourceComputeTargetSslProxyDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeTargetSslProxy without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing TargetSslProxy %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_target_ssl_proxy_generated_meta.yaml b/google/services/compute/resource_compute_target_ssl_proxy_generated_meta.yaml index e4d0fc4f427..683e568d9c3 100644 --- a/google/services/compute/resource_compute_target_ssl_proxy_generated_meta.yaml +++ b/google/services/compute/resource_compute_target_ssl_proxy_generated_meta.yaml @@ -19,3 +19,5 @@ fields: - api_field: sslCertificates - api_field: sslPolicy - api_field: selfLink + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_target_tcp_proxy.go b/google/services/compute/resource_compute_target_tcp_proxy.go index 98fb72a25ce..7468c38f20f 100644 --- a/google/services/compute/resource_compute_target_tcp_proxy.go +++ b/google/services/compute/resource_compute_target_tcp_proxy.go @@ -115,6 +115,7 @@ func ResourceComputeTargetTcpProxy() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -199,6 +200,18 @@ the backend. Default value: "NONE" Possible values: ["NONE", "PROXY_V1"]`, Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -355,6 +368,19 @@ func resourceComputeTargetTcpProxyRead(d *schema.ResourceData, meta interface{}) log.Printf("[DEBUG] Finished reading ComputeTargetTcpProxy %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading TargetTcpProxy: %s", err) } @@ -386,6 +412,19 @@ func resourceComputeTargetTcpProxyRead(d *schema.ResourceData, meta interface{}) } func resourceComputeTargetTcpProxyUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeTargetTcpProxy().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeTargetTcpProxyRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -514,6 +553,13 @@ func resourceComputeTargetTcpProxyUpdate(d *schema.ResourceData, meta interface{ } func resourceComputeTargetTcpProxyDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeTargetTcpProxy without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing TargetTcpProxy %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_target_tcp_proxy_generated_meta.yaml b/google/services/compute/resource_compute_target_tcp_proxy_generated_meta.yaml index b11f217f74d..aa7f5a38925 100644 --- a/google/services/compute/resource_compute_target_tcp_proxy_generated_meta.yaml +++ b/google/services/compute/resource_compute_target_tcp_proxy_generated_meta.yaml @@ -17,3 +17,5 @@ fields: - api_field: id field: proxy_id - api_field: selfLink + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_url_map.go b/google/services/compute/resource_compute_url_map.go index da94e788f77..fc19529777a 100644 --- a/google/services/compute/resource_compute_url_map.go +++ b/google/services/compute/resource_compute_url_map.go @@ -115,6 +115,7 @@ func ResourceComputeUrlMap() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -4565,6 +4566,18 @@ field is used in optimistic locking.`, Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -4787,6 +4800,19 @@ func resourceComputeUrlMapRead(d *schema.ResourceData, meta interface{}) error { log.Printf("[DEBUG] Finished reading ComputeUrlMap %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading UrlMap: %s", err) } @@ -4818,6 +4844,19 @@ func resourceComputeUrlMapRead(d *schema.ResourceData, meta interface{}) error { } func resourceComputeUrlMapUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeUrlMap().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeUrlMapRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -4957,6 +4996,13 @@ func resourceComputeUrlMapUpdate(d *schema.ResourceData, meta interface{}) error } func resourceComputeUrlMapDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeUrlMap without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing UrlMap %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_url_map_generated_meta.yaml b/google/services/compute/resource_compute_url_map_generated_meta.yaml index 8b74730cd15..e54b0c00571 100644 --- a/google/services/compute/resource_compute_url_map_generated_meta.yaml +++ b/google/services/compute/resource_compute_url_map_generated_meta.yaml @@ -600,3 +600,5 @@ fields: - api_field: tests.service field: test.service - api_field: selfLink + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_vpn_gateway.go b/google/services/compute/resource_compute_vpn_gateway.go index 0b30edd2d1e..65998d5bdc8 100644 --- a/google/services/compute/resource_compute_vpn_gateway.go +++ b/google/services/compute/resource_compute_vpn_gateway.go @@ -100,6 +100,7 @@ func ResourceComputeVpnGateway() *schema.Resource { return &schema.Resource{ Create: resourceComputeVpnGatewayCreate, Read: resourceComputeVpnGatewayRead, + Update: resourceComputeVpnGatewayUpdate, Delete: resourceComputeVpnGatewayDelete, Importer: &schema.ResourceImporter{ @@ -113,6 +114,7 @@ func ResourceComputeVpnGateway() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -212,6 +214,18 @@ and values are in the format tagValues/456.`, Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -373,6 +387,19 @@ func resourceComputeVpnGatewayRead(d *schema.ResourceData, meta interface{}) err log.Printf("[DEBUG] Finished reading ComputeVpnGateway %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading VpnGateway: %s", err) } @@ -409,7 +436,19 @@ func resourceComputeVpnGatewayRead(d *schema.ResourceData, meta interface{}) err return nil } +func resourceComputeVpnGatewayUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceComputeVpnGatewayRead(d, meta) +} + func resourceComputeVpnGatewayDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeVpnGateway without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing VpnGateway %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_vpn_gateway_generated_meta.yaml b/google/services/compute/resource_compute_vpn_gateway_generated_meta.yaml index fb443b23b47..6d437b5f016 100644 --- a/google/services/compute/resource_compute_vpn_gateway_generated_meta.yaml +++ b/google/services/compute/resource_compute_vpn_gateway_generated_meta.yaml @@ -16,3 +16,5 @@ fields: - api_field: params.resourceManagerTags - api_field: region - api_field: selfLink + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_vpn_tunnel.go b/google/services/compute/resource_compute_vpn_tunnel.go index a502fa120db..46c9504392a 100644 --- a/google/services/compute/resource_compute_vpn_tunnel.go +++ b/google/services/compute/resource_compute_vpn_tunnel.go @@ -219,6 +219,7 @@ func ResourceComputeVpnTunnel() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -570,6 +571,18 @@ internally during updates.`, Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -886,6 +899,19 @@ func resourceComputeVpnTunnelRead(d *schema.ResourceData, meta interface{}) erro log.Printf("[DEBUG] Finished reading ComputeVpnTunnel %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading VpnTunnel: %s", err) } @@ -923,6 +949,19 @@ func resourceComputeVpnTunnelRead(d *schema.ResourceData, meta interface{}) erro } func resourceComputeVpnTunnelUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeVpnTunnel().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeVpnTunnelRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1017,6 +1056,13 @@ func resourceComputeVpnTunnelUpdate(d *schema.ResourceData, meta interface{}) er } func resourceComputeVpnTunnelDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeVpnTunnel without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing VpnTunnel %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_vpn_tunnel_generated_meta.yaml b/google/services/compute/resource_compute_vpn_tunnel_generated_meta.yaml index bc9741451c2..0551dbfd96e 100644 --- a/google/services/compute/resource_compute_vpn_tunnel_generated_meta.yaml +++ b/google/services/compute/resource_compute_vpn_tunnel_generated_meta.yaml @@ -46,3 +46,5 @@ fields: - api_field: vpnGateway - api_field: vpnGatewayInterface - api_field: selfLink + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_compute_wire_group.go b/google/services/compute/resource_compute_wire_group.go index d456e4e9bf1..96d88a075e4 100644 --- a/google/services/compute/resource_compute_wire_group.go +++ b/google/services/compute/resource_compute_wire_group.go @@ -115,6 +115,7 @@ func ResourceComputeWireGroup() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -334,6 +335,18 @@ DISABLE_PORT: set the port line protocol down when inline probes detect a fault. Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -495,6 +508,19 @@ func resourceComputeWireGroupRead(d *schema.ResourceData, meta interface{}) erro log.Printf("[DEBUG] Finished reading ComputeWireGroup %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading WireGroup: %s", err) } @@ -532,6 +558,19 @@ func resourceComputeWireGroupRead(d *schema.ResourceData, meta interface{}) erro } func resourceComputeWireGroupUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceComputeWireGroup().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceComputeWireGroupRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -670,6 +709,13 @@ func resourceComputeWireGroupUpdate(d *schema.ResourceData, meta interface{}) er } func resourceComputeWireGroupDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ComputeWireGroup without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing WireGroup %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_compute_wire_group_generated_meta.yaml b/google/services/compute/resource_compute_wire_group_generated_meta.yaml index d29c3b7e128..9792d640c13 100644 --- a/google/services/compute/resource_compute_wire_group_generated_meta.yaml +++ b/google/services/compute/resource_compute_wire_group_generated_meta.yaml @@ -32,3 +32,5 @@ fields: - api_field: wires.label - api_field: wires.wireProperties.bandwidthUnmetered - api_field: wires.wireProperties.faultResponse + - field: deletion_policy + provider_only: true diff --git a/google/services/compute/resource_project_usage_export_bucket.go b/google/services/compute/resource_project_usage_export_bucket.go index c1fc6fc2935..0ea72036647 100644 --- a/google/services/compute/resource_project_usage_export_bucket.go +++ b/google/services/compute/resource_project_usage_export_bucket.go @@ -35,6 +35,7 @@ func ResourceProjectUsageBucket() *schema.Resource { return &schema.Resource{ Create: resourceProjectUsageBucketCreate, Read: resourceProjectUsageBucketRead, + Update: resourceProjectUsageBucketUpdate, Delete: resourceProjectUsageBucketDelete, Importer: &schema.ResourceImporter{ State: resourceProjectUsageBucketImportState, @@ -47,6 +48,7 @@ func ResourceProjectUsageBucket() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -69,6 +71,9 @@ func ResourceProjectUsageBucket() *schema.Resource { ForceNew: true, Description: `The project to set the export bucket on. If it is not provided, the provider project is used.`, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, UseJSONNumber: true, } @@ -106,6 +111,11 @@ func resourceProjectUsageBucketRead(d *schema.ResourceData, meta interface{}) er if err := d.Set("bucket_name", p.UsageExportLocation.BucketName); err != nil { return fmt.Errorf("Error setting bucket_name: %s", err) } + + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } @@ -142,7 +152,22 @@ func resourceProjectUsageBucketCreate(d *schema.ResourceData, meta interface{}) return resourceProjectUsageBucketRead(d, meta) } +// UDP update start +func resourceProjectUsageBucketUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceProjectUsageBucketRead(d, meta) +} + +//UDP update end + func resourceProjectUsageBucketDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/compute/resource_project_usage_export_bucket_meta.yaml b/google/services/compute/resource_project_usage_export_bucket_meta.yaml index 79ed369d123..92a6e95d9d9 100644 --- a/google/services/compute/resource_project_usage_export_bucket_meta.yaml +++ b/google/services/compute/resource_project_usage_export_bucket_meta.yaml @@ -11,3 +11,5 @@ fields: - api_field: 'usageExportLocation.reportNamePrefix' field: 'prefix' - field: 'project' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/contactcenterinsights/resource_contact_center_insights_analysis_rule.go b/google/services/contactcenterinsights/resource_contact_center_insights_analysis_rule.go index 67444e2e3a3..d2ad4eebf93 100644 --- a/google/services/contactcenterinsights/resource_contact_center_insights_analysis_rule.go +++ b/google/services/contactcenterinsights/resource_contact_center_insights_analysis_rule.go @@ -115,6 +115,7 @@ func ResourceContactCenterInsightsAnalysisRule() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -331,6 +332,18 @@ for details.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -488,6 +501,19 @@ func resourceContactCenterInsightsAnalysisRuleRead(d *schema.ResourceData, meta log.Printf("[DEBUG] Finished reading ContactCenterInsightsAnalysisRule %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading AnalysisRule: %s", err) } @@ -525,6 +551,19 @@ func resourceContactCenterInsightsAnalysisRuleRead(d *schema.ResourceData, meta } func resourceContactCenterInsightsAnalysisRuleUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceContactCenterInsightsAnalysisRule().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceContactCenterInsightsAnalysisRuleRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -656,6 +695,13 @@ func resourceContactCenterInsightsAnalysisRuleUpdate(d *schema.ResourceData, met } func resourceContactCenterInsightsAnalysisRuleDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ContactCenterInsightsAnalysisRule without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing AnalysisRule %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/contactcenterinsights/resource_contact_center_insights_analysis_rule_generated_meta.yaml b/google/services/contactcenterinsights/resource_contact_center_insights_analysis_rule_generated_meta.yaml index 50d9af33782..12cb7174a31 100644 --- a/google/services/contactcenterinsights/resource_contact_center_insights_analysis_rule_generated_meta.yaml +++ b/google/services/contactcenterinsights/resource_contact_center_insights_analysis_rule_generated_meta.yaml @@ -31,3 +31,5 @@ fields: provider_only: true - api_field: name - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/contactcenterinsights/resource_contact_center_insights_assessment_rule.go b/google/services/contactcenterinsights/resource_contact_center_insights_assessment_rule.go index 3b332647386..9a64f71f51d 100644 --- a/google/services/contactcenterinsights/resource_contact_center_insights_assessment_rule.go +++ b/google/services/contactcenterinsights/resource_contact_center_insights_assessment_rule.go @@ -115,6 +115,7 @@ func ResourceContactCenterInsightsAssessmentRule() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -275,6 +276,18 @@ projects/{project}/locations/{location}/assessmentRules/{assessment_rule}`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -426,6 +439,19 @@ func resourceContactCenterInsightsAssessmentRuleRead(d *schema.ResourceData, met log.Printf("[DEBUG] Finished reading ContactCenterInsightsAssessmentRule %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading AssessmentRule: %s", err) } @@ -463,6 +489,19 @@ func resourceContactCenterInsightsAssessmentRuleRead(d *schema.ResourceData, met } func resourceContactCenterInsightsAssessmentRuleUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceContactCenterInsightsAssessmentRule().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceContactCenterInsightsAssessmentRuleRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -584,6 +623,13 @@ func resourceContactCenterInsightsAssessmentRuleUpdate(d *schema.ResourceData, m } func resourceContactCenterInsightsAssessmentRuleDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ContactCenterInsightsAssessmentRule without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing AssessmentRule %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/contactcenterinsights/resource_contact_center_insights_assessment_rule_generated_meta.yaml b/google/services/contactcenterinsights/resource_contact_center_insights_assessment_rule_generated_meta.yaml index b8179933bc6..23ca1f3ebc1 100644 --- a/google/services/contactcenterinsights/resource_contact_center_insights_assessment_rule_generated_meta.yaml +++ b/google/services/contactcenterinsights/resource_contact_center_insights_assessment_rule_generated_meta.yaml @@ -25,3 +25,5 @@ fields: - api_field: scheduleInfo.startTime - api_field: scheduleInfo.timeZone - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/contactcenterinsights/resource_contact_center_insights_auto_labeling_rule.go b/google/services/contactcenterinsights/resource_contact_center_insights_auto_labeling_rule.go index 11b7ca24ebc..52f412ecc3a 100644 --- a/google/services/contactcenterinsights/resource_contact_center_insights_auto_labeling_rule.go +++ b/google/services/contactcenterinsights/resource_contact_center_insights_auto_labeling_rule.go @@ -115,6 +115,7 @@ func ResourceContactCenterInsightsAutoLabelingRule() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -228,6 +229,18 @@ projects/{project}/locations/{location}/autoLabelingRules/{auto_labeling_rule}`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -391,6 +404,19 @@ func resourceContactCenterInsightsAutoLabelingRuleRead(d *schema.ResourceData, m log.Printf("[DEBUG] Finished reading ContactCenterInsightsAutoLabelingRule %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading AutoLabelingRule: %s", err) } @@ -428,6 +454,19 @@ func resourceContactCenterInsightsAutoLabelingRuleRead(d *schema.ResourceData, m } func resourceContactCenterInsightsAutoLabelingRuleUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceContactCenterInsightsAutoLabelingRule().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceContactCenterInsightsAutoLabelingRuleRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -569,6 +608,13 @@ func resourceContactCenterInsightsAutoLabelingRuleUpdate(d *schema.ResourceData, } func resourceContactCenterInsightsAutoLabelingRuleDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ContactCenterInsightsAutoLabelingRule without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing AutoLabelingRule %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/contactcenterinsights/resource_contact_center_insights_auto_labeling_rule_generated_meta.yaml b/google/services/contactcenterinsights/resource_contact_center_insights_auto_labeling_rule_generated_meta.yaml index 3c818cb19dd..b75a036c50e 100644 --- a/google/services/contactcenterinsights/resource_contact_center_insights_auto_labeling_rule_generated_meta.yaml +++ b/google/services/contactcenterinsights/resource_contact_center_insights_auto_labeling_rule_generated_meta.yaml @@ -22,3 +22,5 @@ fields: provider_only: true - api_field: name - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/contactcenterinsights/resource_contact_center_insights_qa_question.go b/google/services/contactcenterinsights/resource_contact_center_insights_qa_question.go index fc51f41ca56..80b7fd7b979 100644 --- a/google/services/contactcenterinsights/resource_contact_center_insights_qa_question.go +++ b/google/services/contactcenterinsights/resource_contact_center_insights_qa_question.go @@ -115,6 +115,7 @@ func ResourceContactCenterInsightsQaQuestion() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -371,6 +372,18 @@ projects/{project}/locations/{location}/qaScorecards/{qa_scorecard}/revisions/{r Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -574,6 +587,19 @@ func resourceContactCenterInsightsQaQuestionRead(d *schema.ResourceData, meta in log.Printf("[DEBUG] Finished reading ContactCenterInsightsQaQuestion %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading QaQuestion: %s", err) } @@ -623,6 +649,19 @@ func resourceContactCenterInsightsQaQuestionRead(d *schema.ResourceData, meta in } func resourceContactCenterInsightsQaQuestionUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceContactCenterInsightsQaQuestion().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceContactCenterInsightsQaQuestionRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -824,6 +863,13 @@ func resourceContactCenterInsightsQaQuestionUpdate(d *schema.ResourceData, meta } func resourceContactCenterInsightsQaQuestionDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ContactCenterInsightsQaQuestion without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing QaQuestion %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/contactcenterinsights/resource_contact_center_insights_qa_question_generated_meta.yaml b/google/services/contactcenterinsights/resource_contact_center_insights_qa_question_generated_meta.yaml index 33d3580415d..fb93774110a 100644 --- a/google/services/contactcenterinsights/resource_contact_center_insights_qa_question_generated_meta.yaml +++ b/google/services/contactcenterinsights/resource_contact_center_insights_qa_question_generated_meta.yaml @@ -35,3 +35,5 @@ fields: - api_field: tuningMetadata.totalValidLabelCount - api_field: tuningMetadata.tuningError - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/contactcenterinsights/resource_contact_center_insights_qa_scorecard.go b/google/services/contactcenterinsights/resource_contact_center_insights_qa_scorecard.go index 7e679583b57..607ee58b019 100644 --- a/google/services/contactcenterinsights/resource_contact_center_insights_qa_scorecard.go +++ b/google/services/contactcenterinsights/resource_contact_center_insights_qa_scorecard.go @@ -115,6 +115,7 @@ func ResourceContactCenterInsightsQaScorecard() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -205,6 +206,18 @@ projects/{project}/locations/{location}/qaScorecards/{qa_scorecard}`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -350,6 +363,19 @@ func resourceContactCenterInsightsQaScorecardRead(d *schema.ResourceData, meta i log.Printf("[DEBUG] Finished reading ContactCenterInsightsQaScorecard %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading QaScorecard: %s", err) } @@ -387,6 +413,19 @@ func resourceContactCenterInsightsQaScorecardRead(d *schema.ResourceData, meta i } func resourceContactCenterInsightsQaScorecardUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceContactCenterInsightsQaScorecard().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceContactCenterInsightsQaScorecardRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -508,6 +547,13 @@ func resourceContactCenterInsightsQaScorecardUpdate(d *schema.ResourceData, meta } func resourceContactCenterInsightsQaScorecardDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ContactCenterInsightsQaScorecard without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing QaScorecard %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/contactcenterinsights/resource_contact_center_insights_qa_scorecard_generated_meta.yaml b/google/services/contactcenterinsights/resource_contact_center_insights_qa_scorecard_generated_meta.yaml index a5d3c358dc0..14386536314 100644 --- a/google/services/contactcenterinsights/resource_contact_center_insights_qa_scorecard_generated_meta.yaml +++ b/google/services/contactcenterinsights/resource_contact_center_insights_qa_scorecard_generated_meta.yaml @@ -19,3 +19,5 @@ fields: provider_only: true - api_field: source - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/contactcenterinsights/resource_contact_center_insights_view.go b/google/services/contactcenterinsights/resource_contact_center_insights_view.go index 5280283979c..1ca72ed7506 100644 --- a/google/services/contactcenterinsights/resource_contact_center_insights_view.go +++ b/google/services/contactcenterinsights/resource_contact_center_insights_view.go @@ -115,6 +115,7 @@ func ResourceContactCenterInsightsView() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -180,6 +181,18 @@ for details.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -319,6 +332,19 @@ func resourceContactCenterInsightsViewRead(d *schema.ResourceData, meta interfac log.Printf("[DEBUG] Finished reading ContactCenterInsightsView %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading View: %s", err) } @@ -356,6 +382,19 @@ func resourceContactCenterInsightsViewRead(d *schema.ResourceData, meta interfac } func resourceContactCenterInsightsViewUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceContactCenterInsightsView().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceContactCenterInsightsViewRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -457,6 +496,13 @@ func resourceContactCenterInsightsViewUpdate(d *schema.ResourceData, meta interf } func resourceContactCenterInsightsViewDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ContactCenterInsightsView without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing View %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/contactcenterinsights/resource_contact_center_insights_view_generated_meta.yaml b/google/services/contactcenterinsights/resource_contact_center_insights_view_generated_meta.yaml index 686e508e6c6..45642ee59dd 100644 --- a/google/services/contactcenterinsights/resource_contact_center_insights_view_generated_meta.yaml +++ b/google/services/contactcenterinsights/resource_contact_center_insights_view_generated_meta.yaml @@ -15,3 +15,5 @@ fields: - api_field: name - api_field: updateTime - api_field: value + - field: deletion_policy + provider_only: true diff --git a/google/services/container/resource_container_cluster.go b/google/services/container/resource_container_cluster.go index 45b236c4707..61899ce93a1 100644 --- a/google/services/container/resource_container_cluster.go +++ b/google/services/container/resource_container_cluster.go @@ -238,6 +238,7 @@ func ResourceContainerCluster() *schema.Resource { Delete: resourceContainerClusterDelete, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), resourceNodeConfigEmptyGuestAccelerator, customdiff.ForceNewIfChange("enable_l4_ilb_subsetting", isBeenEnabled), customdiff.ForceNewIfChange("enable_fqdn_network_policy", isBeenEnabled), @@ -2583,6 +2584,9 @@ func ResourceContainerCluster() *schema.Resource { }, }, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, } } @@ -3509,10 +3513,19 @@ func resourceContainerClusterRead(d *schema.ResourceData, meta interface{}) erro return err } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } func resourceContainerClusterUpdate(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceContainerCluster) { + return ResourceContainerCluster().Read(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -5154,6 +5167,13 @@ func resourceContainerClusterUpdate(d *schema.ResourceData, meta interface{}) er } func resourceContainerClusterDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + if d.Get("deletion_protection").(bool) { return fmt.Errorf("Cannot destroy cluster because deletion_protection is set to true. Set it to false to proceed with cluster deletion.") } diff --git a/google/services/container/resource_container_cluster_meta.yaml b/google/services/container/resource_container_cluster_meta.yaml index eb420a277d0..d2dda374e03 100644 --- a/google/services/container/resource_container_cluster_meta.yaml +++ b/google/services/container/resource_container_cluster_meta.yaml @@ -816,3 +816,5 @@ fields: - api_field: 'userManagedKeysConfig.serviceAccountVerificationKeys' - api_field: 'verticalPodAutoscaling.enabled' - api_field: 'workloadIdentityConfig.workloadPool' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/container/resource_container_node_pool.go b/google/services/container/resource_container_node_pool.go index 15310b4d1f8..b4d1b3efa91 100644 --- a/google/services/container/resource_container_node_pool.go +++ b/google/services/container/resource_container_node_pool.go @@ -212,6 +212,7 @@ func ResourceContainerNodePool() *schema.Resource { }, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), tpgresource.DefaultProviderProject, resourceNodeConfigEmptyGuestAccelerator, nodePoolAcceleratorNetworkProfileCustomizeDiff, @@ -246,6 +247,9 @@ func ResourceContainerNodePool() *schema.Resource { Type: schema.TypeString, Computed: true, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }), } } @@ -929,10 +933,19 @@ func resourceContainerNodePoolRead(d *schema.ResourceData, meta interface{}) err return fmt.Errorf("Error setting project: %s", err) } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } func resourceContainerNodePoolUpdate(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceContainerNodePool) { + return ResourceContainerNodePool().Read(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -972,6 +985,13 @@ func resourceContainerNodePoolUpdate(d *schema.ResourceData, meta interface{}) e } func resourceContainerNodePoolDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/container/resource_container_node_pool_meta.yaml b/google/services/container/resource_container_node_pool_meta.yaml index e473371164d..dac6a35364e 100644 --- a/google/services/container/resource_container_node_pool_meta.yaml +++ b/google/services/container/resource_container_node_pool_meta.yaml @@ -321,3 +321,5 @@ fields: - api_field: 'upgradeSettings.maxUnavailable' - api_field: 'upgradeSettings.strategy' - api_field: 'version' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/containeranalysis/resource_container_analysis_note.go b/google/services/containeranalysis/resource_container_analysis_note.go index eeff08a73b1..6183533846c 100644 --- a/google/services/containeranalysis/resource_container_analysis_note.go +++ b/google/services/containeranalysis/resource_container_analysis_note.go @@ -115,6 +115,7 @@ func ResourceContainerAnalysisNote() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -236,6 +237,18 @@ example "qa".`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -435,6 +448,19 @@ func resourceContainerAnalysisNoteRead(d *schema.ResourceData, meta interface{}) return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Note: %s", err) } @@ -466,6 +492,19 @@ func resourceContainerAnalysisNoteRead(d *schema.ResourceData, meta interface{}) } func resourceContainerAnalysisNoteUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceContainerAnalysisNote().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceContainerAnalysisNoteRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -614,6 +653,13 @@ func resourceContainerAnalysisNoteUpdate(d *schema.ResourceData, meta interface{ } func resourceContainerAnalysisNoteDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ContainerAnalysisNote without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Note %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/containeranalysis/resource_container_analysis_note_generated_meta.yaml b/google/services/containeranalysis/resource_container_analysis_note_generated_meta.yaml index dd35621a1bc..fc45c1ddb00 100644 --- a/google/services/containeranalysis/resource_container_analysis_note_generated_meta.yaml +++ b/google/services/containeranalysis/resource_container_analysis_note_generated_meta.yaml @@ -18,3 +18,5 @@ fields: - api_field: relatedUrl.url - api_field: shortDescription - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/containeranalysis/resource_container_analysis_occurrence.go b/google/services/containeranalysis/resource_container_analysis_occurrence.go index 0c8dfe6bb04..5fef6aae658 100644 --- a/google/services/containeranalysis/resource_container_analysis_occurrence.go +++ b/google/services/containeranalysis/resource_container_analysis_occurrence.go @@ -115,6 +115,7 @@ func ResourceContainerAnalysisOccurrence() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -220,6 +221,18 @@ requests.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -423,6 +436,19 @@ func resourceContainerAnalysisOccurrenceRead(d *schema.ResourceData, meta interf return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Occurrence: %s", err) } @@ -454,6 +480,19 @@ func resourceContainerAnalysisOccurrenceRead(d *schema.ResourceData, meta interf } func resourceContainerAnalysisOccurrenceUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceContainerAnalysisOccurrence().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceContainerAnalysisOccurrenceRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -562,6 +601,13 @@ func resourceContainerAnalysisOccurrenceUpdate(d *schema.ResourceData, meta inte } func resourceContainerAnalysisOccurrenceDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ContainerAnalysisOccurrence without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Occurrence %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/containeranalysis/resource_container_analysis_occurrence_generated_meta.yaml b/google/services/containeranalysis/resource_container_analysis_occurrence_generated_meta.yaml index 9d6959890bc..238672521df 100644 --- a/google/services/containeranalysis/resource_container_analysis_occurrence_generated_meta.yaml +++ b/google/services/containeranalysis/resource_container_analysis_occurrence_generated_meta.yaml @@ -17,3 +17,5 @@ fields: - api_field: remediation - api_field: resourceUri - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/containerattached/resource_container_attached_cluster.go b/google/services/containerattached/resource_container_attached_cluster.go index f29196065bc..4cdd883f171 100644 --- a/google/services/containerattached/resource_container_attached_cluster.go +++ b/google/services/containerattached/resource_container_attached_cluster.go @@ -127,6 +127,7 @@ func ResourceContainerAttachedCluster() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetAnnotationsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -497,18 +498,18 @@ the Workload Identity Pool.`, }, }, }, - "deletion_policy": { - Type: schema.TypeString, - Optional: true, - Description: `Policy to determine what flags to send on delete. Possible values: DELETE, DELETE_IGNORE_ERRORS`, - Default: "DELETE", - }, "project": { Type: schema.TypeString, Optional: true, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `This field uses a custom implementation please refer to documentation under /hashicorp/terraform-provider-google-beta/website/docs/r/container_attached_cluster.html.markdown for specifics`, + }, }, UseJSONNumber: true, } @@ -720,8 +721,15 @@ func resourceContainerAttachedClusterRead(d *schema.ResourceData, meta interface // Explicitly set virtual fields to default values if unset if _, ok := d.GetOkExists("deletion_policy"); !ok { - if err := d.Set("deletion_policy", "DELETE"); err != nil { - return fmt.Errorf("Error setting deletion_policy: %s", err) + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } } } if err := d.Set("project", project); err != nil { @@ -761,6 +769,19 @@ func resourceContainerAttachedClusterRead(d *schema.ResourceData, meta interface } func resourceContainerAttachedClusterUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceContainerAttachedCluster().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceContainerAttachedClusterRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -995,6 +1016,13 @@ func resourceContainerAttachedClusterUpdate(d *schema.ResourceData, meta interfa } func resourceContainerAttachedClusterDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ContainerAttachedCluster without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Cluster %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1075,9 +1103,6 @@ func resourceContainerAttachedClusterImport(d *schema.ResourceData, meta interfa d.SetId(id) // Explicitly set virtual fields to default values on import - if err := d.Set("deletion_policy", "DELETE"); err != nil { - return nil, fmt.Errorf("Error setting deletion_policy: %s", err) - } return []*schema.ResourceData{d}, nil } diff --git a/google/services/containerattached/resource_container_attached_cluster_generated_meta.yaml b/google/services/containerattached/resource_container_attached_cluster_generated_meta.yaml index 08f606cb5f7..21011d31d7b 100644 --- a/google/services/containerattached/resource_container_attached_cluster_generated_meta.yaml +++ b/google/services/containerattached/resource_container_attached_cluster_generated_meta.yaml @@ -13,8 +13,6 @@ fields: - api_field: binaryAuthorization.evaluationMode - api_field: clusterRegion - api_field: createTime - - field: deletion_policy - provider_only: true - api_field: description - api_field: distribution - field: effective_annotations @@ -41,3 +39,5 @@ fields: - api_field: workloadIdentityConfig.identityProvider - api_field: workloadIdentityConfig.issuerUri - api_field: workloadIdentityConfig.workloadPool + - field: deletion_policy + provider_only: true diff --git a/google/services/containeraws/resource_container_aws_cluster.go b/google/services/containeraws/resource_container_aws_cluster.go index 326e85e97bc..cbd08c2c1fe 100644 --- a/google/services/containeraws/resource_container_aws_cluster.go +++ b/google/services/containeraws/resource_container_aws_cluster.go @@ -49,6 +49,7 @@ func ResourceContainerAwsCluster() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, tpgresource.SetAnnotationsDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -191,6 +192,9 @@ func ResourceContainerAwsCluster() *schema.Resource { Description: "Output only. Workload Identity settings.", Elem: ContainerAwsClusterWorkloadIdentityConfigSchema(), }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, } } @@ -761,9 +765,18 @@ func resourceContainerAwsClusterRead(d *schema.ResourceData, meta interface{}) e return fmt.Errorf("error setting workload_identity_config in state: %s", err) } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } func resourceContainerAwsClusterUpdate(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceContainerAwsCluster) { + return ResourceContainerAwsCluster().Read(d, meta) + } + config := meta.(*transport_tpg.Config) project, err := tpgresource.GetProject(d, config) if err != nil { @@ -817,6 +830,13 @@ func resourceContainerAwsClusterUpdate(d *schema.ResourceData, meta interface{}) } func resourceContainerAwsClusterDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) project, err := tpgresource.GetProject(d, config) if err != nil { diff --git a/google/services/containeraws/resource_container_aws_cluster_meta.yaml b/google/services/containeraws/resource_container_aws_cluster_meta.yaml index fb1502b1f36..42a38fd7f1c 100644 --- a/google/services/containeraws/resource_container_aws_cluster_meta.yaml +++ b/google/services/containeraws/resource_container_aws_cluster_meta.yaml @@ -56,3 +56,5 @@ fields: - api_field: 'workloadIdentityConfig.identityProvider' - api_field: 'workloadIdentityConfig.issuerUri' - api_field: 'workloadIdentityConfig.workloadPool' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/containeraws/resource_container_aws_node_pool.go b/google/services/containeraws/resource_container_aws_node_pool.go index d6cb4ee8f9a..914c60d71bb 100644 --- a/google/services/containeraws/resource_container_aws_node_pool.go +++ b/google/services/containeraws/resource_container_aws_node_pool.go @@ -49,6 +49,7 @@ func ResourceContainerAwsNodePool() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, tpgresource.SetAnnotationsDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -197,6 +198,10 @@ func ResourceContainerAwsNodePool() *schema.Resource { Computed: true, Description: "Output only. The time at which this node pool was last updated.", }, + + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, } } @@ -699,9 +704,18 @@ func resourceContainerAwsNodePoolRead(d *schema.ResourceData, meta interface{}) return fmt.Errorf("error setting update_time in state: %s", err) } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } func resourceContainerAwsNodePoolUpdate(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceContainerAwsNodePool) { + return ResourceContainerAwsNodePool().Read(d, meta) + } + config := meta.(*transport_tpg.Config) project, err := tpgresource.GetProject(d, config) if err != nil { @@ -757,6 +771,13 @@ func resourceContainerAwsNodePoolUpdate(d *schema.ResourceData, meta interface{} } func resourceContainerAwsNodePoolDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) project, err := tpgresource.GetProject(d, config) if err != nil { diff --git a/google/services/containeraws/resource_container_aws_node_pool_meta.yaml b/google/services/containeraws/resource_container_aws_node_pool_meta.yaml index ecd47cdb200..d287d4eb089 100644 --- a/google/services/containeraws/resource_container_aws_node_pool_meta.yaml +++ b/google/services/containeraws/resource_container_aws_node_pool_meta.yaml @@ -50,3 +50,5 @@ fields: - api_field: 'updateSettings.surgeSettings.maxUnavailable' - api_field: 'updateTime' - api_field: 'version' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/containerazure/resource_container_azure_client.go b/google/services/containerazure/resource_container_azure_client.go index 139f2eed16b..4f678d76f39 100644 --- a/google/services/containerazure/resource_container_azure_client.go +++ b/google/services/containerazure/resource_container_azure_client.go @@ -37,6 +37,7 @@ func ResourceContainerAzureClient() *schema.Resource { return &schema.Resource{ Create: resourceContainerAzureClientCreate, Read: resourceContainerAzureClientRead, + Update: resourceContainerAzureClientUpdate, Delete: resourceContainerAzureClientDelete, Importer: &schema.ResourceImporter{ @@ -49,6 +50,7 @@ func ResourceContainerAzureClient() *schema.Resource { }, CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -106,6 +108,9 @@ func ResourceContainerAzureClient() *schema.Resource { Computed: true, Description: "Output only. A globally unique identifier for the client.", }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, } } @@ -224,10 +229,29 @@ func resourceContainerAzureClientRead(d *schema.ResourceData, meta interface{}) return fmt.Errorf("error setting uid in state: %s", err) } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } +// UDP update start +func resourceContainerAzureClientUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceContainerAzureClientRead(d, meta) +} + +//UDP update end + func resourceContainerAzureClientDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) project, err := tpgresource.GetProject(d, config) if err != nil { diff --git a/google/services/containerazure/resource_container_azure_client_meta.yaml b/google/services/containerazure/resource_container_azure_client_meta.yaml index 0a4ff210698..e66b01f4917 100644 --- a/google/services/containerazure/resource_container_azure_client_meta.yaml +++ b/google/services/containerazure/resource_container_azure_client_meta.yaml @@ -14,3 +14,5 @@ fields: - field: 'project' - api_field: 'tenantId' - api_field: 'uid' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/containerazure/resource_container_azure_cluster.go b/google/services/containerazure/resource_container_azure_cluster.go index 293eb1064ba..a22cde711de 100644 --- a/google/services/containerazure/resource_container_azure_cluster.go +++ b/google/services/containerazure/resource_container_azure_cluster.go @@ -49,6 +49,7 @@ func ResourceContainerAzureCluster() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, tpgresource.SetAnnotationsDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -208,6 +209,9 @@ func ResourceContainerAzureCluster() *schema.Resource { Description: "Output only. Workload Identity settings.", Elem: ContainerAzureClusterWorkloadIdentityConfigSchema(), }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, } } @@ -701,9 +705,18 @@ func resourceContainerAzureClusterRead(d *schema.ResourceData, meta interface{}) return fmt.Errorf("error setting workload_identity_config in state: %s", err) } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } func resourceContainerAzureClusterUpdate(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceContainerAzureCluster) { + return ResourceContainerAzureCluster().Read(d, meta) + } + config := meta.(*transport_tpg.Config) project, err := tpgresource.GetProject(d, config) if err != nil { @@ -759,6 +772,13 @@ func resourceContainerAzureClusterUpdate(d *schema.ResourceData, meta interface{ } func resourceContainerAzureClusterDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) project, err := tpgresource.GetProject(d, config) if err != nil { diff --git a/google/services/containerazure/resource_container_azure_cluster_meta.yaml b/google/services/containerazure/resource_container_azure_cluster_meta.yaml index d9c8eb54e81..13b9e6e62f8 100644 --- a/google/services/containerazure/resource_container_azure_cluster_meta.yaml +++ b/google/services/containerazure/resource_container_azure_cluster_meta.yaml @@ -47,3 +47,5 @@ fields: - api_field: 'workloadIdentityConfig.identityProvider' - api_field: 'workloadIdentityConfig.issuerUri' - api_field: 'workloadIdentityConfig.workloadPool' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/containerazure/resource_container_azure_node_pool.go b/google/services/containerazure/resource_container_azure_node_pool.go index 237a7b15c65..89b9421cd2c 100644 --- a/google/services/containerazure/resource_container_azure_node_pool.go +++ b/google/services/containerazure/resource_container_azure_node_pool.go @@ -49,6 +49,7 @@ func ResourceContainerAzureNodePool() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, tpgresource.SetAnnotationsDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -186,6 +187,9 @@ func ResourceContainerAzureNodePool() *schema.Resource { Computed: true, Description: "Output only. The time at which this node pool was last updated.", }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, } } @@ -498,9 +502,18 @@ func resourceContainerAzureNodePoolRead(d *schema.ResourceData, meta interface{} return fmt.Errorf("error setting update_time in state: %s", err) } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } func resourceContainerAzureNodePoolUpdate(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceContainerAzureNodePool) { + return ResourceContainerAzureNodePool().Read(d, meta) + } + config := meta.(*transport_tpg.Config) project, err := tpgresource.GetProject(d, config) if err != nil { @@ -555,6 +568,13 @@ func resourceContainerAzureNodePoolUpdate(d *schema.ResourceData, meta interface } func resourceContainerAzureNodePoolDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) project, err := tpgresource.GetProject(d, config) if err != nil { diff --git a/google/services/containerazure/resource_container_azure_node_pool_meta.yaml b/google/services/containerazure/resource_container_azure_node_pool_meta.yaml index 4ac9855ee01..8db01f41d58 100644 --- a/google/services/containerazure/resource_container_azure_node_pool_meta.yaml +++ b/google/services/containerazure/resource_container_azure_node_pool_meta.yaml @@ -33,3 +33,5 @@ fields: - api_field: 'uid' - api_field: 'updateTime' - api_field: 'version' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/databasemigrationservice/resource_database_migration_service_connection_profile.go b/google/services/databasemigrationservice/resource_database_migration_service_connection_profile.go index de73ec3c68a..6e2d68b370f 100644 --- a/google/services/databasemigrationservice/resource_database_migration_service_connection_profile.go +++ b/google/services/databasemigrationservice/resource_database_migration_service_connection_profile.go @@ -116,6 +116,7 @@ func ResourceDatabaseMigrationServiceConnectionProfile() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -875,6 +876,18 @@ If this field is used then the 'clientCertificate' field is mandatory.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -1048,6 +1061,19 @@ func resourceDatabaseMigrationServiceConnectionProfileRead(d *schema.ResourceDat log.Printf("[DEBUG] Finished reading DatabaseMigrationServiceConnectionProfile %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading ConnectionProfile: %s", err) } @@ -1085,6 +1111,19 @@ func resourceDatabaseMigrationServiceConnectionProfileRead(d *schema.ResourceDat } func resourceDatabaseMigrationServiceConnectionProfileUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDatabaseMigrationServiceConnectionProfile().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDatabaseMigrationServiceConnectionProfileRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1243,6 +1282,13 @@ func resourceDatabaseMigrationServiceConnectionProfileUpdate(d *schema.ResourceD } func resourceDatabaseMigrationServiceConnectionProfileDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DatabaseMigrationServiceConnectionProfile without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ConnectionProfile %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/databasemigrationservice/resource_database_migration_service_connection_profile_generated_meta.yaml b/google/services/databasemigrationservice/resource_database_migration_service_connection_profile_generated_meta.yaml index 9ccadae8c12..4efd29d58fe 100644 --- a/google/services/databasemigrationservice/resource_database_migration_service_connection_profile_generated_meta.yaml +++ b/google/services/databasemigrationservice/resource_database_migration_service_connection_profile_generated_meta.yaml @@ -101,3 +101,5 @@ fields: - api_field: state - field: terraform_labels provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/databasemigrationservice/resource_database_migration_service_migration_job.go b/google/services/databasemigrationservice/resource_database_migration_service_migration_job.go index aa6fb5a8804..76d44d7dd7e 100644 --- a/google/services/databasemigrationservice/resource_database_migration_service_migration_job.go +++ b/google/services/databasemigrationservice/resource_database_migration_service_migration_job.go @@ -116,6 +116,7 @@ func ResourceDatabaseMigrationServiceMigrationJob() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -463,6 +464,18 @@ Cloud SQL console or using Cloud SQL APIs.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -672,6 +685,19 @@ func resourceDatabaseMigrationServiceMigrationJobRead(d *schema.ResourceData, me log.Printf("[DEBUG] Finished reading DatabaseMigrationServiceMigrationJob %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading MigrationJob: %s", err) } @@ -709,6 +735,19 @@ func resourceDatabaseMigrationServiceMigrationJobRead(d *schema.ResourceData, me } func resourceDatabaseMigrationServiceMigrationJobUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDatabaseMigrationServiceMigrationJob().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDatabaseMigrationServiceMigrationJobRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -887,6 +926,13 @@ func resourceDatabaseMigrationServiceMigrationJobUpdate(d *schema.ResourceData, } func resourceDatabaseMigrationServiceMigrationJobDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DatabaseMigrationServiceMigrationJob without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing MigrationJob %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/databasemigrationservice/resource_database_migration_service_migration_job_generated_meta.yaml b/google/services/databasemigrationservice/resource_database_migration_service_migration_job_generated_meta.yaml index 5fe386d9c36..28ef562b8fc 100644 --- a/google/services/databasemigrationservice/resource_database_migration_service_migration_job_generated_meta.yaml +++ b/google/services/databasemigrationservice/resource_database_migration_service_migration_job_generated_meta.yaml @@ -43,3 +43,5 @@ fields: provider_only: true - api_field: type - api_field: vpcPeeringConnectivity.vpc + - field: deletion_policy + provider_only: true diff --git a/google/services/databasemigrationservice/resource_database_migration_service_private_connection.go b/google/services/databasemigrationservice/resource_database_migration_service_private_connection.go index 929313712fc..73c13d5af88 100644 --- a/google/services/databasemigrationservice/resource_database_migration_service_private_connection.go +++ b/google/services/databasemigrationservice/resource_database_migration_service_private_connection.go @@ -116,6 +116,7 @@ func ResourceDatabaseMigrationServicePrivateConnection() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -252,6 +253,18 @@ Please refer to the field 'effective_labels' for all of the labels present on th Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -401,6 +414,19 @@ func resourceDatabaseMigrationServicePrivateConnectionRead(d *schema.ResourceDat log.Printf("[DEBUG] Finished reading DatabaseMigrationServicePrivateConnection %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading PrivateConnection: %s", err) } @@ -438,11 +464,18 @@ func resourceDatabaseMigrationServicePrivateConnectionRead(d *schema.ResourceDat } func resourceDatabaseMigrationServicePrivateConnectionUpdate(d *schema.ResourceData, meta interface{}) error { - // Only the root field "labels", "terraform_labels", and virtual fields are mutable + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable return resourceDatabaseMigrationServicePrivateConnectionRead(d, meta) } func resourceDatabaseMigrationServicePrivateConnectionDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DatabaseMigrationServicePrivateConnection without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing PrivateConnection %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/databasemigrationservice/resource_database_migration_service_private_connection_generated_meta.yaml b/google/services/databasemigrationservice/resource_database_migration_service_private_connection_generated_meta.yaml index 11e42d9b19f..5a24efa914d 100644 --- a/google/services/databasemigrationservice/resource_database_migration_service_private_connection_generated_meta.yaml +++ b/google/services/databasemigrationservice/resource_database_migration_service_private_connection_generated_meta.yaml @@ -25,3 +25,5 @@ fields: provider_only: true - api_field: vpcPeeringConfig.subnet - api_field: vpcPeeringConfig.vpcName + - field: deletion_policy + provider_only: true diff --git a/google/services/datacatalog/resource_data_catalog_entry.go b/google/services/datacatalog/resource_data_catalog_entry.go index eab36e30d26..fc7f552d32b 100644 --- a/google/services/datacatalog/resource_data_catalog_entry.go +++ b/google/services/datacatalog/resource_data_catalog_entry.go @@ -335,6 +335,19 @@ Otherwise, groupedEntry is empty.`, Example: projects/{project_id}/locations/{location}/entryGroups/{entryGroupId}/entries/{entryId}. Note that this Entry and its child resources may not actually be stored in the location in this name.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -496,6 +509,20 @@ func resourceDataCatalogEntryRead(d *schema.ResourceData, meta interface{}) erro log.Printf("[DEBUG] Finished reading DataCatalogEntry %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceDataCatalogEntryFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -517,6 +544,19 @@ func resourceDataCatalogEntryRead(d *schema.ResourceData, meta interface{}) erro } func resourceDataCatalogEntryUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDataCatalogEntry().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDataCatalogEntryRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -655,6 +695,13 @@ func resourceDataCatalogEntryUpdate(d *schema.ResourceData, meta interface{}) er } func resourceDataCatalogEntryDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DataCatalogEntry without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Entry %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/datacatalog/resource_data_catalog_entry_generated_meta.yaml b/google/services/datacatalog/resource_data_catalog_entry_generated_meta.yaml index 00e9f5f24c0..be8e041721c 100644 --- a/google/services/datacatalog/resource_data_catalog_entry_generated_meta.yaml +++ b/google/services/datacatalog/resource_data_catalog_entry_generated_meta.yaml @@ -30,3 +30,5 @@ fields: - api_field: type - api_field: userSpecifiedSystem - api_field: userSpecifiedType + - field: deletion_policy + provider_only: true diff --git a/google/services/datacatalog/resource_data_catalog_entry_group.go b/google/services/datacatalog/resource_data_catalog_entry_group.go index 5882d29979d..3df1bd75721 100644 --- a/google/services/datacatalog/resource_data_catalog_entry_group.go +++ b/google/services/datacatalog/resource_data_catalog_entry_group.go @@ -116,6 +116,7 @@ func ResourceDataCatalogEntryGroup() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, tpgresource.DefaultProviderRegion, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), DeprecationMessage: "`google_data_catalog_entry_group` is deprecated and will be removed in a future major release. Use `google_dataplex_entry_group` instead. For steps to transition your Data Catalog users, workloads, and content to Dataplex Catalog, see https://cloud.google.com/dataplex/docs/transition-to-dataplex-catalog.", @@ -172,6 +173,18 @@ contain only English letters, numbers and underscores, and be at most 64 charact Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -301,6 +314,19 @@ func resourceDataCatalogEntryGroupRead(d *schema.ResourceData, meta interface{}) log.Printf("[DEBUG] Finished reading DataCatalogEntryGroup %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading EntryGroup: %s", err) } @@ -334,6 +360,19 @@ func resourceDataCatalogEntryGroupRead(d *schema.ResourceData, meta interface{}) } func resourceDataCatalogEntryGroupUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDataCatalogEntryGroup().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDataCatalogEntryGroupRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -425,6 +464,13 @@ func resourceDataCatalogEntryGroupUpdate(d *schema.ResourceData, meta interface{ } func resourceDataCatalogEntryGroupDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DataCatalogEntryGroup without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing EntryGroup %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/datacatalog/resource_data_catalog_entry_group_generated_meta.yaml b/google/services/datacatalog/resource_data_catalog_entry_group_generated_meta.yaml index b63e27d0a1f..ba40c8b02c3 100644 --- a/google/services/datacatalog/resource_data_catalog_entry_group_generated_meta.yaml +++ b/google/services/datacatalog/resource_data_catalog_entry_group_generated_meta.yaml @@ -14,3 +14,5 @@ fields: - api_field: name - field: region provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/datacatalog/resource_data_catalog_policy_tag.go b/google/services/datacatalog/resource_data_catalog_policy_tag.go index beaaa1f0bbc..9c3f5a0b096 100644 --- a/google/services/datacatalog/resource_data_catalog_policy_tag.go +++ b/google/services/datacatalog/resource_data_catalog_policy_tag.go @@ -156,6 +156,19 @@ If not set, defaults to an empty string.`, Description: `Resource name of this policy tag, whose format is: "projects/{project}/locations/{region}/taxonomies/{taxonomy}/policyTags/{policytag}"`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -268,6 +281,20 @@ func resourceDataCatalogPolicyTagRead(d *schema.ResourceData, meta interface{}) log.Printf("[DEBUG] Finished reading DataCatalogPolicyTag %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceDataCatalogPolicyTagFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -277,6 +304,19 @@ func resourceDataCatalogPolicyTagRead(d *schema.ResourceData, meta interface{}) } func resourceDataCatalogPolicyTagUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDataCatalogPolicyTag().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDataCatalogPolicyTagRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -362,6 +402,13 @@ func resourceDataCatalogPolicyTagUpdate(d *schema.ResourceData, meta interface{} } func resourceDataCatalogPolicyTagDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DataCatalogPolicyTag without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing PolicyTag %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/datacatalog/resource_data_catalog_policy_tag_generated_meta.yaml b/google/services/datacatalog/resource_data_catalog_policy_tag_generated_meta.yaml index 3f0d3a87f85..cdaa6243cdb 100644 --- a/google/services/datacatalog/resource_data_catalog_policy_tag_generated_meta.yaml +++ b/google/services/datacatalog/resource_data_catalog_policy_tag_generated_meta.yaml @@ -14,3 +14,5 @@ fields: - api_field: parentPolicyTag - field: taxonomy provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/datacatalog/resource_data_catalog_tag.go b/google/services/datacatalog/resource_data_catalog_tag.go index b9544d8e9fb..c8a7dad153c 100644 --- a/google/services/datacatalog/resource_data_catalog_tag.go +++ b/google/services/datacatalog/resource_data_catalog_tag.go @@ -220,6 +220,19 @@ where tag_id is a system-generated identifier. Note that this Tag may not actual Computed: true, Description: `The display name of the tag template.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -360,6 +373,20 @@ func resourceDataCatalogTagRead(d *schema.ResourceData, meta interface{}) error return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceDataCatalogTagFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -381,6 +408,19 @@ func resourceDataCatalogTagRead(d *schema.ResourceData, meta interface{}) error } func resourceDataCatalogTagUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDataCatalogTag().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDataCatalogTagRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -471,6 +511,13 @@ func resourceDataCatalogTagUpdate(d *schema.ResourceData, meta interface{}) erro } func resourceDataCatalogTagDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DataCatalogTag without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Tag %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/datacatalog/resource_data_catalog_tag_generated_meta.yaml b/google/services/datacatalog/resource_data_catalog_tag_generated_meta.yaml index 8fee3b58a3a..e7f2c6a516c 100644 --- a/google/services/datacatalog/resource_data_catalog_tag_generated_meta.yaml +++ b/google/services/datacatalog/resource_data_catalog_tag_generated_meta.yaml @@ -28,3 +28,5 @@ fields: - api_field: template - api_field: templateDisplayName field: template_displayname + - field: deletion_policy + provider_only: true diff --git a/google/services/datacatalog/resource_data_catalog_tag_template.go b/google/services/datacatalog/resource_data_catalog_tag_template.go index 50c5697bdd0..ca644f5133a 100644 --- a/google/services/datacatalog/resource_data_catalog_tag_template.go +++ b/google/services/datacatalog/resource_data_catalog_tag_template.go @@ -176,6 +176,7 @@ func ResourceDataCatalogTagTemplate() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, tpgresource.DefaultProviderRegion, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), DeprecationMessage: "`google_data_catalog_tag_template` is deprecated and will be removed in a future major release. Use `google_dataplex_aspect_type` instead. For steps to transition your Data Catalog users, workloads, and content to Dataplex Catalog, see https://cloud.google.com/dataplex/docs/transition-to-dataplex-catalog.", @@ -316,6 +317,18 @@ Multiple fields can have the same order, and field orders within a tag do not ha Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -457,6 +470,19 @@ func resourceDataCatalogTagTemplateRead(d *schema.ResourceData, meta interface{} log.Printf("[DEBUG] Finished reading DataCatalogTagTemplate %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading TagTemplate: %s", err) } @@ -490,6 +516,19 @@ func resourceDataCatalogTagTemplateRead(d *schema.ResourceData, meta interface{} } func resourceDataCatalogTagTemplateUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDataCatalogTagTemplate().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDataCatalogTagTemplateRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -708,6 +747,13 @@ func resourceDataCatalogTagTemplateUpdate(d *schema.ResourceData, meta interface } func resourceDataCatalogTagTemplateDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DataCatalogTagTemplate without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing TagTemplate %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/datacatalog/resource_data_catalog_tag_template_generated_meta.yaml b/google/services/datacatalog/resource_data_catalog_tag_template_generated_meta.yaml index 0b3abfb9ccc..981e63aeec1 100644 --- a/google/services/datacatalog/resource_data_catalog_tag_template_generated_meta.yaml +++ b/google/services/datacatalog/resource_data_catalog_tag_template_generated_meta.yaml @@ -31,3 +31,5 @@ fields: provider_only: true - field: tag_template_id provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/datacatalog/resource_data_catalog_taxonomy.go b/google/services/datacatalog/resource_data_catalog_taxonomy.go index b0450db8adf..92c3743c81d 100644 --- a/google/services/datacatalog/resource_data_catalog_taxonomy.go +++ b/google/services/datacatalog/resource_data_catalog_taxonomy.go @@ -115,6 +115,7 @@ func ResourceDataCatalogTaxonomy() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -178,6 +179,18 @@ long when encoded in UTF-8. If not set, defaults to an empty description.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -313,6 +326,19 @@ func resourceDataCatalogTaxonomyRead(d *schema.ResourceData, meta interface{}) e log.Printf("[DEBUG] Finished reading DataCatalogTaxonomy %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Taxonomy: %s", err) } @@ -338,6 +364,19 @@ func resourceDataCatalogTaxonomyRead(d *schema.ResourceData, meta interface{}) e } func resourceDataCatalogTaxonomyUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDataCatalogTaxonomy().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDataCatalogTaxonomyRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -439,6 +478,13 @@ func resourceDataCatalogTaxonomyUpdate(d *schema.ResourceData, meta interface{}) } func resourceDataCatalogTaxonomyDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DataCatalogTaxonomy without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Taxonomy %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/datacatalog/resource_data_catalog_taxonomy_generated_meta.yaml b/google/services/datacatalog/resource_data_catalog_taxonomy_generated_meta.yaml index 662a3528bcb..954344d64da 100644 --- a/google/services/datacatalog/resource_data_catalog_taxonomy_generated_meta.yaml +++ b/google/services/datacatalog/resource_data_catalog_taxonomy_generated_meta.yaml @@ -13,3 +13,5 @@ fields: - api_field: name - field: region provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/dataflow/resource_dataflow_job.go b/google/services/dataflow/resource_dataflow_job.go index e6b86829b88..9de7951bcc1 100644 --- a/google/services/dataflow/resource_dataflow_job.go +++ b/google/services/dataflow/resource_dataflow_job.go @@ -107,6 +107,7 @@ func ResourceDataflowJob() *schema.Resource { Update: schema.DefaultTimeout(10 * time.Minute), }, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), tpgresource.SetLabelsDiff, resourceDataflowJobTypeCustomizeDiff, ), @@ -294,6 +295,9 @@ func ResourceDataflowJob() *schema.Resource { Default: false, Description: `If true, treat DRAINING and CANCELLING as terminal job states and do not wait for further changes before removing from terraform state and moving on. WARNING: this will lead to job name conflicts if you do not ensure that the job names are different, e.g. by embedding a release ID or by using a random_id.`, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, UseJSONNumber: true, } @@ -461,6 +465,10 @@ func resourceDataflowJobRead(d *schema.ResourceData, meta interface{}) error { } d.SetId(job.Id) + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } @@ -471,6 +479,10 @@ func resourceDataflowJobUpdateByReplacement(d *schema.ResourceData, meta interfa return nil } + if tpgresource.DeletionPolicyPreUpdate(d, ResourceDataflowJob) { + return ResourceDataflowJob().Read(d, meta) + } + if jobHasUpdate(d, ResourceDataflowJob().Schema) { config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) @@ -527,6 +539,13 @@ func resourceDataflowJobUpdateByReplacement(d *schema.ResourceData, meta interfa } func resourceDataflowJobDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/dataflow/resource_dataflow_job_meta.yaml b/google/services/dataflow/resource_dataflow_job_meta.yaml index 4333b645ac8..92ca6c8cc80 100644 --- a/google/services/dataflow/resource_dataflow_job_meta.yaml +++ b/google/services/dataflow/resource_dataflow_job_meta.yaml @@ -33,3 +33,5 @@ fields: - api_field: 'transformNameMapping' - api_field: 'type' - field: 'zone' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/dataform/resource_dataform_folder.go b/google/services/dataform/resource_dataform_folder.go index a3b8ba1a8e8..5de22e950d5 100644 --- a/google/services/dataform/resource_dataform_folder.go +++ b/google/services/dataform/resource_dataform_folder.go @@ -115,6 +115,7 @@ func ResourceDataformFolder() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -174,6 +175,18 @@ Format: 'projects/*/locations/*/folders/*' or 'projects/*/locations/*/teamFolder Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -316,6 +329,19 @@ func resourceDataformFolderRead(d *schema.ResourceData, meta interface{}) error log.Printf("[DEBUG] Finished reading DataformFolder %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Folder: %s", err) } @@ -353,6 +379,19 @@ func resourceDataformFolderRead(d *schema.ResourceData, meta interface{}) error } func resourceDataformFolderUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDataformFolder().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDataformFolderRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -454,6 +493,13 @@ func resourceDataformFolderUpdate(d *schema.ResourceData, meta interface{}) erro } func resourceDataformFolderDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DataformFolder without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Folder %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/dataform/resource_dataform_folder_generated_meta.yaml b/google/services/dataform/resource_dataform_folder_generated_meta.yaml index 727191505c6..21d8172fe02 100644 --- a/google/services/dataform/resource_dataform_folder_generated_meta.yaml +++ b/google/services/dataform/resource_dataform_folder_generated_meta.yaml @@ -14,3 +14,5 @@ fields: - api_field: name - field: region provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/dataform/resource_dataform_team_folder.go b/google/services/dataform/resource_dataform_team_folder.go index e7aa1273bd2..6da89dee522 100644 --- a/google/services/dataform/resource_dataform_team_folder.go +++ b/google/services/dataform/resource_dataform_team_folder.go @@ -115,6 +115,7 @@ func ResourceDataformTeamFolder() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -168,6 +169,18 @@ func ResourceDataformTeamFolder() *schema.Resource { Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -304,6 +317,19 @@ func resourceDataformTeamFolderRead(d *schema.ResourceData, meta interface{}) er log.Printf("[DEBUG] Finished reading DataformTeamFolder %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading TeamFolder: %s", err) } @@ -341,6 +367,19 @@ func resourceDataformTeamFolderRead(d *schema.ResourceData, meta interface{}) er } func resourceDataformTeamFolderUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDataformTeamFolder().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDataformTeamFolderRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -432,6 +471,13 @@ func resourceDataformTeamFolderUpdate(d *schema.ResourceData, meta interface{}) } func resourceDataformTeamFolderDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DataformTeamFolder without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing TeamFolder %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/dataform/resource_dataform_team_folder_generated_meta.yaml b/google/services/dataform/resource_dataform_team_folder_generated_meta.yaml index 27f06d10e0a..65910cfc61f 100644 --- a/google/services/dataform/resource_dataform_team_folder_generated_meta.yaml +++ b/google/services/dataform/resource_dataform_team_folder_generated_meta.yaml @@ -13,3 +13,5 @@ fields: provider_only: true - api_field: name field: teamfolder_id + - field: deletion_policy + provider_only: true diff --git a/google/services/datafusion/resource_data_fusion_instance.go b/google/services/datafusion/resource_data_fusion_instance.go index c80bfd6e13a..e60edb15f89 100644 --- a/google/services/datafusion/resource_data_fusion_instance.go +++ b/google/services/datafusion/resource_data_fusion_instance.go @@ -139,6 +139,7 @@ func ResourceDataFusionInstance() *schema.Resource { tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, tpgresource.DefaultProviderRegion, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -486,6 +487,18 @@ The field is ignored (both PUT & PATCH) when empty.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -731,6 +744,19 @@ func resourceDataFusionInstanceRead(d *schema.ResourceData, meta interface{}) er log.Printf("[DEBUG] Finished reading DataFusionInstance %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Instance: %s", err) } @@ -776,6 +802,19 @@ func resourceDataFusionInstanceRead(d *schema.ResourceData, meta interface{}) er } func resourceDataFusionInstanceUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDataFusionInstance().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDataFusionInstanceRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -923,6 +962,13 @@ func resourceDataFusionInstanceUpdate(d *schema.ResourceData, meta interface{}) } func resourceDataFusionInstanceDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DataFusionInstance without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Instance %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/datafusion/resource_data_fusion_instance_generated_meta.yaml b/google/services/datafusion/resource_data_fusion_instance_generated_meta.yaml index c364c340355..96d6f9a3520 100644 --- a/google/services/datafusion/resource_data_fusion_instance_generated_meta.yaml +++ b/google/services/datafusion/resource_data_fusion_instance_generated_meta.yaml @@ -48,3 +48,5 @@ fields: - api_field: updateTime - api_field: version - api_field: zone + - field: deletion_policy + provider_only: true diff --git a/google/services/datalineage/resource_data_lineage_config.go b/google/services/datalineage/resource_data_lineage_config.go index 6e293368aa7..b93dde9eeca 100644 --- a/google/services/datalineage/resource_data_lineage_config.go +++ b/google/services/datalineage/resource_data_lineage_config.go @@ -211,6 +211,19 @@ folders/{folder_id}/locations/{location}/config, projects/{project_id}/locations/{location}/config, or projects/{project_number}/locations/{location}/config.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -327,6 +340,20 @@ func resourceDataLineageConfigRead(d *schema.ResourceData, meta interface{}) err log.Printf("[DEBUG] Finished reading DataLineageConfig %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceDataLineageConfigFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -354,6 +381,19 @@ func resourceDataLineageConfigRead(d *schema.ResourceData, meta interface{}) err } func resourceDataLineageConfigUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDataLineageConfig().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDataLineageConfigRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -425,6 +465,13 @@ func resourceDataLineageConfigUpdate(d *schema.ResourceData, meta interface{}) e } func resourceDataLineageConfigDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DataLineageConfig without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Config %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/datalineage/resource_data_lineage_config_generated_meta.yaml b/google/services/datalineage/resource_data_lineage_config_generated_meta.yaml index f8aca66f26f..0bb8e7cb4d0 100644 --- a/google/services/datalineage/resource_data_lineage_config_generated_meta.yaml +++ b/google/services/datalineage/resource_data_lineage_config_generated_meta.yaml @@ -21,3 +21,5 @@ fields: - api_field: name - field: parent provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/datalossprevention/resource_data_loss_prevention_deidentify_template.go b/google/services/datalossprevention/resource_data_loss_prevention_deidentify_template.go index a5c818d3f73..836ee25fb21 100644 --- a/google/services/datalossprevention/resource_data_loss_prevention_deidentify_template.go +++ b/google/services/datalossprevention/resource_data_loss_prevention_deidentify_template.go @@ -4286,6 +4286,19 @@ that is, it must match the regular expression: [a-zA-Z\d-_]+. The maximum length Computed: true, Description: `The last update timestamp of an deidentifyTemplate. Set by the server.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -4431,6 +4444,20 @@ func resourceDataLossPreventionDeidentifyTemplateRead(d *schema.ResourceData, me return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceDataLossPreventionDeidentifyTemplateFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -4458,6 +4485,19 @@ func resourceDataLossPreventionDeidentifyTemplateRead(d *schema.ResourceData, me } func resourceDataLossPreventionDeidentifyTemplateUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDataLossPreventionDeidentifyTemplate().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDataLossPreventionDeidentifyTemplateRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -4563,6 +4603,13 @@ func resourceDataLossPreventionDeidentifyTemplateUpdate(d *schema.ResourceData, } func resourceDataLossPreventionDeidentifyTemplateDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DataLossPreventionDeidentifyTemplate without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing DeidentifyTemplate %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/datalossprevention/resource_data_loss_prevention_deidentify_template_generated_meta.yaml b/google/services/datalossprevention/resource_data_loss_prevention_deidentify_template_generated_meta.yaml index c05a747592e..46b0dcdd5b6 100644 --- a/google/services/datalossprevention/resource_data_loss_prevention_deidentify_template_generated_meta.yaml +++ b/google/services/datalossprevention/resource_data_loss_prevention_deidentify_template_generated_meta.yaml @@ -366,3 +366,5 @@ fields: - field: template_id provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/datalossprevention/resource_data_loss_prevention_discovery_config.go b/google/services/datalossprevention/resource_data_loss_prevention_discovery_config.go index 52ab7800de7..e893540a237 100644 --- a/google/services/datalossprevention/resource_data_loss_prevention_discovery_config.go +++ b/google/services/datalossprevention/resource_data_loss_prevention_discovery_config.go @@ -1449,6 +1449,19 @@ an organization parent, or "my-project/sensitive" for a project parent.`, Computed: true, Description: `Output only. The last update timestamp of a DiscoveryConfig.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -1618,6 +1631,20 @@ func resourceDataLossPreventionDiscoveryConfigRead(d *schema.ResourceData, meta return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceDataLossPreventionDiscoveryConfigFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -1645,6 +1672,19 @@ func resourceDataLossPreventionDiscoveryConfigRead(d *schema.ResourceData, meta } func resourceDataLossPreventionDiscoveryConfigUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDataLossPreventionDiscoveryConfig().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDataLossPreventionDiscoveryConfigRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1790,6 +1830,13 @@ func resourceDataLossPreventionDiscoveryConfigUpdate(d *schema.ResourceData, met } func resourceDataLossPreventionDiscoveryConfigDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DataLossPreventionDiscoveryConfig without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing DiscoveryConfig %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/datalossprevention/resource_data_loss_prevention_discovery_config_generated_meta.yaml b/google/services/datalossprevention/resource_data_loss_prevention_discovery_config_generated_meta.yaml index 3aae7b118ca..c2ffa07b841 100644 --- a/google/services/datalossprevention/resource_data_loss_prevention_discovery_config_generated_meta.yaml +++ b/google/services/datalossprevention/resource_data_loss_prevention_discovery_config_generated_meta.yaml @@ -107,3 +107,5 @@ fields: - api_field: targets.otherCloudTarget.generationCadence.refreshFrequency - api_field: targets.secretsTarget - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/datalossprevention/resource_data_loss_prevention_inspect_template.go b/google/services/datalossprevention/resource_data_loss_prevention_inspect_template.go index 6077434c397..b0dcf4fd5ee 100644 --- a/google/services/datalossprevention/resource_data_loss_prevention_inspect_template.go +++ b/google/services/datalossprevention/resource_data_loss_prevention_inspect_template.go @@ -823,6 +823,19 @@ that is, it must match the regular expression: [a-zA-Z\d-_]+. The maximum length Computed: true, Description: `The resource name of the inspect template. Set by the server.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -968,6 +981,20 @@ func resourceDataLossPreventionInspectTemplateRead(d *schema.ResourceData, meta return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceDataLossPreventionInspectTemplateFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -995,6 +1022,19 @@ func resourceDataLossPreventionInspectTemplateRead(d *schema.ResourceData, meta } func resourceDataLossPreventionInspectTemplateUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDataLossPreventionInspectTemplate().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDataLossPreventionInspectTemplateRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1100,6 +1140,13 @@ func resourceDataLossPreventionInspectTemplateUpdate(d *schema.ResourceData, met } func resourceDataLossPreventionInspectTemplateDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DataLossPreventionInspectTemplate without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing InspectTemplate %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/datalossprevention/resource_data_loss_prevention_inspect_template_generated_meta.yaml b/google/services/datalossprevention/resource_data_loss_prevention_inspect_template_generated_meta.yaml index d5ded635879..ed6fce13b29 100644 --- a/google/services/datalossprevention/resource_data_loss_prevention_inspect_template_generated_meta.yaml +++ b/google/services/datalossprevention/resource_data_loss_prevention_inspect_template_generated_meta.yaml @@ -60,3 +60,5 @@ fields: provider_only: true - field: template_id provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/datalossprevention/resource_data_loss_prevention_job_trigger.go b/google/services/datalossprevention/resource_data_loss_prevention_job_trigger.go index 704a5e4aade..dcd0fdbc936 100644 --- a/google/services/datalossprevention/resource_data_loss_prevention_job_trigger.go +++ b/google/services/datalossprevention/resource_data_loss_prevention_job_trigger.go @@ -1523,6 +1523,19 @@ The maximum length is 100 characters. Can be empty to allow the system to genera Computed: true, Description: `The last update timestamp of an inspectTemplate. Set by the server.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -1680,6 +1693,20 @@ func resourceDataLossPreventionJobTriggerRead(d *schema.ResourceData, meta inter return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceDataLossPreventionJobTriggerFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -1707,6 +1734,19 @@ func resourceDataLossPreventionJobTriggerRead(d *schema.ResourceData, meta inter } func resourceDataLossPreventionJobTriggerUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDataLossPreventionJobTrigger().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDataLossPreventionJobTriggerRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1832,6 +1872,13 @@ func resourceDataLossPreventionJobTriggerUpdate(d *schema.ResourceData, meta int } func resourceDataLossPreventionJobTriggerDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DataLossPreventionJobTrigger without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing JobTrigger %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/datalossprevention/resource_data_loss_prevention_job_trigger_generated_meta.yaml b/google/services/datalossprevention/resource_data_loss_prevention_job_trigger_generated_meta.yaml index 2029d2e089a..ba7b38b60ce 100644 --- a/google/services/datalossprevention/resource_data_loss_prevention_job_trigger_generated_meta.yaml +++ b/google/services/datalossprevention/resource_data_loss_prevention_job_trigger_generated_meta.yaml @@ -115,3 +115,5 @@ fields: - api_field: triggers.manual - api_field: triggers.schedule.recurrencePeriodDuration - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/datalossprevention/resource_data_loss_prevention_stored_info_type.go b/google/services/datalossprevention/resource_data_loss_prevention_stored_info_type.go index f7af69db0b3..9b0332fcc65 100644 --- a/google/services/datalossprevention/resource_data_loss_prevention_stored_info_type.go +++ b/google/services/datalossprevention/resource_data_loss_prevention_stored_info_type.go @@ -141,6 +141,7 @@ func ResourceDataLossPreventionStoredInfoType() *schema.Resource { CustomizeDiff: customdiff.All( storedInfoTypeCustomizeDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -364,6 +365,19 @@ characters. Can be empty to allow the system to generate one.`, Computed: true, Description: `The resource name of the info type. Set by the server.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -569,6 +583,20 @@ func resourceDataLossPreventionStoredInfoTypeRead(d *schema.ResourceData, meta i return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceDataLossPreventionStoredInfoTypeFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -596,6 +624,19 @@ func resourceDataLossPreventionStoredInfoTypeRead(d *schema.ResourceData, meta i } func resourceDataLossPreventionStoredInfoTypeUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDataLossPreventionStoredInfoType().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDataLossPreventionStoredInfoTypeRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -721,6 +762,13 @@ func resourceDataLossPreventionStoredInfoTypeUpdate(d *schema.ResourceData, meta } func resourceDataLossPreventionStoredInfoTypeDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DataLossPreventionStoredInfoType without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing StoredInfoType %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/datalossprevention/resource_data_loss_prevention_stored_info_type_generated_meta.yaml b/google/services/datalossprevention/resource_data_loss_prevention_stored_info_type_generated_meta.yaml index 51e256f1a44..17ff6f5047f 100644 --- a/google/services/datalossprevention/resource_data_loss_prevention_stored_info_type_generated_meta.yaml +++ b/google/services/datalossprevention/resource_data_loss_prevention_stored_info_type_generated_meta.yaml @@ -24,3 +24,5 @@ fields: - api_field: regex.pattern - field: stored_info_type_id provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/datapipeline/resource_data_pipeline_pipeline.go b/google/services/datapipeline/resource_data_pipeline_pipeline.go index d1b2cda3be5..bb22486462b 100644 --- a/google/services/datapipeline/resource_data_pipeline_pipeline.go +++ b/google/services/datapipeline/resource_data_pipeline_pipeline.go @@ -115,6 +115,7 @@ func ResourceDataPipelinePipeline() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -592,6 +593,18 @@ A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to n Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -761,6 +774,19 @@ func resourceDataPipelinePipelineRead(d *schema.ResourceData, meta interface{}) log.Printf("[DEBUG] Finished reading DataPipelinePipeline %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Pipeline: %s", err) } @@ -798,6 +824,19 @@ func resourceDataPipelinePipelineRead(d *schema.ResourceData, meta interface{}) } func resourceDataPipelinePipelineUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDataPipelinePipeline().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDataPipelinePipelineRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -919,6 +958,13 @@ func resourceDataPipelinePipelineUpdate(d *schema.ResourceData, meta interface{} } func resourceDataPipelinePipelineDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DataPipelinePipeline without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Pipeline %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/datapipeline/resource_data_pipeline_pipeline_generated_meta.yaml b/google/services/datapipeline/resource_data_pipeline_pipeline_generated_meta.yaml index 04d7a674450..96bb33677f2 100644 --- a/google/services/datapipeline/resource_data_pipeline_pipeline_generated_meta.yaml +++ b/google/services/datapipeline/resource_data_pipeline_pipeline_generated_meta.yaml @@ -70,3 +70,5 @@ fields: - api_field: workload.dataflowLaunchTemplateRequest.location - api_field: workload.dataflowLaunchTemplateRequest.projectId - api_field: workload.dataflowLaunchTemplateRequest.validateOnly + - field: deletion_policy + provider_only: true diff --git a/google/services/dataplex/resource_dataplex_aspect_type.go b/google/services/dataplex/resource_dataplex_aspect_type.go index 1a7a58df901..f426d0b997d 100644 --- a/google/services/dataplex/resource_dataplex_aspect_type.go +++ b/google/services/dataplex/resource_dataplex_aspect_type.go @@ -116,6 +116,7 @@ func ResourceDataplexAspectType() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -237,6 +238,18 @@ for Aspect Type created from Dataplex API.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -398,6 +411,19 @@ func resourceDataplexAspectTypeRead(d *schema.ResourceData, meta interface{}) er log.Printf("[DEBUG] Finished reading DataplexAspectType %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading AspectType: %s", err) } @@ -435,6 +461,19 @@ func resourceDataplexAspectTypeRead(d *schema.ResourceData, meta interface{}) er } func resourceDataplexAspectTypeUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDataplexAspectType().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDataplexAspectTypeRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -563,6 +602,13 @@ func resourceDataplexAspectTypeUpdate(d *schema.ResourceData, meta interface{}) } func resourceDataplexAspectTypeDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DataplexAspectType without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing AspectType %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/dataplex/resource_dataplex_aspect_type_generated_meta.yaml b/google/services/dataplex/resource_dataplex_aspect_type_generated_meta.yaml index f15845f0f55..faf10e7857a 100644 --- a/google/services/dataplex/resource_dataplex_aspect_type_generated_meta.yaml +++ b/google/services/dataplex/resource_dataplex_aspect_type_generated_meta.yaml @@ -26,3 +26,5 @@ fields: - api_field: transferStatus - api_field: uid - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/dataplex/resource_dataplex_asset.go b/google/services/dataplex/resource_dataplex_asset.go index 8c379c1fc52..541f8452907 100644 --- a/google/services/dataplex/resource_dataplex_asset.go +++ b/google/services/dataplex/resource_dataplex_asset.go @@ -52,6 +52,7 @@ func ResourceDataplexAsset() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, tpgresource.SetLabelsDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -182,6 +183,9 @@ func ResourceDataplexAsset() *schema.Resource { Computed: true, Description: "Output only. The time when the asset was last updated.", }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, } } @@ -589,9 +593,18 @@ func resourceDataplexAssetRead(d *schema.ResourceData, meta interface{}) error { return fmt.Errorf("error setting update_time in state: %s", err) } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } func resourceDataplexAssetUpdate(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceDataplexAsset) { + return ResourceDataplexAsset().Read(d, meta) + } + config := meta.(*transport_tpg.Config) project, err := tpgresource.GetProject(d, config) if err != nil { @@ -644,6 +657,13 @@ func resourceDataplexAssetUpdate(d *schema.ResourceData, meta interface{}) error } func resourceDataplexAssetDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) project, err := tpgresource.GetProject(d, config) if err != nil { diff --git a/google/services/dataplex/resource_dataplex_asset_meta.yaml b/google/services/dataplex/resource_dataplex_asset_meta.yaml index 4eca8d006ed..1073d96dd16 100644 --- a/google/services/dataplex/resource_dataplex_asset_meta.yaml +++ b/google/services/dataplex/resource_dataplex_asset_meta.yaml @@ -50,3 +50,5 @@ fields: provider_only: true - api_field: 'uid' - api_field: 'updateTime' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/dataplex/resource_dataplex_datascan.go b/google/services/dataplex/resource_dataplex_datascan.go index ce35a8effb9..c85ec1f6a60 100644 --- a/google/services/dataplex/resource_dataplex_datascan.go +++ b/google/services/dataplex/resource_dataplex_datascan.go @@ -116,6 +116,7 @@ func ResourceDataplexDatascan() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiffWithoutAttributionLabel, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -1000,6 +1001,18 @@ Please refer to the field 'effective_labels' for all of the labels present on th Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -1191,6 +1204,19 @@ func resourceDataplexDatascanRead(d *schema.ResourceData, meta interface{}) erro log.Printf("[DEBUG] Finished reading DataplexDatascan %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Datascan: %s", err) } @@ -1228,6 +1254,19 @@ func resourceDataplexDatascanRead(d *schema.ResourceData, meta interface{}) erro } func resourceDataplexDatascanUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDataplexDatascan().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDataplexDatascanRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1396,6 +1435,13 @@ func resourceDataplexDatascanUpdate(d *schema.ResourceData, meta interface{}) er } func resourceDataplexDatascanDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DataplexDatascan without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Datascan %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/dataplex/resource_dataplex_datascan_generated_meta.yaml b/google/services/dataplex/resource_dataplex_datascan_generated_meta.yaml index 4e855a52ad8..7360099718b 100644 --- a/google/services/dataplex/resource_dataplex_datascan_generated_meta.yaml +++ b/google/services/dataplex/resource_dataplex_datascan_generated_meta.yaml @@ -94,3 +94,5 @@ fields: - api_field: type - api_field: uid - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/dataplex/resource_dataplex_entry.go b/google/services/dataplex/resource_dataplex_entry.go index 7ab27f498f9..2dce50ad4dc 100644 --- a/google/services/dataplex/resource_dataplex_entry.go +++ b/google/services/dataplex/resource_dataplex_entry.go @@ -309,6 +309,7 @@ func ResourceDataplexEntry() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -536,6 +537,18 @@ The maximum size of the field is 4000 characters.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -721,6 +734,19 @@ func resourceDataplexEntryRead(d *schema.ResourceData, meta interface{}) error { return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Entry: %s", err) } @@ -764,6 +790,19 @@ func resourceDataplexEntryRead(d *schema.ResourceData, meta interface{}) error { } func resourceDataplexEntryUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDataplexEntry().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDataplexEntryRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -927,6 +966,13 @@ func resourceDataplexEntryUpdate(d *schema.ResourceData, meta interface{}) error } func resourceDataplexEntryDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DataplexEntry without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Entry %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/dataplex/resource_dataplex_entry_generated_meta.yaml b/google/services/dataplex/resource_dataplex_entry_generated_meta.yaml index febe580e395..b8281d35d9e 100644 --- a/google/services/dataplex/resource_dataplex_entry_generated_meta.yaml +++ b/google/services/dataplex/resource_dataplex_entry_generated_meta.yaml @@ -37,3 +37,5 @@ fields: - api_field: name - api_field: parentEntry - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/dataplex/resource_dataplex_entry_group.go b/google/services/dataplex/resource_dataplex_entry_group.go index 27b8c34f41f..2412a91ec3e 100644 --- a/google/services/dataplex/resource_dataplex_entry_group.go +++ b/google/services/dataplex/resource_dataplex_entry_group.go @@ -116,6 +116,7 @@ func ResourceDataplexEntryGroup() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -219,6 +220,18 @@ for Entry Group created from Dataplex API.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -368,6 +381,19 @@ func resourceDataplexEntryGroupRead(d *schema.ResourceData, meta interface{}) er log.Printf("[DEBUG] Finished reading DataplexEntryGroup %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading EntryGroup: %s", err) } @@ -405,6 +431,19 @@ func resourceDataplexEntryGroupRead(d *schema.ResourceData, meta interface{}) er } func resourceDataplexEntryGroupUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDataplexEntryGroup().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDataplexEntryGroupRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -523,6 +562,13 @@ func resourceDataplexEntryGroupUpdate(d *schema.ResourceData, meta interface{}) } func resourceDataplexEntryGroupDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DataplexEntryGroup without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing EntryGroup %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/dataplex/resource_dataplex_entry_group_generated_meta.yaml b/google/services/dataplex/resource_dataplex_entry_group_generated_meta.yaml index 32b9daec77c..b36cd036bad 100644 --- a/google/services/dataplex/resource_dataplex_entry_group_generated_meta.yaml +++ b/google/services/dataplex/resource_dataplex_entry_group_generated_meta.yaml @@ -23,3 +23,5 @@ fields: - api_field: transferStatus - api_field: uid - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/dataplex/resource_dataplex_entry_link.go b/google/services/dataplex/resource_dataplex_entry_link.go index 38da3cc3aa5..fbba0c88ccd 100644 --- a/google/services/dataplex/resource_dataplex_entry_link.go +++ b/google/services/dataplex/resource_dataplex_entry_link.go @@ -268,6 +268,7 @@ func ResourceDataplexEntryLink() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -429,6 +430,18 @@ projects/{project_id_or_number}/locations/{location_id}/entryGroups/{entry_group Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -592,6 +605,19 @@ func resourceDataplexEntryLinkRead(d *schema.ResourceData, meta interface{}) err return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading EntryLink: %s", err) } @@ -635,6 +661,19 @@ func resourceDataplexEntryLinkRead(d *schema.ResourceData, meta interface{}) err } func resourceDataplexEntryLinkUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDataplexEntryLink().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDataplexEntryLinkRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -722,6 +761,13 @@ func resourceDataplexEntryLinkUpdate(d *schema.ResourceData, meta interface{}) e } func resourceDataplexEntryLinkDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DataplexEntryLink without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing EntryLink %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/dataplex/resource_dataplex_entry_link_generated_meta.yaml b/google/services/dataplex/resource_dataplex_entry_link_generated_meta.yaml index b36cf62ad9f..9e636a5036a 100644 --- a/google/services/dataplex/resource_dataplex_entry_link_generated_meta.yaml +++ b/google/services/dataplex/resource_dataplex_entry_link_generated_meta.yaml @@ -27,3 +27,5 @@ fields: provider_only: true - api_field: name - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/dataplex/resource_dataplex_entry_type.go b/google/services/dataplex/resource_dataplex_entry_type.go index e0b198ab3c2..6199569a47b 100644 --- a/google/services/dataplex/resource_dataplex_entry_type.go +++ b/google/services/dataplex/resource_dataplex_entry_type.go @@ -116,6 +116,7 @@ func ResourceDataplexEntryType() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -245,6 +246,18 @@ Please refer to the field 'effective_labels' for all of the labels present on th Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -418,6 +431,19 @@ func resourceDataplexEntryTypeRead(d *schema.ResourceData, meta interface{}) err log.Printf("[DEBUG] Finished reading DataplexEntryType %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading EntryType: %s", err) } @@ -455,6 +481,19 @@ func resourceDataplexEntryTypeRead(d *schema.ResourceData, meta interface{}) err } func resourceDataplexEntryTypeUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDataplexEntryType().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDataplexEntryTypeRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -613,6 +652,13 @@ func resourceDataplexEntryTypeUpdate(d *schema.ResourceData, meta interface{}) e } func resourceDataplexEntryTypeDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DataplexEntryType without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing EntryType %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/dataplex/resource_dataplex_entry_type_generated_meta.yaml b/google/services/dataplex/resource_dataplex_entry_type_generated_meta.yaml index b9247ef9847..c9941ebbf24 100644 --- a/google/services/dataplex/resource_dataplex_entry_type_generated_meta.yaml +++ b/google/services/dataplex/resource_dataplex_entry_type_generated_meta.yaml @@ -26,3 +26,5 @@ fields: - api_field: typeAliases - api_field: uid - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/dataplex/resource_dataplex_glossary.go b/google/services/dataplex/resource_dataplex_glossary.go index f602c3986f2..03e21c70e8e 100644 --- a/google/services/dataplex/resource_dataplex_glossary.go +++ b/google/services/dataplex/resource_dataplex_glossary.go @@ -116,6 +116,7 @@ func ResourceDataplexGlossary() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -223,6 +224,18 @@ Please refer to the field 'effective_labels' for all of the labels present on th Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -372,6 +385,19 @@ func resourceDataplexGlossaryRead(d *schema.ResourceData, meta interface{}) erro log.Printf("[DEBUG] Finished reading DataplexGlossary %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Glossary: %s", err) } @@ -409,6 +435,19 @@ func resourceDataplexGlossaryRead(d *schema.ResourceData, meta interface{}) erro } func resourceDataplexGlossaryUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDataplexGlossary().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDataplexGlossaryRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -527,6 +566,13 @@ func resourceDataplexGlossaryUpdate(d *schema.ResourceData, meta interface{}) er } func resourceDataplexGlossaryDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DataplexGlossary without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Glossary %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/dataplex/resource_dataplex_glossary_category.go b/google/services/dataplex/resource_dataplex_glossary_category.go index 288f8d8ce26..79cef9207e1 100644 --- a/google/services/dataplex/resource_dataplex_glossary_category.go +++ b/google/services/dataplex/resource_dataplex_glossary_category.go @@ -116,6 +116,7 @@ func ResourceDataplexGlossaryCategory() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -228,6 +229,18 @@ Please refer to the field 'effective_labels' for all of the labels present on th Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -378,6 +391,19 @@ func resourceDataplexGlossaryCategoryRead(d *schema.ResourceData, meta interface log.Printf("[DEBUG] Finished reading DataplexGlossaryCategory %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading GlossaryCategory: %s", err) } @@ -421,6 +447,19 @@ func resourceDataplexGlossaryCategoryRead(d *schema.ResourceData, meta interface } func resourceDataplexGlossaryCategoryUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDataplexGlossaryCategory().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDataplexGlossaryCategoryRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -547,6 +586,13 @@ func resourceDataplexGlossaryCategoryUpdate(d *schema.ResourceData, meta interfa } func resourceDataplexGlossaryCategoryDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DataplexGlossaryCategory without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing GlossaryCategory %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/dataplex/resource_dataplex_glossary_category_generated_meta.yaml b/google/services/dataplex/resource_dataplex_glossary_category_generated_meta.yaml index 3bd106c377a..c5d85f8d942 100644 --- a/google/services/dataplex/resource_dataplex_glossary_category_generated_meta.yaml +++ b/google/services/dataplex/resource_dataplex_glossary_category_generated_meta.yaml @@ -25,3 +25,5 @@ fields: provider_only: true - api_field: uid - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/dataplex/resource_dataplex_glossary_generated_meta.yaml b/google/services/dataplex/resource_dataplex_glossary_generated_meta.yaml index f8eca65e71c..5ac6d131b32 100644 --- a/google/services/dataplex/resource_dataplex_glossary_generated_meta.yaml +++ b/google/services/dataplex/resource_dataplex_glossary_generated_meta.yaml @@ -24,3 +24,5 @@ fields: provider_only: true - api_field: uid - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/dataplex/resource_dataplex_glossary_term.go b/google/services/dataplex/resource_dataplex_glossary_term.go index 492c69bdc43..21c57d7f209 100644 --- a/google/services/dataplex/resource_dataplex_glossary_term.go +++ b/google/services/dataplex/resource_dataplex_glossary_term.go @@ -116,6 +116,7 @@ func ResourceDataplexGlossaryTerm() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -228,6 +229,18 @@ Please refer to the field 'effective_labels' for all of the labels present on th Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -378,6 +391,19 @@ func resourceDataplexGlossaryTermRead(d *schema.ResourceData, meta interface{}) log.Printf("[DEBUG] Finished reading DataplexGlossaryTerm %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading GlossaryTerm: %s", err) } @@ -421,6 +447,19 @@ func resourceDataplexGlossaryTermRead(d *schema.ResourceData, meta interface{}) } func resourceDataplexGlossaryTermUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDataplexGlossaryTerm().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDataplexGlossaryTermRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -547,6 +586,13 @@ func resourceDataplexGlossaryTermUpdate(d *schema.ResourceData, meta interface{} } func resourceDataplexGlossaryTermDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DataplexGlossaryTerm without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing GlossaryTerm %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/dataplex/resource_dataplex_glossary_term_generated_meta.yaml b/google/services/dataplex/resource_dataplex_glossary_term_generated_meta.yaml index 00aa48a1f99..36f92754748 100644 --- a/google/services/dataplex/resource_dataplex_glossary_term_generated_meta.yaml +++ b/google/services/dataplex/resource_dataplex_glossary_term_generated_meta.yaml @@ -25,3 +25,5 @@ fields: provider_only: true - api_field: uid - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/dataplex/resource_dataplex_lake.go b/google/services/dataplex/resource_dataplex_lake.go index b58b400379c..f08f8dc7f06 100644 --- a/google/services/dataplex/resource_dataplex_lake.go +++ b/google/services/dataplex/resource_dataplex_lake.go @@ -52,6 +52,7 @@ func ResourceDataplexLake() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, tpgresource.SetLabelsDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -160,6 +161,9 @@ func ResourceDataplexLake() *schema.Resource { Computed: true, Description: "Output only. The time when the lake was last updated.", }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, } } @@ -372,9 +376,18 @@ func resourceDataplexLakeRead(d *schema.ResourceData, meta interface{}) error { return fmt.Errorf("error setting update_time in state: %s", err) } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } func resourceDataplexLakeUpdate(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceDataplexLake) { + return ResourceDataplexLake().Read(d, meta) + } + config := meta.(*transport_tpg.Config) project, err := tpgresource.GetProject(d, config) if err != nil { @@ -424,6 +437,13 @@ func resourceDataplexLakeUpdate(d *schema.ResourceData, meta interface{}) error } func resourceDataplexLakeDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) project, err := tpgresource.GetProject(d, config) if err != nil { diff --git a/google/services/dataplex/resource_dataplex_lake_meta.yaml b/google/services/dataplex/resource_dataplex_lake_meta.yaml index 119d137fc63..844d4e63ab1 100644 --- a/google/services/dataplex/resource_dataplex_lake_meta.yaml +++ b/google/services/dataplex/resource_dataplex_lake_meta.yaml @@ -29,3 +29,5 @@ fields: provider_only: true - api_field: 'uid' - api_field: 'updateTime' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/dataplex/resource_dataplex_task.go b/google/services/dataplex/resource_dataplex_task.go index a12338d6ebd..939abadb2a8 100644 --- a/google/services/dataplex/resource_dataplex_task.go +++ b/google/services/dataplex/resource_dataplex_task.go @@ -116,6 +116,7 @@ func ResourceDataplexTask() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiffWithoutAttributionLabel, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -656,6 +657,18 @@ Please refer to the field 'effective_labels' for all of the labels present on th Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -834,6 +847,19 @@ func resourceDataplexTaskRead(d *schema.ResourceData, meta interface{}) error { log.Printf("[DEBUG] Finished reading DataplexTask %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Task: %s", err) } @@ -877,6 +903,19 @@ func resourceDataplexTaskRead(d *schema.ResourceData, meta interface{}) error { } func resourceDataplexTaskUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDataplexTask().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDataplexTaskRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1040,6 +1079,13 @@ func resourceDataplexTaskUpdate(d *schema.ResourceData, meta interface{}) error } func resourceDataplexTaskDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DataplexTask without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Task %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/dataplex/resource_dataplex_task_generated_meta.yaml b/google/services/dataplex/resource_dataplex_task_generated_meta.yaml index f2cdf819e35..44cfabd3d60 100644 --- a/google/services/dataplex/resource_dataplex_task_generated_meta.yaml +++ b/google/services/dataplex/resource_dataplex_task_generated_meta.yaml @@ -73,3 +73,5 @@ fields: - api_field: triggerSpec.type - api_field: uid - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/dataplex/resource_dataplex_zone.go b/google/services/dataplex/resource_dataplex_zone.go index 1234e79cc02..0213dc39934 100644 --- a/google/services/dataplex/resource_dataplex_zone.go +++ b/google/services/dataplex/resource_dataplex_zone.go @@ -52,6 +52,7 @@ func ResourceDataplexZone() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, tpgresource.SetLabelsDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -170,6 +171,9 @@ func ResourceDataplexZone() *schema.Resource { Computed: true, Description: "Output only. The time when the zone was last updated.", }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, } } @@ -461,9 +465,18 @@ func resourceDataplexZoneRead(d *schema.ResourceData, meta interface{}) error { return fmt.Errorf("error setting update_time in state: %s", err) } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } func resourceDataplexZoneUpdate(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceDataplexZone) { + return ResourceDataplexZone().Read(d, meta) + } + config := meta.(*transport_tpg.Config) project, err := tpgresource.GetProject(d, config) if err != nil { @@ -516,6 +529,13 @@ func resourceDataplexZoneUpdate(d *schema.ResourceData, meta interface{}) error } func resourceDataplexZoneDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) project, err := tpgresource.GetProject(d, config) if err != nil { diff --git a/google/services/dataplex/resource_dataplex_zone_meta.yaml b/google/services/dataplex/resource_dataplex_zone_meta.yaml index aa68c213379..1666232f493 100644 --- a/google/services/dataplex/resource_dataplex_zone_meta.yaml +++ b/google/services/dataplex/resource_dataplex_zone_meta.yaml @@ -36,3 +36,5 @@ fields: - api_field: 'type' - api_field: 'uid' - api_field: 'updateTime' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/dataproc/resource_dataproc_autoscaling_policy.go b/google/services/dataproc/resource_dataproc_autoscaling_policy.go index 7e47cf02306..7c04b761b81 100644 --- a/google/services/dataproc/resource_dataproc_autoscaling_policy.go +++ b/google/services/dataproc/resource_dataproc_autoscaling_policy.go @@ -115,6 +115,7 @@ func ResourceDataprocAutoscalingPolicy() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -335,6 +336,18 @@ only on primary workers, the cluster will use primary workers only and no second Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -480,6 +493,19 @@ func resourceDataprocAutoscalingPolicyRead(d *schema.ResourceData, meta interfac log.Printf("[DEBUG] Finished reading DataprocAutoscalingPolicy %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading AutoscalingPolicy: %s", err) } @@ -517,6 +543,19 @@ func resourceDataprocAutoscalingPolicyRead(d *schema.ResourceData, meta interfac } func resourceDataprocAutoscalingPolicyUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDataprocAutoscalingPolicy().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDataprocAutoscalingPolicyRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -611,6 +650,13 @@ func resourceDataprocAutoscalingPolicyUpdate(d *schema.ResourceData, meta interf } func resourceDataprocAutoscalingPolicyDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DataprocAutoscalingPolicy without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing AutoscalingPolicy %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/dataproc/resource_dataproc_autoscaling_policy_generated_meta.yaml b/google/services/dataproc/resource_dataproc_autoscaling_policy_generated_meta.yaml index a5c2612aedc..f5909695d85 100644 --- a/google/services/dataproc/resource_dataproc_autoscaling_policy_generated_meta.yaml +++ b/google/services/dataproc/resource_dataproc_autoscaling_policy_generated_meta.yaml @@ -28,3 +28,5 @@ fields: - api_field: workerConfig.maxInstances - api_field: workerConfig.minInstances - api_field: workerConfig.weight + - field: deletion_policy + provider_only: true diff --git a/google/services/dataproc/resource_dataproc_batch.go b/google/services/dataproc/resource_dataproc_batch.go index 1ff1503583d..f37f3351e8d 100644 --- a/google/services/dataproc/resource_dataproc_batch.go +++ b/google/services/dataproc/resource_dataproc_batch.go @@ -132,6 +132,7 @@ func ResourceDataprocBatch() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -776,6 +777,18 @@ properties, such as --conf, since a collision can occur that causes an incorrect Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -961,6 +974,19 @@ func resourceDataprocBatchRead(d *schema.ResourceData, meta interface{}) error { return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Batch: %s", err) } @@ -998,11 +1024,18 @@ func resourceDataprocBatchRead(d *schema.ResourceData, meta interface{}) error { } func resourceDataprocBatchUpdate(d *schema.ResourceData, meta interface{}) error { - // Only the root field "labels", "terraform_labels", and virtual fields are mutable + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable return resourceDataprocBatchRead(d, meta) } func resourceDataprocBatchDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DataprocBatch without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Batch %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/dataproc/resource_dataproc_batch_generated_meta.yaml b/google/services/dataproc/resource_dataproc_batch_generated_meta.yaml index e346b5ffd1c..bdaba179d7c 100644 --- a/google/services/dataproc/resource_dataproc_batch_generated_meta.yaml +++ b/google/services/dataproc/resource_dataproc_batch_generated_meta.yaml @@ -78,3 +78,5 @@ fields: - field: terraform_labels provider_only: true - api_field: uuid + - field: deletion_policy + provider_only: true diff --git a/google/services/dataproc/resource_dataproc_cluster.go b/google/services/dataproc/resource_dataproc_cluster.go index 3ba51381086..553f747447c 100644 --- a/google/services/dataproc/resource_dataproc_cluster.go +++ b/google/services/dataproc/resource_dataproc_cluster.go @@ -215,6 +215,7 @@ func ResourceDataprocCluster() *schema.Resource { }, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), tpgresource.DefaultProviderProject, // User labels are not supported in Dataproc Virtual Cluster tpgresource.SetLabelsDiffWithoutAttributionLabel, @@ -2052,6 +2053,9 @@ by Dataproc`, }, }, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, UseJSONNumber: true, } @@ -3026,6 +3030,11 @@ func expandAccelerators(configured []interface{}) []*dataproc.AcceleratorConfig } func resourceDataprocClusterUpdate(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceDataprocCluster) { + return ResourceDataprocCluster().Read(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -3217,6 +3226,10 @@ func resourceDataprocClusterRead(d *schema.ResourceData, meta interface{}) error return err } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } @@ -3858,6 +3871,13 @@ func ExtractInitTimeout(t string) (int, error) { } func resourceDataprocClusterDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/dataproc/resource_dataproc_cluster_meta.yaml b/google/services/dataproc/resource_dataproc_cluster_meta.yaml index e3790bbd7d4..a7f36b2f7a3 100644 --- a/google/services/dataproc/resource_dataproc_cluster_meta.yaml +++ b/google/services/dataproc/resource_dataproc_cluster_meta.yaml @@ -154,3 +154,5 @@ fields: - api_field: 'virtualClusterConfig.kubernetesClusterConfig.kubernetesSoftwareConfig.componentVersion' - api_field: 'virtualClusterConfig.kubernetesClusterConfig.kubernetesSoftwareConfig.properties' - api_field: 'virtualClusterConfig.stagingBucket' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/dataproc/resource_dataproc_job.go b/google/services/dataproc/resource_dataproc_job.go index 70458402ec6..0c5768b48c8 100644 --- a/google/services/dataproc/resource_dataproc_job.go +++ b/google/services/dataproc/resource_dataproc_job.go @@ -48,6 +48,7 @@ func ResourceDataprocJob() *schema.Resource { }, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), tpgresource.DefaultProviderProject, tpgresource.SetLabelsDiff, ), @@ -229,6 +230,9 @@ func ResourceDataprocJob() *schema.Resource { "pig_config": pigSchema, "sparksql_config": sparkSqlSchema, "presto_config": prestoSchema, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, UseJSONNumber: true, } @@ -429,10 +433,22 @@ func resourceDataprocJobRead(d *schema.ResourceData, meta interface{}) error { return fmt.Errorf("Error setting presto_config: %s", err) } } + + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } func resourceDataprocJobDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/dataproc/resource_dataproc_job_meta.yaml b/google/services/dataproc/resource_dataproc_job_meta.yaml index 75e54371429..038f633a0db 100644 --- a/google/services/dataproc/resource_dataproc_job_meta.yaml +++ b/google/services/dataproc/resource_dataproc_job_meta.yaml @@ -77,3 +77,5 @@ fields: provider_only: true - field: 'wait_for_completion' provider_only: true + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/dataproc/resource_dataproc_session_template.go b/google/services/dataproc/resource_dataproc_session_template.go index 7056fd19e92..5fff4d390c2 100644 --- a/google/services/dataproc/resource_dataproc_session_template.go +++ b/google/services/dataproc/resource_dataproc_session_template.go @@ -116,6 +116,7 @@ func ResourceDataprocSessionTemplate() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -381,6 +382,18 @@ Please refer to the field 'effective_labels' for all of the labels present on th Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -528,6 +541,19 @@ func resourceDataprocSessionTemplateRead(d *schema.ResourceData, meta interface{ log.Printf("[DEBUG] Finished reading DataprocSessionTemplate %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading SessionTemplate: %s", err) } @@ -553,6 +579,19 @@ func resourceDataprocSessionTemplateRead(d *schema.ResourceData, meta interface{ } func resourceDataprocSessionTemplateUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDataprocSessionTemplate().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDataprocSessionTemplateRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -643,6 +682,13 @@ func resourceDataprocSessionTemplateUpdate(d *schema.ResourceData, meta interfac } func resourceDataprocSessionTemplateDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DataprocSessionTemplate without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing SessionTemplate %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/dataproc/resource_dataproc_session_template_generated_meta.yaml b/google/services/dataproc/resource_dataproc_session_template_generated_meta.yaml index f116a772c03..d1f45991990 100644 --- a/google/services/dataproc/resource_dataproc_session_template_generated_meta.yaml +++ b/google/services/dataproc/resource_dataproc_session_template_generated_meta.yaml @@ -38,3 +38,5 @@ fields: provider_only: true - api_field: updateTime - api_field: uuid + - field: deletion_policy + provider_only: true diff --git a/google/services/dataproc/resource_dataproc_workflow_template.go b/google/services/dataproc/resource_dataproc_workflow_template.go index 7dd1a4e7270..9f9a7a80b8e 100644 --- a/google/services/dataproc/resource_dataproc_workflow_template.go +++ b/google/services/dataproc/resource_dataproc_workflow_template.go @@ -48,6 +48,7 @@ func ResourceDataprocWorkflowTemplate() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, tpgresource.SetLabelsDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), SchemaVersion: 1, StateUpgraders: []schema.StateUpgrader{ @@ -163,6 +164,9 @@ func ResourceDataprocWorkflowTemplate() *schema.Resource { Computed: true, Description: "Output only. The time template was last updated.", }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, } } @@ -2261,6 +2265,10 @@ func resourceDataprocWorkflowTemplateRead(d *schema.ResourceData, meta interface return fmt.Errorf("error setting update_time in state: %s", err) } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } func resourceDataprocWorkflowTemplateUpdate(d *schema.ResourceData, meta interface{}) error { @@ -2270,6 +2278,13 @@ func resourceDataprocWorkflowTemplateUpdate(d *schema.ResourceData, meta interfa } func resourceDataprocWorkflowTemplateDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) project, err := tpgresource.GetProject(d, config) if err != nil { diff --git a/google/services/dataproc/resource_dataproc_workflow_template_meta.yaml b/google/services/dataproc/resource_dataproc_workflow_template_meta.yaml index 93454f5234b..b156898f8ab 100644 --- a/google/services/dataproc/resource_dataproc_workflow_template_meta.yaml +++ b/google/services/dataproc/resource_dataproc_workflow_template_meta.yaml @@ -180,3 +180,5 @@ fields: provider_only: true - api_field: 'updateTime' - api_field: 'version' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/dataprocgdc/resource_dataproc_gdc_application_environment.go b/google/services/dataprocgdc/resource_dataproc_gdc_application_environment.go index 24e61f5906c..41690f0f929 100644 --- a/google/services/dataprocgdc/resource_dataproc_gdc_application_environment.go +++ b/google/services/dataprocgdc/resource_dataproc_gdc_application_environment.go @@ -117,6 +117,7 @@ func ResourceDataprocGdcApplicationEnvironment() *schema.Resource { tpgresource.SetLabelsDiff, tpgresource.SetAnnotationsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -259,6 +260,18 @@ Please refer to the field 'effective_labels' for all of the labels present on th Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -415,6 +428,19 @@ func resourceDataprocGdcApplicationEnvironmentRead(d *schema.ResourceData, meta log.Printf("[DEBUG] Finished reading DataprocGdcApplicationEnvironment %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading ApplicationEnvironment: %s", err) } @@ -458,6 +484,19 @@ func resourceDataprocGdcApplicationEnvironmentRead(d *schema.ResourceData, meta } func resourceDataprocGdcApplicationEnvironmentUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDataprocGdcApplicationEnvironment().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDataprocGdcApplicationEnvironmentRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -594,6 +633,13 @@ func resourceDataprocGdcApplicationEnvironmentUpdate(d *schema.ResourceData, met } func resourceDataprocGdcApplicationEnvironmentDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DataprocGdcApplicationEnvironment without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ApplicationEnvironment %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/dataprocgdc/resource_dataproc_gdc_application_environment_generated_meta.yaml b/google/services/dataprocgdc/resource_dataproc_gdc_application_environment_generated_meta.yaml index cbad21a4dcc..ad7a5131bc7 100644 --- a/google/services/dataprocgdc/resource_dataproc_gdc_application_environment_generated_meta.yaml +++ b/google/services/dataprocgdc/resource_dataproc_gdc_application_environment_generated_meta.yaml @@ -30,3 +30,5 @@ fields: provider_only: true - api_field: uid - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/dataprocgdc/resource_dataproc_gdc_service_instance.go b/google/services/dataprocgdc/resource_dataproc_gdc_service_instance.go index 270fde39565..b5bca0cb39e 100644 --- a/google/services/dataprocgdc/resource_dataproc_gdc_service_instance.go +++ b/google/services/dataprocgdc/resource_dataproc_gdc_service_instance.go @@ -116,6 +116,7 @@ func ResourceDataprocGdcServiceInstance() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -285,6 +286,18 @@ Please refer to the field 'effective_labels' for all of the labels present on th Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -446,6 +459,19 @@ func resourceDataprocGdcServiceInstanceRead(d *schema.ResourceData, meta interfa log.Printf("[DEBUG] Finished reading DataprocGdcServiceInstance %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading ServiceInstance: %s", err) } @@ -483,11 +509,18 @@ func resourceDataprocGdcServiceInstanceRead(d *schema.ResourceData, meta interfa } func resourceDataprocGdcServiceInstanceUpdate(d *schema.ResourceData, meta interface{}) error { - // Only the root field "labels", "terraform_labels", and virtual fields are mutable + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable return resourceDataprocGdcServiceInstanceRead(d, meta) } func resourceDataprocGdcServiceInstanceDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DataprocGdcServiceInstance without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ServiceInstance %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/dataprocgdc/resource_dataproc_gdc_service_instance_generated_meta.yaml b/google/services/dataprocgdc/resource_dataproc_gdc_service_instance_generated_meta.yaml index 769394ba84a..819f782fa6d 100644 --- a/google/services/dataprocgdc/resource_dataproc_gdc_service_instance_generated_meta.yaml +++ b/google/services/dataprocgdc/resource_dataproc_gdc_service_instance_generated_meta.yaml @@ -30,3 +30,5 @@ fields: provider_only: true - api_field: uid - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/dataprocgdc/resource_dataproc_gdc_spark_application.go b/google/services/dataprocgdc/resource_dataproc_gdc_spark_application.go index 78d2c4d2970..0f92b686f39 100644 --- a/google/services/dataprocgdc/resource_dataproc_gdc_spark_application.go +++ b/google/services/dataprocgdc/resource_dataproc_gdc_spark_application.go @@ -117,6 +117,7 @@ func ResourceDataprocGdcSparkApplication() *schema.Resource { tpgresource.SetLabelsDiff, tpgresource.SetAnnotationsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -526,6 +527,18 @@ Possible values: Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -734,6 +747,19 @@ func resourceDataprocGdcSparkApplicationRead(d *schema.ResourceData, meta interf log.Printf("[DEBUG] Finished reading DataprocGdcSparkApplication %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading SparkApplication: %s", err) } @@ -777,11 +803,18 @@ func resourceDataprocGdcSparkApplicationRead(d *schema.ResourceData, meta interf } func resourceDataprocGdcSparkApplicationUpdate(d *schema.ResourceData, meta interface{}) error { - // Only the root field "labels", "terraform_labels", and virtual fields are mutable + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable return resourceDataprocGdcSparkApplicationRead(d, meta) } func resourceDataprocGdcSparkApplicationDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DataprocGdcSparkApplication without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing SparkApplication %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/dataprocgdc/resource_dataproc_gdc_spark_application_generated_meta.yaml b/google/services/dataprocgdc/resource_dataproc_gdc_spark_application_generated_meta.yaml index 28c5a20ea10..9f3f2662238 100644 --- a/google/services/dataprocgdc/resource_dataproc_gdc_spark_application_generated_meta.yaml +++ b/google/services/dataprocgdc/resource_dataproc_gdc_spark_application_generated_meta.yaml @@ -57,3 +57,5 @@ fields: - api_field: uid - api_field: updateTime - api_field: version + - field: deletion_policy + provider_only: true diff --git a/google/services/dataprocmetastore/resource_dataproc_metastore_federation.go b/google/services/dataprocmetastore/resource_dataproc_metastore_federation.go index 7c985e4cbd0..48fb71d8114 100644 --- a/google/services/dataprocmetastore/resource_dataproc_metastore_federation.go +++ b/google/services/dataprocmetastore/resource_dataproc_metastore_federation.go @@ -116,6 +116,7 @@ func ResourceDataprocMetastoreFederation() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -266,6 +267,18 @@ or 'terraform destroy' that would delete the federation will fail.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -427,6 +440,18 @@ func resourceDataprocMetastoreFederationRead(d *schema.ResourceData, meta interf return fmt.Errorf("Error setting deletion_protection: %s", err) } } + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Federation: %s", err) } @@ -464,6 +489,19 @@ func resourceDataprocMetastoreFederationRead(d *schema.ResourceData, meta interf } func resourceDataprocMetastoreFederationUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDataprocMetastoreFederation().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDataprocMetastoreFederationRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -572,6 +610,13 @@ func resourceDataprocMetastoreFederationUpdate(d *schema.ResourceData, meta inte } func resourceDataprocMetastoreFederationDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DataprocMetastoreFederation without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Federation %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/dataprocmetastore/resource_dataproc_metastore_federation_generated_meta.yaml b/google/services/dataprocmetastore/resource_dataproc_metastore_federation_generated_meta.yaml index f97c8ac1695..fa583a690f5 100644 --- a/google/services/dataprocmetastore/resource_dataproc_metastore_federation_generated_meta.yaml +++ b/google/services/dataprocmetastore/resource_dataproc_metastore_federation_generated_meta.yaml @@ -33,3 +33,5 @@ fields: - api_field: uid - api_field: updateTime - api_field: version + - field: deletion_policy + provider_only: true diff --git a/google/services/dataprocmetastore/resource_dataproc_metastore_service.go b/google/services/dataprocmetastore/resource_dataproc_metastore_service.go index 4ef3761e825..3733448e41e 100644 --- a/google/services/dataprocmetastore/resource_dataproc_metastore_service.go +++ b/google/services/dataprocmetastore/resource_dataproc_metastore_service.go @@ -116,6 +116,7 @@ func ResourceDataprocMetastoreService() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -594,6 +595,18 @@ Keys must be in the format tagKeys/{tag_key_id}, and values are in the format ta Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -821,6 +834,19 @@ func resourceDataprocMetastoreServiceRead(d *schema.ResourceData, meta interface log.Printf("[DEBUG] Finished reading DataprocMetastoreService %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Service: %s", err) } @@ -858,6 +884,19 @@ func resourceDataprocMetastoreServiceRead(d *schema.ResourceData, meta interface } func resourceDataprocMetastoreServiceUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDataprocMetastoreService().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDataprocMetastoreServiceRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1056,6 +1095,13 @@ func resourceDataprocMetastoreServiceUpdate(d *schema.ResourceData, meta interfa } func resourceDataprocMetastoreServiceDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DataprocMetastoreService without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Service %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/dataprocmetastore/resource_dataproc_metastore_service_generated_meta.yaml b/google/services/dataprocmetastore/resource_dataproc_metastore_service_generated_meta.yaml index 216bed03af7..df664d84d04 100644 --- a/google/services/dataprocmetastore/resource_dataproc_metastore_service_generated_meta.yaml +++ b/google/services/dataprocmetastore/resource_dataproc_metastore_service_generated_meta.yaml @@ -59,3 +59,5 @@ fields: - api_field: tier - api_field: uid - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/datastream/resource_datastream_connection_profile.go b/google/services/datastream/resource_datastream_connection_profile.go index 3a317314641..56366560b36 100644 --- a/google/services/datastream/resource_datastream_connection_profile.go +++ b/google/services/datastream/resource_datastream_connection_profile.go @@ -127,6 +127,7 @@ func ResourceDatastreamConnectionProfile() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -738,6 +739,18 @@ and the server identity will be authenticated.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -940,6 +953,19 @@ func resourceDatastreamConnectionProfileRead(d *schema.ResourceData, meta interf log.Printf("[DEBUG] Finished reading DatastreamConnectionProfile %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading ConnectionProfile: %s", err) } @@ -977,6 +1003,19 @@ func resourceDatastreamConnectionProfileRead(d *schema.ResourceData, meta interf } func resourceDatastreamConnectionProfileUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDatastreamConnectionProfile().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDatastreamConnectionProfileRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1203,6 +1242,13 @@ func resourceDatastreamConnectionProfileUpdate(d *schema.ResourceData, meta inte } func resourceDatastreamConnectionProfileDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DatastreamConnectionProfile without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ConnectionProfile %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/datastream/resource_datastream_connection_profile_generated_meta.yaml b/google/services/datastream/resource_datastream_connection_profile_generated_meta.yaml index 3aa4c3f7b48..61819adbf85 100644 --- a/google/services/datastream/resource_datastream_connection_profile_generated_meta.yaml +++ b/google/services/datastream/resource_datastream_connection_profile_generated_meta.yaml @@ -78,3 +78,5 @@ fields: - api_field: sqlServerProfile.username - field: terraform_labels provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/datastream/resource_datastream_private_connection.go b/google/services/datastream/resource_datastream_private_connection.go index 4de88fc2982..21033e1a3f1 100644 --- a/google/services/datastream/resource_datastream_private_connection.go +++ b/google/services/datastream/resource_datastream_private_connection.go @@ -157,6 +157,7 @@ func ResourceDatastreamPrivateConnection() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("FORCE"), ), Identity: &schema.ResourceIdentity{ @@ -312,21 +313,18 @@ Format: projects/{project}/global/{networks}/{name}`, and default labels configured on the provider.`, Elem: &schema.Schema{Type: schema.TypeString}, }, - "deletion_policy": { - Type: schema.TypeString, - Optional: true, - Description: `The deletion policy for the private connection. Setting 'FORCE' will also delete any child -routes that belong to this private connection. Setting 'DEFAULT' will fail the delete if -child routes exist. Defaults to 'FORCE' for backwards compatibility. -Possible values: 'DEFAULT', 'FORCE'.`, - Default: "FORCE", - }, "project": { Type: schema.TypeString, Optional: true, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `This field uses a custom implementation please refer to documentation under /hashicorp/terraform-provider-google-beta/website/docs/r/datastream_private_connection.html.markdown for specifics`, + }, }, UseJSONNumber: true, } @@ -488,8 +486,15 @@ func resourceDatastreamPrivateConnectionRead(d *schema.ResourceData, meta interf // Explicitly set virtual fields to default values if unset if _, ok := d.GetOkExists("deletion_policy"); !ok { - if err := d.Set("deletion_policy", "FORCE"); err != nil { - return fmt.Errorf("Error setting deletion_policy: %s", err) + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "FORCE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } } } if err := d.Set("project", project); err != nil { @@ -529,11 +534,18 @@ func resourceDatastreamPrivateConnectionRead(d *schema.ResourceData, meta interf } func resourceDatastreamPrivateConnectionUpdate(d *schema.ResourceData, meta interface{}) error { - // Only the root field "labels", "terraform_labels", and virtual fields are mutable + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable return resourceDatastreamPrivateConnectionRead(d, meta) } func resourceDatastreamPrivateConnectionDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DatastreamPrivateConnection without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing PrivateConnection %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -613,9 +625,6 @@ func resourceDatastreamPrivateConnectionImport(d *schema.ResourceData, meta inte d.SetId(id) // Explicitly set virtual fields to default values on import - if err := d.Set("deletion_policy", "FORCE"); err != nil { - return nil, fmt.Errorf("Error setting deletion_policy: %s", err) - } if err := waitForPrivateConnectionReady(d, config, d.Timeout(schema.TimeoutCreate)-time.Minute); err != nil { return nil, fmt.Errorf("Error waiting for PrivateConnection %q to be CREATED during importing: %q", d.Get("name").(string), err) } diff --git a/google/services/datastream/resource_datastream_private_connection_generated_meta.yaml b/google/services/datastream/resource_datastream_private_connection_generated_meta.yaml index 608b5aaacb4..376e73cf08d 100644 --- a/google/services/datastream/resource_datastream_private_connection_generated_meta.yaml +++ b/google/services/datastream/resource_datastream_private_connection_generated_meta.yaml @@ -9,8 +9,6 @@ api_resource_type_kind: PrivateConnection fields: - field: create_without_validation provider_only: true - - field: deletion_policy - provider_only: true - api_field: displayName - field: effective_labels provider_only: true @@ -28,3 +26,5 @@ fields: provider_only: true - api_field: vpcPeeringConfig.subnet - api_field: vpcPeeringConfig.vpc + - field: deletion_policy + provider_only: true diff --git a/google/services/datastream/resource_datastream_stream.go b/google/services/datastream/resource_datastream_stream.go index 7c74a3a74fd..95cda9a24e2 100644 --- a/google/services/datastream/resource_datastream_stream.go +++ b/google/services/datastream/resource_datastream_stream.go @@ -182,6 +182,7 @@ func ResourceDatastreamStream() *schema.Resource { resourceDatastreamStreamCustomDiff, tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -2653,6 +2654,18 @@ Possible values: NOT_STARTED, RUNNING, PAUSED. Default: NOT_STARTED`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -2854,6 +2867,18 @@ func resourceDatastreamStreamRead(d *schema.ResourceData, meta interface{}) erro return fmt.Errorf("Error setting desired_state: %s", err) } } + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Stream: %s", err) } @@ -2891,6 +2916,19 @@ func resourceDatastreamStreamRead(d *schema.ResourceData, meta interface{}) erro } func resourceDatastreamStreamUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDatastreamStream().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDatastreamStreamRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -3089,6 +3127,13 @@ func resourceDatastreamStreamUpdate(d *schema.ResourceData, meta interface{}) er } func resourceDatastreamStreamDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DatastreamStream without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Stream %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/datastream/resource_datastream_stream_generated_meta.yaml b/google/services/datastream/resource_datastream_stream_generated_meta.yaml index c884bffbb24..90c5e3e2781 100644 --- a/google/services/datastream/resource_datastream_stream_generated_meta.yaml +++ b/google/services/datastream/resource_datastream_stream_generated_meta.yaml @@ -244,3 +244,5 @@ fields: provider_only: true - field: terraform_labels provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/deploymentmanager/resource_deployment_manager_deployment.go b/google/services/deploymentmanager/resource_deployment_manager_deployment.go index 204f9bc53e4..9a693fdc335 100644 --- a/google/services/deploymentmanager/resource_deployment_manager_deployment.go +++ b/google/services/deploymentmanager/resource_deployment_manager_deployment.go @@ -141,6 +141,7 @@ func ResourceDeploymentManagerDeployment() *schema.Resource { CustomizeDiff: customdiff.All( customDiffDeploymentManagerDeployment, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -289,6 +290,18 @@ was successfully deployed.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -457,6 +470,19 @@ func resourceDeploymentManagerDeploymentRead(d *schema.ResourceData, meta interf log.Printf("[DEBUG] Finished reading DeploymentManagerDeployment %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Deployment: %s", err) } @@ -488,6 +514,19 @@ func resourceDeploymentManagerDeploymentRead(d *schema.ResourceData, meta interf } func resourceDeploymentManagerDeploymentUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDeploymentManagerDeployment().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDeploymentManagerDeploymentRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -667,6 +706,13 @@ func resourceDeploymentManagerDeploymentUpdate(d *schema.ResourceData, meta inte } func resourceDeploymentManagerDeploymentDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DeploymentManagerDeployment without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Deployment %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/deploymentmanager/resource_deployment_manager_deployment_generated_meta.yaml b/google/services/deploymentmanager/resource_deployment_manager_deployment_generated_meta.yaml index afcf132d740..68ed0fd8ea4 100644 --- a/google/services/deploymentmanager/resource_deployment_manager_deployment_generated_meta.yaml +++ b/google/services/deploymentmanager/resource_deployment_manager_deployment_generated_meta.yaml @@ -24,3 +24,5 @@ fields: - api_field: target.config.content - api_field: target.imports.content - api_field: target.imports.name + - field: deletion_policy + provider_only: true diff --git a/google/services/developerconnect/resource_developer_connect_account_connector.go b/google/services/developerconnect/resource_developer_connect_account_connector.go index 89d2ab32d5e..f7315d9a6bd 100644 --- a/google/services/developerconnect/resource_developer_connect_account_connector.go +++ b/google/services/developerconnect/resource_developer_connect_account_connector.go @@ -117,6 +117,7 @@ func ResourceDeveloperConnectAccountConnector() *schema.Resource { tpgresource.SetAnnotationsDiff, tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -368,6 +369,18 @@ behalf of the user configured under the account connector.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -535,6 +548,19 @@ func resourceDeveloperConnectAccountConnectorRead(d *schema.ResourceData, meta i log.Printf("[DEBUG] Finished reading DeveloperConnectAccountConnector %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading AccountConnector: %s", err) } @@ -572,6 +598,19 @@ func resourceDeveloperConnectAccountConnectorRead(d *schema.ResourceData, meta i } func resourceDeveloperConnectAccountConnectorUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDeveloperConnectAccountConnector().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDeveloperConnectAccountConnectorRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -720,6 +759,13 @@ func resourceDeveloperConnectAccountConnectorUpdate(d *schema.ResourceData, meta } func resourceDeveloperConnectAccountConnectorDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DeveloperConnectAccountConnector without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing AccountConnector %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/developerconnect/resource_developer_connect_account_connector_generated_meta.yaml b/google/services/developerconnect/resource_developer_connect_account_connector_generated_meta.yaml index de0874e2168..94f1e3155bf 100644 --- a/google/services/developerconnect/resource_developer_connect_account_connector_generated_meta.yaml +++ b/google/services/developerconnect/resource_developer_connect_account_connector_generated_meta.yaml @@ -39,3 +39,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/developerconnect/resource_developer_connect_connection.go b/google/services/developerconnect/resource_developer_connect_connection.go index 091d40c918a..c4b95ea362a 100644 --- a/google/services/developerconnect/resource_developer_connect_connection.go +++ b/google/services/developerconnect/resource_developer_connect_connection.go @@ -117,6 +117,7 @@ func ResourceDeveloperConnectConnection() *schema.Resource { tpgresource.SetLabelsDiff, tpgresource.SetAnnotationsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -833,6 +834,18 @@ background.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -1036,6 +1049,19 @@ func resourceDeveloperConnectConnectionRead(d *schema.ResourceData, meta interfa log.Printf("[DEBUG] Finished reading DeveloperConnectConnection %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Connection: %s", err) } @@ -1073,6 +1099,19 @@ func resourceDeveloperConnectConnectionRead(d *schema.ResourceData, meta interfa } func resourceDeveloperConnectConnectionUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDeveloperConnectConnection().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDeveloperConnectConnectionRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1281,6 +1320,13 @@ func resourceDeveloperConnectConnectionUpdate(d *schema.ResourceData, meta inter } func resourceDeveloperConnectConnectionDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DeveloperConnectConnection without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Connection %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/developerconnect/resource_developer_connect_connection_generated_meta.yaml b/google/services/developerconnect/resource_developer_connect_connection_generated_meta.yaml index 1a7e47172a0..cc99d444a24 100644 --- a/google/services/developerconnect/resource_developer_connect_connection_generated_meta.yaml +++ b/google/services/developerconnect/resource_developer_connect_connection_generated_meta.yaml @@ -82,3 +82,5 @@ fields: provider_only: true - api_field: uid - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/developerconnect/resource_developer_connect_git_repository_link.go b/google/services/developerconnect/resource_developer_connect_git_repository_link.go index 3f01fc40201..609e6c98db2 100644 --- a/google/services/developerconnect/resource_developer_connect_git_repository_link.go +++ b/google/services/developerconnect/resource_developer_connect_git_repository_link.go @@ -117,6 +117,7 @@ func ResourceDeveloperConnectGitRepositoryLink() *schema.Resource { tpgresource.SetLabelsDiff, tpgresource.SetAnnotationsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -259,6 +260,18 @@ background.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -419,6 +432,19 @@ func resourceDeveloperConnectGitRepositoryLinkRead(d *schema.ResourceData, meta log.Printf("[DEBUG] Finished reading DeveloperConnectGitRepositoryLink %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading GitRepositoryLink: %s", err) } @@ -462,11 +488,18 @@ func resourceDeveloperConnectGitRepositoryLinkRead(d *schema.ResourceData, meta } func resourceDeveloperConnectGitRepositoryLinkUpdate(d *schema.ResourceData, meta interface{}) error { - // Only the root field "labels", "terraform_labels", and virtual fields are mutable + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable return resourceDeveloperConnectGitRepositoryLinkRead(d, meta) } func resourceDeveloperConnectGitRepositoryLinkDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DeveloperConnectGitRepositoryLink without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing GitRepositoryLink %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/developerconnect/resource_developer_connect_git_repository_link_generated_meta.yaml b/google/services/developerconnect/resource_developer_connect_git_repository_link_generated_meta.yaml index bf772bdaa4a..c62b0a420a6 100644 --- a/google/services/developerconnect/resource_developer_connect_git_repository_link_generated_meta.yaml +++ b/google/services/developerconnect/resource_developer_connect_git_repository_link_generated_meta.yaml @@ -30,3 +30,5 @@ fields: provider_only: true - api_field: uid - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/developerconnect/resource_developer_connect_insights_config.go b/google/services/developerconnect/resource_developer_connect_insights_config.go index 2233c728f12..0516949c76c 100644 --- a/google/services/developerconnect/resource_developer_connect_insights_config.go +++ b/google/services/developerconnect/resource_developer_connect_insights_config.go @@ -117,6 +117,7 @@ func ResourceDeveloperConnectInsightsConfig() *schema.Resource { tpgresource.SetAnnotationsDiff, tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -436,6 +437,18 @@ ERROR`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -597,6 +610,19 @@ func resourceDeveloperConnectInsightsConfigRead(d *schema.ResourceData, meta int log.Printf("[DEBUG] Finished reading DeveloperConnectInsightsConfig %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading InsightsConfig: %s", err) } @@ -634,6 +660,19 @@ func resourceDeveloperConnectInsightsConfigRead(d *schema.ResourceData, meta int } func resourceDeveloperConnectInsightsConfigUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDeveloperConnectInsightsConfig().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDeveloperConnectInsightsConfigRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -762,6 +801,13 @@ func resourceDeveloperConnectInsightsConfigUpdate(d *schema.ResourceData, meta i } func resourceDeveloperConnectInsightsConfigDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DeveloperConnectInsightsConfig without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing InsightsConfig %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/developerconnect/resource_developer_connect_insights_config_generated_meta.yaml b/google/services/developerconnect/resource_developer_connect_insights_config_generated_meta.yaml index 08784037385..6a5ed731f22 100644 --- a/google/services/developerconnect/resource_developer_connect_insights_config_generated_meta.yaml +++ b/google/services/developerconnect/resource_developer_connect_insights_config_generated_meta.yaml @@ -42,3 +42,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/dialogflow/resource_dialogflow_agent.go b/google/services/dialogflow/resource_dialogflow_agent.go index 8c700c3efa8..072ec59b9e7 100644 --- a/google/services/dialogflow/resource_dialogflow_agent.go +++ b/google/services/dialogflow/resource_dialogflow_agent.go @@ -115,6 +115,7 @@ func ResourceDialogflowAgent() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -232,6 +233,18 @@ the [avatarUri] field can be used.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -409,6 +422,19 @@ func resourceDialogflowAgentRead(d *schema.ResourceData, meta interface{}) error log.Printf("[DEBUG] Finished reading DialogflowAgent %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Agent: %s", err) } @@ -434,6 +460,19 @@ func resourceDialogflowAgentRead(d *schema.ResourceData, meta interface{}) error } func resourceDialogflowAgentUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDialogflowAgent().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDialogflowAgentRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -560,6 +599,13 @@ func resourceDialogflowAgentUpdate(d *schema.ResourceData, meta interface{}) err } func resourceDialogflowAgentDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DialogflowAgent without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Agent %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/dialogflow/resource_dialogflow_agent_generated_meta.yaml b/google/services/dialogflow/resource_dialogflow_agent_generated_meta.yaml index 03f3b8a9e4e..aec721aa774 100644 --- a/google/services/dialogflow/resource_dialogflow_agent_generated_meta.yaml +++ b/google/services/dialogflow/resource_dialogflow_agent_generated_meta.yaml @@ -20,3 +20,5 @@ fields: - api_field: supportedLanguageCodes - api_field: tier - api_field: timeZone + - field: deletion_policy + provider_only: true diff --git a/google/services/dialogflow/resource_dialogflow_conversation_profile.go b/google/services/dialogflow/resource_dialogflow_conversation_profile.go index f412283b6ad..86b9b387bad 100644 --- a/google/services/dialogflow/resource_dialogflow_conversation_profile.go +++ b/google/services/dialogflow/resource_dialogflow_conversation_profile.go @@ -115,6 +115,7 @@ func ResourceDialogflowConversationProfile() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -970,6 +971,18 @@ Leave this field unspecified to use Agent Speech settings for model selection.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -1207,6 +1220,19 @@ func resourceDialogflowConversationProfileRead(d *schema.ResourceData, meta inte log.Printf("[DEBUG] Finished reading DialogflowConversationProfile %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading ConversationProfile: %s", err) } @@ -1232,6 +1258,19 @@ func resourceDialogflowConversationProfileRead(d *schema.ResourceData, meta inte } func resourceDialogflowConversationProfileUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDialogflowConversationProfile().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDialogflowConversationProfileRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1445,6 +1484,13 @@ func resourceDialogflowConversationProfileUpdate(d *schema.ResourceData, meta in } func resourceDialogflowConversationProfileDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DialogflowConversationProfile without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ConversationProfile %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/dialogflow/resource_dialogflow_conversation_profile_generated_meta.yaml b/google/services/dialogflow/resource_dialogflow_conversation_profile_generated_meta.yaml index 7219432bd5e..6543d2ecba6 100644 --- a/google/services/dialogflow/resource_dialogflow_conversation_profile_generated_meta.yaml +++ b/google/services/dialogflow/resource_dialogflow_conversation_profile_generated_meta.yaml @@ -87,3 +87,5 @@ fields: - api_field: ttsConfig.voice.name - api_field: ttsConfig.voice.ssmlGender - api_field: ttsConfig.volumeGainDb + - field: deletion_policy + provider_only: true diff --git a/google/services/dialogflow/resource_dialogflow_entity_type.go b/google/services/dialogflow/resource_dialogflow_entity_type.go index 805ba4908d2..e7fef7518fc 100644 --- a/google/services/dialogflow/resource_dialogflow_entity_type.go +++ b/google/services/dialogflow/resource_dialogflow_entity_type.go @@ -115,6 +115,7 @@ func ResourceDialogflowEntityType() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -195,6 +196,18 @@ Format: projects//agent/entityTypes/.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -336,6 +349,19 @@ func resourceDialogflowEntityTypeRead(d *schema.ResourceData, meta interface{}) log.Printf("[DEBUG] Finished reading DialogflowEntityType %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading EntityType: %s", err) } @@ -361,6 +387,19 @@ func resourceDialogflowEntityTypeRead(d *schema.ResourceData, meta interface{}) } func resourceDialogflowEntityTypeUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDialogflowEntityType().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDialogflowEntityTypeRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -445,6 +484,13 @@ func resourceDialogflowEntityTypeUpdate(d *schema.ResourceData, meta interface{} } func resourceDialogflowEntityTypeDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DialogflowEntityType without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing EntityType %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/dialogflow/resource_dialogflow_entity_type_generated_meta.yaml b/google/services/dialogflow/resource_dialogflow_entity_type_generated_meta.yaml index fdb5b07748d..574474a93d5 100644 --- a/google/services/dialogflow/resource_dialogflow_entity_type_generated_meta.yaml +++ b/google/services/dialogflow/resource_dialogflow_entity_type_generated_meta.yaml @@ -13,3 +13,5 @@ fields: - api_field: entities.value - api_field: kind - api_field: name + - field: deletion_policy + provider_only: true diff --git a/google/services/dialogflow/resource_dialogflow_environment.go b/google/services/dialogflow/resource_dialogflow_environment.go index bfe9b356581..3e46fa96804 100644 --- a/google/services/dialogflow/resource_dialogflow_environment.go +++ b/google/services/dialogflow/resource_dialogflow_environment.go @@ -115,6 +115,7 @@ func ResourceDialogflowEnvironment() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -331,6 +332,18 @@ func ResourceDialogflowEnvironment() *schema.Resource { Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -476,6 +489,19 @@ func resourceDialogflowEnvironmentRead(d *schema.ResourceData, meta interface{}) log.Printf("[DEBUG] Finished reading DialogflowEnvironment %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Environment: %s", err) } @@ -513,6 +539,19 @@ func resourceDialogflowEnvironmentRead(d *schema.ResourceData, meta interface{}) } func resourceDialogflowEnvironmentUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDialogflowEnvironment().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDialogflowEnvironmentRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -634,6 +673,13 @@ func resourceDialogflowEnvironmentUpdate(d *schema.ResourceData, meta interface{ } func resourceDialogflowEnvironmentDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DialogflowEnvironment without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Environment %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/dialogflow/resource_dialogflow_environment_generated_meta.yaml b/google/services/dialogflow/resource_dialogflow_environment_generated_meta.yaml index a17b15a6f97..35ec2771e9a 100644 --- a/google/services/dialogflow/resource_dialogflow_environment_generated_meta.yaml +++ b/google/services/dialogflow/resource_dialogflow_environment_generated_meta.yaml @@ -39,3 +39,5 @@ fields: field: text_to_speech_settings.synthesize_speech_configs.voice.ssml_gender - api_field: textToSpeechSettings.synthesizeSpeechConfigs.value.volumeGainDb field: text_to_speech_settings.synthesize_speech_configs.volume_gain_db + - field: deletion_policy + provider_only: true diff --git a/google/services/dialogflow/resource_dialogflow_fulfillment.go b/google/services/dialogflow/resource_dialogflow_fulfillment.go index e6d832466ff..fb829769e73 100644 --- a/google/services/dialogflow/resource_dialogflow_fulfillment.go +++ b/google/services/dialogflow/resource_dialogflow_fulfillment.go @@ -115,6 +115,7 @@ func ResourceDialogflowFulfillment() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -202,6 +203,18 @@ Format: projects//agent/fulfillment - projects//location Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -343,6 +356,19 @@ func resourceDialogflowFulfillmentRead(d *schema.ResourceData, meta interface{}) log.Printf("[DEBUG] Finished reading DialogflowFulfillment %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Fulfillment: %s", err) } @@ -368,6 +394,19 @@ func resourceDialogflowFulfillmentRead(d *schema.ResourceData, meta interface{}) } func resourceDialogflowFulfillmentUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDialogflowFulfillment().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDialogflowFulfillmentRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -479,6 +518,13 @@ func resourceDialogflowFulfillmentUpdate(d *schema.ResourceData, meta interface{ } func resourceDialogflowFulfillmentDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DialogflowFulfillment without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Fulfillment %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/dialogflow/resource_dialogflow_fulfillment_generated_meta.yaml b/google/services/dialogflow/resource_dialogflow_fulfillment_generated_meta.yaml index 2369c455941..aa315153350 100644 --- a/google/services/dialogflow/resource_dialogflow_fulfillment_generated_meta.yaml +++ b/google/services/dialogflow/resource_dialogflow_fulfillment_generated_meta.yaml @@ -15,3 +15,5 @@ fields: - api_field: genericWebService.uri - api_field: genericWebService.username - api_field: name + - field: deletion_policy + provider_only: true diff --git a/google/services/dialogflow/resource_dialogflow_generator.go b/google/services/dialogflow/resource_dialogflow_generator.go index 7d3edf91c0f..0b3cebddfc1 100644 --- a/google/services/dialogflow/resource_dialogflow_generator.go +++ b/google/services/dialogflow/resource_dialogflow_generator.go @@ -115,6 +115,7 @@ func ResourceDialogflowGenerator() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -384,6 +385,18 @@ func ResourceDialogflowGenerator() *schema.Resource { Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -589,6 +602,19 @@ func resourceDialogflowGeneratorRead(d *schema.ResourceData, meta interface{}) e log.Printf("[DEBUG] Finished reading DialogflowGenerator %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Generator: %s", err) } @@ -626,6 +652,19 @@ func resourceDialogflowGeneratorRead(d *schema.ResourceData, meta interface{}) e } func resourceDialogflowGeneratorUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDialogflowGenerator().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDialogflowGeneratorRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -779,6 +818,13 @@ func resourceDialogflowGeneratorUpdate(d *schema.ResourceData, meta interface{}) } func resourceDialogflowGeneratorDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DialogflowGenerator without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Generator %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/dialogflow/resource_dialogflow_generator_generated_meta.yaml b/google/services/dialogflow/resource_dialogflow_generator_generated_meta.yaml index 0cd3656ce8c..95b7beaacae 100644 --- a/google/services/dialogflow/resource_dialogflow_generator_generated_meta.yaml +++ b/google/services/dialogflow/resource_dialogflow_generator_generated_meta.yaml @@ -33,3 +33,5 @@ fields: - api_field: summarizationContext.summarizationSections.type - api_field: summarizationContext.version - api_field: triggerEvent + - field: deletion_policy + provider_only: true diff --git a/google/services/dialogflow/resource_dialogflow_intent.go b/google/services/dialogflow/resource_dialogflow_intent.go index 3808fd76b98..dacfad94d73 100644 --- a/google/services/dialogflow/resource_dialogflow_intent.go +++ b/google/services/dialogflow/resource_dialogflow_intent.go @@ -115,6 +115,7 @@ func ResourceDialogflowIntent() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -262,6 +263,18 @@ Format: projects//agent/intents/.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -445,6 +458,19 @@ func resourceDialogflowIntentRead(d *schema.ResourceData, meta interface{}) erro log.Printf("[DEBUG] Finished reading DialogflowIntent %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Intent: %s", err) } @@ -470,6 +496,19 @@ func resourceDialogflowIntentRead(d *schema.ResourceData, meta interface{}) erro } func resourceDialogflowIntentUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDialogflowIntent().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDialogflowIntentRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -590,6 +629,13 @@ func resourceDialogflowIntentUpdate(d *schema.ResourceData, meta interface{}) er } func resourceDialogflowIntentDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DialogflowIntent without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Intent %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/dialogflow/resource_dialogflow_intent_generated_meta.yaml b/google/services/dialogflow/resource_dialogflow_intent_generated_meta.yaml index 7be6fa1dfc8..48c9e7bfa39 100644 --- a/google/services/dialogflow/resource_dialogflow_intent_generated_meta.yaml +++ b/google/services/dialogflow/resource_dialogflow_intent_generated_meta.yaml @@ -22,3 +22,5 @@ fields: - api_field: resetContexts - api_field: rootFollowupIntentName - api_field: webhookState + - field: deletion_policy + provider_only: true diff --git a/google/services/dialogflow/resource_dialogflow_version.go b/google/services/dialogflow/resource_dialogflow_version.go index c419c076bf6..cbaba107f4d 100644 --- a/google/services/dialogflow/resource_dialogflow_version.go +++ b/google/services/dialogflow/resource_dialogflow_version.go @@ -160,6 +160,19 @@ Format: projects//agent.`, Computed: true, Description: `The sequential number of this version.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -276,6 +289,20 @@ func resourceDialogflowVersionRead(d *schema.ResourceData, meta interface{}) err log.Printf("[DEBUG] Finished reading DialogflowVersion %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceDialogflowVersionFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -303,6 +330,19 @@ func resourceDialogflowVersionRead(d *schema.ResourceData, meta interface{}) err } func resourceDialogflowVersionUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDialogflowVersion().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDialogflowVersionRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -383,6 +423,13 @@ func resourceDialogflowVersionUpdate(d *schema.ResourceData, meta interface{}) e } func resourceDialogflowVersionDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DialogflowVersion without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Version %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/dialogflow/resource_dialogflow_version_generated_meta.yaml b/google/services/dialogflow/resource_dialogflow_version_generated_meta.yaml index 625c5fa370a..c30612da7d7 100644 --- a/google/services/dialogflow/resource_dialogflow_version_generated_meta.yaml +++ b/google/services/dialogflow/resource_dialogflow_version_generated_meta.yaml @@ -13,3 +13,5 @@ fields: provider_only: true - api_field: status - api_field: versionNumber + - field: deletion_policy + provider_only: true diff --git a/google/services/dialogflowcx/resource_dialogflow_cx_agent.go b/google/services/dialogflowcx/resource_dialogflow_cx_agent.go index fe03a8b3aa2..80f1b81adf6 100644 --- a/google/services/dialogflowcx/resource_dialogflow_cx_agent.go +++ b/google/services/dialogflowcx/resource_dialogflow_cx_agent.go @@ -115,6 +115,7 @@ func ResourceDialogflowCXAgent() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -550,6 +551,18 @@ The ID of the implicitly created engine is stored in the 'genAppBuilderSettings' Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -803,6 +816,18 @@ func resourceDialogflowCXAgentRead(d *schema.ResourceData, meta interface{}) err return fmt.Errorf("Error setting delete_chat_engine_on_destroy: %s", err) } } + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Agent: %s", err) } @@ -840,6 +865,19 @@ func resourceDialogflowCXAgentRead(d *schema.ResourceData, meta interface{}) err } func resourceDialogflowCXAgentUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDialogflowCXAgent().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDialogflowCXAgentRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1111,6 +1149,13 @@ func resourceDialogflowCXAgentUpdate(d *schema.ResourceData, meta interface{}) e } func resourceDialogflowCXAgentDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DialogflowCXAgent without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Agent %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/dialogflowcx/resource_dialogflow_cx_agent_generated_meta.yaml b/google/services/dialogflowcx/resource_dialogflow_cx_agent_generated_meta.yaml index 61a46826bd8..a1a7f0393d4 100644 --- a/google/services/dialogflowcx/resource_dialogflow_cx_agent_generated_meta.yaml +++ b/google/services/dialogflowcx/resource_dialogflow_cx_agent_generated_meta.yaml @@ -53,3 +53,5 @@ fields: - api_field: textToSpeechSettings.synthesizeSpeechConfigs json: true - api_field: timeZone + - field: deletion_policy + provider_only: true diff --git a/google/services/dialogflowcx/resource_dialogflow_cx_entity_type.go b/google/services/dialogflowcx/resource_dialogflow_cx_entity_type.go index 0981da03bdd..68e5cb681df 100644 --- a/google/services/dialogflowcx/resource_dialogflow_cx_entity_type.go +++ b/google/services/dialogflowcx/resource_dialogflow_cx_entity_type.go @@ -229,6 +229,19 @@ Format: projects//locations//agents/.`, Description: `The unique identifier of the entity type. Format: projects//locations//agents//entityTypes/.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -421,6 +434,20 @@ func resourceDialogflowCXEntityTypeRead(d *schema.ResourceData, meta interface{} log.Printf("[DEBUG] Finished reading DialogflowCXEntityType %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceDialogflowCXEntityTypeFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -448,6 +475,19 @@ func resourceDialogflowCXEntityTypeRead(d *schema.ResourceData, meta interface{} } func resourceDialogflowCXEntityTypeUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDialogflowCXEntityType().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDialogflowCXEntityTypeRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -608,6 +648,13 @@ func resourceDialogflowCXEntityTypeUpdate(d *schema.ResourceData, meta interface } func resourceDialogflowCXEntityTypeDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DialogflowCXEntityType without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing EntityType %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/dialogflowcx/resource_dialogflow_cx_entity_type_generated_meta.yaml b/google/services/dialogflowcx/resource_dialogflow_cx_entity_type_generated_meta.yaml index 8e015177c75..3faefb71fef 100644 --- a/google/services/dialogflowcx/resource_dialogflow_cx_entity_type_generated_meta.yaml +++ b/google/services/dialogflowcx/resource_dialogflow_cx_entity_type_generated_meta.yaml @@ -20,3 +20,5 @@ fields: - field: parent provider_only: true - api_field: redact + - field: deletion_policy + provider_only: true diff --git a/google/services/dialogflowcx/resource_dialogflow_cx_environment.go b/google/services/dialogflowcx/resource_dialogflow_cx_environment.go index d63a202a82b..6fbed8ae004 100644 --- a/google/services/dialogflowcx/resource_dialogflow_cx_environment.go +++ b/google/services/dialogflowcx/resource_dialogflow_cx_environment.go @@ -115,6 +115,7 @@ func ResourceDialogflowCXEnvironment() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -180,6 +181,19 @@ Format: projects//locations//agents/.`, Computed: true, Description: `Update time of this environment. A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -366,6 +380,20 @@ func resourceDialogflowCXEnvironmentRead(d *schema.ResourceData, meta interface{ log.Printf("[DEBUG] Finished reading DialogflowCXEnvironment %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceDialogflowCXEnvironmentFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -393,6 +421,19 @@ func resourceDialogflowCXEnvironmentRead(d *schema.ResourceData, meta interface{ } func resourceDialogflowCXEnvironmentUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDialogflowCXEnvironment().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDialogflowCXEnvironmentRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -520,6 +561,13 @@ func resourceDialogflowCXEnvironmentUpdate(d *schema.ResourceData, meta interfac } func resourceDialogflowCXEnvironmentDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DialogflowCXEnvironment without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Environment %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/dialogflowcx/resource_dialogflow_cx_environment_generated_meta.yaml b/google/services/dialogflowcx/resource_dialogflow_cx_environment_generated_meta.yaml index cd20a9216a5..2adb572ff6f 100644 --- a/google/services/dialogflowcx/resource_dialogflow_cx_environment_generated_meta.yaml +++ b/google/services/dialogflowcx/resource_dialogflow_cx_environment_generated_meta.yaml @@ -14,3 +14,5 @@ fields: provider_only: true - api_field: updateTime - api_field: versionConfigs.version + - field: deletion_policy + provider_only: true diff --git a/google/services/dialogflowcx/resource_dialogflow_cx_flow.go b/google/services/dialogflowcx/resource_dialogflow_cx_flow.go index de68e67ca2a..b9408812393 100644 --- a/google/services/dialogflowcx/resource_dialogflow_cx_flow.go +++ b/google/services/dialogflowcx/resource_dialogflow_cx_flow.go @@ -1305,6 +1305,19 @@ The Default Start Flow cannot be deleted; deleting the 'google_dialogflow_cx_flo ~> Avoid having multiple 'google_dialogflow_cx_flow' resources linked to the same agent with 'is_default_start_flow = true' because they will compete to control a single Default Start Flow resource in GCP.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -1535,6 +1548,18 @@ func resourceDialogflowCXFlowRead(d *schema.ResourceData, meta interface{}) erro log.Printf("[DEBUG] Finished reading DialogflowCXFlow %q: %#v", d.Id(), res) // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } err = ResourceDialogflowCXFlowFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { @@ -1563,6 +1588,19 @@ func resourceDialogflowCXFlowRead(d *schema.ResourceData, meta interface{}) erro } func resourceDialogflowCXFlowUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDialogflowCXFlow().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDialogflowCXFlowRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1733,6 +1771,13 @@ func resourceDialogflowCXFlowUpdate(d *schema.ResourceData, meta interface{}) er } func resourceDialogflowCXFlowDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DialogflowCXFlow without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Flow %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/dialogflowcx/resource_dialogflow_cx_flow_generated_meta.yaml b/google/services/dialogflowcx/resource_dialogflow_cx_flow_generated_meta.yaml index c05954e5421..79e6f9cdbed 100644 --- a/google/services/dialogflowcx/resource_dialogflow_cx_flow_generated_meta.yaml +++ b/google/services/dialogflowcx/resource_dialogflow_cx_flow_generated_meta.yaml @@ -133,3 +133,5 @@ fields: json: true - api_field: transitionRoutes.triggerFulfillment.tag - api_field: transitionRoutes.triggerFulfillment.webhook + - field: deletion_policy + provider_only: true diff --git a/google/services/dialogflowcx/resource_dialogflow_cx_generative_settings.go b/google/services/dialogflowcx/resource_dialogflow_cx_generative_settings.go index 07a97559e0a..97d02f95d8c 100644 --- a/google/services/dialogflowcx/resource_dialogflow_cx_generative_settings.go +++ b/google/services/dialogflowcx/resource_dialogflow_cx_generative_settings.go @@ -459,6 +459,7 @@ func resourceDialogflowCXGenerativeSettingsRead(d *schema.ResourceData, meta int } func resourceDialogflowCXGenerativeSettingsUpdate(d *schema.ResourceData, meta interface{}) error { + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/dialogflowcx/resource_dialogflow_cx_generator.go b/google/services/dialogflowcx/resource_dialogflow_cx_generator.go index 6c77232d677..e864241e5e4 100644 --- a/google/services/dialogflowcx/resource_dialogflow_cx_generator.go +++ b/google/services/dialogflowcx/resource_dialogflow_cx_generator.go @@ -247,6 +247,19 @@ Format: projects//locations//agents/.`, Description: `The unique identifier of the Generator. Format: projects//locations//agents//generators/.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -431,6 +444,20 @@ func resourceDialogflowCXGeneratorRead(d *schema.ResourceData, meta interface{}) log.Printf("[DEBUG] Finished reading DialogflowCXGenerator %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceDialogflowCXGeneratorFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -458,6 +485,19 @@ func resourceDialogflowCXGeneratorRead(d *schema.ResourceData, meta interface{}) } func resourceDialogflowCXGeneratorUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDialogflowCXGenerator().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDialogflowCXGeneratorRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -598,6 +638,13 @@ func resourceDialogflowCXGeneratorUpdate(d *schema.ResourceData, meta interface{ } func resourceDialogflowCXGeneratorDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DialogflowCXGenerator without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Generator %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/dialogflowcx/resource_dialogflow_cx_generator_generated_meta.yaml b/google/services/dialogflowcx/resource_dialogflow_cx_generator_generated_meta.yaml index 8fff8241ff8..736d5c5b4aa 100644 --- a/google/services/dialogflowcx/resource_dialogflow_cx_generator_generated_meta.yaml +++ b/google/services/dialogflowcx/resource_dialogflow_cx_generator_generated_meta.yaml @@ -22,3 +22,5 @@ fields: - api_field: placeholders.id - api_field: placeholders.name - api_field: promptText.text + - field: deletion_policy + provider_only: true diff --git a/google/services/dialogflowcx/resource_dialogflow_cx_intent.go b/google/services/dialogflowcx/resource_dialogflow_cx_intent.go index 56cf9cac562..f4daf8bee25 100644 --- a/google/services/dialogflowcx/resource_dialogflow_cx_intent.go +++ b/google/services/dialogflowcx/resource_dialogflow_cx_intent.go @@ -115,6 +115,7 @@ func ResourceDialogflowCXIntent() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -302,6 +303,19 @@ The Default Negative Intent cannot be deleted; deleting the 'google_dialogflow_c ~> Avoid having multiple 'google_dialogflow_cx_intent' resources linked to the same agent with 'is_default_negative_intent = true' because they will compete to control a single Default Negative Intent resource in GCP.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -526,6 +540,18 @@ func resourceDialogflowCXIntentRead(d *schema.ResourceData, meta interface{}) er log.Printf("[DEBUG] Finished reading DialogflowCXIntent %q: %#v", d.Id(), res) // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } err = ResourceDialogflowCXIntentFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { @@ -554,6 +580,19 @@ func resourceDialogflowCXIntentRead(d *schema.ResourceData, meta interface{}) er } func resourceDialogflowCXIntentUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDialogflowCXIntent().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDialogflowCXIntentRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -714,6 +753,13 @@ func resourceDialogflowCXIntentUpdate(d *schema.ResourceData, meta interface{}) } func resourceDialogflowCXIntentDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DialogflowCXIntent without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Intent %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/dialogflowcx/resource_dialogflow_cx_intent_generated_meta.yaml b/google/services/dialogflowcx/resource_dialogflow_cx_intent_generated_meta.yaml index b7fdfc14308..59ce4418611 100644 --- a/google/services/dialogflowcx/resource_dialogflow_cx_intent_generated_meta.yaml +++ b/google/services/dialogflowcx/resource_dialogflow_cx_intent_generated_meta.yaml @@ -32,3 +32,5 @@ fields: - api_field: trainingPhrases.parts.parameterId - api_field: trainingPhrases.parts.text - api_field: trainingPhrases.repeatCount + - field: deletion_policy + provider_only: true diff --git a/google/services/dialogflowcx/resource_dialogflow_cx_page.go b/google/services/dialogflowcx/resource_dialogflow_cx_page.go index 02f3c27f40a..5e740186acb 100644 --- a/google/services/dialogflowcx/resource_dialogflow_cx_page.go +++ b/google/services/dialogflowcx/resource_dialogflow_cx_page.go @@ -1946,6 +1946,19 @@ You may set this, for example: Description: `The unique identifier of the page. Format: projects//locations//agents//flows//pages/.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -2150,6 +2163,20 @@ func resourceDialogflowCXPageRead(d *schema.ResourceData, meta interface{}) erro log.Printf("[DEBUG] Finished reading DialogflowCXPage %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceDialogflowCXPageFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -2177,6 +2204,19 @@ func resourceDialogflowCXPageRead(d *schema.ResourceData, meta interface{}) erro } func resourceDialogflowCXPageUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDialogflowCXPage().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDialogflowCXPageRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -2347,6 +2387,13 @@ func resourceDialogflowCXPageUpdate(d *schema.ResourceData, meta interface{}) er } func resourceDialogflowCXPageDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DialogflowCXPage without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Page %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/dialogflowcx/resource_dialogflow_cx_page_generated_meta.yaml b/google/services/dialogflowcx/resource_dialogflow_cx_page_generated_meta.yaml index dcace3355fe..c77156837d2 100644 --- a/google/services/dialogflowcx/resource_dialogflow_cx_page_generated_meta.yaml +++ b/google/services/dialogflowcx/resource_dialogflow_cx_page_generated_meta.yaml @@ -201,3 +201,5 @@ fields: json: true - api_field: transitionRoutes.triggerFulfillment.tag - api_field: transitionRoutes.triggerFulfillment.webhook + - field: deletion_policy + provider_only: true diff --git a/google/services/dialogflowcx/resource_dialogflow_cx_playbook.go b/google/services/dialogflowcx/resource_dialogflow_cx_playbook.go index 8103613cda7..5f765d0a4ac 100644 --- a/google/services/dialogflowcx/resource_dialogflow_cx_playbook.go +++ b/google/services/dialogflowcx/resource_dialogflow_cx_playbook.go @@ -263,6 +263,19 @@ Format: projects//locations//agents//playbook Uses RFC 3339, where generated output will always be Z-normalized and uses 0, 3, 6 or 9 fractional digits. Offsets other than "Z" are also accepted. Examples: "2014-10-02T15:01:23Z", "2014-10-02T15:01:23.045123456Z" or "2014-10-02T15:01:23+05:30".`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -449,6 +462,20 @@ func resourceDialogflowCXPlaybookRead(d *schema.ResourceData, meta interface{}) log.Printf("[DEBUG] Finished reading DialogflowCXPlaybook %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceDialogflowCXPlaybookFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -476,6 +503,19 @@ func resourceDialogflowCXPlaybookRead(d *schema.ResourceData, meta interface{}) } func resourceDialogflowCXPlaybookUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDialogflowCXPlaybook().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDialogflowCXPlaybookRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -647,6 +687,13 @@ func resourceDialogflowCXPlaybookUpdate(d *schema.ResourceData, meta interface{} } func resourceDialogflowCXPlaybookDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DialogflowCXPlaybook without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Playbook %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/dialogflowcx/resource_dialogflow_cx_playbook_generated_meta.yaml b/google/services/dialogflowcx/resource_dialogflow_cx_playbook_generated_meta.yaml index 9704a22426c..20eb6028dad 100644 --- a/google/services/dialogflowcx/resource_dialogflow_cx_playbook_generated_meta.yaml +++ b/google/services/dialogflowcx/resource_dialogflow_cx_playbook_generated_meta.yaml @@ -25,3 +25,5 @@ fields: - api_field: referencedTools - api_field: tokenCount - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/dialogflowcx/resource_dialogflow_cx_security_settings.go b/google/services/dialogflowcx/resource_dialogflow_cx_security_settings.go index 548f9846de0..a2c6430ab0f 100644 --- a/google/services/dialogflowcx/resource_dialogflow_cx_security_settings.go +++ b/google/services/dialogflowcx/resource_dialogflow_cx_security_settings.go @@ -115,6 +115,7 @@ func ResourceDialogflowCXSecuritySettings() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -270,6 +271,18 @@ Format: projects//locations//securitySettings//locations//agents//testCase Description: `The unique identifier of the test case. Format: projects//locations//agents//testCases/.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -853,6 +866,20 @@ func resourceDialogflowCXTestCaseRead(d *schema.ResourceData, meta interface{}) log.Printf("[DEBUG] Finished reading DialogflowCXTestCase %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceDialogflowCXTestCaseFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -880,6 +907,19 @@ func resourceDialogflowCXTestCaseRead(d *schema.ResourceData, meta interface{}) } func resourceDialogflowCXTestCaseUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDialogflowCXTestCase().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDialogflowCXTestCaseRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1020,6 +1060,13 @@ func resourceDialogflowCXTestCaseUpdate(d *schema.ResourceData, meta interface{} } func resourceDialogflowCXTestCaseDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DialogflowCXTestCase without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing TestCase %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/dialogflowcx/resource_dialogflow_cx_test_case_generated_meta.yaml b/google/services/dialogflowcx/resource_dialogflow_cx_test_case_generated_meta.yaml index 0ab7dc43c4e..384da866067 100644 --- a/google/services/dialogflowcx/resource_dialogflow_cx_test_case_generated_meta.yaml +++ b/google/services/dialogflowcx/resource_dialogflow_cx_test_case_generated_meta.yaml @@ -59,3 +59,5 @@ fields: - api_field: testConfig.flow - api_field: testConfig.page - api_field: testConfig.trackingParameters + - field: deletion_policy + provider_only: true diff --git a/google/services/dialogflowcx/resource_dialogflow_cx_tool.go b/google/services/dialogflowcx/resource_dialogflow_cx_tool.go index 8cd1b1d9b2d..f76fcb3e645 100644 --- a/google/services/dialogflowcx/resource_dialogflow_cx_tool.go +++ b/google/services/dialogflowcx/resource_dialogflow_cx_tool.go @@ -442,6 +442,19 @@ Format: projects//locations//agents//tools//locations//agents//webhooks Computed: true, Description: `Deprecated. Name of the start flow in this agent. A start flow will be automatically created when the agent is created, and can only be deleted by deleting the agent. Format: projects//locations//agents//flows/.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -736,6 +749,20 @@ func resourceDialogflowCXWebhookRead(d *schema.ResourceData, meta interface{}) e log.Printf("[DEBUG] Finished reading DialogflowCXWebhook %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceDialogflowCXWebhookFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -763,6 +790,19 @@ func resourceDialogflowCXWebhookRead(d *schema.ResourceData, meta interface{}) e } func resourceDialogflowCXWebhookUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDialogflowCXWebhook().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDialogflowCXWebhookRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -933,6 +973,13 @@ func resourceDialogflowCXWebhookUpdate(d *schema.ResourceData, meta interface{}) } func resourceDialogflowCXWebhookDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DialogflowCXWebhook without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Webhook %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/dialogflowcx/resource_dialogflow_cx_webhook_generated_meta.yaml b/google/services/dialogflowcx/resource_dialogflow_cx_webhook_generated_meta.yaml index d1e2fe342f7..0fa259c8d12 100644 --- a/google/services/dialogflowcx/resource_dialogflow_cx_webhook_generated_meta.yaml +++ b/google/services/dialogflowcx/resource_dialogflow_cx_webhook_generated_meta.yaml @@ -54,3 +54,5 @@ fields: - api_field: serviceDirectory.service - api_field: startFlow - api_field: timeout + - field: deletion_policy + provider_only: true diff --git a/google/services/discoveryengine/resource_discovery_engine_acl_config.go b/google/services/discoveryengine/resource_discovery_engine_acl_config.go index 91814582ee8..4ba19b2ba20 100644 --- a/google/services/discoveryengine/resource_discovery_engine_acl_config.go +++ b/google/services/discoveryengine/resource_discovery_engine_acl_config.go @@ -340,6 +340,7 @@ func resourceDiscoveryEngineAclConfigRead(d *schema.ResourceData, meta interface } func resourceDiscoveryEngineAclConfigUpdate(d *schema.ResourceData, meta interface{}) error { + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/discoveryengine/resource_discovery_engine_assistant.go b/google/services/discoveryengine/resource_discovery_engine_assistant.go index 9613c23cb1c..68d31cf320f 100644 --- a/google/services/discoveryengine/resource_discovery_engine_assistant.go +++ b/google/services/discoveryengine/resource_discovery_engine_assistant.go @@ -115,6 +115,7 @@ func ResourceDiscoveryEngineAssistant() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -312,6 +313,18 @@ It must be a UTF-8 encoded string with a length limit of 1024 characters.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -473,6 +486,19 @@ func resourceDiscoveryEngineAssistantRead(d *schema.ResourceData, meta interface log.Printf("[DEBUG] Finished reading DiscoveryEngineAssistant %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Assistant: %s", err) } @@ -522,6 +548,19 @@ func resourceDiscoveryEngineAssistantRead(d *schema.ResourceData, meta interface } func resourceDiscoveryEngineAssistantUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDiscoveryEngineAssistant().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDiscoveryEngineAssistantRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -663,6 +702,13 @@ func resourceDiscoveryEngineAssistantUpdate(d *schema.ResourceData, meta interfa } func resourceDiscoveryEngineAssistantDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DiscoveryEngineAssistant without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Assistant %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/discoveryengine/resource_discovery_engine_assistant_generated_meta.yaml b/google/services/discoveryengine/resource_discovery_engine_assistant_generated_meta.yaml index d27ff4810f6..bb32b68bb00 100644 --- a/google/services/discoveryengine/resource_discovery_engine_assistant_generated_meta.yaml +++ b/google/services/discoveryengine/resource_discovery_engine_assistant_generated_meta.yaml @@ -27,3 +27,5 @@ fields: provider_only: true - api_field: name - api_field: webGroundingType + - field: deletion_policy + provider_only: true diff --git a/google/services/discoveryengine/resource_discovery_engine_chat_engine.go b/google/services/discoveryengine/resource_discovery_engine_chat_engine.go index e1725d34b85..e3f3a88bf4b 100644 --- a/google/services/discoveryengine/resource_discovery_engine_chat_engine.go +++ b/google/services/discoveryengine/resource_discovery_engine_chat_engine.go @@ -115,6 +115,7 @@ func ResourceDiscoveryEngineChatEngine() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -305,6 +306,18 @@ characters.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -476,6 +489,19 @@ func resourceDiscoveryEngineChatEngineRead(d *schema.ResourceData, meta interfac log.Printf("[DEBUG] Finished reading DiscoveryEngineChatEngine %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading ChatEngine: %s", err) } @@ -519,6 +545,19 @@ func resourceDiscoveryEngineChatEngineRead(d *schema.ResourceData, meta interfac } func resourceDiscoveryEngineChatEngineUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDiscoveryEngineChatEngine().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDiscoveryEngineChatEngineRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -630,6 +669,13 @@ func resourceDiscoveryEngineChatEngineUpdate(d *schema.ResourceData, meta interf } func resourceDiscoveryEngineChatEngineDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DiscoveryEngineChatEngine without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ChatEngine %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/discoveryengine/resource_discovery_engine_chat_engine_generated_meta.yaml b/google/services/discoveryengine/resource_discovery_engine_chat_engine_generated_meta.yaml index ef7912b5330..9d2781e345f 100644 --- a/google/services/discoveryengine/resource_discovery_engine_chat_engine_generated_meta.yaml +++ b/google/services/discoveryengine/resource_discovery_engine_chat_engine_generated_meta.yaml @@ -27,3 +27,5 @@ fields: provider_only: true - api_field: name - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/discoveryengine/resource_discovery_engine_cmek_config.go b/google/services/discoveryengine/resource_discovery_engine_cmek_config.go index 908fff02fd7..774fcfc5404 100644 --- a/google/services/discoveryengine/resource_discovery_engine_cmek_config.go +++ b/google/services/discoveryengine/resource_discovery_engine_cmek_config.go @@ -115,6 +115,7 @@ func ResourceDiscoveryEngineCmekConfig() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -225,6 +226,18 @@ characters.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -368,6 +381,19 @@ func resourceDiscoveryEngineCmekConfigRead(d *schema.ResourceData, meta interfac log.Printf("[DEBUG] Finished reading DiscoveryEngineCmekConfig %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading CmekConfig: %s", err) } @@ -405,6 +431,19 @@ func resourceDiscoveryEngineCmekConfigRead(d *schema.ResourceData, meta interfac } func resourceDiscoveryEngineCmekConfigUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDiscoveryEngineCmekConfig().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDiscoveryEngineCmekConfigRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -494,6 +533,13 @@ func resourceDiscoveryEngineCmekConfigUpdate(d *schema.ResourceData, meta interf } func resourceDiscoveryEngineCmekConfigDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DiscoveryEngineCmekConfig without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing CmekConfig %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/discoveryengine/resource_discovery_engine_cmek_config_generated_meta.yaml b/google/services/discoveryengine/resource_discovery_engine_cmek_config_generated_meta.yaml index 7809a57ad3b..e610c8559d1 100644 --- a/google/services/discoveryengine/resource_discovery_engine_cmek_config_generated_meta.yaml +++ b/google/services/discoveryengine/resource_discovery_engine_cmek_config_generated_meta.yaml @@ -21,3 +21,5 @@ fields: provider_only: true - api_field: singleRegionKeys.kmsKey - api_field: state + - field: deletion_policy + provider_only: true diff --git a/google/services/discoveryengine/resource_discovery_engine_control.go b/google/services/discoveryengine/resource_discovery_engine_control.go index fd30219d054..e4b95291c97 100644 --- a/google/services/discoveryengine/resource_discovery_engine_control.go +++ b/google/services/discoveryengine/resource_discovery_engine_control.go @@ -115,6 +115,7 @@ func ResourceDiscoveryEngineControl() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -451,6 +452,18 @@ characters.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -636,6 +649,19 @@ func resourceDiscoveryEngineControlRead(d *schema.ResourceData, meta interface{} log.Printf("[DEBUG] Finished reading DiscoveryEngineControl %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Control: %s", err) } @@ -685,6 +711,19 @@ func resourceDiscoveryEngineControlRead(d *schema.ResourceData, meta interface{} } func resourceDiscoveryEngineControlUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDiscoveryEngineControl().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDiscoveryEngineControlRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -859,6 +898,13 @@ func resourceDiscoveryEngineControlUpdate(d *schema.ResourceData, meta interface } func resourceDiscoveryEngineControlDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DiscoveryEngineControl without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Control %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/discoveryengine/resource_discovery_engine_control_generated_meta.yaml b/google/services/discoveryengine/resource_discovery_engine_control_generated_meta.yaml index 73328abb182..bbfdcf83f52 100644 --- a/google/services/discoveryengine/resource_discovery_engine_control_generated_meta.yaml +++ b/google/services/discoveryengine/resource_discovery_engine_control_generated_meta.yaml @@ -43,3 +43,5 @@ fields: - api_field: solutionType - api_field: synonymsAction.synonyms - api_field: useCases + - field: deletion_policy + provider_only: true diff --git a/google/services/discoveryengine/resource_discovery_engine_data_connector.go b/google/services/discoveryengine/resource_discovery_engine_data_connector.go index 1927df30fb2..a812bad30af 100644 --- a/google/services/discoveryengine/resource_discovery_engine_data_connector.go +++ b/google/services/discoveryengine/resource_discovery_engine_data_connector.go @@ -128,6 +128,7 @@ func ResourceDiscoveryEngineDataConnector() *schema.Resource { }, CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -587,6 +588,18 @@ This project must be allowlisted by in order for the connector to function.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -814,6 +827,19 @@ func resourceDiscoveryEngineDataConnectorRead(d *schema.ResourceData, meta inter log.Printf("[DEBUG] Finished reading DiscoveryEngineDataConnector %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading DataConnector: %s", err) } @@ -851,6 +877,19 @@ func resourceDiscoveryEngineDataConnectorRead(d *schema.ResourceData, meta inter } func resourceDiscoveryEngineDataConnectorUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDiscoveryEngineDataConnector().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDiscoveryEngineDataConnectorRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1063,6 +1102,13 @@ func resourceDiscoveryEngineDataConnectorUpdate(d *schema.ResourceData, meta int } func resourceDiscoveryEngineDataConnectorDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DiscoveryEngineDataConnector without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing DataConnector %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/discoveryengine/resource_discovery_engine_data_connector_generated_meta.yaml b/google/services/discoveryengine/resource_discovery_engine_data_connector_generated_meta.yaml index c6462666a6a..71aee449c41 100644 --- a/google/services/discoveryengine/resource_discovery_engine_data_connector_generated_meta.yaml +++ b/google/services/discoveryengine/resource_discovery_engine_data_connector_generated_meta.yaml @@ -56,3 +56,5 @@ fields: - api_field: staticIpEnabled - api_field: syncMode - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/discoveryengine/resource_discovery_engine_data_store.go b/google/services/discoveryengine/resource_discovery_engine_data_store.go index 882f56e7177..536e77e5694 100644 --- a/google/services/discoveryengine/resource_discovery_engine_data_store.go +++ b/google/services/discoveryengine/resource_discovery_engine_data_store.go @@ -115,6 +115,7 @@ func ResourceDiscoveryEngineDataStore() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -495,6 +496,18 @@ characters.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -668,6 +681,19 @@ func resourceDiscoveryEngineDataStoreRead(d *schema.ResourceData, meta interface log.Printf("[DEBUG] Finished reading DiscoveryEngineDataStore %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading DataStore: %s", err) } @@ -705,6 +731,19 @@ func resourceDiscoveryEngineDataStoreRead(d *schema.ResourceData, meta interface } func resourceDiscoveryEngineDataStoreUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDiscoveryEngineDataStore().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDiscoveryEngineDataStoreRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -806,6 +845,13 @@ func resourceDiscoveryEngineDataStoreUpdate(d *schema.ResourceData, meta interfa } func resourceDiscoveryEngineDataStoreDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DiscoveryEngineDataStore without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing DataStore %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/discoveryengine/resource_discovery_engine_data_store_generated_meta.yaml b/google/services/discoveryengine/resource_discovery_engine_data_store_generated_meta.yaml index 1405316147d..fe0c8644a17 100644 --- a/google/services/discoveryengine/resource_discovery_engine_data_store_generated_meta.yaml +++ b/google/services/discoveryengine/resource_discovery_engine_data_store_generated_meta.yaml @@ -56,3 +56,5 @@ fields: - field: skip_default_schema_creation provider_only: true - api_field: solutionTypes + - field: deletion_policy + provider_only: true diff --git a/google/services/discoveryengine/resource_discovery_engine_license_config.go b/google/services/discoveryengine/resource_discovery_engine_license_config.go index ef94cc71d26..66e6b3e65d1 100644 --- a/google/services/discoveryengine/resource_discovery_engine_license_config.go +++ b/google/services/discoveryengine/resource_discovery_engine_license_config.go @@ -443,6 +443,7 @@ func resourceDiscoveryEngineLicenseConfigRead(d *schema.ResourceData, meta inter } func resourceDiscoveryEngineLicenseConfigUpdate(d *schema.ResourceData, meta interface{}) error { + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/discoveryengine/resource_discovery_engine_recommendation_engine.go b/google/services/discoveryengine/resource_discovery_engine_recommendation_engine.go index bf5e1cec537..8e96505bed5 100644 --- a/google/services/discoveryengine/resource_discovery_engine_recommendation_engine.go +++ b/google/services/discoveryengine/resource_discovery_engine_recommendation_engine.go @@ -115,6 +115,7 @@ func ResourceDiscoveryEngineRecommendationEngine() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -331,6 +332,18 @@ This field must be a UTF-8 encoded string with a length limit of 1024 characters Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -497,6 +510,19 @@ func resourceDiscoveryEngineRecommendationEngineRead(d *schema.ResourceData, met log.Printf("[DEBUG] Finished reading DiscoveryEngineRecommendationEngine %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading RecommendationEngine: %s", err) } @@ -534,6 +560,19 @@ func resourceDiscoveryEngineRecommendationEngineRead(d *schema.ResourceData, met } func resourceDiscoveryEngineRecommendationEngineUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDiscoveryEngineRecommendationEngine().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDiscoveryEngineRecommendationEngineRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -650,6 +689,13 @@ func resourceDiscoveryEngineRecommendationEngineUpdate(d *schema.ResourceData, m } func resourceDiscoveryEngineRecommendationEngineDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DiscoveryEngineRecommendationEngine without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing RecommendationEngine %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/discoveryengine/resource_discovery_engine_recommendation_engine_generated_meta.yaml b/google/services/discoveryengine/resource_discovery_engine_recommendation_engine_generated_meta.yaml index d4ce9a8d231..f6cb4a4b269 100644 --- a/google/services/discoveryengine/resource_discovery_engine_recommendation_engine_generated_meta.yaml +++ b/google/services/discoveryengine/resource_discovery_engine_recommendation_engine_generated_meta.yaml @@ -25,3 +25,5 @@ fields: - api_field: mediaRecommendationEngineConfig.type - api_field: name - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/discoveryengine/resource_discovery_engine_schema.go b/google/services/discoveryengine/resource_discovery_engine_schema.go index a873a83c317..7a1178ae03b 100644 --- a/google/services/discoveryengine/resource_discovery_engine_schema.go +++ b/google/services/discoveryengine/resource_discovery_engine_schema.go @@ -100,6 +100,7 @@ func ResourceDiscoveryEngineSchema() *schema.Resource { return &schema.Resource{ Create: resourceDiscoveryEngineSchemaCreate, Read: resourceDiscoveryEngineSchemaRead, + Update: resourceDiscoveryEngineSchemaUpdate, Delete: resourceDiscoveryEngineSchemaDelete, Importer: &schema.ResourceImporter{ @@ -113,6 +114,7 @@ func ResourceDiscoveryEngineSchema() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -185,6 +187,18 @@ characters.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -327,6 +341,19 @@ func resourceDiscoveryEngineSchemaRead(d *schema.ResourceData, meta interface{}) log.Printf("[DEBUG] Finished reading DiscoveryEngineSchema %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Schema: %s", err) } @@ -369,7 +396,19 @@ func resourceDiscoveryEngineSchemaRead(d *schema.ResourceData, meta interface{}) return nil } +func resourceDiscoveryEngineSchemaUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceDiscoveryEngineSchemaRead(d, meta) +} + func resourceDiscoveryEngineSchemaDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DiscoveryEngineSchema without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Schema %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/discoveryengine/resource_discovery_engine_schema_generated_meta.yaml b/google/services/discoveryengine/resource_discovery_engine_schema_generated_meta.yaml index 920e6447a20..3caad14270f 100644 --- a/google/services/discoveryengine/resource_discovery_engine_schema_generated_meta.yaml +++ b/google/services/discoveryengine/resource_discovery_engine_schema_generated_meta.yaml @@ -17,3 +17,5 @@ fields: - api_field: name - field: schema_id provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/discoveryengine/resource_discovery_engine_search_engine.go b/google/services/discoveryengine/resource_discovery_engine_search_engine.go index c5fa9c824df..d4f4a463fbb 100644 --- a/google/services/discoveryengine/resource_discovery_engine_search_engine.go +++ b/google/services/discoveryengine/resource_discovery_engine_search_engine.go @@ -115,6 +115,7 @@ func ResourceDiscoveryEngineSearchEngine() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -354,6 +355,18 @@ characters.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -555,6 +568,19 @@ func resourceDiscoveryEngineSearchEngineRead(d *schema.ResourceData, meta interf log.Printf("[DEBUG] Finished reading DiscoveryEngineSearchEngine %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading SearchEngine: %s", err) } @@ -598,6 +624,19 @@ func resourceDiscoveryEngineSearchEngineRead(d *schema.ResourceData, meta interf } func resourceDiscoveryEngineSearchEngineUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDiscoveryEngineSearchEngine().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDiscoveryEngineSearchEngineRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -759,6 +798,13 @@ func resourceDiscoveryEngineSearchEngineUpdate(d *schema.ResourceData, meta inte } func resourceDiscoveryEngineSearchEngineDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DiscoveryEngineSearchEngine without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing SearchEngine %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/discoveryengine/resource_discovery_engine_search_engine_generated_meta.yaml b/google/services/discoveryengine/resource_discovery_engine_search_engine_generated_meta.yaml index 25539944256..99db97b0546 100644 --- a/google/services/discoveryengine/resource_discovery_engine_search_engine_generated_meta.yaml +++ b/google/services/discoveryengine/resource_discovery_engine_search_engine_generated_meta.yaml @@ -34,3 +34,5 @@ fields: - api_field: searchEngineConfig.searchAddOns - api_field: searchEngineConfig.searchTier - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/discoveryengine/resource_discovery_engine_serving_config.go b/google/services/discoveryengine/resource_discovery_engine_serving_config.go index bffe3003617..4832a65da1e 100644 --- a/google/services/discoveryengine/resource_discovery_engine_serving_config.go +++ b/google/services/discoveryengine/resource_discovery_engine_serving_config.go @@ -438,6 +438,7 @@ func resourceDiscoveryEngineServingConfigRead(d *schema.ResourceData, meta inter } func resourceDiscoveryEngineServingConfigUpdate(d *schema.ResourceData, meta interface{}) error { + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/discoveryengine/resource_discovery_engine_sitemap.go b/google/services/discoveryengine/resource_discovery_engine_sitemap.go index b426aa40afb..7fb7c838c75 100644 --- a/google/services/discoveryengine/resource_discovery_engine_sitemap.go +++ b/google/services/discoveryengine/resource_discovery_engine_sitemap.go @@ -100,6 +100,7 @@ func ResourceDiscoveryEngineSitemap() *schema.Resource { return &schema.Resource{ Create: resourceDiscoveryEngineSitemapCreate, Read: resourceDiscoveryEngineSitemapRead, + Update: resourceDiscoveryEngineSitemapUpdate, Delete: resourceDiscoveryEngineSitemapDelete, Importer: &schema.ResourceImporter{ @@ -113,6 +114,7 @@ func ResourceDiscoveryEngineSitemap() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -174,6 +176,18 @@ characters.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -350,6 +364,19 @@ func resourceDiscoveryEngineSitemapRead(d *schema.ResourceData, meta interface{} res = sitemapData + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Sitemap: %s", err) } @@ -374,7 +401,19 @@ func resourceDiscoveryEngineSitemapRead(d *schema.ResourceData, meta interface{} return nil } +func resourceDiscoveryEngineSitemapUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceDiscoveryEngineSitemapRead(d, meta) +} + func resourceDiscoveryEngineSitemapDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DiscoveryEngineSitemap without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Sitemap %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/discoveryengine/resource_discovery_engine_sitemap_generated_meta.yaml b/google/services/discoveryengine/resource_discovery_engine_sitemap_generated_meta.yaml index a5f4c1307b3..b626b3aebad 100644 --- a/google/services/discoveryengine/resource_discovery_engine_sitemap_generated_meta.yaml +++ b/google/services/discoveryengine/resource_discovery_engine_sitemap_generated_meta.yaml @@ -16,3 +16,5 @@ fields: - field: sitemap_id provider_only: true - api_field: uri + - field: deletion_policy + provider_only: true diff --git a/google/services/discoveryengine/resource_discovery_engine_target_site.go b/google/services/discoveryengine/resource_discovery_engine_target_site.go index f8a47609b00..804f6eff102 100644 --- a/google/services/discoveryengine/resource_discovery_engine_target_site.go +++ b/google/services/discoveryengine/resource_discovery_engine_target_site.go @@ -100,6 +100,7 @@ func ResourceDiscoveryEngineTargetSite() *schema.Resource { return &schema.Resource{ Create: resourceDiscoveryEngineTargetSiteCreate, Read: resourceDiscoveryEngineTargetSiteRead, + Update: resourceDiscoveryEngineTargetSiteUpdate, Delete: resourceDiscoveryEngineTargetSiteDelete, Importer: &schema.ResourceImporter{ @@ -113,6 +114,7 @@ func ResourceDiscoveryEngineTargetSite() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -266,6 +268,18 @@ characters.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -434,6 +448,19 @@ func resourceDiscoveryEngineTargetSiteRead(d *schema.ResourceData, meta interfac log.Printf("[DEBUG] Finished reading DiscoveryEngineTargetSite %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading TargetSite: %s", err) } @@ -476,7 +503,19 @@ func resourceDiscoveryEngineTargetSiteRead(d *schema.ResourceData, meta interfac return nil } +func resourceDiscoveryEngineTargetSiteUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceDiscoveryEngineTargetSiteRead(d, meta) +} + func resourceDiscoveryEngineTargetSiteDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DiscoveryEngineTargetSite without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing TargetSite %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/discoveryengine/resource_discovery_engine_target_site_generated_meta.yaml b/google/services/discoveryengine/resource_discovery_engine_target_site_generated_meta.yaml index 906e4a0d5ce..2e5a238431b 100644 --- a/google/services/discoveryengine/resource_discovery_engine_target_site_generated_meta.yaml +++ b/google/services/discoveryengine/resource_discovery_engine_target_site_generated_meta.yaml @@ -26,3 +26,5 @@ fields: provider_only: true - api_field: type - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/discoveryengine/resource_discovery_engine_user_store.go b/google/services/discoveryengine/resource_discovery_engine_user_store.go index 9a83eab98ae..f7370046c81 100644 --- a/google/services/discoveryengine/resource_discovery_engine_user_store.go +++ b/google/services/discoveryengine/resource_discovery_engine_user_store.go @@ -369,6 +369,7 @@ func resourceDiscoveryEngineUserStoreRead(d *schema.ResourceData, meta interface } func resourceDiscoveryEngineUserStoreUpdate(d *schema.ResourceData, meta interface{}) error { + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/discoveryengine/resource_discovery_engine_widget_config.go b/google/services/discoveryengine/resource_discovery_engine_widget_config.go index 1752bb49e44..0e7301a11c6 100644 --- a/google/services/discoveryengine/resource_discovery_engine_widget_config.go +++ b/google/services/discoveryengine/resource_discovery_engine_widget_config.go @@ -746,6 +746,7 @@ func resourceDiscoveryEngineWidgetConfigRead(d *schema.ResourceData, meta interf } func resourceDiscoveryEngineWidgetConfigUpdate(d *schema.ResourceData, meta interface{}) error { + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/dns/resource_dns_managed_zone.go b/google/services/dns/resource_dns_managed_zone.go index 4cc0285d48f..67abd1c9ccf 100644 --- a/google/services/dns/resource_dns_managed_zone.go +++ b/google/services/dns/resource_dns_managed_zone.go @@ -120,6 +120,7 @@ func ResourceDNSManagedZone() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -427,6 +428,18 @@ defined by the server`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -658,6 +671,18 @@ func resourceDNSManagedZoneRead(d *schema.ResourceData, meta interface{}) error return fmt.Errorf("Error setting force_destroy: %s", err) } } + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading ManagedZone: %s", err) } @@ -689,6 +714,19 @@ func resourceDNSManagedZoneRead(d *schema.ResourceData, meta interface{}) error } func resourceDNSManagedZoneUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDNSManagedZone().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDNSManagedZoneRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -819,6 +857,13 @@ func resourceDNSManagedZoneUpdate(d *schema.ResourceData, meta interface{}) erro } func resourceDNSManagedZoneDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DNSManagedZone without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ManagedZone %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/dns/resource_dns_managed_zone_generated_meta.yaml b/google/services/dns/resource_dns_managed_zone_generated_meta.yaml index c64bfc08351..d79d7f93db0 100644 --- a/google/services/dns/resource_dns_managed_zone_generated_meta.yaml +++ b/google/services/dns/resource_dns_managed_zone_generated_meta.yaml @@ -37,3 +37,5 @@ fields: - field: terraform_labels provider_only: true - api_field: visibility + - field: deletion_policy + provider_only: true diff --git a/google/services/dns/resource_dns_policy.go b/google/services/dns/resource_dns_policy.go index 509837dceca..df7c54a0167 100644 --- a/google/services/dns/resource_dns_policy.go +++ b/google/services/dns/resource_dns_policy.go @@ -115,6 +115,7 @@ func ResourceDNSPolicy() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -242,6 +243,18 @@ Defaults to no logging if not set.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -435,6 +448,19 @@ func resourceDNSPolicyRead(d *schema.ResourceData, meta interface{}) error { log.Printf("[DEBUG] Finished reading DNSPolicy %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Policy: %s", err) } @@ -466,6 +492,19 @@ func resourceDNSPolicyRead(d *schema.ResourceData, meta interface{}) error { } func resourceDNSPolicyUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDNSPolicy().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDNSPolicyRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -567,6 +606,13 @@ func resourceDNSPolicyUpdate(d *schema.ResourceData, meta interface{}) error { } func resourceDNSPolicyDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DNSPolicy without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Policy %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/dns/resource_dns_policy_generated_meta.yaml b/google/services/dns/resource_dns_policy_generated_meta.yaml index b59a9258298..4eaabb33d28 100644 --- a/google/services/dns/resource_dns_policy_generated_meta.yaml +++ b/google/services/dns/resource_dns_policy_generated_meta.yaml @@ -15,3 +15,5 @@ fields: - api_field: enableLogging - api_field: name - api_field: networks.networkUrl + - field: deletion_policy + provider_only: true diff --git a/google/services/dns/resource_dns_record_set.go b/google/services/dns/resource_dns_record_set.go index b0f944612f9..b3829f079aa 100644 --- a/google/services/dns/resource_dns_record_set.go +++ b/google/services/dns/resource_dns_record_set.go @@ -113,6 +113,7 @@ func ResourceDnsRecordSet() *schema.Resource { }, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), tpgresource.DefaultProviderProject, ), @@ -259,6 +260,9 @@ func ResourceDnsRecordSet() *schema.Resource { ForceNew: true, Description: `The ID of the project in which the resource belongs. If it is not provided, the provider project is used.`, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, UseJSONNumber: true, } @@ -493,10 +497,21 @@ func resourceDnsRecordSetRead(d *schema.ResourceData, meta interface{}) error { return fmt.Errorf("Error setting project: %s", err) } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } func resourceDnsRecordSetDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -583,6 +598,11 @@ func resourceDnsRecordSetDelete(d *schema.ResourceData, meta interface{}) error } func resourceDnsRecordSetUpdate(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceDnsRecordSet) { + return ResourceDnsRecordSet().Read(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/dns/resource_dns_record_set_meta.yaml b/google/services/dns/resource_dns_record_set_meta.yaml index 99253930681..39e8584998d 100644 --- a/google/services/dns/resource_dns_record_set_meta.yaml +++ b/google/services/dns/resource_dns_record_set_meta.yaml @@ -54,3 +54,5 @@ fields: - api_field: 'rrdatas' - api_field: 'ttl' - api_field: 'type' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/dns/resource_dns_response_policy.go b/google/services/dns/resource_dns_response_policy.go index 28d6d6f090d..4c4f7064e39 100644 --- a/google/services/dns/resource_dns_response_policy.go +++ b/google/services/dns/resource_dns_response_policy.go @@ -115,6 +115,7 @@ func ResourceDNSResponsePolicy() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -188,6 +189,18 @@ This should be formatted like Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -328,6 +341,19 @@ func resourceDNSResponsePolicyRead(d *schema.ResourceData, meta interface{}) err log.Printf("[DEBUG] Finished reading DNSResponsePolicy %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading ResponsePolicy: %s", err) } @@ -359,6 +385,19 @@ func resourceDNSResponsePolicyRead(d *schema.ResourceData, meta interface{}) err } func resourceDNSResponsePolicyUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDNSResponsePolicy().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDNSResponsePolicyRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -442,6 +481,13 @@ func resourceDNSResponsePolicyUpdate(d *schema.ResourceData, meta interface{}) e } func resourceDNSResponsePolicyDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DNSResponsePolicy without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ResponsePolicy %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/dns/resource_dns_response_policy_generated_meta.yaml b/google/services/dns/resource_dns_response_policy_generated_meta.yaml index 1fca948cd83..44fb9fdbb91 100644 --- a/google/services/dns/resource_dns_response_policy_generated_meta.yaml +++ b/google/services/dns/resource_dns_response_policy_generated_meta.yaml @@ -11,3 +11,5 @@ fields: - api_field: gkeClusters.gkeClusterName - api_field: networks.networkUrl - api_field: responsePolicyName + - field: deletion_policy + provider_only: true diff --git a/google/services/dns/resource_dns_response_policy_rule.go b/google/services/dns/resource_dns_response_policy_rule.go index 69f4ec7002e..e96154a61c7 100644 --- a/google/services/dns/resource_dns_response_policy_rule.go +++ b/google/services/dns/resource_dns_response_policy_rule.go @@ -115,6 +115,7 @@ func ResourceDNSResponsePolicyRule() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -210,6 +211,18 @@ resolvers.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -349,6 +362,19 @@ func resourceDNSResponsePolicyRuleRead(d *schema.ResourceData, meta interface{}) log.Printf("[DEBUG] Finished reading DNSResponsePolicyRule %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading ResponsePolicyRule: %s", err) } @@ -386,6 +412,19 @@ func resourceDNSResponsePolicyRuleRead(d *schema.ResourceData, meta interface{}) } func resourceDNSResponsePolicyRuleUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDNSResponsePolicyRule().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDNSResponsePolicyRuleRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -468,6 +507,13 @@ func resourceDNSResponsePolicyRuleUpdate(d *schema.ResourceData, meta interface{ } func resourceDNSResponsePolicyRuleDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DNSResponsePolicyRule without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ResponsePolicyRule %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/dns/resource_dns_response_policy_rule_generated_meta.yaml b/google/services/dns/resource_dns_response_policy_rule_generated_meta.yaml index 0e27f9c8a6e..a25a2a0845f 100644 --- a/google/services/dns/resource_dns_response_policy_rule_generated_meta.yaml +++ b/google/services/dns/resource_dns_response_policy_rule_generated_meta.yaml @@ -15,3 +15,5 @@ fields: - field: response_policy provider_only: true - api_field: ruleName + - field: deletion_policy + provider_only: true diff --git a/google/services/documentai/resource_document_ai_processor.go b/google/services/documentai/resource_document_ai_processor.go index 14a2c461f39..2c931169a58 100644 --- a/google/services/documentai/resource_document_ai_processor.go +++ b/google/services/documentai/resource_document_ai_processor.go @@ -100,6 +100,7 @@ func ResourceDocumentAIProcessor() *schema.Resource { return &schema.Resource{ Create: resourceDocumentAIProcessorCreate, Read: resourceDocumentAIProcessorRead, + Update: resourceDocumentAIProcessorUpdate, Delete: resourceDocumentAIProcessorDelete, Importer: &schema.ResourceImporter{ @@ -113,6 +114,7 @@ func ResourceDocumentAIProcessor() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -174,6 +176,18 @@ func ResourceDocumentAIProcessor() *schema.Resource { Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -319,6 +333,19 @@ func resourceDocumentAIProcessorRead(d *schema.ResourceData, meta interface{}) e log.Printf("[DEBUG] Finished reading DocumentAIProcessor %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Processor: %s", err) } @@ -355,7 +382,19 @@ func resourceDocumentAIProcessorRead(d *schema.ResourceData, meta interface{}) e return nil } +func resourceDocumentAIProcessorUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceDocumentAIProcessorRead(d, meta) +} + func resourceDocumentAIProcessorDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DocumentAIProcessor without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Processor %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/documentai/resource_document_ai_processor_generated_meta.yaml b/google/services/documentai/resource_document_ai_processor_generated_meta.yaml index 71f4ef1ed36..9a68ba1f6eb 100644 --- a/google/services/documentai/resource_document_ai_processor_generated_meta.yaml +++ b/google/services/documentai/resource_document_ai_processor_generated_meta.yaml @@ -13,3 +13,5 @@ fields: provider_only: true - api_field: name - api_field: type + - field: deletion_policy + provider_only: true diff --git a/google/services/documentai/resource_document_ai_schema.go b/google/services/documentai/resource_document_ai_schema.go index 199dc86ed09..5d65a176e27 100644 --- a/google/services/documentai/resource_document_ai_schema.go +++ b/google/services/documentai/resource_document_ai_schema.go @@ -116,6 +116,7 @@ func ResourceDocumentAISchema() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -197,6 +198,18 @@ Please refer to the field 'effective_labels' for all of the labels present on th Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -336,6 +349,19 @@ func resourceDocumentAISchemaRead(d *schema.ResourceData, meta interface{}) erro log.Printf("[DEBUG] Finished reading DocumentAISchema %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Schema: %s", err) } @@ -373,6 +399,19 @@ func resourceDocumentAISchemaRead(d *schema.ResourceData, meta interface{}) erro } func resourceDocumentAISchemaUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceDocumentAISchema().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceDocumentAISchemaRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -474,6 +513,13 @@ func resourceDocumentAISchemaUpdate(d *schema.ResourceData, meta interface{}) er } func resourceDocumentAISchemaDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DocumentAISchema without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Schema %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/documentai/resource_document_ai_schema_generated_meta.yaml b/google/services/documentai/resource_document_ai_schema_generated_meta.yaml index c330e7256ef..37fe64a408f 100644 --- a/google/services/documentai/resource_document_ai_schema_generated_meta.yaml +++ b/google/services/documentai/resource_document_ai_schema_generated_meta.yaml @@ -18,3 +18,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/documentaiwarehouse/resource_document_ai_warehouse_document_schema.go b/google/services/documentaiwarehouse/resource_document_ai_warehouse_document_schema.go index 2c11da37433..e796caa04c0 100644 --- a/google/services/documentaiwarehouse/resource_document_ai_warehouse_document_schema.go +++ b/google/services/documentaiwarehouse/resource_document_ai_warehouse_document_schema.go @@ -100,6 +100,7 @@ func ResourceDocumentAIWarehouseDocumentSchema() *schema.Resource { return &schema.Resource{ Create: resourceDocumentAIWarehouseDocumentSchemaCreate, Read: resourceDocumentAIWarehouseDocumentSchemaRead, + Update: resourceDocumentAIWarehouseDocumentSchemaUpdate, Delete: resourceDocumentAIWarehouseDocumentSchemaDelete, Importer: &schema.ResourceImporter{ @@ -509,6 +510,19 @@ func ResourceDocumentAIWarehouseDocumentSchema() *schema.Resource { Computed: true, Description: `The resource name of the document schema.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -642,6 +656,20 @@ func resourceDocumentAIWarehouseDocumentSchemaRead(d *schema.ResourceData, meta log.Printf("[DEBUG] Finished reading DocumentAIWarehouseDocumentSchema %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceDocumentAIWarehouseDocumentSchemaFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -674,7 +702,19 @@ func resourceDocumentAIWarehouseDocumentSchemaRead(d *schema.ResourceData, meta return nil } +func resourceDocumentAIWarehouseDocumentSchemaUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceDocumentAIWarehouseDocumentSchemaRead(d, meta) +} + func resourceDocumentAIWarehouseDocumentSchemaDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy DocumentAIWarehouseDocumentSchema without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing DocumentSchema %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/documentaiwarehouse/resource_document_ai_warehouse_document_schema_generated_meta.yaml b/google/services/documentaiwarehouse/resource_document_ai_warehouse_document_schema_generated_meta.yaml index 0adef49289b..98b95e1de39 100644 --- a/google/services/documentaiwarehouse/resource_document_ai_warehouse_document_schema_generated_meta.yaml +++ b/google/services/documentaiwarehouse/resource_document_ai_warehouse_document_schema_generated_meta.yaml @@ -52,3 +52,5 @@ fields: - api_field: propertyDefinitions.schemaSources.processorType - api_field: propertyDefinitions.textTypeOptions - api_field: propertyDefinitions.timestampTypeOptions + - field: deletion_policy + provider_only: true diff --git a/google/services/edgecontainer/resource_edgecontainer_cluster.go b/google/services/edgecontainer/resource_edgecontainer_cluster.go index 8c62497531c..74ba6dbe440 100644 --- a/google/services/edgecontainer/resource_edgecontainer_cluster.go +++ b/google/services/edgecontainer/resource_edgecontainer_cluster.go @@ -116,6 +116,7 @@ func ResourceEdgecontainerCluster() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -710,6 +711,18 @@ if the cluster does not have any worker nodes.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -913,6 +926,19 @@ func resourceEdgecontainerClusterRead(d *schema.ResourceData, meta interface{}) log.Printf("[DEBUG] Finished reading EdgecontainerCluster %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Cluster: %s", err) } @@ -950,6 +976,19 @@ func resourceEdgecontainerClusterRead(d *schema.ResourceData, meta interface{}) } func resourceEdgecontainerClusterUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceEdgecontainerCluster().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceEdgecontainerClusterRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1177,6 +1216,13 @@ func resourceEdgecontainerClusterUpdate(d *schema.ResourceData, meta interface{} } func resourceEdgecontainerClusterDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy EdgecontainerCluster without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Cluster %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/edgecontainer/resource_edgecontainer_cluster_generated_meta.yaml b/google/services/edgecontainer/resource_edgecontainer_cluster_generated_meta.yaml index c860f0181fb..0115a94f16d 100644 --- a/google/services/edgecontainer/resource_edgecontainer_cluster_generated_meta.yaml +++ b/google/services/edgecontainer/resource_edgecontainer_cluster_generated_meta.yaml @@ -64,3 +64,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/edgecontainer/resource_edgecontainer_node_pool.go b/google/services/edgecontainer/resource_edgecontainer_node_pool.go index b39a030df3a..fdf5ab2f1a1 100644 --- a/google/services/edgecontainer/resource_edgecontainer_node_pool.go +++ b/google/services/edgecontainer/resource_edgecontainer_node_pool.go @@ -116,6 +116,7 @@ func ResourceEdgecontainerNodePool() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -272,6 +273,18 @@ documented in more detail in [AIP-160](https://google.aip.dev/160).`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -444,6 +457,19 @@ func resourceEdgecontainerNodePoolRead(d *schema.ResourceData, meta interface{}) log.Printf("[DEBUG] Finished reading EdgecontainerNodePool %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading NodePool: %s", err) } @@ -487,6 +513,19 @@ func resourceEdgecontainerNodePoolRead(d *schema.ResourceData, meta interface{}) } func resourceEdgecontainerNodePoolUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceEdgecontainerNodePool().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceEdgecontainerNodePoolRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -630,6 +669,13 @@ func resourceEdgecontainerNodePoolUpdate(d *schema.ResourceData, meta interface{ } func resourceEdgecontainerNodePoolDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy EdgecontainerNodePool without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing NodePool %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/edgecontainer/resource_edgecontainer_node_pool_generated_meta.yaml b/google/services/edgecontainer/resource_edgecontainer_node_pool_generated_meta.yaml index 17a5c6c3752..21552727af7 100644 --- a/google/services/edgecontainer/resource_edgecontainer_node_pool_generated_meta.yaml +++ b/google/services/edgecontainer/resource_edgecontainer_node_pool_generated_meta.yaml @@ -28,3 +28,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/edgecontainer/resource_edgecontainer_vpn_connection.go b/google/services/edgecontainer/resource_edgecontainer_vpn_connection.go index a7982f82742..129005311e7 100644 --- a/google/services/edgecontainer/resource_edgecontainer_vpn_connection.go +++ b/google/services/edgecontainer/resource_edgecontainer_vpn_connection.go @@ -116,6 +116,7 @@ func ResourceEdgecontainerVpnConnection() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -287,6 +288,18 @@ This is empty if NAT is not used.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -460,6 +473,19 @@ func resourceEdgecontainerVpnConnectionRead(d *schema.ResourceData, meta interfa log.Printf("[DEBUG] Finished reading EdgecontainerVpnConnection %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading VpnConnection: %s", err) } @@ -497,6 +523,19 @@ func resourceEdgecontainerVpnConnectionRead(d *schema.ResourceData, meta interfa } func resourceEdgecontainerVpnConnectionUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceEdgecontainerVpnConnection().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceEdgecontainerVpnConnectionRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -617,6 +656,13 @@ func resourceEdgecontainerVpnConnectionUpdate(d *schema.ResourceData, meta inter } func resourceEdgecontainerVpnConnectionDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy EdgecontainerVpnConnection without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing VpnConnection %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/edgecontainer/resource_edgecontainer_vpn_connection_generated_meta.yaml b/google/services/edgecontainer/resource_edgecontainer_vpn_connection_generated_meta.yaml index ef903eb8bea..88f35d10937 100644 --- a/google/services/edgecontainer/resource_edgecontainer_vpn_connection_generated_meta.yaml +++ b/google/services/edgecontainer/resource_edgecontainer_vpn_connection_generated_meta.yaml @@ -28,3 +28,5 @@ fields: - api_field: updateTime - api_field: vpc - api_field: vpcProject.projectId + - field: deletion_policy + provider_only: true diff --git a/google/services/edgenetwork/resource_edgenetwork_interconnect_attachment.go b/google/services/edgenetwork/resource_edgenetwork_interconnect_attachment.go index 0f9c1ea20d8..0a43f54103c 100644 --- a/google/services/edgenetwork/resource_edgenetwork_interconnect_attachment.go +++ b/google/services/edgenetwork/resource_edgenetwork_interconnect_attachment.go @@ -116,6 +116,7 @@ func ResourceEdgenetworkInterconnectAttachment() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -247,6 +248,18 @@ fractional digits. Examples: '2014-10-02T15:01:23Z' and '2014-10-02T15:01:23.045 Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -419,6 +432,19 @@ func resourceEdgenetworkInterconnectAttachmentRead(d *schema.ResourceData, meta log.Printf("[DEBUG] Finished reading EdgenetworkInterconnectAttachment %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading InterconnectAttachment: %s", err) } @@ -462,11 +488,18 @@ func resourceEdgenetworkInterconnectAttachmentRead(d *schema.ResourceData, meta } func resourceEdgenetworkInterconnectAttachmentUpdate(d *schema.ResourceData, meta interface{}) error { - // Only the root field "labels", "terraform_labels", and virtual fields are mutable + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable return resourceEdgenetworkInterconnectAttachmentRead(d, meta) } func resourceEdgenetworkInterconnectAttachmentDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy EdgenetworkInterconnectAttachment without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing InterconnectAttachment %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/edgenetwork/resource_edgenetwork_interconnect_attachment_generated_meta.yaml b/google/services/edgenetwork/resource_edgenetwork_interconnect_attachment_generated_meta.yaml index d645f8ee33f..bc0d4602be9 100644 --- a/google/services/edgenetwork/resource_edgenetwork_interconnect_attachment_generated_meta.yaml +++ b/google/services/edgenetwork/resource_edgenetwork_interconnect_attachment_generated_meta.yaml @@ -26,3 +26,5 @@ fields: - api_field: vlanId - field: zone provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/edgenetwork/resource_edgenetwork_network.go b/google/services/edgenetwork/resource_edgenetwork_network.go index 5efe569f150..2cf9b51f71f 100644 --- a/google/services/edgenetwork/resource_edgenetwork_network.go +++ b/google/services/edgenetwork/resource_edgenetwork_network.go @@ -116,6 +116,7 @@ func ResourceEdgenetworkNetwork() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -227,6 +228,18 @@ fractional digits. Examples: '2014-10-02T15:01:23Z' and '2014-10-02T15:01:23.045 Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -381,6 +394,19 @@ func resourceEdgenetworkNetworkRead(d *schema.ResourceData, meta interface{}) er log.Printf("[DEBUG] Finished reading EdgenetworkNetwork %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Network: %s", err) } @@ -424,11 +450,18 @@ func resourceEdgenetworkNetworkRead(d *schema.ResourceData, meta interface{}) er } func resourceEdgenetworkNetworkUpdate(d *schema.ResourceData, meta interface{}) error { - // Only the root field "labels", "terraform_labels", and virtual fields are mutable + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable return resourceEdgenetworkNetworkRead(d, meta) } func resourceEdgenetworkNetworkDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy EdgenetworkNetwork without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Network %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/edgenetwork/resource_edgenetwork_network_generated_meta.yaml b/google/services/edgenetwork/resource_edgenetwork_network_generated_meta.yaml index da7055a6058..2cc16662c83 100644 --- a/google/services/edgenetwork/resource_edgenetwork_network_generated_meta.yaml +++ b/google/services/edgenetwork/resource_edgenetwork_network_generated_meta.yaml @@ -23,3 +23,5 @@ fields: - api_field: updateTime - field: zone provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/edgenetwork/resource_edgenetwork_subnet.go b/google/services/edgenetwork/resource_edgenetwork_subnet.go index 892c4e7460b..a01e5643d1d 100644 --- a/google/services/edgenetwork/resource_edgenetwork_subnet.go +++ b/google/services/edgenetwork/resource_edgenetwork_subnet.go @@ -116,6 +116,7 @@ func ResourceEdgenetworkSubnet() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -258,6 +259,18 @@ fractional digits. Examples: '2014-10-02T15:01:23Z' and '2014-10-02T15:01:23.045 Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -430,6 +443,19 @@ func resourceEdgenetworkSubnetRead(d *schema.ResourceData, meta interface{}) err log.Printf("[DEBUG] Finished reading EdgenetworkSubnet %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Subnet: %s", err) } @@ -473,11 +499,18 @@ func resourceEdgenetworkSubnetRead(d *schema.ResourceData, meta interface{}) err } func resourceEdgenetworkSubnetUpdate(d *schema.ResourceData, meta interface{}) error { - // Only the root field "labels", "terraform_labels", and virtual fields are mutable + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable return resourceEdgenetworkSubnetRead(d, meta) } func resourceEdgenetworkSubnetDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy EdgenetworkSubnet without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Subnet %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/edgenetwork/resource_edgenetwork_subnet_generated_meta.yaml b/google/services/edgenetwork/resource_edgenetwork_subnet_generated_meta.yaml index 445d9a19bdb..ab66fa25192 100644 --- a/google/services/edgenetwork/resource_edgenetwork_subnet_generated_meta.yaml +++ b/google/services/edgenetwork/resource_edgenetwork_subnet_generated_meta.yaml @@ -27,3 +27,5 @@ fields: - api_field: vlanId - field: zone provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/essentialcontacts/resource_essential_contacts_contact.go b/google/services/essentialcontacts/resource_essential_contacts_contact.go index 2d46e669296..61e0e40b7f3 100644 --- a/google/services/essentialcontacts/resource_essential_contacts_contact.go +++ b/google/services/essentialcontacts/resource_essential_contacts_contact.go @@ -159,6 +159,19 @@ func ResourceEssentialContactsContact() *schema.Resource { Computed: true, Description: `The identifier for the contact. Format: {resourceType}/{resource_id}/contacts/{contact_id}`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -282,6 +295,20 @@ func resourceEssentialContactsContactRead(d *schema.ResourceData, meta interface log.Printf("[DEBUG] Finished reading EssentialContactsContact %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceEssentialContactsContactFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -303,6 +330,19 @@ func resourceEssentialContactsContactRead(d *schema.ResourceData, meta interface } func resourceEssentialContactsContactUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceEssentialContactsContact().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceEssentialContactsContactRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -388,6 +428,13 @@ func resourceEssentialContactsContactUpdate(d *schema.ResourceData, meta interfa } func resourceEssentialContactsContactDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy EssentialContactsContact without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Contact %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/essentialcontacts/resource_essential_contacts_contact_generated_meta.yaml b/google/services/essentialcontacts/resource_essential_contacts_contact_generated_meta.yaml index 6609edbdfba..daf72c5be24 100644 --- a/google/services/essentialcontacts/resource_essential_contacts_contact_generated_meta.yaml +++ b/google/services/essentialcontacts/resource_essential_contacts_contact_generated_meta.yaml @@ -17,3 +17,5 @@ fields: - api_field: notificationCategorySubscriptions - field: parent provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/eventarc/resource_eventarc_channel.go b/google/services/eventarc/resource_eventarc_channel.go index e108ea02e1f..a599ad594f7 100644 --- a/google/services/eventarc/resource_eventarc_channel.go +++ b/google/services/eventarc/resource_eventarc_channel.go @@ -116,6 +116,7 @@ func ResourceEventarcChannel() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -225,6 +226,18 @@ Please refer to the field 'effective_labels' for all of the labels present on th Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -382,6 +395,19 @@ func resourceEventarcChannelRead(d *schema.ResourceData, meta interface{}) error log.Printf("[DEBUG] Finished reading EventarcChannel %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Channel: %s", err) } @@ -419,6 +445,19 @@ func resourceEventarcChannelRead(d *schema.ResourceData, meta interface{}) error } func resourceEventarcChannelUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceEventarcChannel().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceEventarcChannelRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -528,6 +567,13 @@ func resourceEventarcChannelUpdate(d *schema.ResourceData, meta interface{}) err } func resourceEventarcChannelDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy EventarcChannel without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Channel %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/eventarc/resource_eventarc_channel_generated_meta.yaml b/google/services/eventarc/resource_eventarc_channel_generated_meta.yaml index 95c7a747e6f..27161d83b26 100644 --- a/google/services/eventarc/resource_eventarc_channel_generated_meta.yaml +++ b/google/services/eventarc/resource_eventarc_channel_generated_meta.yaml @@ -24,3 +24,5 @@ fields: field: third_party_provider - api_field: uid - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/eventarc/resource_eventarc_enrollment.go b/google/services/eventarc/resource_eventarc_enrollment.go index 4762da0f23b..969de5b300d 100644 --- a/google/services/eventarc/resource_eventarc_enrollment.go +++ b/google/services/eventarc/resource_eventarc_enrollment.go @@ -117,6 +117,7 @@ func ResourceEventarcEnrollment() *schema.Resource { tpgresource.SetLabelsDiff, tpgresource.SetAnnotationsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -253,6 +254,18 @@ string and guaranteed to remain unchanged until the resource is deleted.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -420,6 +433,19 @@ func resourceEventarcEnrollmentRead(d *schema.ResourceData, meta interface{}) er log.Printf("[DEBUG] Finished reading EventarcEnrollment %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Enrollment: %s", err) } @@ -457,6 +483,19 @@ func resourceEventarcEnrollmentRead(d *schema.ResourceData, meta interface{}) er } func resourceEventarcEnrollmentUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceEventarcEnrollment().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceEventarcEnrollmentRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -595,6 +634,13 @@ func resourceEventarcEnrollmentUpdate(d *schema.ResourceData, meta interface{}) } func resourceEventarcEnrollmentDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy EventarcEnrollment without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Enrollment %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/eventarc/resource_eventarc_enrollment_generated_meta.yaml b/google/services/eventarc/resource_eventarc_enrollment_generated_meta.yaml index 27cd95bd968..fffcea98b14 100644 --- a/google/services/eventarc/resource_eventarc_enrollment_generated_meta.yaml +++ b/google/services/eventarc/resource_eventarc_enrollment_generated_meta.yaml @@ -28,3 +28,5 @@ fields: provider_only: true - api_field: uid - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/eventarc/resource_eventarc_google_api_source.go b/google/services/eventarc/resource_eventarc_google_api_source.go index 65e04142120..f8924681366 100644 --- a/google/services/eventarc/resource_eventarc_google_api_source.go +++ b/google/services/eventarc/resource_eventarc_google_api_source.go @@ -117,6 +117,7 @@ func ResourceEventarcGoogleApiSource() *schema.Resource { tpgresource.SetLabelsDiff, tpgresource.SetAnnotationsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -269,6 +270,18 @@ string and guaranteed to remain unchanged until the resource is deleted.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -436,6 +449,19 @@ func resourceEventarcGoogleApiSourceRead(d *schema.ResourceData, meta interface{ log.Printf("[DEBUG] Finished reading EventarcGoogleApiSource %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading GoogleApiSource: %s", err) } @@ -473,6 +499,19 @@ func resourceEventarcGoogleApiSourceRead(d *schema.ResourceData, meta interface{ } func resourceEventarcGoogleApiSourceUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceEventarcGoogleApiSource().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceEventarcGoogleApiSourceRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -621,6 +660,13 @@ func resourceEventarcGoogleApiSourceUpdate(d *schema.ResourceData, meta interfac } func resourceEventarcGoogleApiSourceDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy EventarcGoogleApiSource without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing GoogleApiSource %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/eventarc/resource_eventarc_google_api_source_generated_meta.yaml b/google/services/eventarc/resource_eventarc_google_api_source_generated_meta.yaml index e2c2663a754..26e1a8adc33 100644 --- a/google/services/eventarc/resource_eventarc_google_api_source_generated_meta.yaml +++ b/google/services/eventarc/resource_eventarc_google_api_source_generated_meta.yaml @@ -28,3 +28,5 @@ fields: provider_only: true - api_field: uid - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/eventarc/resource_eventarc_google_channel_config.go b/google/services/eventarc/resource_eventarc_google_channel_config.go index bf212f29af8..1e3316f6c0d 100644 --- a/google/services/eventarc/resource_eventarc_google_channel_config.go +++ b/google/services/eventarc/resource_eventarc_google_channel_config.go @@ -326,6 +326,7 @@ func resourceEventarcGoogleChannelConfigRead(d *schema.ResourceData, meta interf } func resourceEventarcGoogleChannelConfigUpdate(d *schema.ResourceData, meta interface{}) error { + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/eventarc/resource_eventarc_message_bus.go b/google/services/eventarc/resource_eventarc_message_bus.go index 7ae53a268b2..f7d31a28b23 100644 --- a/google/services/eventarc/resource_eventarc_message_bus.go +++ b/google/services/eventarc/resource_eventarc_message_bus.go @@ -117,6 +117,7 @@ func ResourceEventarcMessageBus() *schema.Resource { tpgresource.SetLabelsDiff, tpgresource.SetAnnotationsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -263,6 +264,18 @@ string and guaranteed to remain unchanged until the resource is deleted.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -424,6 +437,19 @@ func resourceEventarcMessageBusRead(d *schema.ResourceData, meta interface{}) er log.Printf("[DEBUG] Finished reading EventarcMessageBus %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading MessageBus: %s", err) } @@ -461,6 +487,19 @@ func resourceEventarcMessageBusRead(d *schema.ResourceData, meta interface{}) er } func resourceEventarcMessageBusUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceEventarcMessageBus().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceEventarcMessageBusRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -599,6 +638,13 @@ func resourceEventarcMessageBusUpdate(d *schema.ResourceData, meta interface{}) } func resourceEventarcMessageBusDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy EventarcMessageBus without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing MessageBus %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/eventarc/resource_eventarc_message_bus_generated_meta.yaml b/google/services/eventarc/resource_eventarc_message_bus_generated_meta.yaml index 39e09cbf1a0..d51c92e8e90 100644 --- a/google/services/eventarc/resource_eventarc_message_bus_generated_meta.yaml +++ b/google/services/eventarc/resource_eventarc_message_bus_generated_meta.yaml @@ -27,3 +27,5 @@ fields: provider_only: true - api_field: uid - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/eventarc/resource_eventarc_pipeline.go b/google/services/eventarc/resource_eventarc_pipeline.go index aaba361e704..cf5f05c757e 100644 --- a/google/services/eventarc/resource_eventarc_pipeline.go +++ b/google/services/eventarc/resource_eventarc_pipeline.go @@ -117,6 +117,7 @@ func ResourceEventarcPipeline() *schema.Resource { tpgresource.SetAnnotationsDiff, tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -828,6 +829,18 @@ to nine fractional digits. Examples: "2014-10-02T15:01:23Z" and Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -1013,6 +1026,19 @@ func resourceEventarcPipelineRead(d *schema.ResourceData, meta interface{}) erro log.Printf("[DEBUG] Finished reading EventarcPipeline %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Pipeline: %s", err) } @@ -1050,6 +1076,19 @@ func resourceEventarcPipelineRead(d *schema.ResourceData, meta interface{}) erro } func resourceEventarcPipelineUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceEventarcPipeline().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceEventarcPipelineRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1228,6 +1267,13 @@ func resourceEventarcPipelineUpdate(d *schema.ResourceData, meta interface{}) er } func resourceEventarcPipelineDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy EventarcPipeline without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Pipeline %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/eventarc/resource_eventarc_pipeline_generated_meta.yaml b/google/services/eventarc/resource_eventarc_pipeline_generated_meta.yaml index 24b8fca6773..afd6d18576d 100644 --- a/google/services/eventarc/resource_eventarc_pipeline_generated_meta.yaml +++ b/google/services/eventarc/resource_eventarc_pipeline_generated_meta.yaml @@ -47,3 +47,5 @@ fields: provider_only: true - api_field: uid - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/eventarc/resource_eventarc_trigger.go b/google/services/eventarc/resource_eventarc_trigger.go index 3439b645cf9..3e07633b9ca 100644 --- a/google/services/eventarc/resource_eventarc_trigger.go +++ b/google/services/eventarc/resource_eventarc_trigger.go @@ -116,6 +116,7 @@ func ResourceEventarcTrigger() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -380,6 +381,18 @@ value is 1.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -568,6 +581,19 @@ func resourceEventarcTriggerRead(d *schema.ResourceData, meta interface{}) error log.Printf("[DEBUG] Finished reading EventarcTrigger %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Trigger: %s", err) } @@ -581,6 +607,19 @@ func resourceEventarcTriggerRead(d *schema.ResourceData, meta interface{}) error } func resourceEventarcTriggerUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceEventarcTrigger().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceEventarcTriggerRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -709,6 +748,13 @@ func resourceEventarcTriggerUpdate(d *schema.ResourceData, meta interface{}) err } func resourceEventarcTriggerDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy EventarcTrigger without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Trigger %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/eventarc/resource_eventarc_trigger_generated_meta.yaml b/google/services/eventarc/resource_eventarc_trigger_generated_meta.yaml index 28c13b83d60..ebda752b842 100644 --- a/google/services/eventarc/resource_eventarc_trigger_generated_meta.yaml +++ b/google/services/eventarc/resource_eventarc_trigger_generated_meta.yaml @@ -47,3 +47,5 @@ fields: - api_field: transport.pubsub.topic - api_field: uid - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/filestore/resource_filestore_backup.go b/google/services/filestore/resource_filestore_backup.go index 2e0b222e5fe..def95f76b6b 100644 --- a/google/services/filestore/resource_filestore_backup.go +++ b/google/services/filestore/resource_filestore_backup.go @@ -116,6 +116,7 @@ func ResourceFilestoreBackup() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -251,6 +252,18 @@ The field is ignored (both PUT & PATCH) when empty.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -421,6 +434,19 @@ func resourceFilestoreBackupRead(d *schema.ResourceData, meta interface{}) error log.Printf("[DEBUG] Finished reading FilestoreBackup %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Backup: %s", err) } @@ -458,6 +484,19 @@ func resourceFilestoreBackupRead(d *schema.ResourceData, meta interface{}) error } func resourceFilestoreBackupUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceFilestoreBackup().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceFilestoreBackupRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -584,6 +623,13 @@ func resourceFilestoreBackupUpdate(d *schema.ResourceData, meta interface{}) err } func resourceFilestoreBackupDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy FilestoreBackup without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Backup %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/filestore/resource_filestore_backup_generated_meta.yaml b/google/services/filestore/resource_filestore_backup_generated_meta.yaml index 67485bce99a..93cf96cc969 100644 --- a/google/services/filestore/resource_filestore_backup_generated_meta.yaml +++ b/google/services/filestore/resource_filestore_backup_generated_meta.yaml @@ -27,3 +27,5 @@ fields: - api_field: tags - field: terraform_labels provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/filestore/resource_filestore_instance.go b/google/services/filestore/resource_filestore_instance.go index 6b3ca19f588..c9899caae08 100644 --- a/google/services/filestore/resource_filestore_instance.go +++ b/google/services/filestore/resource_filestore_instance.go @@ -152,6 +152,7 @@ func ResourceFilestoreInstance() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -658,6 +659,18 @@ simultaneous updates from overwriting each other.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -902,6 +915,18 @@ func resourceFilestoreInstanceRead(d *schema.ResourceData, meta interface{}) err return fmt.Errorf("Error setting desired_replica_state: %s", err) } } + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Instance: %s", err) } @@ -939,6 +964,19 @@ func resourceFilestoreInstanceRead(d *schema.ResourceData, meta interface{}) err } func resourceFilestoreInstanceUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceFilestoreInstance().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceFilestoreInstanceRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1139,6 +1177,13 @@ func resourceFilestoreInstanceUpdate(d *schema.ResourceData, meta interface{}) e } func resourceFilestoreInstanceDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy FilestoreInstance without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Instance %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/filestore/resource_filestore_instance_generated_meta.yaml b/google/services/filestore/resource_filestore_instance_generated_meta.yaml index af0387a84f7..c29f8bab973 100644 --- a/google/services/filestore/resource_filestore_instance_generated_meta.yaml +++ b/google/services/filestore/resource_filestore_instance_generated_meta.yaml @@ -65,3 +65,5 @@ fields: - api_field: tier - field: zone provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/filestore/resource_filestore_snapshot.go b/google/services/filestore/resource_filestore_snapshot.go index 1b8c8f275ed..5b4acaef8ce 100644 --- a/google/services/filestore/resource_filestore_snapshot.go +++ b/google/services/filestore/resource_filestore_snapshot.go @@ -116,6 +116,7 @@ func ResourceFilestoreSnapshot() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -220,6 +221,18 @@ Please refer to the field 'effective_labels' for all of the labels present on th Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -377,6 +390,19 @@ func resourceFilestoreSnapshotRead(d *schema.ResourceData, meta interface{}) err log.Printf("[DEBUG] Finished reading FilestoreSnapshot %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Snapshot: %s", err) } @@ -420,6 +446,19 @@ func resourceFilestoreSnapshotRead(d *schema.ResourceData, meta interface{}) err } func resourceFilestoreSnapshotUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceFilestoreSnapshot().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceFilestoreSnapshotRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -541,6 +580,13 @@ func resourceFilestoreSnapshotUpdate(d *schema.ResourceData, meta interface{}) e } func resourceFilestoreSnapshotDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy FilestoreSnapshot without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Snapshot %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/filestore/resource_filestore_snapshot_generated_meta.yaml b/google/services/filestore/resource_filestore_snapshot_generated_meta.yaml index 52910089ce1..8895131ac1b 100644 --- a/google/services/filestore/resource_filestore_snapshot_generated_meta.yaml +++ b/google/services/filestore/resource_filestore_snapshot_generated_meta.yaml @@ -22,3 +22,5 @@ fields: - api_field: state - field: terraform_labels provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/firebaseappcheck/resource_firebase_app_check_app_attest_config.go b/google/services/firebaseappcheck/resource_firebase_app_check_app_attest_config.go index 6170c4778df..a68e2fe889b 100644 --- a/google/services/firebaseappcheck/resource_firebase_app_check_app_attest_config.go +++ b/google/services/firebaseappcheck/resource_firebase_app_check_app_attest_config.go @@ -317,6 +317,7 @@ func resourceFirebaseAppCheckAppAttestConfigRead(d *schema.ResourceData, meta in } func resourceFirebaseAppCheckAppAttestConfigUpdate(d *schema.ResourceData, meta interface{}) error { + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/firebaseappcheck/resource_firebase_app_check_debug_token.go b/google/services/firebaseappcheck/resource_firebase_app_check_debug_token.go index 6c27941eb8d..22cd01bb6b3 100644 --- a/google/services/firebaseappcheck/resource_firebase_app_check_debug_token.go +++ b/google/services/firebaseappcheck/resource_firebase_app_check_debug_token.go @@ -115,6 +115,7 @@ func ResourceFirebaseAppCheckDebugToken() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -180,6 +181,18 @@ For security reasons, this field will never be populated in any response.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -319,6 +332,19 @@ func resourceFirebaseAppCheckDebugTokenRead(d *schema.ResourceData, meta interfa log.Printf("[DEBUG] Finished reading FirebaseAppCheckDebugToken %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading DebugToken: %s", err) } @@ -356,6 +382,19 @@ func resourceFirebaseAppCheckDebugTokenRead(d *schema.ResourceData, meta interfa } func resourceFirebaseAppCheckDebugTokenUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceFirebaseAppCheckDebugToken().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceFirebaseAppCheckDebugTokenRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -447,6 +486,13 @@ func resourceFirebaseAppCheckDebugTokenUpdate(d *schema.ResourceData, meta inter } func resourceFirebaseAppCheckDebugTokenDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy FirebaseAppCheckDebugToken without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing DebugToken %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/firebaseappcheck/resource_firebase_app_check_debug_token_generated_meta.yaml b/google/services/firebaseappcheck/resource_firebase_app_check_debug_token_generated_meta.yaml index 4a08959fa42..805647b3da8 100644 --- a/google/services/firebaseappcheck/resource_firebase_app_check_debug_token_generated_meta.yaml +++ b/google/services/firebaseappcheck/resource_firebase_app_check_debug_token_generated_meta.yaml @@ -13,3 +13,5 @@ fields: field: debug_token_id - api_field: displayName - api_field: token + - field: deletion_policy + provider_only: true diff --git a/google/services/firebaseappcheck/resource_firebase_app_check_device_check_config.go b/google/services/firebaseappcheck/resource_firebase_app_check_device_check_config.go index 24caabcc8e3..306aa5bb6d6 100644 --- a/google/services/firebaseappcheck/resource_firebase_app_check_device_check_config.go +++ b/google/services/firebaseappcheck/resource_firebase_app_check_device_check_config.go @@ -346,6 +346,7 @@ func resourceFirebaseAppCheckDeviceCheckConfigRead(d *schema.ResourceData, meta } func resourceFirebaseAppCheckDeviceCheckConfigUpdate(d *schema.ResourceData, meta interface{}) error { + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/firebaseappcheck/resource_firebase_app_check_play_integrity_config.go b/google/services/firebaseappcheck/resource_firebase_app_check_play_integrity_config.go index deadd11ec16..4f4ae678230 100644 --- a/google/services/firebaseappcheck/resource_firebase_app_check_play_integrity_config.go +++ b/google/services/firebaseappcheck/resource_firebase_app_check_play_integrity_config.go @@ -317,6 +317,7 @@ func resourceFirebaseAppCheckPlayIntegrityConfigRead(d *schema.ResourceData, met } func resourceFirebaseAppCheckPlayIntegrityConfigUpdate(d *schema.ResourceData, meta interface{}) error { + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/firebaseappcheck/resource_firebase_app_check_recaptcha_enterprise_config.go b/google/services/firebaseappcheck/resource_firebase_app_check_recaptcha_enterprise_config.go index 10243808e30..476585a815a 100644 --- a/google/services/firebaseappcheck/resource_firebase_app_check_recaptcha_enterprise_config.go +++ b/google/services/firebaseappcheck/resource_firebase_app_check_recaptcha_enterprise_config.go @@ -330,6 +330,7 @@ func resourceFirebaseAppCheckRecaptchaEnterpriseConfigRead(d *schema.ResourceDat } func resourceFirebaseAppCheckRecaptchaEnterpriseConfigUpdate(d *schema.ResourceData, meta interface{}) error { + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/firebaseappcheck/resource_firebase_app_check_recaptcha_v3_config.go b/google/services/firebaseappcheck/resource_firebase_app_check_recaptcha_v3_config.go index 16997e5af11..00f69e7b715 100644 --- a/google/services/firebaseappcheck/resource_firebase_app_check_recaptcha_v3_config.go +++ b/google/services/firebaseappcheck/resource_firebase_app_check_recaptcha_v3_config.go @@ -335,6 +335,7 @@ func resourceFirebaseAppCheckRecaptchaV3ConfigRead(d *schema.ResourceData, meta } func resourceFirebaseAppCheckRecaptchaV3ConfigUpdate(d *schema.ResourceData, meta interface{}) error { + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/firebaseappcheck/resource_firebase_app_check_resource_policy.go b/google/services/firebaseappcheck/resource_firebase_app_check_resource_policy.go index 56447a221f4..5b7a62543d5 100644 --- a/google/services/firebaseappcheck/resource_firebase_app_check_resource_policy.go +++ b/google/services/firebaseappcheck/resource_firebase_app_check_resource_policy.go @@ -115,6 +115,7 @@ func ResourceFirebaseAppCheckResourcePolicy() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -215,6 +216,18 @@ clients in use. Possible values: ["UNENFORCED", "ENFORCED"]`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -354,6 +367,19 @@ func resourceFirebaseAppCheckResourcePolicyRead(d *schema.ResourceData, meta int log.Printf("[DEBUG] Finished reading FirebaseAppCheckResourcePolicy %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading ResourcePolicy: %s", err) } @@ -391,6 +417,19 @@ func resourceFirebaseAppCheckResourcePolicyRead(d *schema.ResourceData, meta int } func resourceFirebaseAppCheckResourcePolicyUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceFirebaseAppCheckResourcePolicy().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceFirebaseAppCheckResourcePolicyRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -492,6 +531,13 @@ func resourceFirebaseAppCheckResourcePolicyUpdate(d *schema.ResourceData, meta i } func resourceFirebaseAppCheckResourcePolicyDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy FirebaseAppCheckResourcePolicy without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ResourcePolicy %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/firebaseappcheck/resource_firebase_app_check_resource_policy_generated_meta.yaml b/google/services/firebaseappcheck/resource_firebase_app_check_resource_policy_generated_meta.yaml index f0c68a772fe..64fead63938 100644 --- a/google/services/firebaseappcheck/resource_firebase_app_check_resource_policy_generated_meta.yaml +++ b/google/services/firebaseappcheck/resource_firebase_app_check_resource_policy_generated_meta.yaml @@ -15,3 +15,5 @@ fields: provider_only: true - api_field: targetResource - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/firebaseappcheck/resource_firebase_app_check_service_config.go b/google/services/firebaseappcheck/resource_firebase_app_check_service_config.go index 92243d02f73..7e4ec91d251 100644 --- a/google/services/firebaseappcheck/resource_firebase_app_check_service_config.go +++ b/google/services/firebaseappcheck/resource_firebase_app_check_service_config.go @@ -115,6 +115,7 @@ func ResourceFirebaseAppCheckServiceConfig() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -193,6 +194,18 @@ clients in use. Possible values: ["UNENFORCED", "ENFORCED"]`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -315,6 +328,19 @@ func resourceFirebaseAppCheckServiceConfigRead(d *schema.ResourceData, meta inte log.Printf("[DEBUG] Finished reading FirebaseAppCheckServiceConfig %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading ServiceConfig: %s", err) } @@ -346,6 +372,19 @@ func resourceFirebaseAppCheckServiceConfigRead(d *schema.ResourceData, meta inte } func resourceFirebaseAppCheckServiceConfigUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceFirebaseAppCheckServiceConfig().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceFirebaseAppCheckServiceConfigRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -432,6 +471,13 @@ func resourceFirebaseAppCheckServiceConfigUpdate(d *schema.ResourceData, meta in } func resourceFirebaseAppCheckServiceConfigDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy FirebaseAppCheckServiceConfig without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ServiceConfig %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/firebaseappcheck/resource_firebase_app_check_service_config_generated_meta.yaml b/google/services/firebaseappcheck/resource_firebase_app_check_service_config_generated_meta.yaml index a3d974a36de..1ffa830226e 100644 --- a/google/services/firebaseappcheck/resource_firebase_app_check_service_config_generated_meta.yaml +++ b/google/services/firebaseappcheck/resource_firebase_app_check_service_config_generated_meta.yaml @@ -11,3 +11,5 @@ fields: - api_field: name - field: service_id provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/firebaseapphosting/resource_firebase_app_hosting_backend.go b/google/services/firebaseapphosting/resource_firebase_app_hosting_backend.go index e38b596149f..c2b83215f6d 100644 --- a/google/services/firebaseapphosting/resource_firebase_app_hosting_backend.go +++ b/google/services/firebaseapphosting/resource_firebase_app_hosting_backend.go @@ -117,6 +117,7 @@ func ResourceFirebaseAppHostingBackend() *schema.Resource { tpgresource.SetAnnotationsDiff, tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -330,6 +331,18 @@ Format: Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -515,6 +528,19 @@ func resourceFirebaseAppHostingBackendRead(d *schema.ResourceData, meta interfac log.Printf("[DEBUG] Finished reading FirebaseAppHostingBackend %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Backend: %s", err) } @@ -552,6 +578,19 @@ func resourceFirebaseAppHostingBackendRead(d *schema.ResourceData, meta interfac } func resourceFirebaseAppHostingBackendUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceFirebaseAppHostingBackend().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceFirebaseAppHostingBackendRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -720,6 +759,13 @@ func resourceFirebaseAppHostingBackendUpdate(d *schema.ResourceData, meta interf } func resourceFirebaseAppHostingBackendDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy FirebaseAppHostingBackend without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Backend %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/firebaseapphosting/resource_firebase_app_hosting_backend_generated_meta.yaml b/google/services/firebaseapphosting/resource_firebase_app_hosting_backend_generated_meta.yaml index 9078cc965bf..aaed00504a4 100644 --- a/google/services/firebaseapphosting/resource_firebase_app_hosting_backend_generated_meta.yaml +++ b/google/services/firebaseapphosting/resource_firebase_app_hosting_backend_generated_meta.yaml @@ -35,3 +35,5 @@ fields: - api_field: uid - api_field: updateTime - api_field: uri + - field: deletion_policy + provider_only: true diff --git a/google/services/firebaseapphosting/resource_firebase_app_hosting_build.go b/google/services/firebaseapphosting/resource_firebase_app_hosting_build.go index 1a98f2abc22..ecf6a73aa94 100644 --- a/google/services/firebaseapphosting/resource_firebase_app_hosting_build.go +++ b/google/services/firebaseapphosting/resource_firebase_app_hosting_build.go @@ -648,7 +648,7 @@ func resourceFirebaseAppHostingBuildRead(d *schema.ResourceData, meta interface{ } func resourceFirebaseAppHostingBuildUpdate(d *schema.ResourceData, meta interface{}) error { - // Only the root field "labels", "terraform_labels", and virtual fields are mutable + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable return resourceFirebaseAppHostingBuildRead(d, meta) } diff --git a/google/services/firebaseapphosting/resource_firebase_app_hosting_default_domain.go b/google/services/firebaseapphosting/resource_firebase_app_hosting_default_domain.go index 0b41f71d4f4..975b2af02bd 100644 --- a/google/services/firebaseapphosting/resource_firebase_app_hosting_default_domain.go +++ b/google/services/firebaseapphosting/resource_firebase_app_hosting_default_domain.go @@ -387,6 +387,7 @@ func resourceFirebaseAppHostingDefaultDomainRead(d *schema.ResourceData, meta in } func resourceFirebaseAppHostingDefaultDomainUpdate(d *schema.ResourceData, meta interface{}) error { + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/firebaseapphosting/resource_firebase_app_hosting_domain.go b/google/services/firebaseapphosting/resource_firebase_app_hosting_domain.go index 5ddac022d34..36ed5d986b0 100644 --- a/google/services/firebaseapphosting/resource_firebase_app_hosting_domain.go +++ b/google/services/firebaseapphosting/resource_firebase_app_hosting_domain.go @@ -115,6 +115,7 @@ func ResourceFirebaseAppHostingDomain() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -539,6 +540,18 @@ permanently deleted.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -712,6 +725,19 @@ func resourceFirebaseAppHostingDomainRead(d *schema.ResourceData, meta interface log.Printf("[DEBUG] Finished reading FirebaseAppHostingDomain %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Domain: %s", err) } @@ -755,6 +781,19 @@ func resourceFirebaseAppHostingDomainRead(d *schema.ResourceData, meta interface } func resourceFirebaseAppHostingDomainUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceFirebaseAppHostingDomain().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceFirebaseAppHostingDomainRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -856,6 +895,13 @@ func resourceFirebaseAppHostingDomainUpdate(d *schema.ResourceData, meta interfa } func resourceFirebaseAppHostingDomainDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy FirebaseAppHostingDomain without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Domain %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/firebaseapphosting/resource_firebase_app_hosting_domain_generated_meta.yaml b/google/services/firebaseapphosting/resource_firebase_app_hosting_domain_generated_meta.yaml index 2d496b4df85..6fab7d7956e 100644 --- a/google/services/firebaseapphosting/resource_firebase_app_hosting_domain_generated_meta.yaml +++ b/google/services/firebaseapphosting/resource_firebase_app_hosting_domain_generated_meta.yaml @@ -52,3 +52,5 @@ fields: - api_field: serve.redirect.uri - api_field: uid - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/firebaseapphosting/resource_firebase_app_hosting_traffic.go b/google/services/firebaseapphosting/resource_firebase_app_hosting_traffic.go index c79a7921623..b0a2d8ac51e 100644 --- a/google/services/firebaseapphosting/resource_firebase_app_hosting_traffic.go +++ b/google/services/firebaseapphosting/resource_firebase_app_hosting_traffic.go @@ -469,6 +469,7 @@ func resourceFirebaseAppHostingTrafficRead(d *schema.ResourceData, meta interfac } func resourceFirebaseAppHostingTrafficUpdate(d *schema.ResourceData, meta interface{}) error { + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/firebasedataconnect/resource_firebase_data_connect_service.go b/google/services/firebasedataconnect/resource_firebase_data_connect_service.go index 8c0926f5f3d..f40d68d0d3c 100644 --- a/google/services/firebasedataconnect/resource_firebase_data_connect_service.go +++ b/google/services/firebasedataconnect/resource_firebase_data_connect_service.go @@ -117,6 +117,7 @@ func ResourceFirebaseDataConnectService() *schema.Resource { tpgresource.SetAnnotationsDiff, tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DEFAULT"), ), Identity: &schema.ResourceIdentity{ @@ -239,22 +240,18 @@ service.`, Computed: true, Description: `Output only. [Output only] Update time stamp.`, }, - "deletion_policy": { - Type: schema.TypeString, - Optional: true, - Description: `The deletion policy for the database. Setting the field to FORCE allows the -Service to be deleted even if a Schema or Connector is present. By default, -the Service deletion will only succeed when no Schema or Connectors are -present. -Possible values: DEFAULT, FORCE`, - Default: "DEFAULT", - }, "project": { Type: schema.TypeString, Optional: true, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `This field uses a custom implementation please refer to documentation under /hashicorp/terraform-provider-google-beta/website/docs/r/firebase_data_connect_service.html.markdown for specifics`, + }, }, UseJSONNumber: true, } @@ -412,8 +409,15 @@ func resourceFirebaseDataConnectServiceRead(d *schema.ResourceData, meta interfa // Explicitly set virtual fields to default values if unset if _, ok := d.GetOkExists("deletion_policy"); !ok { - if err := d.Set("deletion_policy", "DEFAULT"); err != nil { - return fmt.Errorf("Error setting deletion_policy: %s", err) + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DEFAULT"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } } } if err := d.Set("project", project); err != nil { @@ -453,6 +457,19 @@ func resourceFirebaseDataConnectServiceRead(d *schema.ResourceData, meta interfa } func resourceFirebaseDataConnectServiceUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceFirebaseDataConnectService().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceFirebaseDataConnectServiceRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -581,6 +598,13 @@ func resourceFirebaseDataConnectServiceUpdate(d *schema.ResourceData, meta inter } func resourceFirebaseDataConnectServiceDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy FirebaseDataConnectService without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Service %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -657,9 +681,6 @@ func resourceFirebaseDataConnectServiceImport(d *schema.ResourceData, meta inter d.SetId(id) // Explicitly set virtual fields to default values on import - if err := d.Set("deletion_policy", "DEFAULT"); err != nil { - return nil, fmt.Errorf("Error setting deletion_policy: %s", err) - } return []*schema.ResourceData{d}, nil } diff --git a/google/services/firebasedataconnect/resource_firebase_data_connect_service_generated_meta.yaml b/google/services/firebasedataconnect/resource_firebase_data_connect_service_generated_meta.yaml index 9d96fa4695e..fec7fe454ec 100644 --- a/google/services/firebasedataconnect/resource_firebase_data_connect_service_generated_meta.yaml +++ b/google/services/firebasedataconnect/resource_firebase_data_connect_service_generated_meta.yaml @@ -10,8 +10,6 @@ autogen_status: true fields: - api_field: annotations - api_field: createTime - - field: deletion_policy - provider_only: true - api_field: displayName - field: effective_annotations provider_only: true @@ -29,3 +27,5 @@ fields: provider_only: true - api_field: uid - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/firebaseremoteconfig/resource_firebase_remote_config_remote_config.go b/google/services/firebaseremoteconfig/resource_firebase_remote_config_remote_config.go index 2196f2329b7..47bf97a8391 100644 --- a/google/services/firebaseremoteconfig/resource_firebase_remote_config_remote_config.go +++ b/google/services/firebaseremoteconfig/resource_firebase_remote_config_remote_config.go @@ -601,6 +601,7 @@ func resourceFirebaseRemoteConfigRemoteConfigRead(d *schema.ResourceData, meta i } func resourceFirebaseRemoteConfigRemoteConfigUpdate(d *schema.ResourceData, meta interface{}) error { + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/firebaserules/resource_firebaserules_release.go b/google/services/firebaserules/resource_firebaserules_release.go index 2f91ddf4db5..ff3ae9efad2 100644 --- a/google/services/firebaserules/resource_firebaserules_release.go +++ b/google/services/firebaserules/resource_firebaserules_release.go @@ -36,6 +36,7 @@ func ResourceFirebaserulesRelease() *schema.Resource { return &schema.Resource{ Create: resourceFirebaserulesReleaseCreate, Read: resourceFirebaserulesReleaseRead, + Update: resourceFirebaserulesReleaseUpdate, Delete: resourceFirebaserulesReleaseDelete, Importer: &schema.ResourceImporter{ @@ -48,6 +49,7 @@ func ResourceFirebaserulesRelease() *schema.Resource { }, CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -92,6 +94,9 @@ func ResourceFirebaserulesRelease() *schema.Resource { Computed: true, Description: "Output only. Time the release was updated.", }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, } } @@ -200,10 +205,29 @@ func resourceFirebaserulesReleaseRead(d *schema.ResourceData, meta interface{}) return fmt.Errorf("error setting update_time in state: %s", err) } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } +// UDP update start +func resourceFirebaserulesReleaseUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceFirebaserulesReleaseRead(d, meta) +} + +//UDP update end + func resourceFirebaserulesReleaseDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) project, err := tpgresource.GetProject(d, config) if err != nil { diff --git a/google/services/firebaserules/resource_firebaserules_release_meta.yaml b/google/services/firebaserules/resource_firebaserules_release_meta.yaml index 6130f2ff337..6016a550efe 100644 --- a/google/services/firebaserules/resource_firebaserules_release_meta.yaml +++ b/google/services/firebaserules/resource_firebaserules_release_meta.yaml @@ -12,3 +12,5 @@ fields: - field: 'project' - api_field: 'rulesetName' - api_field: 'updateTime' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/firebaserules/resource_firebaserules_ruleset.go b/google/services/firebaserules/resource_firebaserules_ruleset.go index e5bd4a8a621..466906c7aed 100644 --- a/google/services/firebaserules/resource_firebaserules_ruleset.go +++ b/google/services/firebaserules/resource_firebaserules_ruleset.go @@ -36,6 +36,7 @@ func ResourceFirebaserulesRuleset() *schema.Resource { return &schema.Resource{ Create: resourceFirebaserulesRulesetCreate, Read: resourceFirebaserulesRulesetRead, + Update: resourceFirebaserulesRulesetUpdate, Delete: resourceFirebaserulesRulesetDelete, Importer: &schema.ResourceImporter{ @@ -48,6 +49,7 @@ func ResourceFirebaserulesRuleset() *schema.Resource { }, CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -87,6 +89,9 @@ func ResourceFirebaserulesRuleset() *schema.Resource { Computed: true, Description: "Output only. Name of the `Ruleset`. The ruleset_id is auto generated by the service. Format: `projects/{project_id}/rulesets/{ruleset_id}`", }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, } } @@ -263,10 +268,29 @@ func resourceFirebaserulesRulesetRead(d *schema.ResourceData, meta interface{}) return fmt.Errorf("error setting name in state: %s", err) } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } +// UDP update start +func resourceFirebaserulesRulesetUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceFirebaserulesRulesetRead(d, meta) +} + +//UDP update end + func resourceFirebaserulesRulesetDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) project, err := tpgresource.GetProject(d, config) if err != nil { diff --git a/google/services/firebaserules/resource_firebaserules_ruleset_meta.yaml b/google/services/firebaserules/resource_firebaserules_ruleset_meta.yaml index 4df9f4d820d..9e831795454 100644 --- a/google/services/firebaserules/resource_firebaserules_ruleset_meta.yaml +++ b/google/services/firebaserules/resource_firebaserules_ruleset_meta.yaml @@ -14,3 +14,5 @@ fields: - api_field: 'source.files.fingerprint' - api_field: 'source.files.name' - api_field: 'source.language' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/firestore/resource_firestore_backup_schedule.go b/google/services/firestore/resource_firestore_backup_schedule.go index aa4b633dbe2..0bb558e7b8c 100644 --- a/google/services/firestore/resource_firestore_backup_schedule.go +++ b/google/services/firestore/resource_firestore_backup_schedule.go @@ -115,6 +115,7 @@ func ResourceFirestoreBackupSchedule() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -197,6 +198,18 @@ You can set this to a value up to 14 weeks.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -342,6 +355,19 @@ func resourceFirestoreBackupScheduleRead(d *schema.ResourceData, meta interface{ log.Printf("[DEBUG] Finished reading FirestoreBackupSchedule %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading BackupSchedule: %s", err) } @@ -379,6 +405,19 @@ func resourceFirestoreBackupScheduleRead(d *schema.ResourceData, meta interface{ } func resourceFirestoreBackupScheduleUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceFirestoreBackupSchedule().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceFirestoreBackupScheduleRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -470,6 +509,13 @@ func resourceFirestoreBackupScheduleUpdate(d *schema.ResourceData, meta interfac } func resourceFirestoreBackupScheduleDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy FirestoreBackupSchedule without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing BackupSchedule %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/firestore/resource_firestore_backup_schedule_generated_meta.yaml b/google/services/firestore/resource_firestore_backup_schedule_generated_meta.yaml index d66c0022173..6de75f70a1a 100644 --- a/google/services/firestore/resource_firestore_backup_schedule_generated_meta.yaml +++ b/google/services/firestore/resource_firestore_backup_schedule_generated_meta.yaml @@ -13,3 +13,5 @@ fields: - api_field: name - api_field: retention - api_field: weeklyRecurrence.day + - field: deletion_policy + provider_only: true diff --git a/google/services/firestore/resource_firestore_database.go b/google/services/firestore/resource_firestore_database.go index 2ae5587e412..67ab1428076 100644 --- a/google/services/firestore/resource_firestore_database.go +++ b/google/services/firestore/resource_firestore_database.go @@ -115,6 +115,7 @@ func ResourceFirestoreDatabase() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("ABANDON"), ), Identity: &schema.ResourceIdentity{ @@ -335,21 +336,23 @@ Any read or query can specify a readTime within this window, and will read the s If the PITR feature is enabled, the retention period is 7 days. Otherwise, the retention period is 1 hour. A duration in seconds with up to nine fractional digits, ending with 's'. Example: "3.5s".`, }, - "deletion_policy": { + "project": { Type: schema.TypeString, Optional: true, - Description: `Deletion behavior for this database. -If the deletion policy is 'ABANDON', the database will be removed from Terraform state but not deleted from Google Cloud upon destruction. -If the deletion policy is 'DELETE', the database will both be removed from Terraform state and deleted from Google Cloud upon destruction. -The default value is 'ABANDON'. -See also 'delete_protection'.`, - Default: "ABANDON", + Computed: true, + ForceNew: true, }, - "project": { + "deletion_policy": { Type: schema.TypeString, Optional: true, Computed: true, - ForceNew: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "ABANDON". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, }, }, UseJSONNumber: true, @@ -563,8 +566,15 @@ func resourceFirestoreDatabaseRead(d *schema.ResourceData, meta interface{}) err // Explicitly set virtual fields to default values if unset if _, ok := d.GetOkExists("deletion_policy"); !ok { - if err := d.Set("deletion_policy", "ABANDON"); err != nil { - return fmt.Errorf("Error setting deletion_policy: %s", err) + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "ABANDON"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } } } if err := d.Set("project", project); err != nil { @@ -598,6 +608,19 @@ func resourceFirestoreDatabaseRead(d *schema.ResourceData, meta interface{}) err } func resourceFirestoreDatabaseUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceFirestoreDatabase().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceFirestoreDatabaseRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -741,6 +764,13 @@ func resourceFirestoreDatabaseUpdate(d *schema.ResourceData, meta interface{}) e } func resourceFirestoreDatabaseDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy FirestoreDatabase without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Database %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -767,10 +797,6 @@ func resourceFirestoreDatabaseDelete(d *schema.ResourceData, meta interface{}) e } headers := make(http.Header) - if deletionPolicy := d.Get("deletion_policy"); deletionPolicy != "DELETE" { - log.Printf("[WARN] Firestore database %q deletion_policy is not set to 'DELETE', skipping deletion", d.Get("name").(string)) - return nil - } if deleteProtection := d.Get("delete_protection_state"); deleteProtection == "DELETE_PROTECTION_ENABLED" { return fmt.Errorf("Cannot delete Firestore database %s: Delete Protection is enabled. Set delete_protection_state to DELETE_PROTECTION_DISABLED for this resource and run \"terraform apply\" before attempting to delete it.", d.Get("name").(string)) } @@ -811,11 +837,6 @@ func resourceFirestoreDatabaseImport(d *schema.ResourceData, meta interface{}) ( } d.SetId(id) - // Explicitly set virtual fields to default values on import - if err := d.Set("deletion_policy", "ABANDON"); err != nil { - return nil, fmt.Errorf("Error setting deletion_policy: %s", err) - } - return []*schema.ResourceData{d}, nil } diff --git a/google/services/firestore/resource_firestore_database_generated_meta.yaml b/google/services/firestore/resource_firestore_database_generated_meta.yaml index 802d76d086f..2952ac00031 100644 --- a/google/services/firestore/resource_firestore_database_generated_meta.yaml +++ b/google/services/firestore/resource_firestore_database_generated_meta.yaml @@ -14,8 +14,6 @@ fields: - api_field: createTime - api_field: databaseEdition - api_field: deleteProtectionState - - field: deletion_policy - provider_only: true - api_field: earliestVersionTime - api_field: etag - api_field: firestoreDataAccessMode @@ -30,3 +28,5 @@ fields: - api_field: uid - api_field: updateTime - api_field: versionRetentionPeriod + - field: deletion_policy + provider_only: true diff --git a/google/services/firestore/resource_firestore_document.go b/google/services/firestore/resource_firestore_document.go index 5fa1922fad1..a2417dc2d26 100644 --- a/google/services/firestore/resource_firestore_document.go +++ b/google/services/firestore/resource_firestore_document.go @@ -115,6 +115,7 @@ func ResourceFirestoreDocument() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -186,6 +187,18 @@ func ResourceFirestoreDocument() *schema.Resource { Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -321,6 +334,19 @@ func resourceFirestoreDocumentRead(d *schema.ResourceData, meta interface{}) err return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Document: %s", err) } @@ -346,6 +372,19 @@ func resourceFirestoreDocumentRead(d *schema.ResourceData, meta interface{}) err } func resourceFirestoreDocumentUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceFirestoreDocument().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceFirestoreDocumentRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -412,6 +451,13 @@ func resourceFirestoreDocumentUpdate(d *schema.ResourceData, meta interface{}) e } func resourceFirestoreDocumentDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy FirestoreDocument without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Document %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/firestore/resource_firestore_document_generated_meta.yaml b/google/services/firestore/resource_firestore_document_generated_meta.yaml index 9d5785ee7e9..e7acb3ff415 100644 --- a/google/services/firestore/resource_firestore_document_generated_meta.yaml +++ b/google/services/firestore/resource_firestore_document_generated_meta.yaml @@ -19,3 +19,5 @@ fields: - api_field: name - api_field: path - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/firestore/resource_firestore_field.go b/google/services/firestore/resource_firestore_field.go index d6955c03aa3..09c9a379507 100644 --- a/google/services/firestore/resource_firestore_field.go +++ b/google/services/firestore/resource_firestore_field.go @@ -115,6 +115,7 @@ func ResourceFirestoreField() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -199,6 +200,18 @@ the field.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -385,6 +398,19 @@ func resourceFirestoreFieldRead(d *schema.ResourceData, meta interface{}) error log.Printf("[DEBUG] Finished reading FirestoreField %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Field: %s", err) } @@ -410,6 +436,19 @@ func resourceFirestoreFieldRead(d *schema.ResourceData, meta interface{}) error } func resourceFirestoreFieldUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceFirestoreField().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceFirestoreFieldRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -514,6 +553,13 @@ func resourceFirestoreFieldUpdate(d *schema.ResourceData, meta interface{}) erro } func resourceFirestoreFieldDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy FirestoreField without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Field %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/firestore/resource_firestore_field_generated_meta.yaml b/google/services/firestore/resource_firestore_field_generated_meta.yaml index 7ded9f4fdb8..72f8aaa6f00 100644 --- a/google/services/firestore/resource_firestore_field_generated_meta.yaml +++ b/google/services/firestore/resource_firestore_field_generated_meta.yaml @@ -18,3 +18,5 @@ fields: - api_field: indexConfig.indexes.queryScope - api_field: name - api_field: ttlConfig.state + - field: deletion_policy + provider_only: true diff --git a/google/services/firestore/resource_firestore_index.go b/google/services/firestore/resource_firestore_index.go index 9fdd3eee549..cc6fbc52b99 100644 --- a/google/services/firestore/resource_firestore_index.go +++ b/google/services/firestore/resource_firestore_index.go @@ -152,6 +152,7 @@ func ResourceFirestoreIndex() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -364,22 +365,24 @@ with the same dimension.`, Description: `Whether to skip waiting for the index to be created.`, Default: false, }, - "deletion_policy": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: verify.ValidateEnum([]string{"DELETE", "PREVENT", ""}), - Description: `Deletion behavior for this index. -If the deletion policy is 'PREVENT', the index cannot be deleted and a terraform destroy will fail. -If the deletion policy is 'DELETE', the index will both be removed from Terraform state and deleted from Google Cloud upon destruction. -The default value is 'DELETE'. Default value: "DELETE" Possible values: ["DELETE", "PREVENT"]`, - Default: "DELETE", - }, "project": { Type: schema.TypeString, Optional: true, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -582,8 +585,15 @@ func resourceFirestoreIndexRead(d *schema.ResourceData, meta interface{}) error } } if _, ok := d.GetOkExists("deletion_policy"); !ok { - if err := d.Set("deletion_policy", "DELETE"); err != nil { - return fmt.Errorf("Error setting deletion_policy: %s", err) + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } } } if err := d.Set("project", project); err != nil { @@ -611,11 +621,18 @@ func resourceFirestoreIndexRead(d *schema.ResourceData, meta interface{}) error } func resourceFirestoreIndexUpdate(d *schema.ResourceData, meta interface{}) error { - // Only the root field "labels", "terraform_labels", and virtual fields are mutable + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable return resourceFirestoreIndexRead(d, meta) } func resourceFirestoreIndexDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy FirestoreIndex without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Index %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -642,9 +659,6 @@ func resourceFirestoreIndexDelete(d *schema.ResourceData, meta interface{}) erro } headers := make(http.Header) - if d.Get("deletion_policy").(string) == "PREVENT" { - return fmt.Errorf("cannot destroy google_firestore_index resource with id : %q without setting deletion_policy=DELETE and running `terraform apply`", d.Id()) - } log.Printf("[DEBUG] Deleting Index %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ diff --git a/google/services/firestore/resource_firestore_index_generated_meta.yaml b/google/services/firestore/resource_firestore_index_generated_meta.yaml index 69b4abaab78..3a8fd3f1feb 100644 --- a/google/services/firestore/resource_firestore_index_generated_meta.yaml +++ b/google/services/firestore/resource_firestore_index_generated_meta.yaml @@ -10,8 +10,6 @@ fields: - api_field: apiScope - api_field: collection - api_field: database - - field: deletion_policy - provider_only: true - api_field: density - api_field: fields.arrayConfig - api_field: fields.fieldPath @@ -27,3 +25,5 @@ fields: - field: skip_wait provider_only: true - api_field: unique + - field: deletion_policy + provider_only: true diff --git a/google/services/firestore/resource_firestore_user_creds.go b/google/services/firestore/resource_firestore_user_creds.go index 9a75eadfdb1..71e2c534683 100644 --- a/google/services/firestore/resource_firestore_user_creds.go +++ b/google/services/firestore/resource_firestore_user_creds.go @@ -100,6 +100,7 @@ func ResourceFirestoreUserCreds() *schema.Resource { return &schema.Resource{ Create: resourceFirestoreUserCredsCreate, Read: resourceFirestoreUserCredsRead, + Update: resourceFirestoreUserCredsUpdate, Delete: resourceFirestoreUserCredsDelete, Importer: &schema.ResourceImporter{ @@ -113,6 +114,7 @@ func ResourceFirestoreUserCreds() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -198,6 +200,18 @@ See https://cloud.google.com/iam/docs/principal-identifiers.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -334,6 +348,19 @@ func resourceFirestoreUserCredsRead(d *schema.ResourceData, meta interface{}) er log.Printf("[DEBUG] Finished reading FirestoreUserCreds %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading UserCreds: %s", err) } @@ -370,7 +397,19 @@ func resourceFirestoreUserCredsRead(d *schema.ResourceData, meta interface{}) er return nil } +func resourceFirestoreUserCredsUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceFirestoreUserCredsRead(d, meta) +} + func resourceFirestoreUserCredsDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy FirestoreUserCreds without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing UserCreds %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/firestore/resource_firestore_user_creds_generated_meta.yaml b/google/services/firestore/resource_firestore_user_creds_generated_meta.yaml index 10a6bb9a1d2..8959104d172 100644 --- a/google/services/firestore/resource_firestore_user_creds_generated_meta.yaml +++ b/google/services/firestore/resource_firestore_user_creds_generated_meta.yaml @@ -15,3 +15,5 @@ fields: - api_field: securePassword - api_field: state - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/gemini/resource_gemini_code_repository_index.go b/google/services/gemini/resource_gemini_code_repository_index.go index 3a64340873a..f3590d80579 100644 --- a/google/services/gemini/resource_gemini_code_repository_index.go +++ b/google/services/gemini/resource_gemini_code_repository_index.go @@ -116,6 +116,7 @@ func ResourceGeminiCodeRepositoryIndex() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -216,6 +217,18 @@ Possible values are: 'STATE_UNSPECIFIED', 'CREATING', 'ACTIVE', 'DELETING', 'SUS Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -374,6 +387,18 @@ func resourceGeminiCodeRepositoryIndexRead(d *schema.ResourceData, meta interfac return fmt.Errorf("Error setting force_destroy: %s", err) } } + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading CodeRepositoryIndex: %s", err) } @@ -411,6 +436,19 @@ func resourceGeminiCodeRepositoryIndexRead(d *schema.ResourceData, meta interfac } func resourceGeminiCodeRepositoryIndexUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceGeminiCodeRepositoryIndex().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceGeminiCodeRepositoryIndexRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -517,6 +555,13 @@ func resourceGeminiCodeRepositoryIndexUpdate(d *schema.ResourceData, meta interf } func resourceGeminiCodeRepositoryIndexDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy GeminiCodeRepositoryIndex without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing CodeRepositoryIndex %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/gemini/resource_gemini_code_repository_index_generated_meta.yaml b/google/services/gemini/resource_gemini_code_repository_index_generated_meta.yaml index e66f1341354..ffd52ca1c40 100644 --- a/google/services/gemini/resource_gemini_code_repository_index_generated_meta.yaml +++ b/google/services/gemini/resource_gemini_code_repository_index_generated_meta.yaml @@ -23,3 +23,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/gemini/resource_gemini_code_tools_setting.go b/google/services/gemini/resource_gemini_code_tools_setting.go index 7c9c9ca50c8..9de63ea9aeb 100644 --- a/google/services/gemini/resource_gemini_code_tools_setting.go +++ b/google/services/gemini/resource_gemini_code_tools_setting.go @@ -116,6 +116,7 @@ func ResourceGeminiCodeToolsSetting() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -247,6 +248,18 @@ Format:projects/{project}/locations/{location}/codeToolsSettings/{codeToolsSetti Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -387,6 +400,19 @@ func resourceGeminiCodeToolsSettingRead(d *schema.ResourceData, meta interface{} log.Printf("[DEBUG] Finished reading GeminiCodeToolsSetting %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading CodeToolsSetting: %s", err) } @@ -424,6 +450,19 @@ func resourceGeminiCodeToolsSettingRead(d *schema.ResourceData, meta interface{} } func resourceGeminiCodeToolsSettingUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceGeminiCodeToolsSetting().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceGeminiCodeToolsSettingRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -532,6 +571,13 @@ func resourceGeminiCodeToolsSettingUpdate(d *schema.ResourceData, meta interface } func resourceGeminiCodeToolsSettingDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy GeminiCodeToolsSetting without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing CodeToolsSetting %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/gemini/resource_gemini_code_tools_setting_binding.go b/google/services/gemini/resource_gemini_code_tools_setting_binding.go index 4642acf2bb7..289a78252a0 100644 --- a/google/services/gemini/resource_gemini_code_tools_setting_binding.go +++ b/google/services/gemini/resource_gemini_code_tools_setting_binding.go @@ -116,6 +116,7 @@ func ResourceGeminiCodeToolsSettingBinding() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -220,6 +221,18 @@ Format:projects/{project}/locations/{location}/codeToolsSettings/{setting}/setti Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -381,6 +394,19 @@ func resourceGeminiCodeToolsSettingBindingRead(d *schema.ResourceData, meta inte log.Printf("[DEBUG] Finished reading GeminiCodeToolsSettingBinding %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading CodeToolsSettingBinding: %s", err) } @@ -424,6 +450,19 @@ func resourceGeminiCodeToolsSettingBindingRead(d *schema.ResourceData, meta inte } func resourceGeminiCodeToolsSettingBindingUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceGeminiCodeToolsSettingBinding().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceGeminiCodeToolsSettingBindingRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -554,6 +593,13 @@ func resourceGeminiCodeToolsSettingBindingUpdate(d *schema.ResourceData, meta in } func resourceGeminiCodeToolsSettingBindingDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy GeminiCodeToolsSettingBinding without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing CodeToolsSettingBinding %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/gemini/resource_gemini_code_tools_setting_binding_generated_meta.yaml b/google/services/gemini/resource_gemini_code_tools_setting_binding_generated_meta.yaml index ebbc69a2416..4759eb8da9a 100644 --- a/google/services/gemini/resource_gemini_code_tools_setting_binding_generated_meta.yaml +++ b/google/services/gemini/resource_gemini_code_tools_setting_binding_generated_meta.yaml @@ -24,3 +24,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/gemini/resource_gemini_code_tools_setting_generated_meta.yaml b/google/services/gemini/resource_gemini_code_tools_setting_generated_meta.yaml index f36d1f64110..983bd0b72a1 100644 --- a/google/services/gemini/resource_gemini_code_tools_setting_generated_meta.yaml +++ b/google/services/gemini/resource_gemini_code_tools_setting_generated_meta.yaml @@ -26,3 +26,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/gemini/resource_gemini_data_sharing_with_google_setting.go b/google/services/gemini/resource_gemini_data_sharing_with_google_setting.go index 112582c440d..fc13a1564a1 100644 --- a/google/services/gemini/resource_gemini_data_sharing_with_google_setting.go +++ b/google/services/gemini/resource_gemini_data_sharing_with_google_setting.go @@ -116,6 +116,7 @@ func ResourceGeminiDataSharingWithGoogleSetting() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -208,6 +209,18 @@ Format:projects/{project}/locations/{location}/dataSharingWithGoogleSettings/{da Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -354,6 +367,19 @@ func resourceGeminiDataSharingWithGoogleSettingRead(d *schema.ResourceData, meta log.Printf("[DEBUG] Finished reading GeminiDataSharingWithGoogleSetting %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading DataSharingWithGoogleSetting: %s", err) } @@ -391,6 +417,19 @@ func resourceGeminiDataSharingWithGoogleSettingRead(d *schema.ResourceData, meta } func resourceGeminiDataSharingWithGoogleSettingUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceGeminiDataSharingWithGoogleSetting().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceGeminiDataSharingWithGoogleSettingRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -509,6 +548,13 @@ func resourceGeminiDataSharingWithGoogleSettingUpdate(d *schema.ResourceData, me } func resourceGeminiDataSharingWithGoogleSettingDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy GeminiDataSharingWithGoogleSetting without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing DataSharingWithGoogleSetting %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/gemini/resource_gemini_data_sharing_with_google_setting_binding.go b/google/services/gemini/resource_gemini_data_sharing_with_google_setting_binding.go index 0541c718315..b081b14dfe9 100644 --- a/google/services/gemini/resource_gemini_data_sharing_with_google_setting_binding.go +++ b/google/services/gemini/resource_gemini_data_sharing_with_google_setting_binding.go @@ -116,6 +116,7 @@ func ResourceGeminiDataSharingWithGoogleSettingBinding() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -219,6 +220,18 @@ Format:projects/{project}/locations/{location}/dataSharingWithGoogleSettings/{se Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -380,6 +393,19 @@ func resourceGeminiDataSharingWithGoogleSettingBindingRead(d *schema.ResourceDat log.Printf("[DEBUG] Finished reading GeminiDataSharingWithGoogleSettingBinding %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading DataSharingWithGoogleSettingBinding: %s", err) } @@ -423,6 +449,19 @@ func resourceGeminiDataSharingWithGoogleSettingBindingRead(d *schema.ResourceDat } func resourceGeminiDataSharingWithGoogleSettingBindingUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceGeminiDataSharingWithGoogleSettingBinding().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceGeminiDataSharingWithGoogleSettingBindingRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -553,6 +592,13 @@ func resourceGeminiDataSharingWithGoogleSettingBindingUpdate(d *schema.ResourceD } func resourceGeminiDataSharingWithGoogleSettingBindingDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy GeminiDataSharingWithGoogleSettingBinding without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing DataSharingWithGoogleSettingBinding %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/gemini/resource_gemini_data_sharing_with_google_setting_binding_generated_meta.yaml b/google/services/gemini/resource_gemini_data_sharing_with_google_setting_binding_generated_meta.yaml index e74b8e6dc38..cd1b1cccf32 100644 --- a/google/services/gemini/resource_gemini_data_sharing_with_google_setting_binding_generated_meta.yaml +++ b/google/services/gemini/resource_gemini_data_sharing_with_google_setting_binding_generated_meta.yaml @@ -26,3 +26,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/gemini/resource_gemini_data_sharing_with_google_setting_generated_meta.yaml b/google/services/gemini/resource_gemini_data_sharing_with_google_setting_generated_meta.yaml index 93c65d63fd1..b4a8df5e133 100644 --- a/google/services/gemini/resource_gemini_data_sharing_with_google_setting_generated_meta.yaml +++ b/google/services/gemini/resource_gemini_data_sharing_with_google_setting_generated_meta.yaml @@ -22,3 +22,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/gemini/resource_gemini_gemini_gcp_enablement_setting.go b/google/services/gemini/resource_gemini_gemini_gcp_enablement_setting.go index 94284175162..9cc97e378b8 100644 --- a/google/services/gemini/resource_gemini_gemini_gcp_enablement_setting.go +++ b/google/services/gemini/resource_gemini_gemini_gcp_enablement_setting.go @@ -116,6 +116,7 @@ func ResourceGeminiGeminiGcpEnablementSetting() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -217,6 +218,18 @@ Format:projects/{project}/locations/{location}/geminiGcpEnablementSettings/{gemi Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -369,6 +382,19 @@ func resourceGeminiGeminiGcpEnablementSettingRead(d *schema.ResourceData, meta i log.Printf("[DEBUG] Finished reading GeminiGeminiGcpEnablementSetting %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading GeminiGcpEnablementSetting: %s", err) } @@ -406,6 +432,19 @@ func resourceGeminiGeminiGcpEnablementSettingRead(d *schema.ResourceData, meta i } func resourceGeminiGeminiGcpEnablementSettingUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceGeminiGeminiGcpEnablementSetting().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceGeminiGeminiGcpEnablementSettingRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -534,6 +573,13 @@ func resourceGeminiGeminiGcpEnablementSettingUpdate(d *schema.ResourceData, meta } func resourceGeminiGeminiGcpEnablementSettingDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy GeminiGeminiGcpEnablementSetting without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing GeminiGcpEnablementSetting %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/gemini/resource_gemini_gemini_gcp_enablement_setting_binding.go b/google/services/gemini/resource_gemini_gemini_gcp_enablement_setting_binding.go index ce8daca2e41..686b20da002 100644 --- a/google/services/gemini/resource_gemini_gemini_gcp_enablement_setting_binding.go +++ b/google/services/gemini/resource_gemini_gemini_gcp_enablement_setting_binding.go @@ -116,6 +116,7 @@ func ResourceGeminiGeminiGcpEnablementSettingBinding() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -219,6 +220,18 @@ Format:projects/{project}/locations/{location}/geminiGcpEnablementSettings/{sett Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -380,6 +393,19 @@ func resourceGeminiGeminiGcpEnablementSettingBindingRead(d *schema.ResourceData, log.Printf("[DEBUG] Finished reading GeminiGeminiGcpEnablementSettingBinding %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading GeminiGcpEnablementSettingBinding: %s", err) } @@ -423,6 +449,19 @@ func resourceGeminiGeminiGcpEnablementSettingBindingRead(d *schema.ResourceData, } func resourceGeminiGeminiGcpEnablementSettingBindingUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceGeminiGeminiGcpEnablementSettingBinding().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceGeminiGeminiGcpEnablementSettingBindingRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -553,6 +592,13 @@ func resourceGeminiGeminiGcpEnablementSettingBindingUpdate(d *schema.ResourceDat } func resourceGeminiGeminiGcpEnablementSettingBindingDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy GeminiGeminiGcpEnablementSettingBinding without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing GeminiGcpEnablementSettingBinding %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/gemini/resource_gemini_gemini_gcp_enablement_setting_binding_generated_meta.yaml b/google/services/gemini/resource_gemini_gemini_gcp_enablement_setting_binding_generated_meta.yaml index 221dee6e2d8..3eb687f4782 100644 --- a/google/services/gemini/resource_gemini_gemini_gcp_enablement_setting_binding_generated_meta.yaml +++ b/google/services/gemini/resource_gemini_gemini_gcp_enablement_setting_binding_generated_meta.yaml @@ -26,3 +26,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/gemini/resource_gemini_gemini_gcp_enablement_setting_generated_meta.yaml b/google/services/gemini/resource_gemini_gemini_gcp_enablement_setting_generated_meta.yaml index 0c22b7ad19d..072729f4cb6 100644 --- a/google/services/gemini/resource_gemini_gemini_gcp_enablement_setting_generated_meta.yaml +++ b/google/services/gemini/resource_gemini_gemini_gcp_enablement_setting_generated_meta.yaml @@ -23,3 +23,5 @@ fields: provider_only: true - api_field: updateTime - api_field: webGroundingType + - field: deletion_policy + provider_only: true diff --git a/google/services/gemini/resource_gemini_logging_setting.go b/google/services/gemini/resource_gemini_logging_setting.go index d804a65145e..20880b2edfb 100644 --- a/google/services/gemini/resource_gemini_logging_setting.go +++ b/google/services/gemini/resource_gemini_logging_setting.go @@ -116,6 +116,7 @@ func ResourceGeminiLoggingSetting() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -208,6 +209,18 @@ Format:projects/{project}/locations/{location}/loggingsettings/{loggingsetting}` Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -354,6 +367,19 @@ func resourceGeminiLoggingSettingRead(d *schema.ResourceData, meta interface{}) log.Printf("[DEBUG] Finished reading GeminiLoggingSetting %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading LoggingSetting: %s", err) } @@ -391,6 +417,19 @@ func resourceGeminiLoggingSettingRead(d *schema.ResourceData, meta interface{}) } func resourceGeminiLoggingSettingUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceGeminiLoggingSetting().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceGeminiLoggingSettingRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -509,6 +548,13 @@ func resourceGeminiLoggingSettingUpdate(d *schema.ResourceData, meta interface{} } func resourceGeminiLoggingSettingDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy GeminiLoggingSetting without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing LoggingSetting %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/gemini/resource_gemini_logging_setting_binding.go b/google/services/gemini/resource_gemini_logging_setting_binding.go index 32ceaa6e46a..e5fd98494a3 100644 --- a/google/services/gemini/resource_gemini_logging_setting_binding.go +++ b/google/services/gemini/resource_gemini_logging_setting_binding.go @@ -116,6 +116,7 @@ func ResourceGeminiLoggingSettingBinding() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -220,6 +221,18 @@ Format:projects/{project}/locations/{location}/loggingSettings/{setting}/setting Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -381,6 +394,19 @@ func resourceGeminiLoggingSettingBindingRead(d *schema.ResourceData, meta interf log.Printf("[DEBUG] Finished reading GeminiLoggingSettingBinding %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading LoggingSettingBinding: %s", err) } @@ -424,6 +450,19 @@ func resourceGeminiLoggingSettingBindingRead(d *schema.ResourceData, meta interf } func resourceGeminiLoggingSettingBindingUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceGeminiLoggingSettingBinding().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceGeminiLoggingSettingBindingRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -554,6 +593,13 @@ func resourceGeminiLoggingSettingBindingUpdate(d *schema.ResourceData, meta inte } func resourceGeminiLoggingSettingBindingDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy GeminiLoggingSettingBinding without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing LoggingSettingBinding %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/gemini/resource_gemini_logging_setting_binding_generated_meta.yaml b/google/services/gemini/resource_gemini_logging_setting_binding_generated_meta.yaml index 2328ecee407..cccc44129a6 100644 --- a/google/services/gemini/resource_gemini_logging_setting_binding_generated_meta.yaml +++ b/google/services/gemini/resource_gemini_logging_setting_binding_generated_meta.yaml @@ -26,3 +26,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/gemini/resource_gemini_logging_setting_generated_meta.yaml b/google/services/gemini/resource_gemini_logging_setting_generated_meta.yaml index 0fefe3e7bf9..1473c43af3c 100644 --- a/google/services/gemini/resource_gemini_logging_setting_generated_meta.yaml +++ b/google/services/gemini/resource_gemini_logging_setting_generated_meta.yaml @@ -22,3 +22,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/gemini/resource_gemini_release_channel_setting.go b/google/services/gemini/resource_gemini_release_channel_setting.go index f7c84714228..c372cd3891a 100644 --- a/google/services/gemini/resource_gemini_release_channel_setting.go +++ b/google/services/gemini/resource_gemini_release_channel_setting.go @@ -116,6 +116,7 @@ func ResourceGeminiReleaseChannelSetting() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -206,6 +207,18 @@ Format:projects/{project}/locations/{location}/releaseChannelSettings/{releaseCh Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -346,6 +359,19 @@ func resourceGeminiReleaseChannelSettingRead(d *schema.ResourceData, meta interf log.Printf("[DEBUG] Finished reading GeminiReleaseChannelSetting %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading ReleaseChannelSetting: %s", err) } @@ -383,6 +409,19 @@ func resourceGeminiReleaseChannelSettingRead(d *schema.ResourceData, meta interf } func resourceGeminiReleaseChannelSettingUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceGeminiReleaseChannelSetting().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceGeminiReleaseChannelSettingRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -491,6 +530,13 @@ func resourceGeminiReleaseChannelSettingUpdate(d *schema.ResourceData, meta inte } func resourceGeminiReleaseChannelSettingDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy GeminiReleaseChannelSetting without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ReleaseChannelSetting %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/gemini/resource_gemini_release_channel_setting_binding.go b/google/services/gemini/resource_gemini_release_channel_setting_binding.go index b943e22420a..4290af48c91 100644 --- a/google/services/gemini/resource_gemini_release_channel_setting_binding.go +++ b/google/services/gemini/resource_gemini_release_channel_setting_binding.go @@ -116,6 +116,7 @@ func ResourceGeminiReleaseChannelSettingBinding() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -220,6 +221,18 @@ Format:projects/{project}/locations/{location}/releaseChannelSettings/{setting}/ Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -381,6 +394,19 @@ func resourceGeminiReleaseChannelSettingBindingRead(d *schema.ResourceData, meta log.Printf("[DEBUG] Finished reading GeminiReleaseChannelSettingBinding %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading ReleaseChannelSettingBinding: %s", err) } @@ -424,6 +450,19 @@ func resourceGeminiReleaseChannelSettingBindingRead(d *schema.ResourceData, meta } func resourceGeminiReleaseChannelSettingBindingUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceGeminiReleaseChannelSettingBinding().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceGeminiReleaseChannelSettingBindingRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -554,6 +593,13 @@ func resourceGeminiReleaseChannelSettingBindingUpdate(d *schema.ResourceData, me } func resourceGeminiReleaseChannelSettingBindingDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy GeminiReleaseChannelSettingBinding without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ReleaseChannelSettingBinding %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/gemini/resource_gemini_release_channel_setting_binding_generated_meta.yaml b/google/services/gemini/resource_gemini_release_channel_setting_binding_generated_meta.yaml index 1d4c97016f4..48f4f065ac8 100644 --- a/google/services/gemini/resource_gemini_release_channel_setting_binding_generated_meta.yaml +++ b/google/services/gemini/resource_gemini_release_channel_setting_binding_generated_meta.yaml @@ -26,3 +26,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/gemini/resource_gemini_release_channel_setting_generated_meta.yaml b/google/services/gemini/resource_gemini_release_channel_setting_generated_meta.yaml index e4399283c0a..6b4fd97a92b 100644 --- a/google/services/gemini/resource_gemini_release_channel_setting_generated_meta.yaml +++ b/google/services/gemini/resource_gemini_release_channel_setting_generated_meta.yaml @@ -21,3 +21,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/gemini/resource_gemini_repository_group.go b/google/services/gemini/resource_gemini_repository_group.go index 4505824820e..6785e54de62 100644 --- a/google/services/gemini/resource_gemini_repository_group.go +++ b/google/services/gemini/resource_gemini_repository_group.go @@ -116,6 +116,7 @@ func ResourceGeminiRepositoryGroup() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -228,6 +229,18 @@ Please refer to the field 'effective_labels' for all of the labels present on th Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -385,6 +398,19 @@ func resourceGeminiRepositoryGroupRead(d *schema.ResourceData, meta interface{}) log.Printf("[DEBUG] Finished reading GeminiRepositoryGroup %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading RepositoryGroup: %s", err) } @@ -428,6 +454,19 @@ func resourceGeminiRepositoryGroupRead(d *schema.ResourceData, meta interface{}) } func resourceGeminiRepositoryGroupUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceGeminiRepositoryGroup().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceGeminiRepositoryGroupRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -549,6 +588,13 @@ func resourceGeminiRepositoryGroupUpdate(d *schema.ResourceData, meta interface{ } func resourceGeminiRepositoryGroupDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy GeminiRepositoryGroup without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing RepositoryGroup %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/gemini/resource_gemini_repository_group_generated_meta.yaml b/google/services/gemini/resource_gemini_repository_group_generated_meta.yaml index a9d27e89d07..a5f81fd72db 100644 --- a/google/services/gemini/resource_gemini_repository_group_generated_meta.yaml +++ b/google/services/gemini/resource_gemini_repository_group_generated_meta.yaml @@ -23,3 +23,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/gkebackup/resource_gke_backup_backup_channel.go b/google/services/gkebackup/resource_gke_backup_backup_channel.go index 3342b9cd528..d1569a229f5 100644 --- a/google/services/gkebackup/resource_gke_backup_backup_channel.go +++ b/google/services/gkebackup/resource_gke_backup_backup_channel.go @@ -116,6 +116,7 @@ func ResourceGKEBackupBackupChannel() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -219,6 +220,18 @@ backupChannels.delete to ensure that their change will be applied to the same ve Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -374,6 +387,19 @@ func resourceGKEBackupBackupChannelRead(d *schema.ResourceData, meta interface{} log.Printf("[DEBUG] Finished reading GKEBackupBackupChannel %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading BackupChannel: %s", err) } @@ -411,6 +437,19 @@ func resourceGKEBackupBackupChannelRead(d *schema.ResourceData, meta interface{} } func resourceGKEBackupBackupChannelUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceGKEBackupBackupChannel().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceGKEBackupBackupChannelRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -519,6 +558,13 @@ func resourceGKEBackupBackupChannelUpdate(d *schema.ResourceData, meta interface } func resourceGKEBackupBackupChannelDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy GKEBackupBackupChannel without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing BackupChannel %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/gkebackup/resource_gke_backup_backup_channel_generated_meta.yaml b/google/services/gkebackup/resource_gke_backup_backup_channel_generated_meta.yaml index 341d4c9babe..45150062362 100644 --- a/google/services/gkebackup/resource_gke_backup_backup_channel_generated_meta.yaml +++ b/google/services/gkebackup/resource_gke_backup_backup_channel_generated_meta.yaml @@ -20,3 +20,5 @@ fields: - field: terraform_labels provider_only: true - api_field: uid + - field: deletion_policy + provider_only: true diff --git a/google/services/gkebackup/resource_gke_backup_backup_plan.go b/google/services/gkebackup/resource_gke_backup_backup_plan.go index e10cff9d475..0ea0f94f171 100644 --- a/google/services/gkebackup/resource_gke_backup_backup_plan.go +++ b/google/services/gkebackup/resource_gke_backup_backup_plan.go @@ -116,6 +116,7 @@ func ResourceGKEBackupBackupPlan() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -573,6 +574,18 @@ backupPlans.delete to ensure that their change will be applied to the same versi Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -752,6 +765,19 @@ func resourceGKEBackupBackupPlanRead(d *schema.ResourceData, meta interface{}) e log.Printf("[DEBUG] Finished reading GKEBackupBackupPlan %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading BackupPlan: %s", err) } @@ -789,6 +815,19 @@ func resourceGKEBackupBackupPlanRead(d *schema.ResourceData, meta interface{}) e } func resourceGKEBackupBackupPlanUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceGKEBackupBackupPlan().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceGKEBackupBackupPlanRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -937,6 +976,13 @@ func resourceGKEBackupBackupPlanUpdate(d *schema.ResourceData, meta interface{}) } func resourceGKEBackupBackupPlanDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy GKEBackupBackupPlan without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing BackupPlan %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/gkebackup/resource_gke_backup_backup_plan_generated_meta.yaml b/google/services/gkebackup/resource_gke_backup_backup_plan_generated_meta.yaml index eb0cc2a7363..56479f9e2a2 100644 --- a/google/services/gkebackup/resource_gke_backup_backup_plan_generated_meta.yaml +++ b/google/services/gkebackup/resource_gke_backup_backup_plan_generated_meta.yaml @@ -50,3 +50,5 @@ fields: - field: terraform_labels provider_only: true - api_field: uid + - field: deletion_policy + provider_only: true diff --git a/google/services/gkebackup/resource_gke_backup_restore_channel.go b/google/services/gkebackup/resource_gke_backup_restore_channel.go index bb302264b97..9d331ef2283 100644 --- a/google/services/gkebackup/resource_gke_backup_restore_channel.go +++ b/google/services/gkebackup/resource_gke_backup_restore_channel.go @@ -116,6 +116,7 @@ func ResourceGKEBackupRestoreChannel() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -219,6 +220,18 @@ restoreChannels.delete to ensure that their change will be applied to the same v Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -374,6 +387,19 @@ func resourceGKEBackupRestoreChannelRead(d *schema.ResourceData, meta interface{ log.Printf("[DEBUG] Finished reading GKEBackupRestoreChannel %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading RestoreChannel: %s", err) } @@ -411,6 +437,19 @@ func resourceGKEBackupRestoreChannelRead(d *schema.ResourceData, meta interface{ } func resourceGKEBackupRestoreChannelUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceGKEBackupRestoreChannel().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceGKEBackupRestoreChannelRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -519,6 +558,13 @@ func resourceGKEBackupRestoreChannelUpdate(d *schema.ResourceData, meta interfac } func resourceGKEBackupRestoreChannelDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy GKEBackupRestoreChannel without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing RestoreChannel %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/gkebackup/resource_gke_backup_restore_channel_generated_meta.yaml b/google/services/gkebackup/resource_gke_backup_restore_channel_generated_meta.yaml index e6527fbfd0d..573a618c819 100644 --- a/google/services/gkebackup/resource_gke_backup_restore_channel_generated_meta.yaml +++ b/google/services/gkebackup/resource_gke_backup_restore_channel_generated_meta.yaml @@ -20,3 +20,5 @@ fields: - field: terraform_labels provider_only: true - api_field: uid + - field: deletion_policy + provider_only: true diff --git a/google/services/gkebackup/resource_gke_backup_restore_plan.go b/google/services/gkebackup/resource_gke_backup_restore_plan.go index bb4535b4089..19ecfb61a27 100644 --- a/google/services/gkebackup/resource_gke_backup_restore_plan.go +++ b/google/services/gkebackup/resource_gke_backup_restore_plan.go @@ -116,6 +116,7 @@ func ResourceGKEBackupRestorePlan() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -633,6 +634,18 @@ Please refer to the field 'effective_labels' for all of the labels present on th Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -800,6 +813,19 @@ func resourceGKEBackupRestorePlanRead(d *schema.ResourceData, meta interface{}) log.Printf("[DEBUG] Finished reading GKEBackupRestorePlan %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading RestorePlan: %s", err) } @@ -837,6 +863,19 @@ func resourceGKEBackupRestorePlanRead(d *schema.ResourceData, meta interface{}) } func resourceGKEBackupRestorePlanUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceGKEBackupRestorePlan().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceGKEBackupRestorePlanRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -955,6 +994,13 @@ func resourceGKEBackupRestorePlanUpdate(d *schema.ResourceData, meta interface{} } func resourceGKEBackupRestorePlanDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy GKEBackupRestorePlan without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing RestorePlan %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/gkebackup/resource_gke_backup_restore_plan_generated_meta.yaml b/google/services/gkebackup/resource_gke_backup_restore_plan_generated_meta.yaml index 7d2ccbbdf8d..a162c57b5d7 100644 --- a/google/services/gkebackup/resource_gke_backup_restore_plan_generated_meta.yaml +++ b/google/services/gkebackup/resource_gke_backup_restore_plan_generated_meta.yaml @@ -51,3 +51,5 @@ fields: - field: terraform_labels provider_only: true - api_field: uid + - field: deletion_policy + provider_only: true diff --git a/google/services/gkehub/resource_gke_hub_feature_membership.go b/google/services/gkehub/resource_gke_hub_feature_membership.go index 37f0c77b273..a3682a69eb8 100644 --- a/google/services/gkehub/resource_gke_hub_feature_membership.go +++ b/google/services/gkehub/resource_gke_hub_feature_membership.go @@ -107,6 +107,9 @@ func ResourceGkeHubFeatureMembership() *schema.Resource { DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName, Description: "The project of the feature", }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, } } @@ -903,9 +906,18 @@ func resourceGkeHubFeatureMembershipRead(d *schema.ResourceData, meta interface{ return fmt.Errorf("error setting project in state: %s", err) } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } func resourceGkeHubFeatureMembershipUpdate(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceGkeHubFeatureMembership) { + return ResourceGkeHubFeatureMembership().Read(d, meta) + } + config := meta.(*transport_tpg.Config) project, err := tpgresource.GetProject(d, config) if err != nil { @@ -963,6 +975,13 @@ func resourceGkeHubFeatureMembershipUpdate(d *schema.ResourceData, meta interfac } func resourceGkeHubFeatureMembershipDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) project, err := tpgresource.GetProject(d, config) if err != nil { diff --git a/google/services/gkehub/resource_gke_hub_feature_membership_meta.yaml b/google/services/gkehub/resource_gke_hub_feature_membership_meta.yaml index 870f082645a..1d1fee30c76 100644 --- a/google/services/gkehub/resource_gke_hub_feature_membership_meta.yaml +++ b/google/services/gkehub/resource_gke_hub_feature_membership_meta.yaml @@ -74,3 +74,5 @@ fields: - field: 'policycontroller.policy_controller_hub_config.referential_rules_enabled' - field: 'policycontroller.version' - field: 'project' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/gkehub/resource_gke_hub_membership.go b/google/services/gkehub/resource_gke_hub_membership.go index 500aea20d57..fccecf186c8 100644 --- a/google/services/gkehub/resource_gke_hub_membership.go +++ b/google/services/gkehub/resource_gke_hub_membership.go @@ -135,6 +135,7 @@ func ResourceGKEHubMembership() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -261,6 +262,18 @@ The default value is 'global'.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -410,6 +423,19 @@ func resourceGKEHubMembershipRead(d *schema.ResourceData, meta interface{}) erro log.Printf("[DEBUG] Finished reading GKEHubMembership %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Membership: %s", err) } @@ -447,6 +473,19 @@ func resourceGKEHubMembershipRead(d *schema.ResourceData, meta interface{}) erro } func resourceGKEHubMembershipUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceGKEHubMembership().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceGKEHubMembershipRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -555,6 +594,13 @@ func resourceGKEHubMembershipUpdate(d *schema.ResourceData, meta interface{}) er } func resourceGKEHubMembershipDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy GKEHubMembership without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Membership %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/gkehub/resource_gke_hub_membership_generated_meta.yaml b/google/services/gkehub/resource_gke_hub_membership_generated_meta.yaml index 3f14ec064c0..623683238fe 100644 --- a/google/services/gkehub/resource_gke_hub_membership_generated_meta.yaml +++ b/google/services/gkehub/resource_gke_hub_membership_generated_meta.yaml @@ -19,3 +19,5 @@ fields: - api_field: name - field: terraform_labels provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/gkehub2/resource_gke_hub_feature.go b/google/services/gkehub2/resource_gke_hub_feature.go index ad73ad68b77..ac3ddf12b36 100644 --- a/google/services/gkehub2/resource_gke_hub_feature.go +++ b/google/services/gkehub2/resource_gke_hub_feature.go @@ -116,6 +116,7 @@ func ResourceGKEHub2Feature() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -847,6 +848,18 @@ Please refer to the field 'effective_labels' for all of the labels present on th Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -1021,6 +1034,19 @@ func resourceGKEHub2FeatureRead(d *schema.ResourceData, meta interface{}) error log.Printf("[DEBUG] Finished reading GKEHub2Feature %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Feature: %s", err) } @@ -1058,6 +1084,19 @@ func resourceGKEHub2FeatureRead(d *schema.ResourceData, meta interface{}) error } func resourceGKEHub2FeatureUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceGKEHub2Feature().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceGKEHub2FeatureRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1176,6 +1215,13 @@ func resourceGKEHub2FeatureUpdate(d *schema.ResourceData, meta interface{}) erro } func resourceGKEHub2FeatureDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy GKEHub2Feature without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Feature %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/gkehub2/resource_gke_hub_feature_generated_meta.yaml b/google/services/gkehub2/resource_gke_hub_feature_generated_meta.yaml index 35410baa3a3..4662a5eccd6 100644 --- a/google/services/gkehub2/resource_gke_hub_feature_generated_meta.yaml +++ b/google/services/gkehub2/resource_gke_hub_feature_generated_meta.yaml @@ -91,3 +91,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/gkehub2/resource_gke_hub_fleet.go b/google/services/gkehub2/resource_gke_hub_fleet.go index b410c79a32e..e6b331c9ac2 100644 --- a/google/services/gkehub2/resource_gke_hub_fleet.go +++ b/google/services/gkehub2/resource_gke_hub_fleet.go @@ -115,6 +115,7 @@ func ResourceGKEHub2Fleet() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -245,6 +246,18 @@ resource with the same name is created, it gets a different uid.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -378,6 +391,19 @@ func resourceGKEHub2FleetRead(d *schema.ResourceData, meta interface{}) error { log.Printf("[DEBUG] Finished reading GKEHub2Fleet %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Fleet: %s", err) } @@ -403,6 +429,19 @@ func resourceGKEHub2FleetRead(d *schema.ResourceData, meta interface{}) error { } func resourceGKEHub2FleetUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceGKEHub2Fleet().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceGKEHub2FleetRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -501,6 +540,13 @@ func resourceGKEHub2FleetUpdate(d *schema.ResourceData, meta interface{}) error } func resourceGKEHub2FleetDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy GKEHub2Fleet without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Fleet %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/gkehub2/resource_gke_hub_fleet_generated_meta.yaml b/google/services/gkehub2/resource_gke_hub_fleet_generated_meta.yaml index 9c48449cf61..5aeb2e56ed4 100644 --- a/google/services/gkehub2/resource_gke_hub_fleet_generated_meta.yaml +++ b/google/services/gkehub2/resource_gke_hub_fleet_generated_meta.yaml @@ -17,3 +17,5 @@ fields: - api_field: state.code - api_field: uid - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/gkehub2/resource_gke_hub_membership_binding.go b/google/services/gkehub2/resource_gke_hub_membership_binding.go index 52a8238e3fc..34a0e494ba7 100644 --- a/google/services/gkehub2/resource_gke_hub_membership_binding.go +++ b/google/services/gkehub2/resource_gke_hub_membership_binding.go @@ -116,6 +116,7 @@ func ResourceGKEHub2MembershipBinding() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -239,6 +240,18 @@ Please refer to the field 'effective_labels' for all of the labels present on th Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -387,6 +400,19 @@ func resourceGKEHub2MembershipBindingRead(d *schema.ResourceData, meta interface log.Printf("[DEBUG] Finished reading GKEHub2MembershipBinding %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading MembershipBinding: %s", err) } @@ -430,6 +456,19 @@ func resourceGKEHub2MembershipBindingRead(d *schema.ResourceData, meta interface } func resourceGKEHub2MembershipBindingUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceGKEHub2MembershipBinding().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceGKEHub2MembershipBindingRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -543,6 +582,13 @@ func resourceGKEHub2MembershipBindingUpdate(d *schema.ResourceData, meta interfa } func resourceGKEHub2MembershipBindingDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy GKEHub2MembershipBinding without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing MembershipBinding %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/gkehub2/resource_gke_hub_membership_binding_generated_meta.yaml b/google/services/gkehub2/resource_gke_hub_membership_binding_generated_meta.yaml index 5b70e49f058..e07c7b84082 100644 --- a/google/services/gkehub2/resource_gke_hub_membership_binding_generated_meta.yaml +++ b/google/services/gkehub2/resource_gke_hub_membership_binding_generated_meta.yaml @@ -25,3 +25,5 @@ fields: provider_only: true - api_field: uid - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/gkehub2/resource_gke_hub_namespace.go b/google/services/gkehub2/resource_gke_hub_namespace.go index 147e99a1e7a..38cf94109e6 100644 --- a/google/services/gkehub2/resource_gke_hub_namespace.go +++ b/google/services/gkehub2/resource_gke_hub_namespace.go @@ -116,6 +116,7 @@ func ResourceGKEHub2Namespace() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -239,6 +240,18 @@ a key. Keys and values must be Kubernetes-conformant.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -388,6 +401,19 @@ func resourceGKEHub2NamespaceRead(d *schema.ResourceData, meta interface{}) erro log.Printf("[DEBUG] Finished reading GKEHub2Namespace %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Namespace: %s", err) } @@ -425,6 +451,19 @@ func resourceGKEHub2NamespaceRead(d *schema.ResourceData, meta interface{}) erro } func resourceGKEHub2NamespaceUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceGKEHub2Namespace().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceGKEHub2NamespaceRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -533,6 +572,13 @@ func resourceGKEHub2NamespaceUpdate(d *schema.ResourceData, meta interface{}) er } func resourceGKEHub2NamespaceDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy GKEHub2Namespace without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Namespace %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/gkehub2/resource_gke_hub_namespace_generated_meta.yaml b/google/services/gkehub2/resource_gke_hub_namespace_generated_meta.yaml index 4c99cb88e27..a7de39d7a98 100644 --- a/google/services/gkehub2/resource_gke_hub_namespace_generated_meta.yaml +++ b/google/services/gkehub2/resource_gke_hub_namespace_generated_meta.yaml @@ -24,3 +24,5 @@ fields: provider_only: true - api_field: uid - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/gkehub2/resource_gke_hub_scope.go b/google/services/gkehub2/resource_gke_hub_scope.go index 1bc177cc9fc..6fe63d8cb08 100644 --- a/google/services/gkehub2/resource_gke_hub_scope.go +++ b/google/services/gkehub2/resource_gke_hub_scope.go @@ -116,6 +116,7 @@ func ResourceGKEHub2Scope() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -222,6 +223,18 @@ share a key. Keys and values must be Kubernetes-conformant.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -360,6 +373,19 @@ func resourceGKEHub2ScopeRead(d *schema.ResourceData, meta interface{}) error { log.Printf("[DEBUG] Finished reading GKEHub2Scope %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Scope: %s", err) } @@ -391,6 +417,19 @@ func resourceGKEHub2ScopeRead(d *schema.ResourceData, meta interface{}) error { } func resourceGKEHub2ScopeUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceGKEHub2Scope().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceGKEHub2ScopeRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -494,6 +533,13 @@ func resourceGKEHub2ScopeUpdate(d *schema.ResourceData, meta interface{}) error } func resourceGKEHub2ScopeDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy GKEHub2Scope without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Scope %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/gkehub2/resource_gke_hub_scope_generated_meta.yaml b/google/services/gkehub2/resource_gke_hub_scope_generated_meta.yaml index 6038bfc72ee..2b00b2da7b9 100644 --- a/google/services/gkehub2/resource_gke_hub_scope_generated_meta.yaml +++ b/google/services/gkehub2/resource_gke_hub_scope_generated_meta.yaml @@ -21,3 +21,5 @@ fields: provider_only: true - api_field: uid - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/gkehub2/resource_gke_hub_scope_rbac_role_binding.go b/google/services/gkehub2/resource_gke_hub_scope_rbac_role_binding.go index b918084946f..b48d592b37d 100644 --- a/google/services/gkehub2/resource_gke_hub_scope_rbac_role_binding.go +++ b/google/services/gkehub2/resource_gke_hub_scope_rbac_role_binding.go @@ -116,6 +116,7 @@ func ResourceGKEHub2ScopeRBACRoleBinding() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -262,6 +263,18 @@ user is the name of the user as seen by the kubernetes cluster, example Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -417,6 +430,19 @@ func resourceGKEHub2ScopeRBACRoleBindingRead(d *schema.ResourceData, meta interf log.Printf("[DEBUG] Finished reading GKEHub2ScopeRBACRoleBinding %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading ScopeRBACRoleBinding: %s", err) } @@ -454,6 +480,19 @@ func resourceGKEHub2ScopeRBACRoleBindingRead(d *schema.ResourceData, meta interf } func resourceGKEHub2ScopeRBACRoleBindingUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceGKEHub2ScopeRBACRoleBinding().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceGKEHub2ScopeRBACRoleBindingRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -582,6 +621,13 @@ func resourceGKEHub2ScopeRBACRoleBindingUpdate(d *schema.ResourceData, meta inte } func resourceGKEHub2ScopeRBACRoleBindingDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy GKEHub2ScopeRBACRoleBinding without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ScopeRBACRoleBinding %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/gkehub2/resource_gke_hub_scope_rbac_role_binding_generated_meta.yaml b/google/services/gkehub2/resource_gke_hub_scope_rbac_role_binding_generated_meta.yaml index 6089727a018..c21a857548b 100644 --- a/google/services/gkehub2/resource_gke_hub_scope_rbac_role_binding_generated_meta.yaml +++ b/google/services/gkehub2/resource_gke_hub_scope_rbac_role_binding_generated_meta.yaml @@ -26,3 +26,5 @@ fields: - api_field: uid - api_field: updateTime - api_field: user + - field: deletion_policy + provider_only: true diff --git a/google/services/gkeonprem/resource_gkeonprem_bare_metal_admin_cluster.go b/google/services/gkeonprem/resource_gkeonprem_bare_metal_admin_cluster.go index 1d68dfc5118..ad3d57fd028 100644 --- a/google/services/gkeonprem/resource_gkeonprem_bare_metal_admin_cluster.go +++ b/google/services/gkeonprem/resource_gkeonprem_bare_metal_admin_cluster.go @@ -1254,6 +1254,7 @@ func resourceGkeonpremBareMetalAdminClusterRead(d *schema.ResourceData, meta int } func resourceGkeonpremBareMetalAdminClusterUpdate(d *schema.ResourceData, meta interface{}) error { + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/gkeonprem/resource_gkeonprem_bare_metal_cluster.go b/google/services/gkeonprem/resource_gkeonprem_bare_metal_cluster.go index 8a518c0e30e..80442da613d 100644 --- a/google/services/gkeonprem/resource_gkeonprem_bare_metal_cluster.go +++ b/google/services/gkeonprem/resource_gkeonprem_bare_metal_cluster.go @@ -116,6 +116,7 @@ func ResourceGkeonpremBareMetalCluster() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetAnnotationsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -1288,6 +1289,18 @@ indicate real problems requiring user intervention.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -1520,6 +1533,19 @@ func resourceGkeonpremBareMetalClusterRead(d *schema.ResourceData, meta interfac log.Printf("[DEBUG] Finished reading GkeonpremBareMetalCluster %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading BareMetalCluster: %s", err) } @@ -1557,6 +1583,19 @@ func resourceGkeonpremBareMetalClusterRead(d *schema.ResourceData, meta interfac } func resourceGkeonpremBareMetalClusterUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceGkeonpremBareMetalCluster().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceGkeonpremBareMetalClusterRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1805,6 +1844,13 @@ func resourceGkeonpremBareMetalClusterUpdate(d *schema.ResourceData, meta interf } func resourceGkeonpremBareMetalClusterDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy GkeonpremBareMetalCluster without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing BareMetalCluster %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/gkeonprem/resource_gkeonprem_bare_metal_cluster_generated_meta.yaml b/google/services/gkeonprem/resource_gkeonprem_bare_metal_cluster_generated_meta.yaml index 8b7ec75af03..3167fbdf009 100644 --- a/google/services/gkeonprem/resource_gkeonprem_bare_metal_cluster_generated_meta.yaml +++ b/google/services/gkeonprem/resource_gkeonprem_bare_metal_cluster_generated_meta.yaml @@ -103,3 +103,5 @@ fields: - api_field: validationCheck.status.result.details - api_field: validationCheck.status.result.options - api_field: validationCheck.status.result.reason + - field: deletion_policy + provider_only: true diff --git a/google/services/gkeonprem/resource_gkeonprem_bare_metal_node_pool.go b/google/services/gkeonprem/resource_gkeonprem_bare_metal_node_pool.go index 0ac7947356a..61daf5e84d3 100644 --- a/google/services/gkeonprem/resource_gkeonprem_bare_metal_node_pool.go +++ b/google/services/gkeonprem/resource_gkeonprem_bare_metal_node_pool.go @@ -116,6 +116,7 @@ func ResourceGkeonpremBareMetalNodePool() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetAnnotationsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -379,6 +380,18 @@ indicate real problems requiring user intervention.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -532,6 +545,19 @@ func resourceGkeonpremBareMetalNodePoolRead(d *schema.ResourceData, meta interfa log.Printf("[DEBUG] Finished reading GkeonpremBareMetalNodePool %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading BareMetalNodePool: %s", err) } @@ -575,6 +601,19 @@ func resourceGkeonpremBareMetalNodePoolRead(d *schema.ResourceData, meta interfa } func resourceGkeonpremBareMetalNodePoolUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceGkeonpremBareMetalNodePool().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceGkeonpremBareMetalNodePoolRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -698,6 +737,13 @@ func resourceGkeonpremBareMetalNodePoolUpdate(d *schema.ResourceData, meta inter } func resourceGkeonpremBareMetalNodePoolDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy GkeonpremBareMetalNodePool without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing BareMetalNodePool %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/gkeonprem/resource_gkeonprem_bare_metal_node_pool_generated_meta.yaml b/google/services/gkeonprem/resource_gkeonprem_bare_metal_node_pool_generated_meta.yaml index 3eaadaa0a63..bbff9f355dd 100644 --- a/google/services/gkeonprem/resource_gkeonprem_bare_metal_node_pool_generated_meta.yaml +++ b/google/services/gkeonprem/resource_gkeonprem_bare_metal_node_pool_generated_meta.yaml @@ -37,3 +37,5 @@ fields: - api_field: status.errorMessage - api_field: uid - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/gkeonprem/resource_gkeonprem_vmware_admin_cluster.go b/google/services/gkeonprem/resource_gkeonprem_vmware_admin_cluster.go index e319766ca95..5ae268d4691 100644 --- a/google/services/gkeonprem/resource_gkeonprem_vmware_admin_cluster.go +++ b/google/services/gkeonprem/resource_gkeonprem_vmware_admin_cluster.go @@ -1266,6 +1266,7 @@ func resourceGkeonpremVmwareAdminClusterRead(d *schema.ResourceData, meta interf } func resourceGkeonpremVmwareAdminClusterUpdate(d *schema.ResourceData, meta interface{}) error { + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/gkeonprem/resource_gkeonprem_vmware_cluster.go b/google/services/gkeonprem/resource_gkeonprem_vmware_cluster.go index 41ccf3332c3..6bfc14743c3 100644 --- a/google/services/gkeonprem/resource_gkeonprem_vmware_cluster.go +++ b/google/services/gkeonprem/resource_gkeonprem_vmware_cluster.go @@ -116,6 +116,7 @@ func ResourceGkeonpremVmwareCluster() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetAnnotationsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -1004,6 +1005,18 @@ indicate real problems requiring user intervention.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -1242,6 +1255,19 @@ func resourceGkeonpremVmwareClusterRead(d *schema.ResourceData, meta interface{} log.Printf("[DEBUG] Finished reading GkeonpremVmwareCluster %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading VmwareCluster: %s", err) } @@ -1279,6 +1305,19 @@ func resourceGkeonpremVmwareClusterRead(d *schema.ResourceData, meta interface{} } func resourceGkeonpremVmwareClusterUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceGkeonpremVmwareCluster().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceGkeonpremVmwareClusterRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1537,6 +1576,13 @@ func resourceGkeonpremVmwareClusterUpdate(d *schema.ResourceData, meta interface } func resourceGkeonpremVmwareClusterDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy GkeonpremVmwareCluster without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing VmwareCluster %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/gkeonprem/resource_gkeonprem_vmware_cluster_generated_meta.yaml b/google/services/gkeonprem/resource_gkeonprem_vmware_cluster_generated_meta.yaml index 08e8f903b5f..4d1f1d4f732 100644 --- a/google/services/gkeonprem/resource_gkeonprem_vmware_cluster_generated_meta.yaml +++ b/google/services/gkeonprem/resource_gkeonprem_vmware_cluster_generated_meta.yaml @@ -96,3 +96,5 @@ fields: - api_field: vcenter.resourcePool - api_field: vcenter.storagePolicyName - api_field: vmTrackingEnabled + - field: deletion_policy + provider_only: true diff --git a/google/services/gkeonprem/resource_gkeonprem_vmware_node_pool.go b/google/services/gkeonprem/resource_gkeonprem_vmware_node_pool.go index cd43d7809a3..2d916cb5a25 100644 --- a/google/services/gkeonprem/resource_gkeonprem_vmware_node_pool.go +++ b/google/services/gkeonprem/resource_gkeonprem_vmware_node_pool.go @@ -116,6 +116,7 @@ func ResourceGkeonpremVmwareNodePool() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetAnnotationsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -445,6 +446,18 @@ indicate real problems requiring user intervention.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -610,6 +623,19 @@ func resourceGkeonpremVmwareNodePoolRead(d *schema.ResourceData, meta interface{ log.Printf("[DEBUG] Finished reading GkeonpremVmwareNodePool %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading VmwareNodePool: %s", err) } @@ -653,6 +679,19 @@ func resourceGkeonpremVmwareNodePoolRead(d *schema.ResourceData, meta interface{ } func resourceGkeonpremVmwareNodePoolUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceGkeonpremVmwareNodePool().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceGkeonpremVmwareNodePoolRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -796,6 +835,13 @@ func resourceGkeonpremVmwareNodePoolUpdate(d *schema.ResourceData, meta interfac } func resourceGkeonpremVmwareNodePoolDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy GkeonpremVmwareNodePool without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing VmwareNodePool %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/gkeonprem/resource_gkeonprem_vmware_node_pool_generated_meta.yaml b/google/services/gkeonprem/resource_gkeonprem_vmware_node_pool_generated_meta.yaml index 0916655b8a4..293ae80f006 100644 --- a/google/services/gkeonprem/resource_gkeonprem_vmware_node_pool_generated_meta.yaml +++ b/google/services/gkeonprem/resource_gkeonprem_vmware_node_pool_generated_meta.yaml @@ -48,3 +48,5 @@ fields: - api_field: updateTime - field: vmware_cluster provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/healthcare/resource_healthcare_consent_store.go b/google/services/healthcare/resource_healthcare_consent_store.go index 8632ed4010f..c92fdcd6bc4 100644 --- a/google/services/healthcare/resource_healthcare_consent_store.go +++ b/google/services/healthcare/resource_healthcare_consent_store.go @@ -115,6 +115,7 @@ func ResourceHealthcareConsentStore() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -198,6 +199,19 @@ Please refer to the field 'effective_labels' for all of the labels present on th and default labels configured on the provider.`, Elem: &schema.Schema{Type: schema.TypeString}, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -320,6 +334,20 @@ func resourceHealthcareConsentStoreRead(d *schema.ResourceData, meta interface{} log.Printf("[DEBUG] Finished reading HealthcareConsentStore %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceHealthcareConsentStoreFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -347,6 +375,19 @@ func resourceHealthcareConsentStoreRead(d *schema.ResourceData, meta interface{} } func resourceHealthcareConsentStoreUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceHealthcareConsentStore().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceHealthcareConsentStoreRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -447,6 +488,13 @@ func resourceHealthcareConsentStoreUpdate(d *schema.ResourceData, meta interface } func resourceHealthcareConsentStoreDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy HealthcareConsentStore without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ConsentStore %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/healthcare/resource_healthcare_consent_store_generated_meta.yaml b/google/services/healthcare/resource_healthcare_consent_store_generated_meta.yaml index a55e18c1630..fe4989534af 100644 --- a/google/services/healthcare/resource_healthcare_consent_store_generated_meta.yaml +++ b/google/services/healthcare/resource_healthcare_consent_store_generated_meta.yaml @@ -18,3 +18,5 @@ fields: provider_only: true - field: terraform_labels provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/healthcare/resource_healthcare_dataset.go b/google/services/healthcare/resource_healthcare_dataset.go index fdc3884a327..d77ca04463a 100644 --- a/google/services/healthcare/resource_healthcare_dataset.go +++ b/google/services/healthcare/resource_healthcare_dataset.go @@ -115,6 +115,7 @@ func ResourceHealthcareDataset() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -193,6 +194,18 @@ projects/{projectId}/locations/{locationId}/keyRings/{keyRingId}/cryptoKeys/{key Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -346,6 +359,19 @@ func resourceHealthcareDatasetRead(d *schema.ResourceData, meta interface{}) err return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Dataset: %s", err) } @@ -383,6 +409,19 @@ func resourceHealthcareDatasetRead(d *schema.ResourceData, meta interface{}) err } func resourceHealthcareDatasetUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceHealthcareDataset().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceHealthcareDatasetRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -475,6 +514,13 @@ func resourceHealthcareDatasetUpdate(d *schema.ResourceData, meta interface{}) e } func resourceHealthcareDatasetDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy HealthcareDataset without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Dataset %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/healthcare/resource_healthcare_dataset_generated_meta.yaml b/google/services/healthcare/resource_healthcare_dataset_generated_meta.yaml index eaf40962b35..bf3f5d38748 100644 --- a/google/services/healthcare/resource_healthcare_dataset_generated_meta.yaml +++ b/google/services/healthcare/resource_healthcare_dataset_generated_meta.yaml @@ -13,3 +13,5 @@ fields: - api_field: name - api_field: selfLink - api_field: timeZone + - field: deletion_policy + provider_only: true diff --git a/google/services/healthcare/resource_healthcare_dicom_store.go b/google/services/healthcare/resource_healthcare_dicom_store.go index 764559ac805..286e8249830 100644 --- a/google/services/healthcare/resource_healthcare_dicom_store.go +++ b/google/services/healthcare/resource_healthcare_dicom_store.go @@ -115,6 +115,7 @@ func ResourceHealthcareDicomStore() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -217,6 +218,19 @@ Cloud Pub/Sub topic. Not having adequate permissions will cause the calls that s and default labels configured on the provider.`, Elem: &schema.Schema{Type: schema.TypeString}, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -351,6 +365,20 @@ func resourceHealthcareDicomStoreRead(d *schema.ResourceData, meta interface{}) return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceHealthcareDicomStoreFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -378,6 +406,19 @@ func resourceHealthcareDicomStoreRead(d *schema.ResourceData, meta interface{}) } func resourceHealthcareDicomStoreUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceHealthcareDicomStore().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceHealthcareDicomStoreRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -468,6 +509,13 @@ func resourceHealthcareDicomStoreUpdate(d *schema.ResourceData, meta interface{} } func resourceHealthcareDicomStoreDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy HealthcareDicomStore without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing DicomStore %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/healthcare/resource_healthcare_dicom_store_generated_meta.yaml b/google/services/healthcare/resource_healthcare_dicom_store_generated_meta.yaml index 5ed4bb00e4f..c433dbdb5ca 100644 --- a/google/services/healthcare/resource_healthcare_dicom_store_generated_meta.yaml +++ b/google/services/healthcare/resource_healthcare_dicom_store_generated_meta.yaml @@ -18,3 +18,5 @@ fields: - api_field: selfLink - field: terraform_labels provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/healthcare/resource_healthcare_fhir_store.go b/google/services/healthcare/resource_healthcare_fhir_store.go index e1041384a1b..2b81a97751e 100644 --- a/google/services/healthcare/resource_healthcare_fhir_store.go +++ b/google/services/healthcare/resource_healthcare_fhir_store.go @@ -115,6 +115,7 @@ func ResourceHealthcareFhirStore() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -463,6 +464,19 @@ The Cloud Healthcare API does not currently enforce all of the rules in a Struct and default labels configured on the provider.`, Elem: &schema.Schema{Type: schema.TypeString}, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -657,6 +671,20 @@ func resourceHealthcareFhirStoreRead(d *schema.ResourceData, meta interface{}) e return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceHealthcareFhirStoreFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -684,6 +712,19 @@ func resourceHealthcareFhirStoreRead(d *schema.ResourceData, meta interface{}) e } func resourceHealthcareFhirStoreUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceHealthcareFhirStore().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceHealthcareFhirStoreRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -834,6 +875,13 @@ func resourceHealthcareFhirStoreUpdate(d *schema.ResourceData, meta interface{}) } func resourceHealthcareFhirStoreDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy HealthcareFhirStore without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing FhirStore %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/healthcare/resource_healthcare_fhir_store_generated_meta.yaml b/google/services/healthcare/resource_healthcare_fhir_store_generated_meta.yaml index f758527dbed..b012f800d6e 100644 --- a/google/services/healthcare/resource_healthcare_fhir_store_generated_meta.yaml +++ b/google/services/healthcare/resource_healthcare_fhir_store_generated_meta.yaml @@ -38,3 +38,5 @@ fields: - api_field: validationConfig.disableRequiredFieldValidation - api_field: validationConfig.enabledImplementationGuides - api_field: version + - field: deletion_policy + provider_only: true diff --git a/google/services/healthcare/resource_healthcare_hl7_v2_store.go b/google/services/healthcare/resource_healthcare_hl7_v2_store.go index 1ebf658b13d..c0a7e81c59f 100644 --- a/google/services/healthcare/resource_healthcare_hl7_v2_store.go +++ b/google/services/healthcare/resource_healthcare_hl7_v2_store.go @@ -115,6 +115,7 @@ func ResourceHealthcareHl7V2Store() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -299,6 +300,19 @@ A base64-encoded string.`, and default labels configured on the provider.`, Elem: &schema.Schema{Type: schema.TypeString}, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -451,6 +465,20 @@ func resourceHealthcareHl7V2StoreRead(d *schema.ResourceData, meta interface{}) return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceHealthcareHl7V2StoreFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -478,6 +506,19 @@ func resourceHealthcareHl7V2StoreRead(d *schema.ResourceData, meta interface{}) } func resourceHealthcareHl7V2StoreUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceHealthcareHl7V2Store().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceHealthcareHl7V2StoreRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -600,6 +641,13 @@ func resourceHealthcareHl7V2StoreUpdate(d *schema.ResourceData, meta interface{} } func resourceHealthcareHl7V2StoreDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy HealthcareHl7V2Store without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Hl7V2Store %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/healthcare/resource_healthcare_hl7_v2_store_generated_meta.yaml b/google/services/healthcare/resource_healthcare_hl7_v2_store_generated_meta.yaml index db986e7259c..3c4161dfb31 100644 --- a/google/services/healthcare/resource_healthcare_hl7_v2_store_generated_meta.yaml +++ b/google/services/healthcare/resource_healthcare_hl7_v2_store_generated_meta.yaml @@ -25,3 +25,5 @@ fields: - api_field: selfLink - field: terraform_labels provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/healthcare/resource_healthcare_pipeline_job.go b/google/services/healthcare/resource_healthcare_pipeline_job.go index e2554c9194a..083f2c4637b 100644 --- a/google/services/healthcare/resource_healthcare_pipeline_job.go +++ b/google/services/healthcare/resource_healthcare_pipeline_job.go @@ -115,6 +115,7 @@ func ResourceHealthcarePipelineJob() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -367,6 +368,19 @@ in the format of: project/{projectID}/locations/{locationID}/datasets/{datasetNa and default labels configured on the provider.`, Elem: &schema.Schema{Type: schema.TypeString}, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -529,6 +543,20 @@ func resourceHealthcarePipelineJobRead(d *schema.ResourceData, meta interface{}) return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceHealthcarePipelineJobFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -556,6 +584,19 @@ func resourceHealthcarePipelineJobRead(d *schema.ResourceData, meta interface{}) } func resourceHealthcarePipelineJobUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceHealthcarePipelineJob().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceHealthcarePipelineJobRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -693,6 +734,13 @@ func resourceHealthcarePipelineJobUpdate(d *schema.ResourceData, meta interface{ } func resourceHealthcarePipelineJobDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy HealthcarePipelineJob without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing PipelineJob %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/healthcare/resource_healthcare_pipeline_job_generated_meta.yaml b/google/services/healthcare/resource_healthcare_pipeline_job_generated_meta.yaml index d7152ba95f1..02ef4e70c3b 100644 --- a/google/services/healthcare/resource_healthcare_pipeline_job_generated_meta.yaml +++ b/google/services/healthcare/resource_healthcare_pipeline_job_generated_meta.yaml @@ -32,3 +32,5 @@ fields: - api_field: selfLink - field: terraform_labels provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/healthcare/resource_healthcare_workspace.go b/google/services/healthcare/resource_healthcare_workspace.go index 4d11223ee37..79a510fead6 100644 --- a/google/services/healthcare/resource_healthcare_workspace.go +++ b/google/services/healthcare/resource_healthcare_workspace.go @@ -115,6 +115,7 @@ func ResourceHealthcareWorkspace() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -192,6 +193,19 @@ Please refer to the field 'effective_labels' for all of the labels present on th and default labels configured on the provider.`, Elem: &schema.Schema{Type: schema.TypeString}, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -314,6 +328,20 @@ func resourceHealthcareWorkspaceRead(d *schema.ResourceData, meta interface{}) e log.Printf("[DEBUG] Finished reading HealthcareWorkspace %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceHealthcareWorkspaceFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -341,6 +369,19 @@ func resourceHealthcareWorkspaceRead(d *schema.ResourceData, meta interface{}) e } func resourceHealthcareWorkspaceUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceHealthcareWorkspace().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceHealthcareWorkspaceRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -431,6 +472,13 @@ func resourceHealthcareWorkspaceUpdate(d *schema.ResourceData, meta interface{}) } func resourceHealthcareWorkspaceDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy HealthcareWorkspace without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Workspace %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/healthcare/resource_healthcare_workspace_generated_meta.yaml b/google/services/healthcare/resource_healthcare_workspace_generated_meta.yaml index d5f5663d0b7..dbde6fe3f0d 100644 --- a/google/services/healthcare/resource_healthcare_workspace_generated_meta.yaml +++ b/google/services/healthcare/resource_healthcare_workspace_generated_meta.yaml @@ -16,3 +16,5 @@ fields: - api_field: settings.dataProjectIds - field: terraform_labels provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/hypercomputecluster/resource_hypercomputecluster_cluster.go b/google/services/hypercomputecluster/resource_hypercomputecluster_cluster.go index 627f6451593..e9b216c843e 100644 --- a/google/services/hypercomputecluster/resource_hypercomputecluster_cluster.go +++ b/google/services/hypercomputecluster/resource_hypercomputecluster_cluster.go @@ -125,6 +125,7 @@ func ResourceHypercomputeclusterCluster() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -1059,6 +1060,18 @@ state.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -1226,6 +1239,19 @@ func resourceHypercomputeclusterClusterRead(d *schema.ResourceData, meta interfa log.Printf("[DEBUG] Finished reading HypercomputeclusterCluster %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Cluster: %s", err) } @@ -1263,6 +1289,19 @@ func resourceHypercomputeclusterClusterRead(d *schema.ResourceData, meta interfa } func resourceHypercomputeclusterClusterUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceHypercomputeclusterCluster().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceHypercomputeclusterClusterRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1411,6 +1450,13 @@ func resourceHypercomputeclusterClusterUpdate(d *schema.ResourceData, meta inter } func resourceHypercomputeclusterClusterDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy HypercomputeclusterCluster without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Cluster %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/hypercomputecluster/resource_hypercomputecluster_cluster_generated_meta.yaml b/google/services/hypercomputecluster/resource_hypercomputecluster_cluster_generated_meta.yaml index efc440fb6c9..4e04bb583f9 100644 --- a/google/services/hypercomputecluster/resource_hypercomputecluster_cluster_generated_meta.yaml +++ b/google/services/hypercomputecluster/resource_hypercomputecluster_cluster_generated_meta.yaml @@ -125,3 +125,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/iam2/resource_iam_access_boundary_policy.go b/google/services/iam2/resource_iam_access_boundary_policy.go index 1daf83fe253..74ed896038e 100644 --- a/google/services/iam2/resource_iam_access_boundary_policy.go +++ b/google/services/iam2/resource_iam_access_boundary_policy.go @@ -225,6 +225,19 @@ This can be used e.g. in UIs which allow to enter the expression.`, Computed: true, Description: `The hash of the resource. Used internally during updates.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -357,6 +370,20 @@ func resourceIAM2AccessBoundaryPolicyRead(d *schema.ResourceData, meta interface log.Printf("[DEBUG] Finished reading IAM2AccessBoundaryPolicy %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceIAM2AccessBoundaryPolicyFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -384,6 +411,19 @@ func resourceIAM2AccessBoundaryPolicyRead(d *schema.ResourceData, meta interface } func resourceIAM2AccessBoundaryPolicyUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceIAM2AccessBoundaryPolicy().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceIAM2AccessBoundaryPolicyRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -469,6 +509,13 @@ func resourceIAM2AccessBoundaryPolicyUpdate(d *schema.ResourceData, meta interfa } func resourceIAM2AccessBoundaryPolicyDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy IAM2AccessBoundaryPolicy without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing AccessBoundaryPolicy %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/iam2/resource_iam_access_boundary_policy_generated_meta.yaml b/google/services/iam2/resource_iam_access_boundary_policy_generated_meta.yaml index 090394ce01b..259dda98986 100644 --- a/google/services/iam2/resource_iam_access_boundary_policy_generated_meta.yaml +++ b/google/services/iam2/resource_iam_access_boundary_policy_generated_meta.yaml @@ -20,3 +20,5 @@ fields: - api_field: rules.accessBoundaryRule.availablePermissions - api_field: rules.accessBoundaryRule.availableResource - api_field: rules.description + - field: deletion_policy + provider_only: true diff --git a/google/services/iam2/resource_iam_deny_policy.go b/google/services/iam2/resource_iam_deny_policy.go index 7152d9e410b..e5e4984b813 100644 --- a/google/services/iam2/resource_iam_deny_policy.go +++ b/google/services/iam2/resource_iam_deny_policy.go @@ -248,6 +248,19 @@ For example, you could add a Google group to the deniedPrincipals, then exclude Computed: true, Description: `The hash of the resource. Used internally during updates.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -380,6 +393,20 @@ func resourceIAM2DenyPolicyRead(d *schema.ResourceData, meta interface{}) error log.Printf("[DEBUG] Finished reading IAM2DenyPolicy %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceIAM2DenyPolicyFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -407,6 +434,19 @@ func resourceIAM2DenyPolicyRead(d *schema.ResourceData, meta interface{}) error } func resourceIAM2DenyPolicyUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceIAM2DenyPolicy().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceIAM2DenyPolicyRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -492,6 +532,13 @@ func resourceIAM2DenyPolicyUpdate(d *schema.ResourceData, meta interface{}) erro } func resourceIAM2DenyPolicyDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy IAM2DenyPolicy without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing DenyPolicy %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/iam2/resource_iam_deny_policy_generated_meta.yaml b/google/services/iam2/resource_iam_deny_policy_generated_meta.yaml index b86dbb827da..f5ad811a112 100644 --- a/google/services/iam2/resource_iam_deny_policy_generated_meta.yaml +++ b/google/services/iam2/resource_iam_deny_policy_generated_meta.yaml @@ -24,3 +24,5 @@ fields: - api_field: rules.denyRule.exceptionPermissions - api_field: rules.denyRule.exceptionPrincipals - api_field: rules.description + - field: deletion_policy + provider_only: true diff --git a/google/services/iam3/resource_iam_folders_policy_binding.go b/google/services/iam3/resource_iam_folders_policy_binding.go index 6ad4ff8efa7..a7871e9f354 100644 --- a/google/services/iam3/resource_iam_folders_policy_binding.go +++ b/google/services/iam3/resource_iam_folders_policy_binding.go @@ -115,6 +115,7 @@ func ResourceIAM3FoldersPolicyBinding() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetAnnotationsDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -295,6 +296,19 @@ to the policy kind) - The input policy kind Possible values: POLICY_KIND_UNSP Computed: true, Description: `Output only. The time when the policy binding was most recently updated.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -451,6 +465,20 @@ func resourceIAM3FoldersPolicyBindingRead(d *schema.ResourceData, meta interface log.Printf("[DEBUG] Finished reading IAM3FoldersPolicyBinding %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceIAM3FoldersPolicyBindingFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -484,6 +512,18 @@ func resourceIAM3FoldersPolicyBindingRead(d *schema.ResourceData, meta interface } func resourceIAM3FoldersPolicyBindingUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceIAM3FoldersPolicyBinding().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceIAM3FoldersPolicyBindingRead(d, meta) + } var project string config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) @@ -607,6 +647,13 @@ func resourceIAM3FoldersPolicyBindingUpdate(d *schema.ResourceData, meta interfa } func resourceIAM3FoldersPolicyBindingDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy IAM3FoldersPolicyBinding without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing FoldersPolicyBinding %q from Terraform state without deletion", d.Id()) + return nil + } var project string config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) diff --git a/google/services/iam3/resource_iam_folders_policy_binding_generated_meta.yaml b/google/services/iam3/resource_iam_folders_policy_binding_generated_meta.yaml index 36d6730beba..36a53b35742 100644 --- a/google/services/iam3/resource_iam_folders_policy_binding_generated_meta.yaml +++ b/google/services/iam3/resource_iam_folders_policy_binding_generated_meta.yaml @@ -32,3 +32,5 @@ fields: - api_field: target.principalSet - api_field: uid - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/iam3/resource_iam_organizations_policy_binding.go b/google/services/iam3/resource_iam_organizations_policy_binding.go index 3fba028f3d6..9a2d4246e59 100644 --- a/google/services/iam3/resource_iam_organizations_policy_binding.go +++ b/google/services/iam3/resource_iam_organizations_policy_binding.go @@ -115,6 +115,7 @@ func ResourceIAM3OrganizationsPolicyBinding() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetAnnotationsDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -297,6 +298,19 @@ to the policy kind) - The input policy kind Possible values: POLICY_KIND_UNSP Computed: true, Description: `Output only. The time when the policy binding was most recently updated.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -453,6 +467,20 @@ func resourceIAM3OrganizationsPolicyBindingRead(d *schema.ResourceData, meta int log.Printf("[DEBUG] Finished reading IAM3OrganizationsPolicyBinding %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceIAM3OrganizationsPolicyBindingFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -486,6 +514,18 @@ func resourceIAM3OrganizationsPolicyBindingRead(d *schema.ResourceData, meta int } func resourceIAM3OrganizationsPolicyBindingUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceIAM3OrganizationsPolicyBinding().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceIAM3OrganizationsPolicyBindingRead(d, meta) + } var project string config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) @@ -609,6 +649,13 @@ func resourceIAM3OrganizationsPolicyBindingUpdate(d *schema.ResourceData, meta i } func resourceIAM3OrganizationsPolicyBindingDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy IAM3OrganizationsPolicyBinding without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing OrganizationsPolicyBinding %q from Terraform state without deletion", d.Id()) + return nil + } var project string config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) diff --git a/google/services/iam3/resource_iam_organizations_policy_binding_generated_meta.yaml b/google/services/iam3/resource_iam_organizations_policy_binding_generated_meta.yaml index 3101fc4c091..6ef305df0cc 100644 --- a/google/services/iam3/resource_iam_organizations_policy_binding_generated_meta.yaml +++ b/google/services/iam3/resource_iam_organizations_policy_binding_generated_meta.yaml @@ -32,3 +32,5 @@ fields: - api_field: target.principalSet - api_field: uid - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/iam3/resource_iam_principal_access_boundary_policy.go b/google/services/iam3/resource_iam_principal_access_boundary_policy.go index 5ecf4c323b3..0ae743d7fa3 100644 --- a/google/services/iam3/resource_iam_principal_access_boundary_policy.go +++ b/google/services/iam3/resource_iam_principal_access_boundary_policy.go @@ -115,6 +115,7 @@ func ResourceIAM3PrincipalAccessBoundaryPolicy() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetAnnotationsDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -263,6 +264,19 @@ won't get updated when new versions are released.`, Computed: true, Description: `Output only. The time when the principal access boundary policy was most recently updated.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -401,6 +415,20 @@ func resourceIAM3PrincipalAccessBoundaryPolicyRead(d *schema.ResourceData, meta log.Printf("[DEBUG] Finished reading IAM3PrincipalAccessBoundaryPolicy %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceIAM3PrincipalAccessBoundaryPolicyFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -434,6 +462,18 @@ func resourceIAM3PrincipalAccessBoundaryPolicyRead(d *schema.ResourceData, meta } func resourceIAM3PrincipalAccessBoundaryPolicyUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceIAM3PrincipalAccessBoundaryPolicy().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceIAM3PrincipalAccessBoundaryPolicyRead(d, meta) + } var project string config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) @@ -547,6 +587,13 @@ func resourceIAM3PrincipalAccessBoundaryPolicyUpdate(d *schema.ResourceData, met } func resourceIAM3PrincipalAccessBoundaryPolicyDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy IAM3PrincipalAccessBoundaryPolicy without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing PrincipalAccessBoundaryPolicy %q from Terraform state without deletion", d.Id()) + return nil + } var project string config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) diff --git a/google/services/iam3/resource_iam_principal_access_boundary_policy_generated_meta.yaml b/google/services/iam3/resource_iam_principal_access_boundary_policy_generated_meta.yaml index 413166d253e..fe9df9bd44d 100644 --- a/google/services/iam3/resource_iam_principal_access_boundary_policy_generated_meta.yaml +++ b/google/services/iam3/resource_iam_principal_access_boundary_policy_generated_meta.yaml @@ -26,3 +26,5 @@ fields: provider_only: true - api_field: uid - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/iam3/resource_iam_projects_policy_binding.go b/google/services/iam3/resource_iam_projects_policy_binding.go index 323ebab83ca..452cd6ef173 100644 --- a/google/services/iam3/resource_iam_projects_policy_binding.go +++ b/google/services/iam3/resource_iam_projects_policy_binding.go @@ -116,6 +116,7 @@ func ResourceIAM3ProjectsPolicyBinding() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetAnnotationsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -299,6 +300,18 @@ to the policy kind) - The input policy kind Possible values: POLICY_KIND_UNSP Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -472,6 +485,19 @@ func resourceIAM3ProjectsPolicyBindingRead(d *schema.ResourceData, meta interfac log.Printf("[DEBUG] Finished reading IAM3ProjectsPolicyBinding %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading ProjectsPolicyBinding: %s", err) } @@ -509,6 +535,19 @@ func resourceIAM3ProjectsPolicyBindingRead(d *schema.ResourceData, meta interfac } func resourceIAM3ProjectsPolicyBindingUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceIAM3ProjectsPolicyBinding().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceIAM3ProjectsPolicyBindingRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -647,6 +686,13 @@ func resourceIAM3ProjectsPolicyBindingUpdate(d *schema.ResourceData, meta interf } func resourceIAM3ProjectsPolicyBindingDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy IAM3ProjectsPolicyBinding without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ProjectsPolicyBinding %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/iam3/resource_iam_projects_policy_binding_generated_meta.yaml b/google/services/iam3/resource_iam_projects_policy_binding_generated_meta.yaml index 81f30ece4f3..25ee6756e14 100644 --- a/google/services/iam3/resource_iam_projects_policy_binding_generated_meta.yaml +++ b/google/services/iam3/resource_iam_projects_policy_binding_generated_meta.yaml @@ -30,3 +30,5 @@ fields: - api_field: target.principalSet - api_field: uid - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/iambeta/resource_iam_workload_identity_pool.go b/google/services/iambeta/resource_iam_workload_identity_pool.go index f8aca5d43f4..add788acefb 100644 --- a/google/services/iambeta/resource_iam_workload_identity_pool.go +++ b/google/services/iambeta/resource_iam_workload_identity_pool.go @@ -148,6 +148,7 @@ func ResourceIAMBetaWorkloadIdentityPool() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -394,6 +395,18 @@ can be created within 'SYSTEM_TRUST_DOMAIN' mode pools. All identities within a Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -645,6 +658,19 @@ func resourceIAMBetaWorkloadIdentityPoolRead(d *schema.ResourceData, meta interf return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading WorkloadIdentityPool: %s", err) } @@ -676,6 +702,19 @@ func resourceIAMBetaWorkloadIdentityPoolRead(d *schema.ResourceData, meta interf } func resourceIAMBetaWorkloadIdentityPoolUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceIAMBetaWorkloadIdentityPool().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceIAMBetaWorkloadIdentityPoolRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -868,6 +907,13 @@ func resourceIAMBetaWorkloadIdentityPoolUpdate(d *schema.ResourceData, meta inte } func resourceIAMBetaWorkloadIdentityPoolDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy IAMBetaWorkloadIdentityPool without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing WorkloadIdentityPool %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/iambeta/resource_iam_workload_identity_pool_generated_meta.yaml b/google/services/iambeta/resource_iam_workload_identity_pool_generated_meta.yaml index 84aee154dbc..7aae7edcc26 100644 --- a/google/services/iambeta/resource_iam_workload_identity_pool_generated_meta.yaml +++ b/google/services/iambeta/resource_iam_workload_identity_pool_generated_meta.yaml @@ -27,3 +27,5 @@ fields: - api_field: state - field: workload_identity_pool_id provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/iambeta/resource_iam_workload_identity_pool_managed_identity.go b/google/services/iambeta/resource_iam_workload_identity_pool_managed_identity.go index f9b88de7876..dc7a23d8517 100644 --- a/google/services/iambeta/resource_iam_workload_identity_pool_managed_identity.go +++ b/google/services/iambeta/resource_iam_workload_identity_pool_managed_identity.go @@ -160,6 +160,7 @@ func ResourceIAMBetaWorkloadIdentityPoolManagedIdentity() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -267,6 +268,18 @@ soft-deleted managed identity until it is permanently deleted.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -504,6 +517,19 @@ func resourceIAMBetaWorkloadIdentityPoolManagedIdentityRead(d *schema.ResourceDa return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading WorkloadIdentityPoolManagedIdentity: %s", err) } @@ -547,6 +573,19 @@ func resourceIAMBetaWorkloadIdentityPoolManagedIdentityRead(d *schema.ResourceDa } func resourceIAMBetaWorkloadIdentityPoolManagedIdentityUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceIAMBetaWorkloadIdentityPoolManagedIdentity().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceIAMBetaWorkloadIdentityPoolManagedIdentityRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -709,6 +748,13 @@ func resourceIAMBetaWorkloadIdentityPoolManagedIdentityUpdate(d *schema.Resource } func resourceIAMBetaWorkloadIdentityPoolManagedIdentityDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy IAMBetaWorkloadIdentityPoolManagedIdentity without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing WorkloadIdentityPoolManagedIdentity %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/iambeta/resource_iam_workload_identity_pool_managed_identity_generated_meta.yaml b/google/services/iambeta/resource_iam_workload_identity_pool_managed_identity_generated_meta.yaml index cf7e4e731db..3cbe090594d 100644 --- a/google/services/iambeta/resource_iam_workload_identity_pool_managed_identity_generated_meta.yaml +++ b/google/services/iambeta/resource_iam_workload_identity_pool_managed_identity_generated_meta.yaml @@ -18,3 +18,5 @@ fields: provider_only: true - field: workload_identity_pool_namespace_id provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/iambeta/resource_iam_workload_identity_pool_namespace.go b/google/services/iambeta/resource_iam_workload_identity_pool_namespace.go index 22e56a88ce1..ae3a5b5d2f7 100644 --- a/google/services/iambeta/resource_iam_workload_identity_pool_namespace.go +++ b/google/services/iambeta/resource_iam_workload_identity_pool_namespace.go @@ -160,6 +160,7 @@ func ResourceIAMBetaWorkloadIdentityPoolNamespace() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -258,6 +259,18 @@ until it is permanently deleted.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -413,6 +426,19 @@ func resourceIAMBetaWorkloadIdentityPoolNamespaceRead(d *schema.ResourceData, me return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading WorkloadIdentityPoolNamespace: %s", err) } @@ -450,6 +476,19 @@ func resourceIAMBetaWorkloadIdentityPoolNamespaceRead(d *schema.ResourceData, me } func resourceIAMBetaWorkloadIdentityPoolNamespaceUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceIAMBetaWorkloadIdentityPoolNamespace().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceIAMBetaWorkloadIdentityPoolNamespaceRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -558,6 +597,13 @@ func resourceIAMBetaWorkloadIdentityPoolNamespaceUpdate(d *schema.ResourceData, } func resourceIAMBetaWorkloadIdentityPoolNamespaceDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy IAMBetaWorkloadIdentityPoolNamespace without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing WorkloadIdentityPoolNamespace %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/iambeta/resource_iam_workload_identity_pool_namespace_generated_meta.yaml b/google/services/iambeta/resource_iam_workload_identity_pool_namespace_generated_meta.yaml index 1bc3f5e2b3e..1411489710f 100644 --- a/google/services/iambeta/resource_iam_workload_identity_pool_namespace_generated_meta.yaml +++ b/google/services/iambeta/resource_iam_workload_identity_pool_namespace_generated_meta.yaml @@ -16,3 +16,5 @@ fields: provider_only: true - field: workload_identity_pool_namespace_id provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/iambeta/resource_iam_workload_identity_pool_provider.go b/google/services/iambeta/resource_iam_workload_identity_pool_provider.go index c4f74c7272e..ffaa50f27cb 100644 --- a/google/services/iambeta/resource_iam_workload_identity_pool_provider.go +++ b/google/services/iambeta/resource_iam_workload_identity_pool_provider.go @@ -161,6 +161,7 @@ func ResourceIAMBetaWorkloadIdentityPoolProvider() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -486,6 +487,18 @@ ca certificate(either root or intermediate cert).`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -683,6 +696,19 @@ func resourceIAMBetaWorkloadIdentityPoolProviderRead(d *schema.ResourceData, met return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading WorkloadIdentityPoolProvider: %s", err) } @@ -720,6 +746,19 @@ func resourceIAMBetaWorkloadIdentityPoolProviderRead(d *schema.ResourceData, met } func resourceIAMBetaWorkloadIdentityPoolProviderUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceIAMBetaWorkloadIdentityPoolProvider().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceIAMBetaWorkloadIdentityPoolProviderRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -900,6 +939,13 @@ func resourceIAMBetaWorkloadIdentityPoolProviderUpdate(d *schema.ResourceData, m } func resourceIAMBetaWorkloadIdentityPoolProviderDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy IAMBetaWorkloadIdentityPoolProvider without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing WorkloadIdentityPoolProvider %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/iambeta/resource_iam_workload_identity_pool_provider_generated_meta.yaml b/google/services/iambeta/resource_iam_workload_identity_pool_provider_generated_meta.yaml index ef99ac656b9..509f2f9a91a 100644 --- a/google/services/iambeta/resource_iam_workload_identity_pool_provider_generated_meta.yaml +++ b/google/services/iambeta/resource_iam_workload_identity_pool_provider_generated_meta.yaml @@ -25,3 +25,5 @@ fields: provider_only: true - api_field: x509.trustStore.intermediateCas.pemCertificate - api_field: x509.trustStore.trustAnchors.pemCertificate + - field: deletion_policy + provider_only: true diff --git a/google/services/iamworkforcepool/resource_iam_oauth_client.go b/google/services/iamworkforcepool/resource_iam_oauth_client.go index ac459703067..a9f054e2923 100644 --- a/google/services/iamworkforcepool/resource_iam_oauth_client.go +++ b/google/services/iamworkforcepool/resource_iam_oauth_client.go @@ -115,6 +115,7 @@ func ResourceIAMWorkforcePoolOauthClient() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -258,6 +259,18 @@ DELETED`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -438,6 +451,19 @@ func resourceIAMWorkforcePoolOauthClientRead(d *schema.ResourceData, meta interf return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading OauthClient: %s", err) } @@ -475,6 +501,19 @@ func resourceIAMWorkforcePoolOauthClientRead(d *schema.ResourceData, meta interf } func resourceIAMWorkforcePoolOauthClientUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceIAMWorkforcePoolOauthClient().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceIAMWorkforcePoolOauthClientRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -620,6 +659,13 @@ func resourceIAMWorkforcePoolOauthClientUpdate(d *schema.ResourceData, meta inte } func resourceIAMWorkforcePoolOauthClientDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy IAMWorkforcePoolOauthClient without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing OauthClient %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/iamworkforcepool/resource_iam_oauth_client_credential.go b/google/services/iamworkforcepool/resource_iam_oauth_client_credential.go index 97de1c31e57..32129d66f3e 100644 --- a/google/services/iamworkforcepool/resource_iam_oauth_client_credential.go +++ b/google/services/iamworkforcepool/resource_iam_oauth_client_credential.go @@ -115,6 +115,7 @@ func ResourceIAMWorkforcePoolOauthClientCredential() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -204,6 +205,18 @@ Format: Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -359,6 +372,19 @@ func resourceIAMWorkforcePoolOauthClientCredentialRead(d *schema.ResourceData, m return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading OauthClientCredential: %s", err) } @@ -402,6 +428,19 @@ func resourceIAMWorkforcePoolOauthClientCredentialRead(d *schema.ResourceData, m } func resourceIAMWorkforcePoolOauthClientCredentialUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceIAMWorkforcePoolOauthClientCredential().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceIAMWorkforcePoolOauthClientCredentialRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -512,6 +551,13 @@ func resourceIAMWorkforcePoolOauthClientCredentialUpdate(d *schema.ResourceData, } func resourceIAMWorkforcePoolOauthClientCredentialDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy IAMWorkforcePoolOauthClientCredential without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing OauthClientCredential %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/iamworkforcepool/resource_iam_oauth_client_credential_generated_meta.yaml b/google/services/iamworkforcepool/resource_iam_oauth_client_credential_generated_meta.yaml index 6c865b91f6e..4811fe9a8b5 100644 --- a/google/services/iamworkforcepool/resource_iam_oauth_client_credential_generated_meta.yaml +++ b/google/services/iamworkforcepool/resource_iam_oauth_client_credential_generated_meta.yaml @@ -17,3 +17,5 @@ fields: provider_only: true - field: oauthclient provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/iamworkforcepool/resource_iam_oauth_client_generated_meta.yaml b/google/services/iamworkforcepool/resource_iam_oauth_client_generated_meta.yaml index a95ad4d6414..5b2dfe5ae76 100644 --- a/google/services/iamworkforcepool/resource_iam_oauth_client_generated_meta.yaml +++ b/google/services/iamworkforcepool/resource_iam_oauth_client_generated_meta.yaml @@ -22,3 +22,5 @@ fields: - field: oauth_client_id provider_only: true - api_field: state + - field: deletion_policy + provider_only: true diff --git a/google/services/iamworkforcepool/resource_iam_workforce_pool.go b/google/services/iamworkforcepool/resource_iam_workforce_pool.go index 6642d121e08..09a69bd92f9 100644 --- a/google/services/iamworkforcepool/resource_iam_workforce_pool.go +++ b/google/services/iamworkforcepool/resource_iam_workforce_pool.go @@ -255,6 +255,19 @@ Format: 'locations/{location}/workforcePools/{workforcePoolId}'`, existing tokens to access resources. If the pool is undeleted, existing tokens grant access again.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -417,6 +430,20 @@ func resourceIAMWorkforcePoolWorkforcePoolRead(d *schema.ResourceData, meta inte return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceIAMWorkforcePoolWorkforcePoolFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -444,6 +471,19 @@ func resourceIAMWorkforcePoolWorkforcePoolRead(d *schema.ResourceData, meta inte } func resourceIAMWorkforcePoolWorkforcePoolUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceIAMWorkforcePoolWorkforcePool().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceIAMWorkforcePoolWorkforcePoolRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -561,6 +601,13 @@ func resourceIAMWorkforcePoolWorkforcePoolUpdate(d *schema.ResourceData, meta in } func resourceIAMWorkforcePoolWorkforcePoolDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy IAMWorkforcePoolWorkforcePool without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing WorkforcePool %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/iamworkforcepool/resource_iam_workforce_pool_generated_meta.yaml b/google/services/iamworkforcepool/resource_iam_workforce_pool_generated_meta.yaml index f4bb5202ebf..bb3e3a1e046 100644 --- a/google/services/iamworkforcepool/resource_iam_workforce_pool_generated_meta.yaml +++ b/google/services/iamworkforcepool/resource_iam_workforce_pool_generated_meta.yaml @@ -20,3 +20,5 @@ fields: - api_field: state - field: workforce_pool_id provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/iamworkforcepool/resource_iam_workforce_pool_provider.go b/google/services/iamworkforcepool/resource_iam_workforce_pool_provider.go index 3a07ffb8555..d6473582d9b 100644 --- a/google/services/iamworkforcepool/resource_iam_workforce_pool_provider.go +++ b/google/services/iamworkforcepool/resource_iam_workforce_pool_provider.go @@ -653,6 +653,19 @@ Format: 'locations/{location}/workforcePools/{workforcePoolId}/providers/{provid deleted after approximately 30 days. You can restore a soft-deleted provider using [providers.undelete](https://cloud.google.com/iam/docs/reference/rest/v1/locations.workforcePools.providers/undelete#google.iam.admin.v1.WorkforcePools.UndeleteWorkforcePoolProvider).`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -897,6 +910,20 @@ func resourceIAMWorkforcePoolWorkforcePoolProviderRead(d *schema.ResourceData, m return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceIAMWorkforcePoolWorkforcePoolProviderFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -930,6 +957,19 @@ func resourceIAMWorkforcePoolWorkforcePoolProviderRead(d *schema.ResourceData, m } func resourceIAMWorkforcePoolWorkforcePoolProviderUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceIAMWorkforcePoolWorkforcePoolProvider().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceIAMWorkforcePoolWorkforcePoolProviderRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1164,6 +1204,13 @@ func resourceIAMWorkforcePoolWorkforcePoolProviderUpdate(d *schema.ResourceData, } func resourceIAMWorkforcePoolWorkforcePoolProviderDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy IAMWorkforcePoolWorkforcePoolProvider without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing WorkforcePoolProvider %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/iamworkforcepool/resource_iam_workforce_pool_provider_generated_meta.yaml b/google/services/iamworkforcepool/resource_iam_workforce_pool_provider_generated_meta.yaml index d739dc57f55..df5c22f9e09 100644 --- a/google/services/iamworkforcepool/resource_iam_workforce_pool_provider_generated_meta.yaml +++ b/google/services/iamworkforcepool/resource_iam_workforce_pool_provider_generated_meta.yaml @@ -43,3 +43,5 @@ fields: - api_field: state - field: workforce_pool_id provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/iamworkforcepool/resource_iam_workforce_pool_provider_key.go b/google/services/iamworkforcepool/resource_iam_workforce_pool_provider_key.go index e1ad822054a..864a819989b 100644 --- a/google/services/iamworkforcepool/resource_iam_workforce_pool_provider_key.go +++ b/google/services/iamworkforcepool/resource_iam_workforce_pool_provider_key.go @@ -119,6 +119,7 @@ func ResourceIAMWorkforcePoolWorkforcePoolProviderKey() *schema.Resource { return &schema.Resource{ Create: resourceIAMWorkforcePoolWorkforcePoolProviderKeyCreate, Read: resourceIAMWorkforcePoolWorkforcePoolProviderKeyRead, + Update: resourceIAMWorkforcePoolWorkforcePoolProviderKeyUpdate, Delete: resourceIAMWorkforcePoolWorkforcePoolProviderKeyDelete, Importer: &schema.ResourceImporter{ @@ -255,6 +256,19 @@ Format: 'locations/{location}/workforcePools/{workforcePoolId}/providers/{provid Computed: true, Description: `The state of the key.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -391,6 +405,20 @@ func resourceIAMWorkforcePoolWorkforcePoolProviderKeyRead(d *schema.ResourceData log.Printf("[DEBUG] Finished reading IAMWorkforcePoolWorkforcePoolProviderKey %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceIAMWorkforcePoolWorkforcePoolProviderKeyFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -429,7 +457,19 @@ func resourceIAMWorkforcePoolWorkforcePoolProviderKeyRead(d *schema.ResourceData return nil } +func resourceIAMWorkforcePoolWorkforcePoolProviderKeyUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceIAMWorkforcePoolWorkforcePoolProviderKeyRead(d, meta) +} + func resourceIAMWorkforcePoolWorkforcePoolProviderKeyDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy IAMWorkforcePoolWorkforcePoolProviderKey without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing WorkforcePoolProviderKey %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/iamworkforcepool/resource_iam_workforce_pool_provider_key_generated_meta.yaml b/google/services/iamworkforcepool/resource_iam_workforce_pool_provider_key_generated_meta.yaml index 813d2084b70..af385f51437 100644 --- a/google/services/iamworkforcepool/resource_iam_workforce_pool_provider_key_generated_meta.yaml +++ b/google/services/iamworkforcepool/resource_iam_workforce_pool_provider_key_generated_meta.yaml @@ -24,3 +24,5 @@ fields: - api_field: use - field: workforce_pool_id provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/iamworkforcepool/resource_iam_workforce_pool_provider_scim_tenant.go b/google/services/iamworkforcepool/resource_iam_workforce_pool_provider_scim_tenant.go index 72cbb583767..992c6ada909 100644 --- a/google/services/iamworkforcepool/resource_iam_workforce_pool_provider_scim_tenant.go +++ b/google/services/iamworkforcepool/resource_iam_workforce_pool_provider_scim_tenant.go @@ -221,6 +221,19 @@ this tenant will be attached to this service agent.`, * DELETED: The scim tenant is soft-deleted. Soft-deleted scim tenants are permanently deleted after approximately 30 days.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -370,6 +383,20 @@ func resourceIAMWorkforcePoolWorkforcePoolProviderScimTenantRead(d *schema.Resou return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceIAMWorkforcePoolWorkforcePoolProviderScimTenantFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -409,6 +436,19 @@ func resourceIAMWorkforcePoolWorkforcePoolProviderScimTenantRead(d *schema.Resou } func resourceIAMWorkforcePoolWorkforcePoolProviderScimTenantUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceIAMWorkforcePoolWorkforcePoolProviderScimTenant().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceIAMWorkforcePoolWorkforcePoolProviderScimTenantRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -523,6 +563,13 @@ func resourceIAMWorkforcePoolWorkforcePoolProviderScimTenantUpdate(d *schema.Res } func resourceIAMWorkforcePoolWorkforcePoolProviderScimTenantDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy IAMWorkforcePoolWorkforcePoolProviderScimTenant without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing WorkforcePoolProviderScimTenant %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/iamworkforcepool/resource_iam_workforce_pool_provider_scim_tenant_generated_meta.yaml b/google/services/iamworkforcepool/resource_iam_workforce_pool_provider_scim_tenant_generated_meta.yaml index fc492605a02..cbc2d4d7b0e 100644 --- a/google/services/iamworkforcepool/resource_iam_workforce_pool_provider_scim_tenant_generated_meta.yaml +++ b/google/services/iamworkforcepool/resource_iam_workforce_pool_provider_scim_tenant_generated_meta.yaml @@ -25,3 +25,5 @@ fields: - api_field: state - field: workforce_pool_id provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/iamworkforcepool/resource_iam_workforce_pool_provider_scim_token.go b/google/services/iamworkforcepool/resource_iam_workforce_pool_provider_scim_token.go index d6f67052b4a..1b9ef75a636 100644 --- a/google/services/iamworkforcepool/resource_iam_workforce_pool_provider_scim_token.go +++ b/google/services/iamworkforcepool/resource_iam_workforce_pool_provider_scim_token.go @@ -198,6 +198,19 @@ Format: 'locations/{location}/workforcePools/{workforce_pool}/providers/{workfor * ACTIVE: The token is active and may be used to provision users and groups. * DELETED: The token is soft-deleted. Soft-deleted tokens are permanently deleted after approximately 30 days.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -340,6 +353,20 @@ func resourceIAMWorkforcePoolWorkforcePoolProviderScimTokenRead(d *schema.Resour return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceIAMWorkforcePoolWorkforcePoolProviderScimTokenFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -385,6 +412,19 @@ func resourceIAMWorkforcePoolWorkforcePoolProviderScimTokenRead(d *schema.Resour } func resourceIAMWorkforcePoolWorkforcePoolProviderScimTokenUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceIAMWorkforcePoolWorkforcePoolProviderScimToken().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceIAMWorkforcePoolWorkforcePoolProviderScimTokenRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -484,6 +524,13 @@ func resourceIAMWorkforcePoolWorkforcePoolProviderScimTokenUpdate(d *schema.Reso } func resourceIAMWorkforcePoolWorkforcePoolProviderScimTokenDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy IAMWorkforcePoolWorkforcePoolProviderScimToken without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing WorkforcePoolProviderScimToken %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/iamworkforcepool/resource_iam_workforce_pool_provider_scim_token_generated_meta.yaml b/google/services/iamworkforcepool/resource_iam_workforce_pool_provider_scim_token_generated_meta.yaml index ae6cb17512d..c0196be3b06 100644 --- a/google/services/iamworkforcepool/resource_iam_workforce_pool_provider_scim_token_generated_meta.yaml +++ b/google/services/iamworkforcepool/resource_iam_workforce_pool_provider_scim_token_generated_meta.yaml @@ -21,3 +21,5 @@ fields: - api_field: state - field: workforce_pool_id provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/iap/resource_iap_client.go b/google/services/iap/resource_iap_client.go index e0f5445ad56..ce5708045cb 100644 --- a/google/services/iap/resource_iap_client.go +++ b/google/services/iap/resource_iap_client.go @@ -100,6 +100,7 @@ func ResourceIapClient() *schema.Resource { return &schema.Resource{ Create: resourceIapClientCreate, Read: resourceIapClientRead, + Update: resourceIapClientUpdate, Delete: resourceIapClientDelete, Importer: &schema.ResourceImporter{ @@ -158,6 +159,19 @@ is attached to. The format is Description: `Output only. Client secret of the OAuth client.`, Sensitive: true, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -276,6 +290,20 @@ func resourceIapClientRead(d *schema.ResourceData, meta interface{}) error { log.Printf("[DEBUG] Finished reading IapClient %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceIapClientFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -302,7 +330,19 @@ func resourceIapClientRead(d *schema.ResourceData, meta interface{}) error { return nil } +func resourceIapClientUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceIapClientRead(d, meta) +} + func resourceIapClientDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy IapClient without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Client %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/iap/resource_iap_client_generated_meta.yaml b/google/services/iap/resource_iap_client_generated_meta.yaml index 05f0d7f8b5a..15d5c6b079d 100644 --- a/google/services/iap/resource_iap_client_generated_meta.yaml +++ b/google/services/iap/resource_iap_client_generated_meta.yaml @@ -13,3 +13,5 @@ fields: field: client_id - api_field: displayName - api_field: secret + - field: deletion_policy + provider_only: true diff --git a/google/services/iap/resource_iap_settings.go b/google/services/iap/resource_iap_settings.go index 822223f8fd1..ff043420c98 100644 --- a/google/services/iap/resource_iap_settings.go +++ b/google/services/iap/resource_iap_settings.go @@ -469,6 +469,19 @@ but will be ignored at runtime if invalid.`, }, }, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -586,6 +599,20 @@ func resourceIapSettingsRead(d *schema.ResourceData, meta interface{}) error { log.Printf("[DEBUG] Finished reading IapSettings %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceIapSettingsFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -607,6 +634,19 @@ func resourceIapSettingsRead(d *schema.ResourceData, meta interface{}) error { } func resourceIapSettingsUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceIapSettings().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceIapSettingsRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -673,6 +713,13 @@ func resourceIapSettingsUpdate(d *schema.ResourceData, meta interface{}) error { } func resourceIapSettingsDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy IapSettings without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Settings %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/iap/resource_iap_settings_generated_meta.yaml b/google/services/iap/resource_iap_settings_generated_meta.yaml index 63246c8cfc7..0cb742864ac 100644 --- a/google/services/iap/resource_iap_settings_generated_meta.yaml +++ b/google/services/iap/resource_iap_settings_generated_meta.yaml @@ -34,3 +34,5 @@ fields: - api_field: applicationSettings.cookieDomain - api_field: applicationSettings.csmSettings.rctokenAud - api_field: name + - field: deletion_policy + provider_only: true diff --git a/google/services/iap/resource_iap_tunnel_dest_group.go b/google/services/iap/resource_iap_tunnel_dest_group.go index ddea7210806..1f65bde7f22 100644 --- a/google/services/iap/resource_iap_tunnel_dest_group.go +++ b/google/services/iap/resource_iap_tunnel_dest_group.go @@ -115,6 +115,7 @@ func ResourceIapTunnelDestGroup() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -181,6 +182,18 @@ func ResourceIapTunnelDestGroup() *schema.Resource { Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -314,6 +327,19 @@ func resourceIapTunnelDestGroupRead(d *schema.ResourceData, meta interface{}) er log.Printf("[DEBUG] Finished reading IapTunnelDestGroup %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading TunnelDestGroup: %s", err) } @@ -351,6 +377,19 @@ func resourceIapTunnelDestGroupRead(d *schema.ResourceData, meta interface{}) er } func resourceIapTunnelDestGroupUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceIapTunnelDestGroup().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceIapTunnelDestGroupRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -433,6 +472,13 @@ func resourceIapTunnelDestGroupUpdate(d *schema.ResourceData, meta interface{}) } func resourceIapTunnelDestGroupDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy IapTunnelDestGroup without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing TunnelDestGroup %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/iap/resource_iap_tunnel_dest_group_generated_meta.yaml b/google/services/iap/resource_iap_tunnel_dest_group_generated_meta.yaml index da8f0214e97..1b38f9c80e8 100644 --- a/google/services/iap/resource_iap_tunnel_dest_group_generated_meta.yaml +++ b/google/services/iap/resource_iap_tunnel_dest_group_generated_meta.yaml @@ -14,3 +14,5 @@ fields: - api_field: name - field: region provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/identityplatform/resource_identity_platform_config.go b/google/services/identityplatform/resource_identity_platform_config.go index 4e13f059ab6..887ed97ed5f 100644 --- a/google/services/identityplatform/resource_identity_platform_config.go +++ b/google/services/identityplatform/resource_identity_platform_config.go @@ -688,6 +688,7 @@ func resourceIdentityPlatformConfigRead(d *schema.ResourceData, meta interface{} } func resourceIdentityPlatformConfigUpdate(d *schema.ResourceData, meta interface{}) error { + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/identityplatform/resource_identity_platform_default_supported_idp_config.go b/google/services/identityplatform/resource_identity_platform_default_supported_idp_config.go index b91b4e4ddf5..f1d2503440e 100644 --- a/google/services/identityplatform/resource_identity_platform_default_supported_idp_config.go +++ b/google/services/identityplatform/resource_identity_platform_default_supported_idp_config.go @@ -115,6 +115,7 @@ func ResourceIdentityPlatformDefaultSupportedIdpConfig() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -189,6 +190,18 @@ func ResourceIdentityPlatformDefaultSupportedIdpConfig() *schema.Resource { Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -323,6 +336,19 @@ func resourceIdentityPlatformDefaultSupportedIdpConfigRead(d *schema.ResourceDat log.Printf("[DEBUG] Finished reading IdentityPlatformDefaultSupportedIdpConfig %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading DefaultSupportedIdpConfig: %s", err) } @@ -354,6 +380,19 @@ func resourceIdentityPlatformDefaultSupportedIdpConfigRead(d *schema.ResourceDat } func resourceIdentityPlatformDefaultSupportedIdpConfigUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceIdentityPlatformDefaultSupportedIdpConfig().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceIdentityPlatformDefaultSupportedIdpConfigRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -460,6 +499,13 @@ func resourceIdentityPlatformDefaultSupportedIdpConfigUpdate(d *schema.ResourceD } func resourceIdentityPlatformDefaultSupportedIdpConfigDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy IdentityPlatformDefaultSupportedIdpConfig without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing DefaultSupportedIdpConfig %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/identityplatform/resource_identity_platform_default_supported_idp_config_generated_meta.yaml b/google/services/identityplatform/resource_identity_platform_default_supported_idp_config_generated_meta.yaml index bc44a78be40..b0413f4c7b5 100644 --- a/google/services/identityplatform/resource_identity_platform_default_supported_idp_config_generated_meta.yaml +++ b/google/services/identityplatform/resource_identity_platform_default_supported_idp_config_generated_meta.yaml @@ -13,3 +13,5 @@ fields: - field: idp_id provider_only: true - api_field: name + - field: deletion_policy + provider_only: true diff --git a/google/services/identityplatform/resource_identity_platform_inbound_saml_config.go b/google/services/identityplatform/resource_identity_platform_inbound_saml_config.go index 4141fcfcead..6481ed65b8a 100644 --- a/google/services/identityplatform/resource_identity_platform_inbound_saml_config.go +++ b/google/services/identityplatform/resource_identity_platform_inbound_saml_config.go @@ -115,6 +115,7 @@ func ResourceIdentityPlatformInboundSamlConfig() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -235,6 +236,18 @@ and accept an authentication assertion issued by a SAML identity provider.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -381,6 +394,19 @@ func resourceIdentityPlatformInboundSamlConfigRead(d *schema.ResourceData, meta log.Printf("[DEBUG] Finished reading IdentityPlatformInboundSamlConfig %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading InboundSamlConfig: %s", err) } @@ -412,6 +438,19 @@ func resourceIdentityPlatformInboundSamlConfigRead(d *schema.ResourceData, meta } func resourceIdentityPlatformInboundSamlConfigUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceIdentityPlatformInboundSamlConfig().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceIdentityPlatformInboundSamlConfigRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -528,6 +567,13 @@ func resourceIdentityPlatformInboundSamlConfigUpdate(d *schema.ResourceData, met } func resourceIdentityPlatformInboundSamlConfigDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy IdentityPlatformInboundSamlConfig without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing InboundSamlConfig %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/identityplatform/resource_identity_platform_inbound_saml_config_generated_meta.yaml b/google/services/identityplatform/resource_identity_platform_inbound_saml_config_generated_meta.yaml index cae4945e25d..166e27e675f 100644 --- a/google/services/identityplatform/resource_identity_platform_inbound_saml_config_generated_meta.yaml +++ b/google/services/identityplatform/resource_identity_platform_inbound_saml_config_generated_meta.yaml @@ -17,3 +17,5 @@ fields: - api_field: spConfig.callbackUri - api_field: spConfig.spCertificates.x509Certificate - api_field: spConfig.spEntityId + - field: deletion_policy + provider_only: true diff --git a/google/services/identityplatform/resource_identity_platform_oauth_idp_config.go b/google/services/identityplatform/resource_identity_platform_oauth_idp_config.go index f44a0764f63..644f944d7e7 100644 --- a/google/services/identityplatform/resource_identity_platform_oauth_idp_config.go +++ b/google/services/identityplatform/resource_identity_platform_oauth_idp_config.go @@ -115,6 +115,7 @@ func ResourceIdentityPlatformOauthIdpConfig() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -196,6 +197,18 @@ Setting both types to be simultaneously true ({code: true, idToken: true}) is no Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -354,6 +367,19 @@ func resourceIdentityPlatformOauthIdpConfigRead(d *schema.ResourceData, meta int log.Printf("[DEBUG] Finished reading IdentityPlatformOauthIdpConfig %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading OauthIdpConfig: %s", err) } @@ -385,6 +411,19 @@ func resourceIdentityPlatformOauthIdpConfigRead(d *schema.ResourceData, meta int } func resourceIdentityPlatformOauthIdpConfigUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceIdentityPlatformOauthIdpConfig().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceIdentityPlatformOauthIdpConfigRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -521,6 +560,13 @@ func resourceIdentityPlatformOauthIdpConfigUpdate(d *schema.ResourceData, meta i } func resourceIdentityPlatformOauthIdpConfigDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy IdentityPlatformOauthIdpConfig without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing OauthIdpConfig %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/identityplatform/resource_identity_platform_oauth_idp_config_generated_meta.yaml b/google/services/identityplatform/resource_identity_platform_oauth_idp_config_generated_meta.yaml index 523b0fce467..88c17ecdba9 100644 --- a/google/services/identityplatform/resource_identity_platform_oauth_idp_config_generated_meta.yaml +++ b/google/services/identityplatform/resource_identity_platform_oauth_idp_config_generated_meta.yaml @@ -15,3 +15,5 @@ fields: - api_field: name - api_field: responseType.code - api_field: responseType.idToken + - field: deletion_policy + provider_only: true diff --git a/google/services/identityplatform/resource_identity_platform_tenant.go b/google/services/identityplatform/resource_identity_platform_tenant.go index 11fec82f617..c33c124e815 100644 --- a/google/services/identityplatform/resource_identity_platform_tenant.go +++ b/google/services/identityplatform/resource_identity_platform_tenant.go @@ -115,6 +115,7 @@ func ResourceIdentityPlatformTenant() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -200,6 +201,18 @@ are not able to manage its users.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -352,6 +365,19 @@ func resourceIdentityPlatformTenantRead(d *schema.ResourceData, meta interface{} log.Printf("[DEBUG] Finished reading IdentityPlatformTenant %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Tenant: %s", err) } @@ -383,6 +409,19 @@ func resourceIdentityPlatformTenantRead(d *schema.ResourceData, meta interface{} } func resourceIdentityPlatformTenantUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceIdentityPlatformTenant().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceIdentityPlatformTenantRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -509,6 +548,13 @@ func resourceIdentityPlatformTenantUpdate(d *schema.ResourceData, meta interface } func resourceIdentityPlatformTenantDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy IdentityPlatformTenant without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Tenant %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/identityplatform/resource_identity_platform_tenant_default_supported_idp_config.go b/google/services/identityplatform/resource_identity_platform_tenant_default_supported_idp_config.go index 1d6396f8573..67586cf48ff 100644 --- a/google/services/identityplatform/resource_identity_platform_tenant_default_supported_idp_config.go +++ b/google/services/identityplatform/resource_identity_platform_tenant_default_supported_idp_config.go @@ -115,6 +115,7 @@ func ResourceIdentityPlatformTenantDefaultSupportedIdpConfig() *schema.Resource CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -199,6 +200,18 @@ func ResourceIdentityPlatformTenantDefaultSupportedIdpConfig() *schema.Resource Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -338,6 +351,19 @@ func resourceIdentityPlatformTenantDefaultSupportedIdpConfigRead(d *schema.Resou log.Printf("[DEBUG] Finished reading IdentityPlatformTenantDefaultSupportedIdpConfig %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading TenantDefaultSupportedIdpConfig: %s", err) } @@ -375,6 +401,19 @@ func resourceIdentityPlatformTenantDefaultSupportedIdpConfigRead(d *schema.Resou } func resourceIdentityPlatformTenantDefaultSupportedIdpConfigUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceIdentityPlatformTenantDefaultSupportedIdpConfig().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceIdentityPlatformTenantDefaultSupportedIdpConfigRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -486,6 +525,13 @@ func resourceIdentityPlatformTenantDefaultSupportedIdpConfigUpdate(d *schema.Res } func resourceIdentityPlatformTenantDefaultSupportedIdpConfigDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy IdentityPlatformTenantDefaultSupportedIdpConfig without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing TenantDefaultSupportedIdpConfig %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/identityplatform/resource_identity_platform_tenant_default_supported_idp_config_generated_meta.yaml b/google/services/identityplatform/resource_identity_platform_tenant_default_supported_idp_config_generated_meta.yaml index e80bf237365..0f0d9377527 100644 --- a/google/services/identityplatform/resource_identity_platform_tenant_default_supported_idp_config_generated_meta.yaml +++ b/google/services/identityplatform/resource_identity_platform_tenant_default_supported_idp_config_generated_meta.yaml @@ -15,3 +15,5 @@ fields: - api_field: name - field: tenant provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/identityplatform/resource_identity_platform_tenant_generated_meta.yaml b/google/services/identityplatform/resource_identity_platform_tenant_generated_meta.yaml index df36e0e45b2..ccf35ab3663 100644 --- a/google/services/identityplatform/resource_identity_platform_tenant_generated_meta.yaml +++ b/google/services/identityplatform/resource_identity_platform_tenant_generated_meta.yaml @@ -14,3 +14,5 @@ fields: - api_field: displayName - api_field: enableEmailLinkSignin - api_field: name + - field: deletion_policy + provider_only: true diff --git a/google/services/identityplatform/resource_identity_platform_tenant_inbound_saml_config.go b/google/services/identityplatform/resource_identity_platform_tenant_inbound_saml_config.go index 87cb04dacfd..b4c89c2755c 100644 --- a/google/services/identityplatform/resource_identity_platform_tenant_inbound_saml_config.go +++ b/google/services/identityplatform/resource_identity_platform_tenant_inbound_saml_config.go @@ -115,6 +115,7 @@ func ResourceIdentityPlatformTenantInboundSamlConfig() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -245,6 +246,18 @@ and accept an authentication assertion issued by a SAML identity provider.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -396,6 +409,19 @@ func resourceIdentityPlatformTenantInboundSamlConfigRead(d *schema.ResourceData, log.Printf("[DEBUG] Finished reading IdentityPlatformTenantInboundSamlConfig %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading TenantInboundSamlConfig: %s", err) } @@ -433,6 +459,19 @@ func resourceIdentityPlatformTenantInboundSamlConfigRead(d *schema.ResourceData, } func resourceIdentityPlatformTenantInboundSamlConfigUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceIdentityPlatformTenantInboundSamlConfig().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceIdentityPlatformTenantInboundSamlConfigRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -554,6 +593,13 @@ func resourceIdentityPlatformTenantInboundSamlConfigUpdate(d *schema.ResourceDat } func resourceIdentityPlatformTenantInboundSamlConfigDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy IdentityPlatformTenantInboundSamlConfig without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing TenantInboundSamlConfig %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/identityplatform/resource_identity_platform_tenant_inbound_saml_config_generated_meta.yaml b/google/services/identityplatform/resource_identity_platform_tenant_inbound_saml_config_generated_meta.yaml index 4f96bf36ff1..7f237fcb2e0 100644 --- a/google/services/identityplatform/resource_identity_platform_tenant_inbound_saml_config_generated_meta.yaml +++ b/google/services/identityplatform/resource_identity_platform_tenant_inbound_saml_config_generated_meta.yaml @@ -19,3 +19,5 @@ fields: - api_field: spConfig.spEntityId - field: tenant provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/identityplatform/resource_identity_platform_tenant_oauth_idp_config.go b/google/services/identityplatform/resource_identity_platform_tenant_oauth_idp_config.go index 5d0dd151940..ac549e10c13 100644 --- a/google/services/identityplatform/resource_identity_platform_tenant_oauth_idp_config.go +++ b/google/services/identityplatform/resource_identity_platform_tenant_oauth_idp_config.go @@ -115,6 +115,7 @@ func ResourceIdentityPlatformTenantOauthIdpConfig() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -184,6 +185,18 @@ func ResourceIdentityPlatformTenantOauthIdpConfig() *schema.Resource { Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -341,6 +354,19 @@ func resourceIdentityPlatformTenantOauthIdpConfigRead(d *schema.ResourceData, me log.Printf("[DEBUG] Finished reading IdentityPlatformTenantOauthIdpConfig %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading TenantOauthIdpConfig: %s", err) } @@ -378,6 +404,19 @@ func resourceIdentityPlatformTenantOauthIdpConfigRead(d *schema.ResourceData, me } func resourceIdentityPlatformTenantOauthIdpConfigUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceIdentityPlatformTenantOauthIdpConfig().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceIdentityPlatformTenantOauthIdpConfigRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -509,6 +548,13 @@ func resourceIdentityPlatformTenantOauthIdpConfigUpdate(d *schema.ResourceData, } func resourceIdentityPlatformTenantOauthIdpConfigDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy IdentityPlatformTenantOauthIdpConfig without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing TenantOauthIdpConfig %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/identityplatform/resource_identity_platform_tenant_oauth_idp_config_generated_meta.yaml b/google/services/identityplatform/resource_identity_platform_tenant_oauth_idp_config_generated_meta.yaml index 2d53cdb85b3..118d5dbae95 100644 --- a/google/services/identityplatform/resource_identity_platform_tenant_oauth_idp_config_generated_meta.yaml +++ b/google/services/identityplatform/resource_identity_platform_tenant_oauth_idp_config_generated_meta.yaml @@ -15,3 +15,5 @@ fields: - api_field: name - field: tenant provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/integrationconnectors/resource_integration_connectors_connection.go b/google/services/integrationconnectors/resource_integration_connectors_connection.go index 245b888583b..2a75afab9ff 100644 --- a/google/services/integrationconnectors/resource_integration_connectors_connection.go +++ b/google/services/integrationconnectors/resource_integration_connectors_connection.go @@ -135,6 +135,7 @@ func ResourceIntegrationConnectorsConnection() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -1211,6 +1212,18 @@ e.g. "projects/cloud-connectors-e2e-testing/locations/us-central1/namespaces/ist Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -1430,6 +1443,19 @@ func resourceIntegrationConnectorsConnectionRead(d *schema.ResourceData, meta in log.Printf("[DEBUG] Finished reading IntegrationConnectorsConnection %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Connection: %s", err) } @@ -1467,6 +1493,19 @@ func resourceIntegrationConnectorsConnectionRead(d *schema.ResourceData, meta in } func resourceIntegrationConnectorsConnectionUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceIntegrationConnectorsConnection().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceIntegrationConnectorsConnectionRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1698,6 +1737,13 @@ func resourceIntegrationConnectorsConnectionUpdate(d *schema.ResourceData, meta } func resourceIntegrationConnectorsConnectionDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy IntegrationConnectorsConnection without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Connection %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/integrationconnectors/resource_integration_connectors_connection_generated_meta.yaml b/google/services/integrationconnectors/resource_integration_connectors_connection_generated_meta.yaml index f4bff54a517..b845f25babd 100644 --- a/google/services/integrationconnectors/resource_integration_connectors_connection_generated_meta.yaml +++ b/google/services/integrationconnectors/resource_integration_connectors_connection_generated_meta.yaml @@ -158,3 +158,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/integrationconnectors/resource_integration_connectors_endpoint_attachment.go b/google/services/integrationconnectors/resource_integration_connectors_endpoint_attachment.go index db18cdbb511..22e1fc5076b 100644 --- a/google/services/integrationconnectors/resource_integration_connectors_endpoint_attachment.go +++ b/google/services/integrationconnectors/resource_integration_connectors_endpoint_attachment.go @@ -116,6 +116,7 @@ func ResourceIntegrationConnectorsEndpointAttachment() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -214,6 +215,18 @@ Please refer to the field 'effective_labels' for all of the labels present on th Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -369,6 +382,19 @@ func resourceIntegrationConnectorsEndpointAttachmentRead(d *schema.ResourceData, log.Printf("[DEBUG] Finished reading IntegrationConnectorsEndpointAttachment %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading EndpointAttachment: %s", err) } @@ -406,6 +432,19 @@ func resourceIntegrationConnectorsEndpointAttachmentRead(d *schema.ResourceData, } func resourceIntegrationConnectorsEndpointAttachmentUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceIntegrationConnectorsEndpointAttachment().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceIntegrationConnectorsEndpointAttachmentRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -524,6 +563,13 @@ func resourceIntegrationConnectorsEndpointAttachmentUpdate(d *schema.ResourceDat } func resourceIntegrationConnectorsEndpointAttachmentDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy IntegrationConnectorsEndpointAttachment without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing EndpointAttachment %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/integrationconnectors/resource_integration_connectors_endpoint_attachment_generated_meta.yaml b/google/services/integrationconnectors/resource_integration_connectors_endpoint_attachment_generated_meta.yaml index c583494eae3..c18b8c104e5 100644 --- a/google/services/integrationconnectors/resource_integration_connectors_endpoint_attachment_generated_meta.yaml +++ b/google/services/integrationconnectors/resource_integration_connectors_endpoint_attachment_generated_meta.yaml @@ -22,3 +22,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/integrationconnectors/resource_integration_connectors_managed_zone.go b/google/services/integrationconnectors/resource_integration_connectors_managed_zone.go index 6657766092c..3a0969a7d5f 100644 --- a/google/services/integrationconnectors/resource_integration_connectors_managed_zone.go +++ b/google/services/integrationconnectors/resource_integration_connectors_managed_zone.go @@ -116,6 +116,7 @@ func ResourceIntegrationConnectorsManagedZone() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -203,6 +204,18 @@ Please refer to the field 'effective_labels' for all of the labels present on th Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -359,6 +372,19 @@ func resourceIntegrationConnectorsManagedZoneRead(d *schema.ResourceData, meta i log.Printf("[DEBUG] Finished reading IntegrationConnectorsManagedZone %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading ManagedZone: %s", err) } @@ -390,6 +416,19 @@ func resourceIntegrationConnectorsManagedZoneRead(d *schema.ResourceData, meta i } func resourceIntegrationConnectorsManagedZoneUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceIntegrationConnectorsManagedZone().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceIntegrationConnectorsManagedZoneRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -523,6 +562,13 @@ func resourceIntegrationConnectorsManagedZoneUpdate(d *schema.ResourceData, meta } func resourceIntegrationConnectorsManagedZoneDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy IntegrationConnectorsManagedZone without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ManagedZone %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/integrationconnectors/resource_integration_connectors_managed_zone_generated_meta.yaml b/google/services/integrationconnectors/resource_integration_connectors_managed_zone_generated_meta.yaml index 9d4323177de..030d333140b 100644 --- a/google/services/integrationconnectors/resource_integration_connectors_managed_zone_generated_meta.yaml +++ b/google/services/integrationconnectors/resource_integration_connectors_managed_zone_generated_meta.yaml @@ -20,3 +20,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/integrations/resource_integrations_auth_config.go b/google/services/integrations/resource_integrations_auth_config.go index a64f18deca9..5041dbc9adb 100644 --- a/google/services/integrations/resource_integrations_auth_config.go +++ b/google/services/integrations/resource_integrations_auth_config.go @@ -115,6 +115,7 @@ func ResourceIntegrationsAuthConfig() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -556,6 +557,18 @@ A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to n Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -744,6 +757,19 @@ func resourceIntegrationsAuthConfigRead(d *schema.ResourceData, meta interface{} log.Printf("[DEBUG] Finished reading IntegrationsAuthConfig %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading AuthConfig: %s", err) } @@ -775,6 +801,19 @@ func resourceIntegrationsAuthConfigRead(d *schema.ResourceData, meta interface{} } func resourceIntegrationsAuthConfigUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceIntegrationsAuthConfig().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceIntegrationsAuthConfigRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -910,6 +949,13 @@ func resourceIntegrationsAuthConfigUpdate(d *schema.ResourceData, meta interface } func resourceIntegrationsAuthConfigDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy IntegrationsAuthConfig without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing AuthConfig %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/integrations/resource_integrations_auth_config_generated_meta.yaml b/google/services/integrations/resource_integrations_auth_config_generated_meta.yaml index 8ae637ef7f2..617ea01aa3f 100644 --- a/google/services/integrations/resource_integrations_auth_config_generated_meta.yaml +++ b/google/services/integrations/resource_integrations_auth_config_generated_meta.yaml @@ -57,3 +57,5 @@ fields: - api_field: updateTime - api_field: validTime - api_field: visibility + - field: deletion_policy + provider_only: true diff --git a/google/services/integrations/resource_integrations_client.go b/google/services/integrations/resource_integrations_client.go index 1b1b6e21a32..b970d546166 100644 --- a/google/services/integrations/resource_integrations_client.go +++ b/google/services/integrations/resource_integrations_client.go @@ -100,6 +100,7 @@ func ResourceIntegrationsClient() *schema.Resource { return &schema.Resource{ Create: resourceIntegrationsClientCreate, Read: resourceIntegrationsClientRead, + Update: resourceIntegrationsClientUpdate, Delete: resourceIntegrationsClientDelete, Importer: &schema.ResourceImporter{ @@ -113,6 +114,7 @@ func ResourceIntegrationsClient() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -211,6 +213,18 @@ encrypted with GMEK.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -369,6 +383,19 @@ func resourceIntegrationsClientRead(d *schema.ResourceData, meta interface{}) er return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Client: %s", err) } @@ -399,7 +426,19 @@ func resourceIntegrationsClientRead(d *schema.ResourceData, meta interface{}) er return nil } +func resourceIntegrationsClientUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceIntegrationsClientRead(d, meta) +} + func resourceIntegrationsClientDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy IntegrationsClient without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Client %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/integrations/resource_integrations_client_generated_meta.yaml b/google/services/integrations/resource_integrations_client_generated_meta.yaml index 3d8370ae2cf..f3e18a6fa91 100644 --- a/google/services/integrations/resource_integrations_client_generated_meta.yaml +++ b/google/services/integrations/resource_integrations_client_generated_meta.yaml @@ -16,3 +16,5 @@ fields: - field: location provider_only: true - api_field: runAsServiceAccount + - field: deletion_policy + provider_only: true diff --git a/google/services/kms/resource_kms_autokey_config.go b/google/services/kms/resource_kms_autokey_config.go index daf725247ef..932b2112d80 100644 --- a/google/services/kms/resource_kms_autokey_config.go +++ b/google/services/kms/resource_kms_autokey_config.go @@ -159,6 +159,19 @@ CryptoKey for any new KeyHandle the Developer creates. Should have the form Computed: true, Description: `The etag of the AutokeyConfig for optimistic concurrency control.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -278,6 +291,20 @@ func resourceKMSAutokeyConfigRead(d *schema.ResourceData, meta interface{}) erro log.Printf("[DEBUG] Finished reading KMSAutokeyConfig %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceKMSAutokeyConfigFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -299,6 +326,19 @@ func resourceKMSAutokeyConfigRead(d *schema.ResourceData, meta interface{}) erro } func resourceKMSAutokeyConfigUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceKMSAutokeyConfig().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceKMSAutokeyConfigRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -368,6 +408,13 @@ func resourceKMSAutokeyConfigUpdate(d *schema.ResourceData, meta interface{}) er } func resourceKMSAutokeyConfigDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy KMSAutokeyConfig without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing AutokeyConfig %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/kms/resource_kms_autokey_config_generated_meta.yaml b/google/services/kms/resource_kms_autokey_config_generated_meta.yaml index 15619ca347a..3728ff55e4c 100644 --- a/google/services/kms/resource_kms_autokey_config_generated_meta.yaml +++ b/google/services/kms/resource_kms_autokey_config_generated_meta.yaml @@ -12,3 +12,5 @@ fields: provider_only: true - api_field: keyProject - api_field: keyProjectResolutionMode + - field: deletion_policy + provider_only: true diff --git a/google/services/kms/resource_kms_crypto_key.go b/google/services/kms/resource_kms_crypto_key.go index 8a88ba5f288..0fe6ded315c 100644 --- a/google/services/kms/resource_kms_crypto_key.go +++ b/google/services/kms/resource_kms_crypto_key.go @@ -124,6 +124,7 @@ func ResourceKMSCryptoKey() *schema.Resource { }, CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -277,6 +278,19 @@ Keys with purpose ENCRYPT_DECRYPT may have a primary. For other keys, this field and default labels configured on the provider.`, Elem: &schema.Schema{Type: schema.TypeString}, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -448,6 +462,20 @@ func resourceKMSCryptoKeyRead(d *schema.ResourceData, meta interface{}) error { return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceKMSCryptoKeyFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -475,6 +503,19 @@ func resourceKMSCryptoKeyRead(d *schema.ResourceData, meta interface{}) error { } func resourceKMSCryptoKeyUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceKMSCryptoKey().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceKMSCryptoKeyRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -584,6 +625,13 @@ func resourceKMSCryptoKeyUpdate(d *schema.ResourceData, meta interface{}) error } func resourceKMSCryptoKeyDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy KMSCryptoKey without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing CryptoKey %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/kms/resource_kms_crypto_key_generated_meta.yaml b/google/services/kms/resource_kms_crypto_key_generated_meta.yaml index 4b46f4f07cd..7e978b34c19 100644 --- a/google/services/kms/resource_kms_crypto_key_generated_meta.yaml +++ b/google/services/kms/resource_kms_crypto_key_generated_meta.yaml @@ -27,3 +27,5 @@ fields: provider_only: true - api_field: versionTemplate.algorithm - api_field: versionTemplate.protectionLevel + - field: deletion_policy + provider_only: true diff --git a/google/services/kms/resource_kms_crypto_key_version.go b/google/services/kms/resource_kms_crypto_key_version.go index bdc65c7bb5f..c42244b423c 100644 --- a/google/services/kms/resource_kms_crypto_key_version.go +++ b/google/services/kms/resource_kms_crypto_key_version.go @@ -259,6 +259,19 @@ Only provided for key versions with protectionLevel HSM.`, Computed: true, Description: `The ProtectionLevel describing how crypto operations are performed with this CryptoKeyVersion.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -376,6 +389,20 @@ func resourceKMSCryptoKeyVersionRead(d *schema.ResourceData, meta interface{}) e log.Printf("[DEBUG] Finished reading KMSCryptoKeyVersion %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceKMSCryptoKeyVersionFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -397,6 +424,19 @@ func resourceKMSCryptoKeyVersionRead(d *schema.ResourceData, meta interface{}) e } func resourceKMSCryptoKeyVersionUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceKMSCryptoKeyVersion().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceKMSCryptoKeyVersionRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -502,6 +542,13 @@ func resourceKMSCryptoKeyVersionUpdate(d *schema.ResourceData, meta interface{}) } func resourceKMSCryptoKeyVersionDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy KMSCryptoKeyVersion without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing CryptoKeyVersion %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/kms/resource_kms_crypto_key_version_generated_meta.yaml b/google/services/kms/resource_kms_crypto_key_version_generated_meta.yaml index 23356784c18..1ce72b92a5d 100644 --- a/google/services/kms/resource_kms_crypto_key_version_generated_meta.yaml +++ b/google/services/kms/resource_kms_crypto_key_version_generated_meta.yaml @@ -23,3 +23,5 @@ fields: - api_field: name - api_field: protectionLevel - api_field: state + - field: deletion_policy + provider_only: true diff --git a/google/services/kms/resource_kms_ekm_connection.go b/google/services/kms/resource_kms_ekm_connection.go index f208459ab0c..ac2bea5a8b4 100644 --- a/google/services/kms/resource_kms_ekm_connection.go +++ b/google/services/kms/resource_kms_ekm_connection.go @@ -459,6 +459,7 @@ func resourceKMSEkmConnectionRead(d *schema.ResourceData, meta interface{}) erro } func resourceKMSEkmConnectionUpdate(d *schema.ResourceData, meta interface{}) error { + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/kms/resource_kms_key_ring_import_job.go b/google/services/kms/resource_kms_key_ring_import_job.go index 5f1cc531739..2f2a0ec4e7c 100644 --- a/google/services/kms/resource_kms_key_ring_import_job.go +++ b/google/services/kms/resource_kms_key_ring_import_job.go @@ -100,6 +100,7 @@ func ResourceKMSKeyRingImportJob() *schema.Resource { return &schema.Resource{ Create: resourceKMSKeyRingImportJobCreate, Read: resourceKMSKeyRingImportJobRead, + Update: resourceKMSKeyRingImportJobUpdate, Delete: resourceKMSKeyRingImportJobDelete, Importer: &schema.ResourceImporter{ @@ -209,6 +210,19 @@ for General Considerations and Textual Encoding of Subject Public Key Info.`, Computed: true, Description: `The current state of the ImportJob, indicating if it can be used.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -326,6 +340,20 @@ func resourceKMSKeyRingImportJobRead(d *schema.ResourceData, meta interface{}) e log.Printf("[DEBUG] Finished reading KMSKeyRingImportJob %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceKMSKeyRingImportJobFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -346,7 +374,19 @@ func resourceKMSKeyRingImportJobRead(d *schema.ResourceData, meta interface{}) e return nil } +func resourceKMSKeyRingImportJobUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceKMSKeyRingImportJobRead(d, meta) +} + func resourceKMSKeyRingImportJobDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy KMSKeyRingImportJob without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing KeyRingImportJob %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/kms/resource_kms_key_ring_import_job_generated_meta.yaml b/google/services/kms/resource_kms_key_ring_import_job_generated_meta.yaml index e335c1804f3..83917720d85 100644 --- a/google/services/kms/resource_kms_key_ring_import_job_generated_meta.yaml +++ b/google/services/kms/resource_kms_key_ring_import_job_generated_meta.yaml @@ -21,3 +21,5 @@ fields: - api_field: protectionLevel - api_field: publicKey.pem - api_field: state + - field: deletion_policy + provider_only: true diff --git a/google/services/kms/resource_kms_project_autokey_config.go b/google/services/kms/resource_kms_project_autokey_config.go index b7c4f185c98..53ade6cd19f 100644 --- a/google/services/kms/resource_kms_project_autokey_config.go +++ b/google/services/kms/resource_kms_project_autokey_config.go @@ -115,6 +115,7 @@ func ResourceKMSProjectAutokeyConfig() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -150,6 +151,18 @@ func ResourceKMSProjectAutokeyConfig() *schema.Resource { Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -270,6 +283,19 @@ func resourceKMSProjectAutokeyConfigRead(d *schema.ResourceData, meta interface{ log.Printf("[DEBUG] Finished reading KMSProjectAutokeyConfig %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading ProjectAutokeyConfig: %s", err) } @@ -295,6 +321,19 @@ func resourceKMSProjectAutokeyConfigRead(d *schema.ResourceData, meta interface{ } func resourceKMSProjectAutokeyConfigUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceKMSProjectAutokeyConfig().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceKMSProjectAutokeyConfigRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -363,6 +402,13 @@ func resourceKMSProjectAutokeyConfigUpdate(d *schema.ResourceData, meta interfac } func resourceKMSProjectAutokeyConfigDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy KMSProjectAutokeyConfig without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ProjectAutokeyConfig %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/kms/resource_kms_project_autokey_config_generated_meta.yaml b/google/services/kms/resource_kms_project_autokey_config_generated_meta.yaml index 5fee24d5437..59410669667 100644 --- a/google/services/kms/resource_kms_project_autokey_config_generated_meta.yaml +++ b/google/services/kms/resource_kms_project_autokey_config_generated_meta.yaml @@ -9,3 +9,5 @@ api_resource_type_kind: ProjectAutokeyConfig fields: - api_field: etag - api_field: keyProjectResolutionMode + - field: deletion_policy + provider_only: true diff --git a/google/services/logging/resource_logging_billing_account_bucket_config_meta.yaml b/google/services/logging/resource_logging_billing_account_bucket_config_meta.yaml index 1211c1b1422..ea229ee0bc5 100644 --- a/google/services/logging/resource_logging_billing_account_bucket_config_meta.yaml +++ b/google/services/logging/resource_logging_billing_account_bucket_config_meta.yaml @@ -21,3 +21,6 @@ fields: - field: 'location' - api_field: 'name' - api_field: 'retentionDays' + - field: 'deletion_policy' + provider_only: true + \ No newline at end of file diff --git a/google/services/logging/resource_logging_billing_account_sink.go b/google/services/logging/resource_logging_billing_account_sink.go index 1f2461169d6..fa52cc04b0c 100644 --- a/google/services/logging/resource_logging_billing_account_sink.go +++ b/google/services/logging/resource_logging_billing_account_sink.go @@ -19,6 +19,7 @@ package logging import ( "fmt" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-provider-google/google/registry" "github.com/hashicorp/terraform-provider-google/google/tpgresource" @@ -35,6 +36,9 @@ func ResourceLoggingBillingAccountSink() *schema.Resource { Importer: &schema.ResourceImporter{ State: resourceLoggingSinkImportState("billing_account"), }, + CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), + ), UseJSONNumber: true, } schm.Schema["billing_account"] = &schema.Schema{ @@ -81,10 +85,19 @@ func resourceLoggingBillingAccountSinkRead(d *schema.ResourceData, meta interfac return err } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } func resourceLoggingBillingAccountSinkUpdate(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceLoggingBillingAccountSink) { + return ResourceLoggingBillingAccountSink().Read(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -104,6 +117,13 @@ func resourceLoggingBillingAccountSinkUpdate(d *schema.ResourceData, meta interf } func resourceLoggingBillingAccountSinkDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/logging/resource_logging_billing_account_sink_meta.yaml b/google/services/logging/resource_logging_billing_account_sink_meta.yaml index 99455776efa..11371d082d4 100644 --- a/google/services/logging/resource_logging_billing_account_sink_meta.yaml +++ b/google/services/logging/resource_logging_billing_account_sink_meta.yaml @@ -20,3 +20,5 @@ fields: - api_field: 'filter' - api_field: 'name' - api_field: 'writerIdentity' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/logging/resource_logging_bucket_config.go b/google/services/logging/resource_logging_bucket_config.go index be9fb24be29..3539af92291 100644 --- a/google/services/logging/resource_logging_bucket_config.go +++ b/google/services/logging/resource_logging_bucket_config.go @@ -128,6 +128,9 @@ For example: jsonPayload.request.status`, }, }, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end } type loggingBucketConfigIDFunc func(d *schema.ResourceData, config *transport_tpg.Config) (string, error) @@ -146,6 +149,7 @@ func ResourceLoggingBucketConfig(parentType string, parentSpecificSchema map[str Schema: tpgresource.MergeSchemas(loggingBucketConfigSchema, parentSpecificSchema), UseJSONNumber: true, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), tpgresource.DefaultProviderProject, ), } @@ -335,10 +339,29 @@ func resourceLoggingBucketConfigRead(d *schema.ResourceData, meta interface{}) e return fmt.Errorf("Error setting index_configs: %s", err) } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } func resourceLoggingBucketConfigUpdate(d *schema.ResourceData, meta interface{}) error { + + //due to non standard resource function, Universal Deletion Policy pre-update code is included here in entirety + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range loggingBucketConfigSchema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceLoggingBucketConfigRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -392,6 +415,13 @@ func resourceLoggingBucketConfigUpdate(d *schema.ResourceData, meta interface{}) } func resourceLoggingBucketConfigDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + name := d.Get("bucket_id") for _, restrictedName := range []string{"_Required", "_Default"} { if name == restrictedName { diff --git a/google/services/logging/resource_logging_folder_bucket_config_meta.yaml b/google/services/logging/resource_logging_folder_bucket_config_meta.yaml index d8d91d750d3..7c733f060ca 100644 --- a/google/services/logging/resource_logging_folder_bucket_config_meta.yaml +++ b/google/services/logging/resource_logging_folder_bucket_config_meta.yaml @@ -21,3 +21,5 @@ fields: - field: 'location' - api_field: 'name' - api_field: 'retentionDays' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/logging/resource_logging_folder_settings.go b/google/services/logging/resource_logging_folder_settings.go index 5d8c9e99fef..53f8de06bdc 100644 --- a/google/services/logging/resource_logging_folder_settings.go +++ b/google/services/logging/resource_logging_folder_settings.go @@ -306,6 +306,7 @@ func resourceLoggingFolderSettingsRead(d *schema.ResourceData, meta interface{}) } func resourceLoggingFolderSettingsUpdate(d *schema.ResourceData, meta interface{}) error { + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/logging/resource_logging_folder_sink.go b/google/services/logging/resource_logging_folder_sink.go index f48b89ed65a..a961c7a9fa5 100644 --- a/google/services/logging/resource_logging_folder_sink.go +++ b/google/services/logging/resource_logging_folder_sink.go @@ -20,6 +20,7 @@ import ( "fmt" "strings" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-provider-google/google/registry" "github.com/hashicorp/terraform-provider-google/google/services/resourcemanager" @@ -34,6 +35,9 @@ func ResourceLoggingFolderSink() *schema.Resource { Delete: resourceLoggingFolderSinkDelete, Update: resourceLoggingFolderSinkUpdate, Schema: resourceLoggingSinkSchema(), + CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), + ), Importer: &schema.ResourceImporter{ State: resourceLoggingSinkImportState("folder"), }, @@ -110,10 +114,19 @@ func resourceLoggingFolderSinkRead(d *schema.ResourceData, meta interface{}) err return fmt.Errorf("Error setting intercept_children: %s", err) } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } func resourceLoggingFolderSinkUpdate(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceLoggingFolderSink) { + return ResourceLoggingFolderSink().Read(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -133,6 +146,13 @@ func resourceLoggingFolderSinkUpdate(d *schema.ResourceData, meta interface{}) e } func resourceLoggingFolderSinkDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/logging/resource_logging_folder_sink_meta.yaml b/google/services/logging/resource_logging_folder_sink_meta.yaml index 2a4d670ceeb..7ae43082df9 100644 --- a/google/services/logging/resource_logging_folder_sink_meta.yaml +++ b/google/services/logging/resource_logging_folder_sink_meta.yaml @@ -22,3 +22,5 @@ fields: - api_field: 'interceptChildren' - api_field: 'name' - api_field: 'writerIdentity' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/logging/resource_logging_linked_dataset.go b/google/services/logging/resource_logging_linked_dataset.go index 400688f2ed5..0bb16e400f7 100644 --- a/google/services/logging/resource_logging_linked_dataset.go +++ b/google/services/logging/resource_logging_linked_dataset.go @@ -100,6 +100,7 @@ func ResourceLoggingLinkedDataset() *schema.Resource { return &schema.Resource{ Create: resourceLoggingLinkedDatasetCreate, Read: resourceLoggingLinkedDatasetRead, + Update: resourceLoggingLinkedDatasetUpdate, Delete: resourceLoggingLinkedDatasetDelete, Importer: &schema.ResourceImporter{ @@ -211,6 +212,19 @@ and "2014-10-02T15:01:23.045123456Z".`, Description: `The resource name of the linked dataset. The name can have up to 100 characters. A valid link id (at the end of the link name) must only have alphanumeric characters and underscores within it.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -346,6 +360,20 @@ func resourceLoggingLinkedDatasetRead(d *schema.ResourceData, meta interface{}) log.Printf("[DEBUG] Finished reading LoggingLinkedDataset %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceLoggingLinkedDatasetFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -384,7 +412,19 @@ func resourceLoggingLinkedDatasetRead(d *schema.ResourceData, meta interface{}) return nil } +func resourceLoggingLinkedDatasetUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceLoggingLinkedDatasetRead(d, meta) +} + func resourceLoggingLinkedDatasetDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy LoggingLinkedDataset without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing LinkedDataset %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/logging/resource_logging_linked_dataset_generated_meta.yaml b/google/services/logging/resource_logging_linked_dataset_generated_meta.yaml index 5f6477302ad..c20afd52af6 100644 --- a/google/services/logging/resource_logging_linked_dataset_generated_meta.yaml +++ b/google/services/logging/resource_logging_linked_dataset_generated_meta.yaml @@ -25,3 +25,5 @@ fields: - api_field: name - field: parent provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/logging/resource_logging_log_scope.go b/google/services/logging/resource_logging_log_scope.go index 547cc5e5aec..63e38bb2bd5 100644 --- a/google/services/logging/resource_logging_log_scope.go +++ b/google/services/logging/resource_logging_log_scope.go @@ -182,6 +182,19 @@ func ResourceLoggingLogScope() *schema.Resource { Computed: true, Description: `Output only. The last update timestamp of the log scopes.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -314,6 +327,20 @@ func resourceLoggingLogScopeRead(d *schema.ResourceData, meta interface{}) error log.Printf("[DEBUG] Finished reading LoggingLogScope %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceLoggingLogScopeFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -347,6 +374,19 @@ func resourceLoggingLogScopeRead(d *schema.ResourceData, meta interface{}) error } func resourceLoggingLogScopeUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceLoggingLogScope().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceLoggingLogScopeRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -447,6 +487,13 @@ func resourceLoggingLogScopeUpdate(d *schema.ResourceData, meta interface{}) err } func resourceLoggingLogScopeDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy LoggingLogScope without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing LogScope %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/logging/resource_logging_log_scope_generated_meta.yaml b/google/services/logging/resource_logging_log_scope_generated_meta.yaml index 7b3edea19bd..2befaa0a59e 100644 --- a/google/services/logging/resource_logging_log_scope_generated_meta.yaml +++ b/google/services/logging/resource_logging_log_scope_generated_meta.yaml @@ -16,3 +16,5 @@ fields: provider_only: true - api_field: resourceNames - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/logging/resource_logging_log_view.go b/google/services/logging/resource_logging_log_view.go index 6c2c838342d..9f74d082838 100644 --- a/google/services/logging/resource_logging_log_view.go +++ b/google/services/logging/resource_logging_log_view.go @@ -190,6 +190,19 @@ func ResourceLoggingLogView() *schema.Resource { Computed: true, Description: `Output only. The last update timestamp of the view.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -332,6 +345,20 @@ func resourceLoggingLogViewRead(d *schema.ResourceData, meta interface{}) error log.Printf("[DEBUG] Finished reading LoggingLogView %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceLoggingLogViewFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -371,6 +398,19 @@ func resourceLoggingLogViewRead(d *schema.ResourceData, meta interface{}) error } func resourceLoggingLogViewUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceLoggingLogView().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceLoggingLogViewRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -476,6 +516,13 @@ func resourceLoggingLogViewUpdate(d *schema.ResourceData, meta interface{}) erro } func resourceLoggingLogViewDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy LoggingLogView without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing LogView %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/logging/resource_logging_log_view_generated_meta.yaml b/google/services/logging/resource_logging_log_view_generated_meta.yaml index 6e9056859c0..c032eea8c8e 100644 --- a/google/services/logging/resource_logging_log_view_generated_meta.yaml +++ b/google/services/logging/resource_logging_log_view_generated_meta.yaml @@ -23,3 +23,5 @@ fields: - field: parent provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/logging/resource_logging_metric.go b/google/services/logging/resource_logging_metric.go index 99dd6b4343c..e84d00434b0 100644 --- a/google/services/logging/resource_logging_metric.go +++ b/google/services/logging/resource_logging_metric.go @@ -115,6 +115,7 @@ func ResourceLoggingMetric() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -334,6 +335,18 @@ error to specify a regex that does not include exactly one capture group.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -537,6 +550,19 @@ func resourceLoggingMetricRead(d *schema.ResourceData, meta interface{}) error { log.Printf("[DEBUG] Finished reading LoggingMetric %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Metric: %s", err) } @@ -568,6 +594,19 @@ func resourceLoggingMetricRead(d *schema.ResourceData, meta interface{}) error { } func resourceLoggingMetricUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceLoggingMetric().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceLoggingMetricRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -694,6 +733,13 @@ func resourceLoggingMetricUpdate(d *schema.ResourceData, meta interface{}) error } func resourceLoggingMetricDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy LoggingMetric without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Metric %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/logging/resource_logging_metric_generated_meta.yaml b/google/services/logging/resource_logging_metric_generated_meta.yaml index efb046f5063..83e22f36da7 100644 --- a/google/services/logging/resource_logging_metric_generated_meta.yaml +++ b/google/services/logging/resource_logging_metric_generated_meta.yaml @@ -30,3 +30,5 @@ fields: - api_field: metricDescriptor.valueType - api_field: name - api_field: valueExtractor + - field: deletion_policy + provider_only: true diff --git a/google/services/logging/resource_logging_organization_bucket_config_meta.yaml b/google/services/logging/resource_logging_organization_bucket_config_meta.yaml index 8667dde986e..97e15038147 100644 --- a/google/services/logging/resource_logging_organization_bucket_config_meta.yaml +++ b/google/services/logging/resource_logging_organization_bucket_config_meta.yaml @@ -21,3 +21,5 @@ fields: - api_field: 'name' - field: 'organization' - api_field: 'retentionDays' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/logging/resource_logging_organization_settings.go b/google/services/logging/resource_logging_organization_settings.go index 7a179dce4ff..aa2af8fb7a7 100644 --- a/google/services/logging/resource_logging_organization_settings.go +++ b/google/services/logging/resource_logging_organization_settings.go @@ -306,6 +306,7 @@ func resourceLoggingOrganizationSettingsRead(d *schema.ResourceData, meta interf } func resourceLoggingOrganizationSettingsUpdate(d *schema.ResourceData, meta interface{}) error { + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/logging/resource_logging_organization_sink.go b/google/services/logging/resource_logging_organization_sink.go index fc8190ec84f..c868be6c86d 100644 --- a/google/services/logging/resource_logging_organization_sink.go +++ b/google/services/logging/resource_logging_organization_sink.go @@ -20,6 +20,7 @@ import ( "fmt" "strings" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-provider-google/google/registry" "github.com/hashicorp/terraform-provider-google/google/tpgresource" @@ -33,6 +34,9 @@ func ResourceLoggingOrganizationSink() *schema.Resource { Delete: resourceLoggingOrganizationSinkDelete, Update: resourceLoggingOrganizationSinkUpdate, Schema: resourceLoggingSinkSchema(), + CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), + ), Importer: &schema.ResourceImporter{ State: resourceLoggingSinkImportState("org_id"), }, @@ -109,10 +113,19 @@ func resourceLoggingOrganizationSinkRead(d *schema.ResourceData, meta interface{ return fmt.Errorf("Error setting intercept_children: %s", err) } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } func resourceLoggingOrganizationSinkUpdate(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceLoggingOrganizationSink) { + return ResourceLoggingOrganizationSink().Read(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -132,6 +145,13 @@ func resourceLoggingOrganizationSinkUpdate(d *schema.ResourceData, meta interfac } func resourceLoggingOrganizationSinkDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/logging/resource_logging_organization_sink_meta.yaml b/google/services/logging/resource_logging_organization_sink_meta.yaml index c751e7ccf9d..635287352af 100644 --- a/google/services/logging/resource_logging_organization_sink_meta.yaml +++ b/google/services/logging/resource_logging_organization_sink_meta.yaml @@ -22,3 +22,5 @@ fields: - api_field: 'name' - field: 'org_id' - api_field: 'writerIdentity' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/logging/resource_logging_project_bucket_config.go b/google/services/logging/resource_logging_project_bucket_config.go index a0a14513d29..e902fc6b008 100644 --- a/google/services/logging/resource_logging_project_bucket_config.go +++ b/google/services/logging/resource_logging_project_bucket_config.go @@ -145,6 +145,9 @@ For example: jsonPayload.request.status`, }, }, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end } func projectBucketConfigID(d *schema.ResourceData, config *transport_tpg.Config) (string, error) { diff --git a/google/services/logging/resource_logging_project_bucket_config_meta.yaml b/google/services/logging/resource_logging_project_bucket_config_meta.yaml index 982aef8e507..7403d543e2c 100644 --- a/google/services/logging/resource_logging_project_bucket_config_meta.yaml +++ b/google/services/logging/resource_logging_project_bucket_config_meta.yaml @@ -23,3 +23,6 @@ fields: - api_field: 'name' - field: 'project' - api_field: 'retentionDays' + - field: 'deletion_policy' + provider_only: true + \ No newline at end of file diff --git a/google/services/logging/resource_logging_project_sink.go b/google/services/logging/resource_logging_project_sink.go index 34af2f96ba1..50dd96b4800 100644 --- a/google/services/logging/resource_logging_project_sink.go +++ b/google/services/logging/resource_logging_project_sink.go @@ -26,6 +26,7 @@ import ( "github.com/hashicorp/terraform-provider-google/google/tpgresource" transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -33,12 +34,15 @@ const nonUniqueWriterAccount = "serviceAccount:cloud-logs@system.gserviceaccount func ResourceLoggingProjectSink() *schema.Resource { schm := &schema.Resource{ - Create: resourceLoggingProjectSinkAcquireOrCreate, - Read: resourceLoggingProjectSinkRead, - Delete: resourceLoggingProjectSinkDelete, - Update: resourceLoggingProjectSinkUpdate, - Schema: resourceLoggingSinkSchema(), - CustomizeDiff: resourceLoggingProjectSinkCustomizeDiff, + Create: resourceLoggingProjectSinkAcquireOrCreate, + Read: resourceLoggingProjectSinkRead, + Delete: resourceLoggingProjectSinkDelete, + Update: resourceLoggingProjectSinkUpdate, + Schema: resourceLoggingSinkSchema(), + CustomizeDiff: customdiff.All( + resourceLoggingProjectSinkCustomizeDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), + ), Importer: &schema.ResourceImporter{ State: resourceLoggingSinkImportState("project"), }, @@ -187,10 +191,20 @@ func resourceLoggingProjectSinkRead(d *schema.ResourceData, meta interface{}) er return fmt.Errorf("Error setting unique_writer_identity: %s", err) } } + + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } func resourceLoggingProjectSinkUpdate(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceLoggingProjectSink) { + return ResourceLoggingProjectSink().Read(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -221,6 +235,13 @@ func resourceLoggingProjectSinkUpdate(d *schema.ResourceData, meta interface{}) } func resourceLoggingProjectSinkDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + name := d.Get("name") for _, restrictedName := range []string{"_Required", "_Default"} { if name == restrictedName { diff --git a/google/services/logging/resource_logging_project_sink_meta.yaml b/google/services/logging/resource_logging_project_sink_meta.yaml index 39a4e687f97..6ce97512beb 100644 --- a/google/services/logging/resource_logging_project_sink_meta.yaml +++ b/google/services/logging/resource_logging_project_sink_meta.yaml @@ -22,3 +22,5 @@ fields: - field: 'project' - field: 'unique_writer_identity' - api_field: 'writerIdentity' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/logging/resource_logging_saved_query.go b/google/services/logging/resource_logging_saved_query.go index bedc26a6291..c922c662f4f 100644 --- a/google/services/logging/resource_logging_saved_query.go +++ b/google/services/logging/resource_logging_saved_query.go @@ -241,6 +241,19 @@ is used to match log entries.`, Computed: true, Description: `Output only. The last update timestamp of the saved query.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -380,6 +393,20 @@ func resourceLoggingSavedQueryRead(d *schema.ResourceData, meta interface{}) err log.Printf("[DEBUG] Finished reading LoggingSavedQuery %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceLoggingSavedQueryFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -413,6 +440,19 @@ func resourceLoggingSavedQueryRead(d *schema.ResourceData, meta interface{}) err } func resourceLoggingSavedQueryUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceLoggingSavedQuery().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceLoggingSavedQueryRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -538,6 +578,13 @@ func resourceLoggingSavedQueryUpdate(d *schema.ResourceData, meta interface{}) e } func resourceLoggingSavedQueryDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy LoggingSavedQuery without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing SavedQuery %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/logging/resource_logging_saved_query_generated_meta.yaml b/google/services/logging/resource_logging_saved_query_generated_meta.yaml index b1077d9f619..5d3260c4f36 100644 --- a/google/services/logging/resource_logging_saved_query_generated_meta.yaml +++ b/google/services/logging/resource_logging_saved_query_generated_meta.yaml @@ -28,3 +28,5 @@ fields: provider_only: true - api_field: updateTime - api_field: visibility + - field: deletion_policy + provider_only: true diff --git a/google/services/logging/resource_logging_sink.go b/google/services/logging/resource_logging_sink.go index 98a2077f307..a92cf9f8b8e 100644 --- a/google/services/logging/resource_logging_sink.go +++ b/google/services/logging/resource_logging_sink.go @@ -20,6 +20,8 @@ import ( "fmt" "strings" + "github.com/hashicorp/terraform-provider-google/google/tpgresource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "google.golang.org/api/logging/v2" ) @@ -116,6 +118,10 @@ func resourceLoggingSinkSchema() map[string]*schema.Schema { }, }, }, + + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end } } diff --git a/google/services/looker/resource_looker_instance.go b/google/services/looker/resource_looker_instance.go index 6c267783a38..e38ace5edfc 100644 --- a/google/services/looker/resource_looker_instance.go +++ b/google/services/looker/resource_looker_instance.go @@ -115,6 +115,7 @@ func ResourceLookerInstance() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DEFAULT"), ), Identity: &schema.ResourceIdentity{ @@ -679,21 +680,18 @@ accurate to nanoseconds.`, Description: `The time the instance was updated in RFC3339 UTC "Zulu" format, accurate to nanoseconds.`, }, - "deletion_policy": { - Type: schema.TypeString, - Optional: true, - Description: `Policy to determine if the cluster should be deleted forcefully. -If setting deletion_policy = "FORCE", the Looker instance will be deleted regardless -of its nested resources. If set to "DEFAULT", Looker instances that still have -nested resources will return an error. Possible values: DEFAULT, FORCE`, - Default: "DEFAULT", - }, "project": { Type: schema.TypeString, Optional: true, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `This field uses a custom implementation please refer to documentation under /hashicorp/terraform-provider-google-beta/website/docs/r/looker_instance.html.markdown for specifics`, + }, }, UseJSONNumber: true, } @@ -943,8 +941,15 @@ func resourceLookerInstanceRead(d *schema.ResourceData, meta interface{}) error // Explicitly set virtual fields to default values if unset if _, ok := d.GetOkExists("deletion_policy"); !ok { - if err := d.Set("deletion_policy", "DEFAULT"); err != nil { - return fmt.Errorf("Error setting deletion_policy: %s", err) + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DEFAULT"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } } } if err := d.Set("project", project); err != nil { @@ -984,6 +989,19 @@ func resourceLookerInstanceRead(d *schema.ResourceData, meta interface{}) error } func resourceLookerInstanceUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceLookerInstance().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceLookerInstanceRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1255,6 +1273,13 @@ func resourceLookerInstanceUpdate(d *schema.ResourceData, meta interface{}) erro } func resourceLookerInstanceDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy LookerInstance without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Instance %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1333,9 +1358,6 @@ func resourceLookerInstanceImport(d *schema.ResourceData, meta interface{}) ([]* d.SetId(id) // Explicitly set virtual fields to default values on import - if err := d.Set("deletion_policy", "DEFAULT"); err != nil { - return nil, fmt.Errorf("Error setting deletion_policy: %s", err) - } return []*schema.ResourceData{d}, nil } diff --git a/google/services/looker/resource_looker_instance_generated_meta.yaml b/google/services/looker/resource_looker_instance_generated_meta.yaml index d9592572511..2da5bcb692b 100644 --- a/google/services/looker/resource_looker_instance_generated_meta.yaml +++ b/google/services/looker/resource_looker_instance_generated_meta.yaml @@ -15,8 +15,6 @@ fields: - api_field: createTime - api_field: customDomain.domain - api_field: customDomain.state - - field: deletion_policy - provider_only: true - api_field: denyMaintenancePeriod.endDate.day - api_field: denyMaintenancePeriod.endDate.month - api_field: denyMaintenancePeriod.endDate.year @@ -68,3 +66,5 @@ fields: - api_field: userMetadata.additionalDeveloperUserCount - api_field: userMetadata.additionalStandardUserCount - api_field: userMetadata.additionalViewerUserCount + - field: deletion_policy + provider_only: true diff --git a/google/services/lustre/resource_lustre_instance.go b/google/services/lustre/resource_lustre_instance.go index 64c893f8980..57de0f7b3d1 100644 --- a/google/services/lustre/resource_lustre_instance.go +++ b/google/services/lustre/resource_lustre_instance.go @@ -116,6 +116,7 @@ func ResourceLustreInstance() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -628,6 +629,18 @@ squash uid.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -831,6 +844,19 @@ func resourceLustreInstanceRead(d *schema.ResourceData, meta interface{}) error log.Printf("[DEBUG] Finished reading LustreInstance %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Instance: %s", err) } @@ -868,6 +894,19 @@ func resourceLustreInstanceRead(d *schema.ResourceData, meta interface{}) error } func resourceLustreInstanceUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceLustreInstance().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceLustreInstanceRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1026,6 +1065,13 @@ func resourceLustreInstanceUpdate(d *schema.ResourceData, meta interface{}) erro } func resourceLustreInstanceDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy LustreInstance without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Instance %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/lustre/resource_lustre_instance_generated_meta.yaml b/google/services/lustre/resource_lustre_instance_generated_meta.yaml index 3f49b3267c5..f98edab761b 100644 --- a/google/services/lustre/resource_lustre_instance_generated_meta.yaml +++ b/google/services/lustre/resource_lustre_instance_generated_meta.yaml @@ -56,3 +56,5 @@ fields: - api_field: upcomingMaintenanceSchedule.endTime - api_field: upcomingMaintenanceSchedule.startTime - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/managedkafka/resource_managed_kafka_acl.go b/google/services/managedkafka/resource_managed_kafka_acl.go index d1afa2029f7..d3a2a7dd691 100644 --- a/google/services/managedkafka/resource_managed_kafka_acl.go +++ b/google/services/managedkafka/resource_managed_kafka_acl.go @@ -115,6 +115,7 @@ func ResourceManagedKafkaAcl() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -211,6 +212,18 @@ truncated due to repeated field limits.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -386,6 +399,19 @@ func resourceManagedKafkaAclRead(d *schema.ResourceData, meta interface{}) error log.Printf("[DEBUG] Finished reading ManagedKafkaAcl %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Acl: %s", err) } @@ -429,6 +455,19 @@ func resourceManagedKafkaAclRead(d *schema.ResourceData, meta interface{}) error } func resourceManagedKafkaAclUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceManagedKafkaAcl().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceManagedKafkaAclRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -539,6 +578,13 @@ func resourceManagedKafkaAclUpdate(d *schema.ResourceData, meta interface{}) err } func resourceManagedKafkaAclDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ManagedKafkaAcl without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Acl %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/managedkafka/resource_managed_kafka_acl_generated_meta.yaml b/google/services/managedkafka/resource_managed_kafka_acl_generated_meta.yaml index bc8c4e4c7b3..145a839327e 100644 --- a/google/services/managedkafka/resource_managed_kafka_acl_generated_meta.yaml +++ b/google/services/managedkafka/resource_managed_kafka_acl_generated_meta.yaml @@ -22,3 +22,5 @@ fields: - api_field: patternType - api_field: resourceName - api_field: resourceType + - field: deletion_policy + provider_only: true diff --git a/google/services/managedkafka/resource_managed_kafka_cluster.go b/google/services/managedkafka/resource_managed_kafka_cluster.go index 80cca6d5aa9..8dab8206c58 100644 --- a/google/services/managedkafka/resource_managed_kafka_cluster.go +++ b/google/services/managedkafka/resource_managed_kafka_cluster.go @@ -116,6 +116,7 @@ func ResourceManagedKafkaCluster() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -335,6 +336,18 @@ Please refer to the field 'effective_labels' for all of the labels present on th Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -502,6 +515,19 @@ func resourceManagedKafkaClusterRead(d *schema.ResourceData, meta interface{}) e log.Printf("[DEBUG] Finished reading ManagedKafkaCluster %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Cluster: %s", err) } @@ -539,6 +565,19 @@ func resourceManagedKafkaClusterRead(d *schema.ResourceData, meta interface{}) e } func resourceManagedKafkaClusterUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceManagedKafkaCluster().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceManagedKafkaClusterRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -687,6 +726,13 @@ func resourceManagedKafkaClusterUpdate(d *schema.ResourceData, meta interface{}) } func resourceManagedKafkaClusterDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ManagedKafkaCluster without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Cluster %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/managedkafka/resource_managed_kafka_cluster_generated_meta.yaml b/google/services/managedkafka/resource_managed_kafka_cluster_generated_meta.yaml index c0af10e393b..8d0ff473187 100644 --- a/google/services/managedkafka/resource_managed_kafka_cluster_generated_meta.yaml +++ b/google/services/managedkafka/resource_managed_kafka_cluster_generated_meta.yaml @@ -29,3 +29,5 @@ fields: - api_field: tlsConfig.sslPrincipalMappingRules - api_field: tlsConfig.trustConfig.casConfigs.caPool - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/managedkafka/resource_managed_kafka_connect_cluster.go b/google/services/managedkafka/resource_managed_kafka_connect_cluster.go index 6068779a78c..5ebbaf91c59 100644 --- a/google/services/managedkafka/resource_managed_kafka_connect_cluster.go +++ b/google/services/managedkafka/resource_managed_kafka_connect_cluster.go @@ -116,6 +116,7 @@ func ResourceManagedKafkaConnectCluster() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -279,6 +280,18 @@ Please refer to the field 'effective_labels' for all of the labels present on th Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -434,6 +447,19 @@ func resourceManagedKafkaConnectClusterRead(d *schema.ResourceData, meta interfa log.Printf("[DEBUG] Finished reading ManagedKafkaConnectCluster %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading ConnectCluster: %s", err) } @@ -471,6 +497,19 @@ func resourceManagedKafkaConnectClusterRead(d *schema.ResourceData, meta interfa } func resourceManagedKafkaConnectClusterUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceManagedKafkaConnectCluster().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceManagedKafkaConnectClusterRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -599,6 +638,13 @@ func resourceManagedKafkaConnectClusterUpdate(d *schema.ResourceData, meta inter } func resourceManagedKafkaConnectClusterDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ManagedKafkaConnectCluster without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ConnectCluster %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/managedkafka/resource_managed_kafka_connect_cluster_generated_meta.yaml b/google/services/managedkafka/resource_managed_kafka_connect_cluster_generated_meta.yaml index 362e6aa3baa..1044bc2f11d 100644 --- a/google/services/managedkafka/resource_managed_kafka_connect_cluster_generated_meta.yaml +++ b/google/services/managedkafka/resource_managed_kafka_connect_cluster_generated_meta.yaml @@ -26,3 +26,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/managedkafka/resource_managed_kafka_connector.go b/google/services/managedkafka/resource_managed_kafka_connector.go index e6d9729a2c0..259ca7849cc 100644 --- a/google/services/managedkafka/resource_managed_kafka_connector.go +++ b/google/services/managedkafka/resource_managed_kafka_connector.go @@ -115,6 +115,7 @@ func ResourceManagedKafkaConnector() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -207,6 +208,18 @@ A duration in seconds with up to nine fractional digits, terminated by 's'. Exam Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -345,6 +358,19 @@ func resourceManagedKafkaConnectorRead(d *schema.ResourceData, meta interface{}) log.Printf("[DEBUG] Finished reading ManagedKafkaConnector %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Connector: %s", err) } @@ -388,6 +414,19 @@ func resourceManagedKafkaConnectorRead(d *schema.ResourceData, meta interface{}) } func resourceManagedKafkaConnectorUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceManagedKafkaConnector().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceManagedKafkaConnectorRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -494,6 +533,13 @@ func resourceManagedKafkaConnectorUpdate(d *schema.ResourceData, meta interface{ } func resourceManagedKafkaConnectorDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ManagedKafkaConnector without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Connector %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/managedkafka/resource_managed_kafka_connector_generated_meta.yaml b/google/services/managedkafka/resource_managed_kafka_connector_generated_meta.yaml index 3dabfc54b27..c44c7eb5f17 100644 --- a/google/services/managedkafka/resource_managed_kafka_connector_generated_meta.yaml +++ b/google/services/managedkafka/resource_managed_kafka_connector_generated_meta.yaml @@ -18,3 +18,5 @@ fields: - api_field: state - api_field: taskRestartPolicy.maximumBackoff - api_field: taskRestartPolicy.minimumBackoff + - field: deletion_policy + provider_only: true diff --git a/google/services/managedkafka/resource_managed_kafka_topic.go b/google/services/managedkafka/resource_managed_kafka_topic.go index 9688774d9da..42ee35fd2c7 100644 --- a/google/services/managedkafka/resource_managed_kafka_topic.go +++ b/google/services/managedkafka/resource_managed_kafka_topic.go @@ -115,6 +115,7 @@ func ResourceManagedKafkaTopic() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -191,6 +192,18 @@ func ResourceManagedKafkaTopic() *schema.Resource { Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -340,6 +353,19 @@ func resourceManagedKafkaTopicRead(d *schema.ResourceData, meta interface{}) err log.Printf("[DEBUG] Finished reading ManagedKafkaTopic %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Topic: %s", err) } @@ -383,6 +409,19 @@ func resourceManagedKafkaTopicRead(d *schema.ResourceData, meta interface{}) err } func resourceManagedKafkaTopicUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceManagedKafkaTopic().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceManagedKafkaTopicRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -493,6 +532,13 @@ func resourceManagedKafkaTopicUpdate(d *schema.ResourceData, meta interface{}) e } func resourceManagedKafkaTopicDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ManagedKafkaTopic without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Topic %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/managedkafka/resource_managed_kafka_topic_generated_meta.yaml b/google/services/managedkafka/resource_managed_kafka_topic_generated_meta.yaml index 45d8ba917cc..7f7dbc8dbc2 100644 --- a/google/services/managedkafka/resource_managed_kafka_topic_generated_meta.yaml +++ b/google/services/managedkafka/resource_managed_kafka_topic_generated_meta.yaml @@ -18,3 +18,5 @@ fields: - api_field: replicationFactor - field: topic_id provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/memcache/resource_memcache_instance.go b/google/services/memcache/resource_memcache_instance.go index 165ea1b949e..9839db95f6b 100644 --- a/google/services/memcache/resource_memcache_instance.go +++ b/google/services/memcache/resource_memcache_instance.go @@ -116,6 +116,7 @@ func ResourceMemcacheInstance() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -468,6 +469,18 @@ When the field is set to false, deleting the instance is allowed.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -660,6 +673,18 @@ func resourceMemcacheInstanceRead(d *schema.ResourceData, meta interface{}) erro log.Printf("[DEBUG] Finished reading MemcacheInstance %q: %#v", d.Id(), res) // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Instance: %s", err) } @@ -697,6 +722,19 @@ func resourceMemcacheInstanceRead(d *schema.ResourceData, meta interface{}) erro } func resourceMemcacheInstanceUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceMemcacheInstance().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceMemcacheInstanceRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -874,6 +912,13 @@ func resourceMemcacheInstanceUpdate(d *schema.ResourceData, meta interface{}) er } func resourceMemcacheInstanceDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy MemcacheInstance without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Instance %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/memcache/resource_memcache_instance_generated_meta.yaml b/google/services/memcache/resource_memcache_instance_generated_meta.yaml index b4dd94a78ed..9fe91345ec8 100644 --- a/google/services/memcache/resource_memcache_instance_generated_meta.yaml +++ b/google/services/memcache/resource_memcache_instance_generated_meta.yaml @@ -50,3 +50,5 @@ fields: - field: terraform_labels provider_only: true - api_field: zones + - field: deletion_policy + provider_only: true diff --git a/google/services/memorystore/resource_memorystore_instance.go b/google/services/memorystore/resource_memorystore_instance.go index 279386f6f53..ea6926a60ab 100644 --- a/google/services/memorystore/resource_memorystore_instance.go +++ b/google/services/memorystore/resource_memorystore_instance.go @@ -130,6 +130,7 @@ func ResourceMemorystoreInstance() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -1096,6 +1097,18 @@ projects/{project_id}/global/networks/{network_id}.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -1371,6 +1384,18 @@ func resourceMemorystoreInstanceRead(d *schema.ResourceData, meta interface{}) e } // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Instance: %s", err) } @@ -1408,6 +1433,19 @@ func resourceMemorystoreInstanceRead(d *schema.ResourceData, meta interface{}) e } func resourceMemorystoreInstanceUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceMemorystoreInstance().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceMemorystoreInstanceRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1621,6 +1659,13 @@ func resourceMemorystoreInstanceUpdate(d *schema.ResourceData, meta interface{}) } func resourceMemorystoreInstanceDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy MemorystoreInstance without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Instance %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/memorystore/resource_memorystore_instance_desired_user_created_endpoints.go b/google/services/memorystore/resource_memorystore_instance_desired_user_created_endpoints.go index 336fb018d7a..f37f30b553b 100644 --- a/google/services/memorystore/resource_memorystore_instance_desired_user_created_endpoints.go +++ b/google/services/memorystore/resource_memorystore_instance_desired_user_created_endpoints.go @@ -115,6 +115,7 @@ func ResourceMemorystoreInstanceDesiredUserCreatedEndpoints() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -238,6 +239,18 @@ service attachment.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -375,6 +388,19 @@ func resourceMemorystoreInstanceDesiredUserCreatedEndpointsRead(d *schema.Resour log.Printf("[DEBUG] Finished reading MemorystoreInstanceDesiredUserCreatedEndpoints %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading InstanceDesiredUserCreatedEndpoints: %s", err) } @@ -412,6 +438,19 @@ func resourceMemorystoreInstanceDesiredUserCreatedEndpointsRead(d *schema.Resour } func resourceMemorystoreInstanceDesiredUserCreatedEndpointsUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceMemorystoreInstanceDesiredUserCreatedEndpoints().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceMemorystoreInstanceDesiredUserCreatedEndpointsRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -510,6 +549,13 @@ func resourceMemorystoreInstanceDesiredUserCreatedEndpointsUpdate(d *schema.Reso } func resourceMemorystoreInstanceDesiredUserCreatedEndpointsDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy MemorystoreInstanceDesiredUserCreatedEndpoints without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing InstanceDesiredUserCreatedEndpoints %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/memorystore/resource_memorystore_instance_desired_user_created_endpoints_generated_meta.yaml b/google/services/memorystore/resource_memorystore_instance_desired_user_created_endpoints_generated_meta.yaml index fe764d88e49..61a621ae39e 100644 --- a/google/services/memorystore/resource_memorystore_instance_desired_user_created_endpoints_generated_meta.yaml +++ b/google/services/memorystore/resource_memorystore_instance_desired_user_created_endpoints_generated_meta.yaml @@ -27,3 +27,5 @@ fields: provider_only: true - field: region provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/memorystore/resource_memorystore_instance_generated_meta.yaml b/google/services/memorystore/resource_memorystore_instance_generated_meta.yaml index 72fb9195b0b..2dbc4ea1565 100644 --- a/google/services/memorystore/resource_memorystore_instance_generated_meta.yaml +++ b/google/services/memorystore/resource_memorystore_instance_generated_meta.yaml @@ -105,3 +105,5 @@ fields: - api_field: updateTime - api_field: zoneDistributionConfig.mode - api_field: zoneDistributionConfig.zone + - field: deletion_policy + provider_only: true diff --git a/google/services/migrationcenter/resource_migration_center_group.go b/google/services/migrationcenter/resource_migration_center_group.go index dcd9317268d..b1d06604074 100644 --- a/google/services/migrationcenter/resource_migration_center_group.go +++ b/google/services/migrationcenter/resource_migration_center_group.go @@ -116,6 +116,7 @@ func ResourceMigrationCenterGroup() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -207,6 +208,18 @@ Please refer to the field 'effective_labels' for all of the labels present on th Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -356,6 +369,19 @@ func resourceMigrationCenterGroupRead(d *schema.ResourceData, meta interface{}) log.Printf("[DEBUG] Finished reading MigrationCenterGroup %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Group: %s", err) } @@ -393,6 +419,19 @@ func resourceMigrationCenterGroupRead(d *schema.ResourceData, meta interface{}) } func resourceMigrationCenterGroupUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceMigrationCenterGroup().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceMigrationCenterGroupRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -511,6 +550,13 @@ func resourceMigrationCenterGroupUpdate(d *schema.ResourceData, meta interface{} } func resourceMigrationCenterGroupDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy MigrationCenterGroup without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Group %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/migrationcenter/resource_migration_center_group_generated_meta.yaml b/google/services/migrationcenter/resource_migration_center_group_generated_meta.yaml index 0e0d1d7c976..d4b3303743e 100644 --- a/google/services/migrationcenter/resource_migration_center_group_generated_meta.yaml +++ b/google/services/migrationcenter/resource_migration_center_group_generated_meta.yaml @@ -22,3 +22,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/migrationcenter/resource_migration_center_preference_set.go b/google/services/migrationcenter/resource_migration_center_preference_set.go index 3da2af017e6..11cfc096d84 100644 --- a/google/services/migrationcenter/resource_migration_center_preference_set.go +++ b/google/services/migrationcenter/resource_migration_center_preference_set.go @@ -115,6 +115,7 @@ func ResourceMigrationCenterPreferenceSet() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -341,6 +342,18 @@ func ResourceMigrationCenterPreferenceSet() *schema.Resource { Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -490,6 +503,19 @@ func resourceMigrationCenterPreferenceSetRead(d *schema.ResourceData, meta inter log.Printf("[DEBUG] Finished reading MigrationCenterPreferenceSet %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading PreferenceSet: %s", err) } @@ -527,6 +553,19 @@ func resourceMigrationCenterPreferenceSetRead(d *schema.ResourceData, meta inter } func resourceMigrationCenterPreferenceSetUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceMigrationCenterPreferenceSet().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceMigrationCenterPreferenceSetRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -645,6 +684,13 @@ func resourceMigrationCenterPreferenceSetUpdate(d *schema.ResourceData, meta int } func resourceMigrationCenterPreferenceSetDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy MigrationCenterPreferenceSet without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing PreferenceSet %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/migrationcenter/resource_migration_center_preference_set_generated_meta.yaml b/google/services/migrationcenter/resource_migration_center_preference_set_generated_meta.yaml index 630fb96114f..51abf1c9528 100644 --- a/google/services/migrationcenter/resource_migration_center_preference_set_generated_meta.yaml +++ b/google/services/migrationcenter/resource_migration_center_preference_set_generated_meta.yaml @@ -32,3 +32,5 @@ fields: - api_field: virtualMachinePreferences.vmwareEnginePreferences.cpuOvercommitRatio - api_field: virtualMachinePreferences.vmwareEnginePreferences.memoryOvercommitRatio - api_field: virtualMachinePreferences.vmwareEnginePreferences.storageDeduplicationCompressionRatio + - field: deletion_policy + provider_only: true diff --git a/google/services/mlengine/resource_ml_engine_model.go b/google/services/mlengine/resource_ml_engine_model.go index bd208a4f82e..a340c7dab5d 100644 --- a/google/services/mlengine/resource_ml_engine_model.go +++ b/google/services/mlengine/resource_ml_engine_model.go @@ -125,6 +125,7 @@ func ResourceMLEngineModel() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), DeprecationMessage: "This resource is deprecated at the API level and will be removed in a future version of Terraform.", @@ -231,6 +232,18 @@ Currently only one region per model is supported`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -389,6 +402,19 @@ func resourceMLEngineModelRead(d *schema.ResourceData, meta interface{}) error { log.Printf("[DEBUG] Finished reading MLEngineModel %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Model: %s", err) } @@ -420,11 +446,18 @@ func resourceMLEngineModelRead(d *schema.ResourceData, meta interface{}) error { } func resourceMLEngineModelUpdate(d *schema.ResourceData, meta interface{}) error { - // Only the root field "labels", "terraform_labels", and virtual fields are mutable + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable return resourceMLEngineModelRead(d, meta) } func resourceMLEngineModelDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy MLEngineModel without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Model %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/mlengine/resource_ml_engine_model_generated_meta.yaml b/google/services/mlengine/resource_ml_engine_model_generated_meta.yaml index cb7ecac16a3..300af75825c 100644 --- a/google/services/mlengine/resource_ml_engine_model_generated_meta.yaml +++ b/google/services/mlengine/resource_ml_engine_model_generated_meta.yaml @@ -18,3 +18,5 @@ fields: - api_field: regions - field: terraform_labels provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/modelarmor/resource_model_armor_template.go b/google/services/modelarmor/resource_model_armor_template.go index 897818dbfb4..b930b133bce 100644 --- a/google/services/modelarmor/resource_model_armor_template.go +++ b/google/services/modelarmor/resource_model_armor_template.go @@ -116,6 +116,7 @@ func ResourceModelArmorTemplate() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -425,6 +426,18 @@ INSPECT_AND_BLOCK`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -564,6 +577,19 @@ func resourceModelArmorTemplateRead(d *schema.ResourceData, meta interface{}) er log.Printf("[DEBUG] Finished reading ModelArmorTemplate %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Template: %s", err) } @@ -601,6 +627,19 @@ func resourceModelArmorTemplateRead(d *schema.ResourceData, meta interface{}) er } func resourceModelArmorTemplateUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceModelArmorTemplate().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceModelArmorTemplateRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -712,6 +751,13 @@ func resourceModelArmorTemplateUpdate(d *schema.ResourceData, meta interface{}) } func resourceModelArmorTemplateDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ModelArmorTemplate without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Template %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/modelarmor/resource_model_armor_template_generated_meta.yaml b/google/services/modelarmor/resource_model_armor_template_generated_meta.yaml index 51f495ea54f..b7b83ea6d28 100644 --- a/google/services/modelarmor/resource_model_armor_template_generated_meta.yaml +++ b/google/services/modelarmor/resource_model_armor_template_generated_meta.yaml @@ -37,3 +37,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/modelarmorglobal/resource_model_armor_floorsetting.go b/google/services/modelarmorglobal/resource_model_armor_floorsetting.go index 4015c45ffca..b2098788d91 100644 --- a/google/services/modelarmorglobal/resource_model_armor_floorsetting.go +++ b/google/services/modelarmorglobal/resource_model_armor_floorsetting.go @@ -591,6 +591,7 @@ func resourceModelArmorGlobalFloorsettingRead(d *schema.ResourceData, meta inter } func resourceModelArmorGlobalFloorsettingUpdate(d *schema.ResourceData, meta interface{}) error { + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/monitoring/resource_monitoring_alert_policy.go b/google/services/monitoring/resource_monitoring_alert_policy.go index 498f2a95b1e..4be5e20e663 100644 --- a/google/services/monitoring/resource_monitoring_alert_policy.go +++ b/google/services/monitoring/resource_monitoring_alert_policy.go @@ -120,6 +120,7 @@ func ResourceMonitoringAlertPolicy() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -1301,6 +1302,18 @@ Its syntax is: projects/[PROJECT_ID]/alertPolicies/[ALERT_POLICY_ID]`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -1488,6 +1501,19 @@ func resourceMonitoringAlertPolicyRead(d *schema.ResourceData, meta interface{}) log.Printf("[DEBUG] Finished reading MonitoringAlertPolicy %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading AlertPolicy: %s", err) } @@ -1519,6 +1545,19 @@ func resourceMonitoringAlertPolicyRead(d *schema.ResourceData, meta interface{}) } func resourceMonitoringAlertPolicyUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceMonitoringAlertPolicy().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceMonitoringAlertPolicyRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1694,6 +1733,13 @@ func resourceMonitoringAlertPolicyUpdate(d *schema.ResourceData, meta interface{ } func resourceMonitoringAlertPolicyDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy MonitoringAlertPolicy without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing AlertPolicy %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/monitoring/resource_monitoring_alert_policy_generated_meta.yaml b/google/services/monitoring/resource_monitoring_alert_policy_generated_meta.yaml index a9b462c921c..c540c0a0c56 100644 --- a/google/services/monitoring/resource_monitoring_alert_policy_generated_meta.yaml +++ b/google/services/monitoring/resource_monitoring_alert_policy_generated_meta.yaml @@ -79,3 +79,5 @@ fields: - api_field: notificationChannels - api_field: severity - api_field: userLabels + - field: deletion_policy + provider_only: true diff --git a/google/services/monitoring/resource_monitoring_custom_service.go b/google/services/monitoring/resource_monitoring_custom_service.go index b74004e8c28..55d8077431d 100644 --- a/google/services/monitoring/resource_monitoring_custom_service.go +++ b/google/services/monitoring/resource_monitoring_custom_service.go @@ -115,6 +115,7 @@ func ResourceMonitoringService() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -191,6 +192,18 @@ projects/[PROJECT_ID]/services/[SERVICE_ID].`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -344,6 +357,19 @@ func resourceMonitoringServiceRead(d *schema.ResourceData, meta interface{}) err log.Printf("[DEBUG] Finished reading MonitoringService %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Service: %s", err) } @@ -375,6 +401,19 @@ func resourceMonitoringServiceRead(d *schema.ResourceData, meta interface{}) err } func resourceMonitoringServiceUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceMonitoringService().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceMonitoringServiceRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -487,6 +526,13 @@ func resourceMonitoringServiceUpdate(d *schema.ResourceData, meta interface{}) e } func resourceMonitoringServiceDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy MonitoringService without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Service %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/monitoring/resource_monitoring_custom_service_generated_meta.yaml b/google/services/monitoring/resource_monitoring_custom_service_generated_meta.yaml index e234e21bf35..c5b9bac792d 100644 --- a/google/services/monitoring/resource_monitoring_custom_service_generated_meta.yaml +++ b/google/services/monitoring/resource_monitoring_custom_service_generated_meta.yaml @@ -13,3 +13,5 @@ fields: field: service_id - api_field: telemetry.resourceName - api_field: userLabels + - field: deletion_policy + provider_only: true diff --git a/google/services/monitoring/resource_monitoring_dashboard.go b/google/services/monitoring/resource_monitoring_dashboard.go index bb04fce0eb3..12509fe0db1 100644 --- a/google/services/monitoring/resource_monitoring_dashboard.go +++ b/google/services/monitoring/resource_monitoring_dashboard.go @@ -92,6 +92,7 @@ func ResourceMonitoringDashboard() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -113,6 +114,9 @@ func ResourceMonitoringDashboard() *schema.Resource { ForceNew: true, Description: `The ID of the project in which the resource belongs. If it is not provided, the provider project is used.`, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, UseJSONNumber: true, } @@ -200,10 +204,19 @@ func resourceMonitoringDashboardRead(d *schema.ResourceData, meta interface{}) e return fmt.Errorf("Error reading Dashboard: %s", err) } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } func resourceMonitoringDashboardUpdate(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceMonitoringDashboard) { + return ResourceMonitoringDashboard().Read(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -246,6 +259,13 @@ func resourceMonitoringDashboardUpdate(d *schema.ResourceData, meta interface{}) } func resourceMonitoringDashboardDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/monitoring/resource_monitoring_dashboard_meta.yaml b/google/services/monitoring/resource_monitoring_dashboard_meta.yaml index eb4c23be8dc..9fcc29636cf 100644 --- a/google/services/monitoring/resource_monitoring_dashboard_meta.yaml +++ b/google/services/monitoring/resource_monitoring_dashboard_meta.yaml @@ -10,3 +10,5 @@ fields: api_field: '*' json: true - field: 'project' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/monitoring/resource_monitoring_group.go b/google/services/monitoring/resource_monitoring_group.go index 03478d45165..59d3e07cb18 100644 --- a/google/services/monitoring/resource_monitoring_group.go +++ b/google/services/monitoring/resource_monitoring_group.go @@ -115,6 +115,7 @@ func ResourceMonitoringGroup() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -176,6 +177,18 @@ groups with no parent, parentName is the empty string, "".`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -331,6 +344,19 @@ func resourceMonitoringGroupRead(d *schema.ResourceData, meta interface{}) error log.Printf("[DEBUG] Finished reading MonitoringGroup %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Group: %s", err) } @@ -362,6 +388,19 @@ func resourceMonitoringGroupRead(d *schema.ResourceData, meta interface{}) error } func resourceMonitoringGroupUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceMonitoringGroup().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceMonitoringGroupRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -459,6 +498,13 @@ func resourceMonitoringGroupUpdate(d *schema.ResourceData, meta interface{}) err } func resourceMonitoringGroupDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy MonitoringGroup without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Group %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/monitoring/resource_monitoring_group_generated_meta.yaml b/google/services/monitoring/resource_monitoring_group_generated_meta.yaml index 6eb9a6a080e..e44b9ebeb50 100644 --- a/google/services/monitoring/resource_monitoring_group_generated_meta.yaml +++ b/google/services/monitoring/resource_monitoring_group_generated_meta.yaml @@ -12,3 +12,5 @@ fields: - api_field: isCluster - api_field: name - api_field: parentName + - field: deletion_policy + provider_only: true diff --git a/google/services/monitoring/resource_monitoring_metric_descriptor.go b/google/services/monitoring/resource_monitoring_metric_descriptor.go index 9cfe6b1894d..b8a1eb69fab 100644 --- a/google/services/monitoring/resource_monitoring_metric_descriptor.go +++ b/google/services/monitoring/resource_monitoring_metric_descriptor.go @@ -115,6 +115,7 @@ func ResourceMonitoringMetricDescriptor() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -248,6 +249,18 @@ More info can be found in the API documentation Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -497,6 +510,19 @@ func resourceMonitoringMetricDescriptorRead(d *schema.ResourceData, meta interfa log.Printf("[DEBUG] Finished reading MonitoringMetricDescriptor %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading MetricDescriptor: %s", err) } @@ -528,6 +554,19 @@ func resourceMonitoringMetricDescriptorRead(d *schema.ResourceData, meta interfa } func resourceMonitoringMetricDescriptorUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceMonitoringMetricDescriptor().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceMonitoringMetricDescriptorRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -653,6 +692,13 @@ func resourceMonitoringMetricDescriptorUpdate(d *schema.ResourceData, meta inter } func resourceMonitoringMetricDescriptorDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy MonitoringMetricDescriptor without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing MetricDescriptor %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/monitoring/resource_monitoring_metric_descriptor_generated_meta.yaml b/google/services/monitoring/resource_monitoring_metric_descriptor_generated_meta.yaml index aff92ee7396..d877ac597c5 100644 --- a/google/services/monitoring/resource_monitoring_metric_descriptor_generated_meta.yaml +++ b/google/services/monitoring/resource_monitoring_metric_descriptor_generated_meta.yaml @@ -21,3 +21,5 @@ fields: - api_field: type - api_field: unit - api_field: valueType + - field: deletion_policy + provider_only: true diff --git a/google/services/monitoring/resource_monitoring_monitored_project.go b/google/services/monitoring/resource_monitoring_monitored_project.go index b55fbd46508..91434df24be 100644 --- a/google/services/monitoring/resource_monitoring_monitored_project.go +++ b/google/services/monitoring/resource_monitoring_monitored_project.go @@ -133,6 +133,7 @@ func ResourceMonitoringMonitoredProject() *schema.Resource { return &schema.Resource{ Create: resourceMonitoringMonitoredProjectCreate, Read: resourceMonitoringMonitoredProjectRead, + Update: resourceMonitoringMonitoredProjectUpdate, Delete: resourceMonitoringMonitoredProjectDelete, Importer: &schema.ResourceImporter{ @@ -174,6 +175,19 @@ func ResourceMonitoringMonitoredProject() *schema.Resource { Computed: true, Description: `Output only. The time when this 'MonitoredProject' was created.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -307,6 +321,20 @@ func resourceMonitoringMonitoredProjectRead(d *schema.ResourceData, meta interfa return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceMonitoringMonitoredProjectFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -315,7 +343,19 @@ func resourceMonitoringMonitoredProjectRead(d *schema.ResourceData, meta interfa return nil } +func resourceMonitoringMonitoredProjectUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceMonitoringMonitoredProjectRead(d, meta) +} + func resourceMonitoringMonitoredProjectDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy MonitoringMonitoredProject without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing MonitoredProject %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/monitoring/resource_monitoring_monitored_project_generated_meta.yaml b/google/services/monitoring/resource_monitoring_monitored_project_generated_meta.yaml index fb01b57555d..cec55f0c794 100644 --- a/google/services/monitoring/resource_monitoring_monitored_project_generated_meta.yaml +++ b/google/services/monitoring/resource_monitoring_monitored_project_generated_meta.yaml @@ -11,3 +11,5 @@ fields: - field: metrics_scope provider_only: true - api_field: name + - field: deletion_policy + provider_only: true diff --git a/google/services/monitoring/resource_monitoring_notification_channel.go b/google/services/monitoring/resource_monitoring_notification_channel.go index 54ff1597968..fb61203282e 100644 --- a/google/services/monitoring/resource_monitoring_notification_channel.go +++ b/google/services/monitoring/resource_monitoring_notification_channel.go @@ -132,6 +132,7 @@ func ResourceMonitoringNotificationChannel() *schema.Resource { CustomizeDiff: customdiff.All( sensitiveLabelCustomizeDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -296,6 +297,18 @@ deleted in a delete operation.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -487,6 +500,18 @@ func resourceMonitoringNotificationChannelRead(d *schema.ResourceData, meta inte return fmt.Errorf("Error setting force_delete: %s", err) } } + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading NotificationChannel: %s", err) } @@ -512,6 +537,19 @@ func resourceMonitoringNotificationChannelRead(d *schema.ResourceData, meta inte } func resourceMonitoringNotificationChannelUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceMonitoringNotificationChannel().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceMonitoringNotificationChannelRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -627,6 +665,13 @@ func resourceMonitoringNotificationChannelUpdate(d *schema.ResourceData, meta in } func resourceMonitoringNotificationChannelDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy MonitoringNotificationChannel without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing NotificationChannel %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/monitoring/resource_monitoring_notification_channel_generated_meta.yaml b/google/services/monitoring/resource_monitoring_notification_channel_generated_meta.yaml index 7cb52ae15e3..250dd776158 100644 --- a/google/services/monitoring/resource_monitoring_notification_channel_generated_meta.yaml +++ b/google/services/monitoring/resource_monitoring_notification_channel_generated_meta.yaml @@ -32,3 +32,5 @@ fields: - api_field: type - api_field: userLabels - api_field: verificationStatus + - field: deletion_policy + provider_only: true diff --git a/google/services/monitoring/resource_monitoring_service.go b/google/services/monitoring/resource_monitoring_service.go index b68f09b2617..db666eb6ce7 100644 --- a/google/services/monitoring/resource_monitoring_service.go +++ b/google/services/monitoring/resource_monitoring_service.go @@ -115,6 +115,7 @@ func ResourceMonitoringGenericService() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -215,6 +216,18 @@ https://cloud.google.com/apis/design/resource_names.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -351,6 +364,19 @@ func resourceMonitoringGenericServiceRead(d *schema.ResourceData, meta interface log.Printf("[DEBUG] Finished reading MonitoringGenericService %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading GenericService: %s", err) } @@ -382,6 +408,19 @@ func resourceMonitoringGenericServiceRead(d *schema.ResourceData, meta interface } func resourceMonitoringGenericServiceUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceMonitoringGenericService().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceMonitoringGenericServiceRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -479,6 +518,13 @@ func resourceMonitoringGenericServiceUpdate(d *schema.ResourceData, meta interfa } func resourceMonitoringGenericServiceDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy MonitoringGenericService without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing GenericService %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/monitoring/resource_monitoring_service_generated_meta.yaml b/google/services/monitoring/resource_monitoring_service_generated_meta.yaml index 4aea653c3ed..b9d96489359 100644 --- a/google/services/monitoring/resource_monitoring_service_generated_meta.yaml +++ b/google/services/monitoring/resource_monitoring_service_generated_meta.yaml @@ -15,3 +15,5 @@ fields: provider_only: true - api_field: telemetry.resourceName - api_field: userLabels + - field: deletion_policy + provider_only: true diff --git a/google/services/monitoring/resource_monitoring_slo.go b/google/services/monitoring/resource_monitoring_slo.go index 0fd1af543b2..f1fd3301f07 100644 --- a/google/services/monitoring/resource_monitoring_slo.go +++ b/google/services/monitoring/resource_monitoring_slo.go @@ -130,6 +130,7 @@ func ResourceMonitoringSlo() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -825,6 +826,18 @@ projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]/serviceLevelObjectives/[SL Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -1001,6 +1014,19 @@ func resourceMonitoringSloRead(d *schema.ResourceData, meta interface{}) error { log.Printf("[DEBUG] Finished reading MonitoringSlo %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Slo: %s", err) } @@ -1032,6 +1058,19 @@ func resourceMonitoringSloRead(d *schema.ResourceData, meta interface{}) error { } func resourceMonitoringSloUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceMonitoringSlo().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceMonitoringSloRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1204,6 +1243,13 @@ func resourceMonitoringSloUpdate(d *schema.ResourceData, meta interface{}) error } func resourceMonitoringSloDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy MonitoringSlo without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Slo %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/monitoring/resource_monitoring_slo_generated_meta.yaml b/google/services/monitoring/resource_monitoring_slo_generated_meta.yaml index 9b3dc9988ec..41a3d95f7ef 100644 --- a/google/services/monitoring/resource_monitoring_slo_generated_meta.yaml +++ b/google/services/monitoring/resource_monitoring_slo_generated_meta.yaml @@ -80,3 +80,5 @@ fields: field: windows_based_sli.metric_sum_in_range.time_series - api_field: serviceLevelIndicator.windowsBased.windowPeriod field: windows_based_sli.window_period + - field: deletion_policy + provider_only: true diff --git a/google/services/monitoring/resource_monitoring_uptime_check_config.go b/google/services/monitoring/resource_monitoring_uptime_check_config.go index d10241a771b..a91cc5ef801 100644 --- a/google/services/monitoring/resource_monitoring_uptime_check_config.go +++ b/google/services/monitoring/resource_monitoring_uptime_check_config.go @@ -128,6 +128,7 @@ func ResourceMonitoringUptimeCheckConfig() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -539,6 +540,18 @@ uptime checks: Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -753,6 +766,19 @@ func resourceMonitoringUptimeCheckConfigRead(d *schema.ResourceData, meta interf log.Printf("[DEBUG] Finished reading MonitoringUptimeCheckConfig %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading UptimeCheckConfig: %s", err) } @@ -784,6 +810,19 @@ func resourceMonitoringUptimeCheckConfigRead(d *schema.ResourceData, meta interf } func resourceMonitoringUptimeCheckConfigUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceMonitoringUptimeCheckConfig().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceMonitoringUptimeCheckConfigRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -963,6 +1002,13 @@ func resourceMonitoringUptimeCheckConfigUpdate(d *schema.ResourceData, meta inte } func resourceMonitoringUptimeCheckConfigDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy MonitoringUptimeCheckConfig without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing UptimeCheckConfig %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/monitoring/resource_monitoring_uptime_check_config_generated_meta.yaml b/google/services/monitoring/resource_monitoring_uptime_check_config_generated_meta.yaml index 14b8263a7de..8967548d9e3 100644 --- a/google/services/monitoring/resource_monitoring_uptime_check_config_generated_meta.yaml +++ b/google/services/monitoring/resource_monitoring_uptime_check_config_generated_meta.yaml @@ -46,3 +46,5 @@ fields: - api_field: id field: uptime_check_id - api_field: userLabels + - field: deletion_policy + provider_only: true diff --git a/google/services/netapp/resource_netapp_active_directory.go b/google/services/netapp/resource_netapp_active_directory.go index 2ad34ae287f..03061be82c9 100644 --- a/google/services/netapp/resource_netapp_active_directory.go +++ b/google/services/netapp/resource_netapp_active_directory.go @@ -116,6 +116,7 @@ func ResourceNetappActiveDirectory() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -300,6 +301,18 @@ Use when Active Directory domain controllers in multiple regions are configured. Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -539,6 +552,19 @@ func resourceNetappActiveDirectoryRead(d *schema.ResourceData, meta interface{}) log.Printf("[DEBUG] Finished reading NetappActiveDirectory %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading ActiveDirectory: %s", err) } @@ -576,6 +602,19 @@ func resourceNetappActiveDirectoryRead(d *schema.ResourceData, meta interface{}) } func resourceNetappActiveDirectoryUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetappActiveDirectory().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetappActiveDirectoryRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -844,6 +883,13 @@ func resourceNetappActiveDirectoryUpdate(d *schema.ResourceData, meta interface{ } func resourceNetappActiveDirectoryDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetappActiveDirectory without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ActiveDirectory %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/netapp/resource_netapp_active_directory_generated_meta.yaml b/google/services/netapp/resource_netapp_active_directory_generated_meta.yaml index 1ffa5330ee9..6c9e8f95586 100644 --- a/google/services/netapp/resource_netapp_active_directory_generated_meta.yaml +++ b/google/services/netapp/resource_netapp_active_directory_generated_meta.yaml @@ -36,3 +36,5 @@ fields: - field: terraform_labels provider_only: true - api_field: username + - field: deletion_policy + provider_only: true diff --git a/google/services/netapp/resource_netapp_backup.go b/google/services/netapp/resource_netapp_backup.go index b1b091fcac9..a9ba643200a 100644 --- a/google/services/netapp/resource_netapp_backup.go +++ b/google/services/netapp/resource_netapp_backup.go @@ -116,6 +116,7 @@ func ResourceNetappBackup() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -249,6 +250,18 @@ Total size of all backups in a chain in bytes = baseline backup size + sum(incre Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -409,6 +422,19 @@ func resourceNetappBackupRead(d *schema.ResourceData, meta interface{}) error { log.Printf("[DEBUG] Finished reading NetappBackup %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Backup: %s", err) } @@ -452,6 +478,19 @@ func resourceNetappBackupRead(d *schema.ResourceData, meta interface{}) error { } func resourceNetappBackupUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetappBackup().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetappBackupRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -575,6 +614,13 @@ func resourceNetappBackupUpdate(d *schema.ResourceData, meta interface{}) error } func resourceNetappBackupDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetappBackup without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Backup %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/netapp/resource_netapp_backup_generated_meta.yaml b/google/services/netapp/resource_netapp_backup_generated_meta.yaml index a764fcb9dc3..2d244b78440 100644 --- a/google/services/netapp/resource_netapp_backup_generated_meta.yaml +++ b/google/services/netapp/resource_netapp_backup_generated_meta.yaml @@ -30,3 +30,5 @@ fields: provider_only: true - api_field: volumeRegion - api_field: volumeUsageBytes + - field: deletion_policy + provider_only: true diff --git a/google/services/netapp/resource_netapp_backup_policy.go b/google/services/netapp/resource_netapp_backup_policy.go index 463f3355bfe..4df4f288940 100644 --- a/google/services/netapp/resource_netapp_backup_policy.go +++ b/google/services/netapp/resource_netapp_backup_policy.go @@ -116,6 +116,7 @@ func ResourceNetappBackupPolicy() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -225,6 +226,18 @@ Please refer to the field 'effective_labels' for all of the labels present on th Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -392,6 +405,19 @@ func resourceNetappBackupPolicyRead(d *schema.ResourceData, meta interface{}) er log.Printf("[DEBUG] Finished reading NetappBackupPolicy %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading BackupPolicy: %s", err) } @@ -429,6 +455,19 @@ func resourceNetappBackupPolicyRead(d *schema.ResourceData, meta interface{}) er } func resourceNetappBackupPolicyUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetappBackupPolicy().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetappBackupPolicyRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -577,6 +616,13 @@ func resourceNetappBackupPolicyUpdate(d *schema.ResourceData, meta interface{}) } func resourceNetappBackupPolicyDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetappBackupPolicy without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing BackupPolicy %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/netapp/resource_netapp_backup_policy_generated_meta.yaml b/google/services/netapp/resource_netapp_backup_policy_generated_meta.yaml index e3af15d5b98..901bf9313f8 100644 --- a/google/services/netapp/resource_netapp_backup_policy_generated_meta.yaml +++ b/google/services/netapp/resource_netapp_backup_policy_generated_meta.yaml @@ -24,3 +24,5 @@ fields: - field: terraform_labels provider_only: true - api_field: weeklyBackupLimit + - field: deletion_policy + provider_only: true diff --git a/google/services/netapp/resource_netapp_backup_vault.go b/google/services/netapp/resource_netapp_backup_vault.go index 86f28b31edd..9379d62b141 100644 --- a/google/services/netapp/resource_netapp_backup_vault.go +++ b/google/services/netapp/resource_netapp_backup_vault.go @@ -116,6 +116,7 @@ func ResourceNetappBackupVault() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -279,6 +280,18 @@ Format: Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -446,6 +459,19 @@ func resourceNetappBackupVaultRead(d *schema.ResourceData, meta interface{}) err log.Printf("[DEBUG] Finished reading NetappBackupVault %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading BackupVault: %s", err) } @@ -483,6 +509,19 @@ func resourceNetappBackupVaultRead(d *schema.ResourceData, meta interface{}) err } func resourceNetappBackupVaultUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetappBackupVault().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetappBackupVaultRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -631,6 +670,13 @@ func resourceNetappBackupVaultUpdate(d *schema.ResourceData, meta interface{}) e } func resourceNetappBackupVaultDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetappBackupVault without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing BackupVault %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/netapp/resource_netapp_backup_vault_generated_meta.yaml b/google/services/netapp/resource_netapp_backup_vault_generated_meta.yaml index 9299b2db205..6580097826d 100644 --- a/google/services/netapp/resource_netapp_backup_vault_generated_meta.yaml +++ b/google/services/netapp/resource_netapp_backup_vault_generated_meta.yaml @@ -32,3 +32,5 @@ fields: - api_field: state - field: terraform_labels provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/netapp/resource_netapp_host_group.go b/google/services/netapp/resource_netapp_host_group.go index 310211a7fb8..db15651a4ca 100644 --- a/google/services/netapp/resource_netapp_host_group.go +++ b/google/services/netapp/resource_netapp_host_group.go @@ -116,6 +116,7 @@ func ResourceNetappHostGroup() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -222,6 +223,18 @@ Please refer to the field 'effective_labels' for all of the labels present on th Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -389,6 +402,19 @@ func resourceNetappHostGroupRead(d *schema.ResourceData, meta interface{}) error log.Printf("[DEBUG] Finished reading NetappHostGroup %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading HostGroup: %s", err) } @@ -426,6 +452,19 @@ func resourceNetappHostGroupRead(d *schema.ResourceData, meta interface{}) error } func resourceNetappHostGroupUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetappHostGroup().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetappHostGroupRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -544,6 +583,13 @@ func resourceNetappHostGroupUpdate(d *schema.ResourceData, meta interface{}) err } func resourceNetappHostGroupDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetappHostGroup without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing HostGroup %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/netapp/resource_netapp_host_group_generated_meta.yaml b/google/services/netapp/resource_netapp_host_group_generated_meta.yaml index 407ba7f19a8..336e3745a27 100644 --- a/google/services/netapp/resource_netapp_host_group_generated_meta.yaml +++ b/google/services/netapp/resource_netapp_host_group_generated_meta.yaml @@ -21,3 +21,5 @@ fields: - field: terraform_labels provider_only: true - api_field: type + - field: deletion_policy + provider_only: true diff --git a/google/services/netapp/resource_netapp_kmsconfig.go b/google/services/netapp/resource_netapp_kmsconfig.go index f7e4e66748a..c10fa62c845 100644 --- a/google/services/netapp/resource_netapp_kmsconfig.go +++ b/google/services/netapp/resource_netapp_kmsconfig.go @@ -116,6 +116,7 @@ func ResourceNetappkmsconfig() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -205,6 +206,18 @@ To make the policy work, a CMEK policy check is required, which verifies key acc Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -372,6 +385,19 @@ func resourceNetappkmsconfigRead(d *schema.ResourceData, meta interface{}) error log.Printf("[DEBUG] Finished reading Netappkmsconfig %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading kmsconfig: %s", err) } @@ -409,6 +435,19 @@ func resourceNetappkmsconfigRead(d *schema.ResourceData, meta interface{}) error } func resourceNetappkmsconfigUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetappkmsconfig().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetappkmsconfigRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -527,6 +566,13 @@ func resourceNetappkmsconfigUpdate(d *schema.ResourceData, meta interface{}) err } func resourceNetappkmsconfigDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy Netappkmsconfig without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing kmsconfig %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/netapp/resource_netapp_kmsconfig_generated_meta.yaml b/google/services/netapp/resource_netapp_kmsconfig_generated_meta.yaml index 60f85403093..6a981ce17aa 100644 --- a/google/services/netapp/resource_netapp_kmsconfig_generated_meta.yaml +++ b/google/services/netapp/resource_netapp_kmsconfig_generated_meta.yaml @@ -20,3 +20,5 @@ fields: - api_field: serviceAccount - field: terraform_labels provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/netapp/resource_netapp_storage_pool.go b/google/services/netapp/resource_netapp_storage_pool.go index b5b9094d75f..c1fa2138e75 100644 --- a/google/services/netapp/resource_netapp_storage_pool.go +++ b/google/services/netapp/resource_netapp_storage_pool.go @@ -116,6 +116,7 @@ func ResourceNetappStoragePool() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -345,6 +346,18 @@ If you want to create a zonal Flex pool, specify a zone name for 'location' and Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -596,6 +609,19 @@ func resourceNetappStoragePoolRead(d *schema.ResourceData, meta interface{}) err log.Printf("[DEBUG] Finished reading NetappStoragePool %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading StoragePool: %s", err) } @@ -633,6 +659,19 @@ func resourceNetappStoragePoolRead(d *schema.ResourceData, meta interface{}) err } func resourceNetappStoragePoolUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetappStoragePool().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetappStoragePoolRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -906,6 +945,13 @@ func resourceNetappStoragePoolUpdate(d *schema.ResourceData, meta interface{}) e } func resourceNetappStoragePoolDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetappStoragePool without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing StoragePool %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/netapp/resource_netapp_storage_pool_generated_meta.yaml b/google/services/netapp/resource_netapp_storage_pool_generated_meta.yaml index 002ac9bff67..7e5cac2ddf5 100644 --- a/google/services/netapp/resource_netapp_storage_pool_generated_meta.yaml +++ b/google/services/netapp/resource_netapp_storage_pool_generated_meta.yaml @@ -41,3 +41,5 @@ fields: - api_field: volumeCapacityGib - api_field: volumeCount - api_field: zone + - field: deletion_policy + provider_only: true diff --git a/google/services/netapp/resource_netapp_volume.go b/google/services/netapp/resource_netapp_volume.go index 6e2b0d0dc95..766e09c9990 100644 --- a/google/services/netapp/resource_netapp_volume.go +++ b/google/services/netapp/resource_netapp_volume.go @@ -159,6 +159,7 @@ func ResourceNetappVolume() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DEFAULT"), ), Identity: &schema.ResourceIdentity{ @@ -975,21 +976,18 @@ Format for SMB volumes: '\\\\netbios_prefix-four_random_hex_letters.domain_name\ Computed: true, Description: `Specifies the active zone for regional volume.`, }, - "deletion_policy": { - Type: schema.TypeString, - Optional: true, - Description: `Policy to determine if the volume should be deleted forcefully. -Volumes may have nested snapshot resources. Deleting such a volume will fail. -Setting this parameter to FORCE will delete volumes including nested snapshots. -Possible values: DEFAULT, FORCE.`, - Default: "DEFAULT", - }, "project": { Type: schema.TypeString, Optional: true, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `This field uses a custom implementation please refer to documentation under /hashicorp/terraform-provider-google-beta/website/docs/r/netapp_volume.html.markdown for specifics`, + }, }, UseJSONNumber: true, } @@ -1267,8 +1265,15 @@ func resourceNetappVolumeRead(d *schema.ResourceData, meta interface{}) error { // Explicitly set virtual fields to default values if unset if _, ok := d.GetOkExists("deletion_policy"); !ok { - if err := d.Set("deletion_policy", "DEFAULT"); err != nil { - return fmt.Errorf("Error setting deletion_policy: %s", err) + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DEFAULT"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } } } if err := d.Set("project", project); err != nil { @@ -1308,6 +1313,19 @@ func resourceNetappVolumeRead(d *schema.ResourceData, meta interface{}) error { } func resourceNetappVolumeUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetappVolume().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetappVolumeRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1757,6 +1775,13 @@ func resourceNetappVolumeUpdate(d *schema.ResourceData, meta interface{}) error } func resourceNetappVolumeDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetappVolume without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Volume %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1833,9 +1858,6 @@ func resourceNetappVolumeImport(d *schema.ResourceData, meta interface{}) ([]*sc d.SetId(id) // Explicitly set virtual fields to default values on import - if err := d.Set("deletion_policy", "DEFAULT"); err != nil { - return nil, fmt.Errorf("Error setting deletion_policy: %s", err) - } return []*schema.ResourceData{d}, nil } diff --git a/google/services/netapp/resource_netapp_volume_generated_meta.yaml b/google/services/netapp/resource_netapp_volume_generated_meta.yaml index 2313da0f9a2..b4e402b6d1d 100644 --- a/google/services/netapp/resource_netapp_volume_generated_meta.yaml +++ b/google/services/netapp/resource_netapp_volume_generated_meta.yaml @@ -30,8 +30,6 @@ fields: - api_field: capacityGib - api_field: coldTierSizeGib - api_field: createTime - - field: deletion_policy - provider_only: true - api_field: description - field: effective_labels provider_only: true @@ -116,3 +114,5 @@ fields: - api_field: unixPermissions - api_field: usedGib - api_field: zone + - field: deletion_policy + provider_only: true diff --git a/google/services/netapp/resource_netapp_volume_quota_rule.go b/google/services/netapp/resource_netapp_volume_quota_rule.go index 9dc619c599a..53adb5dd05a 100644 --- a/google/services/netapp/resource_netapp_volume_quota_rule.go +++ b/google/services/netapp/resource_netapp_volume_quota_rule.go @@ -116,6 +116,7 @@ func ResourceNetappVolumeQuotaRule() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -235,6 +236,18 @@ Leave empty for default quotas`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -401,6 +414,19 @@ func resourceNetappVolumeQuotaRuleRead(d *schema.ResourceData, meta interface{}) log.Printf("[DEBUG] Finished reading NetappVolumeQuotaRule %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading VolumeQuotaRule: %s", err) } @@ -444,6 +470,19 @@ func resourceNetappVolumeQuotaRuleRead(d *schema.ResourceData, meta interface{}) } func resourceNetappVolumeQuotaRuleUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetappVolumeQuotaRule().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetappVolumeQuotaRuleRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -587,6 +626,13 @@ func resourceNetappVolumeQuotaRuleUpdate(d *schema.ResourceData, meta interface{ } func resourceNetappVolumeQuotaRuleDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetappVolumeQuotaRule without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing VolumeQuotaRule %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/netapp/resource_netapp_volume_quota_rule_generated_meta.yaml b/google/services/netapp/resource_netapp_volume_quota_rule_generated_meta.yaml index 73d47ab8429..572e7b75e88 100644 --- a/google/services/netapp/resource_netapp_volume_quota_rule_generated_meta.yaml +++ b/google/services/netapp/resource_netapp_volume_quota_rule_generated_meta.yaml @@ -25,3 +25,5 @@ fields: - api_field: type - field: volume_name provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/netapp/resource_netapp_volume_replication.go b/google/services/netapp/resource_netapp_volume_replication.go index 1e4b731efe5..37a0a9c6a77 100644 --- a/google/services/netapp/resource_netapp_volume_replication.go +++ b/google/services/netapp/resource_netapp_volume_replication.go @@ -168,6 +168,7 @@ func ResourceNetappVolumeReplication() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -518,6 +519,18 @@ create/stop/resume operations, set this parameter to true. Default is false.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -707,6 +720,18 @@ func resourceNetappVolumeReplicationRead(d *schema.ResourceData, meta interface{ return fmt.Errorf("Error setting wait_for_mirror: %s", err) } } + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading VolumeReplication: %s", err) } @@ -750,6 +775,19 @@ func resourceNetappVolumeReplicationRead(d *schema.ResourceData, meta interface{ } func resourceNetappVolumeReplicationUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetappVolumeReplication().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetappVolumeReplicationRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -972,6 +1010,13 @@ func resourceNetappVolumeReplicationUpdate(d *schema.ResourceData, meta interfac } func resourceNetappVolumeReplicationDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetappVolumeReplication without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing VolumeReplication %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/netapp/resource_netapp_volume_replication_generated_meta.yaml b/google/services/netapp/resource_netapp_volume_replication_generated_meta.yaml index ec3fd824212..5c24f2305f6 100644 --- a/google/services/netapp/resource_netapp_volume_replication_generated_meta.yaml +++ b/google/services/netapp/resource_netapp_volume_replication_generated_meta.yaml @@ -59,3 +59,5 @@ fields: provider_only: true - field: wait_for_mirror provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/netapp/resource_netapp_volume_snapshot.go b/google/services/netapp/resource_netapp_volume_snapshot.go index a6ad8fa4b70..adb4dffb500 100644 --- a/google/services/netapp/resource_netapp_volume_snapshot.go +++ b/google/services/netapp/resource_netapp_volume_snapshot.go @@ -116,6 +116,7 @@ func ResourceNetappVolumeSnapshot() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -203,6 +204,18 @@ Please refer to the field 'effective_labels' for all of the labels present on th Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -351,6 +364,19 @@ func resourceNetappVolumeSnapshotRead(d *schema.ResourceData, meta interface{}) log.Printf("[DEBUG] Finished reading NetappVolumeSnapshot %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading VolumeSnapshot: %s", err) } @@ -394,6 +420,19 @@ func resourceNetappVolumeSnapshotRead(d *schema.ResourceData, meta interface{}) } func resourceNetappVolumeSnapshotUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetappVolumeSnapshot().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetappVolumeSnapshotRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -507,6 +546,13 @@ func resourceNetappVolumeSnapshotUpdate(d *schema.ResourceData, meta interface{} } func resourceNetappVolumeSnapshotDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetappVolumeSnapshot without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing VolumeSnapshot %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/netapp/resource_netapp_volume_snapshot_generated_meta.yaml b/google/services/netapp/resource_netapp_volume_snapshot_generated_meta.yaml index bbd3b6d7735..3c88cc36f87 100644 --- a/google/services/netapp/resource_netapp_volume_snapshot_generated_meta.yaml +++ b/google/services/netapp/resource_netapp_volume_snapshot_generated_meta.yaml @@ -20,3 +20,5 @@ fields: - api_field: usedBytes - field: volume_name provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/networkconnectivity/resource_network_connectivity_destination.go b/google/services/networkconnectivity/resource_network_connectivity_destination.go index 7b4a312acbc..5be46c0e667 100644 --- a/google/services/networkconnectivity/resource_network_connectivity_destination.go +++ b/google/services/networkconnectivity/resource_network_connectivity_destination.go @@ -116,6 +116,7 @@ func ResourceNetworkConnectivityDestination() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -270,6 +271,18 @@ created, the new resource is assigned a different and unique ID.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -463,6 +476,19 @@ func resourceNetworkConnectivityDestinationRead(d *schema.ResourceData, meta int log.Printf("[DEBUG] Finished reading NetworkConnectivityDestination %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Destination: %s", err) } @@ -506,6 +532,19 @@ func resourceNetworkConnectivityDestinationRead(d *schema.ResourceData, meta int } func resourceNetworkConnectivityDestinationUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetworkConnectivityDestination().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetworkConnectivityDestinationRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -639,6 +678,13 @@ func resourceNetworkConnectivityDestinationUpdate(d *schema.ResourceData, meta i } func resourceNetworkConnectivityDestinationDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkConnectivityDestination without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Destination %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/networkconnectivity/resource_network_connectivity_destination_generated_meta.yaml b/google/services/networkconnectivity/resource_network_connectivity_destination_generated_meta.yaml index 88cb8986daf..1d3e37e2f34 100644 --- a/google/services/networkconnectivity/resource_network_connectivity_destination_generated_meta.yaml +++ b/google/services/networkconnectivity/resource_network_connectivity_destination_generated_meta.yaml @@ -30,3 +30,5 @@ fields: provider_only: true - api_field: uid - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/networkconnectivity/resource_network_connectivity_group.go b/google/services/networkconnectivity/resource_network_connectivity_group.go index 4ca79659f14..989a57d8fe5 100644 --- a/google/services/networkconnectivity/resource_network_connectivity_group.go +++ b/google/services/networkconnectivity/resource_network_connectivity_group.go @@ -116,6 +116,7 @@ func ResourceNetworkConnectivityGroup() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -234,6 +235,18 @@ Please refer to the field 'effective_labels' for all of the labels present on th Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -389,6 +402,19 @@ func resourceNetworkConnectivityGroupRead(d *schema.ResourceData, meta interface log.Printf("[DEBUG] Finished reading NetworkConnectivityGroup %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Group: %s", err) } @@ -426,6 +452,19 @@ func resourceNetworkConnectivityGroupRead(d *schema.ResourceData, meta interface } func resourceNetworkConnectivityGroupUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetworkConnectivityGroup().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetworkConnectivityGroupRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -522,6 +561,13 @@ func resourceNetworkConnectivityGroupUpdate(d *schema.ResourceData, meta interfa } func resourceNetworkConnectivityGroupDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkConnectivityGroup without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Group %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/networkconnectivity/resource_network_connectivity_group_generated_meta.yaml b/google/services/networkconnectivity/resource_network_connectivity_group_generated_meta.yaml index 5c3a35fd14e..01119183316 100644 --- a/google/services/networkconnectivity/resource_network_connectivity_group_generated_meta.yaml +++ b/google/services/networkconnectivity/resource_network_connectivity_group_generated_meta.yaml @@ -22,3 +22,5 @@ fields: provider_only: true - api_field: uid - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/networkconnectivity/resource_network_connectivity_hub.go b/google/services/networkconnectivity/resource_network_connectivity_hub.go index dad943cac31..235c3b763bf 100644 --- a/google/services/networkconnectivity/resource_network_connectivity_hub.go +++ b/google/services/networkconnectivity/resource_network_connectivity_hub.go @@ -116,6 +116,7 @@ func ResourceNetworkConnectivityHub() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -217,6 +218,18 @@ Please refer to the field 'effective_labels' for all of the labels present on th Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -363,6 +376,19 @@ func resourceNetworkConnectivityHubRead(d *schema.ResourceData, meta interface{} log.Printf("[DEBUG] Finished reading NetworkConnectivityHub %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Hub: %s", err) } @@ -376,6 +402,19 @@ func resourceNetworkConnectivityHubRead(d *schema.ResourceData, meta interface{} } func resourceNetworkConnectivityHubUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetworkConnectivityHub().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetworkConnectivityHubRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -474,6 +513,13 @@ func resourceNetworkConnectivityHubUpdate(d *schema.ResourceData, meta interface } func resourceNetworkConnectivityHubDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkConnectivityHub without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Hub %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/networkconnectivity/resource_network_connectivity_hub_generated_meta.yaml b/google/services/networkconnectivity/resource_network_connectivity_hub_generated_meta.yaml index e255c5aa742..7e2140b3719 100644 --- a/google/services/networkconnectivity/resource_network_connectivity_hub_generated_meta.yaml +++ b/google/services/networkconnectivity/resource_network_connectivity_hub_generated_meta.yaml @@ -22,3 +22,5 @@ fields: provider_only: true - api_field: uniqueId - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/networkconnectivity/resource_network_connectivity_multicloud_data_transfer_config.go b/google/services/networkconnectivity/resource_network_connectivity_multicloud_data_transfer_config.go index 6121e9e26a0..bbc9b963ccc 100644 --- a/google/services/networkconnectivity/resource_network_connectivity_multicloud_data_transfer_config.go +++ b/google/services/networkconnectivity/resource_network_connectivity_multicloud_data_transfer_config.go @@ -116,6 +116,7 @@ func ResourceNetworkConnectivityMulticloudDataTransferConfig() *schema.Resource CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -233,6 +234,18 @@ created, the new resource is assigned a different and unique ID.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -420,6 +433,19 @@ func resourceNetworkConnectivityMulticloudDataTransferConfigRead(d *schema.Resou log.Printf("[DEBUG] Finished reading NetworkConnectivityMulticloudDataTransferConfig %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading MulticloudDataTransferConfig: %s", err) } @@ -457,6 +483,19 @@ func resourceNetworkConnectivityMulticloudDataTransferConfigRead(d *schema.Resou } func resourceNetworkConnectivityMulticloudDataTransferConfigUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetworkConnectivityMulticloudDataTransferConfig().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetworkConnectivityMulticloudDataTransferConfigRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -585,6 +624,13 @@ func resourceNetworkConnectivityMulticloudDataTransferConfigUpdate(d *schema.Res } func resourceNetworkConnectivityMulticloudDataTransferConfigDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkConnectivityMulticloudDataTransferConfig without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing MulticloudDataTransferConfig %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/networkconnectivity/resource_network_connectivity_multicloud_data_transfer_config_generated_meta.yaml b/google/services/networkconnectivity/resource_network_connectivity_multicloud_data_transfer_config_generated_meta.yaml index e66ecf92da6..e957c6908df 100644 --- a/google/services/networkconnectivity/resource_network_connectivity_multicloud_data_transfer_config_generated_meta.yaml +++ b/google/services/networkconnectivity/resource_network_connectivity_multicloud_data_transfer_config_generated_meta.yaml @@ -29,3 +29,5 @@ fields: provider_only: true - api_field: uid - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/networkconnectivity/resource_network_connectivity_policy_based_route.go b/google/services/networkconnectivity/resource_network_connectivity_policy_based_route.go index 0cb07200f19..d72e9ceaa71 100644 --- a/google/services/networkconnectivity/resource_network_connectivity_policy_based_route.go +++ b/google/services/networkconnectivity/resource_network_connectivity_policy_based_route.go @@ -116,6 +116,7 @@ func ResourceNetworkConnectivityPolicyBasedRoute() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -326,6 +327,18 @@ Please refer to the field 'effective_labels' for all of the labels present on th Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -506,6 +519,19 @@ func resourceNetworkConnectivityPolicyBasedRouteRead(d *schema.ResourceData, met log.Printf("[DEBUG] Finished reading NetworkConnectivityPolicyBasedRoute %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading PolicyBasedRoute: %s", err) } @@ -537,11 +563,18 @@ func resourceNetworkConnectivityPolicyBasedRouteRead(d *schema.ResourceData, met } func resourceNetworkConnectivityPolicyBasedRouteUpdate(d *schema.ResourceData, meta interface{}) error { - // Only the root field "labels", "terraform_labels", and virtual fields are mutable + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable return resourceNetworkConnectivityPolicyBasedRouteRead(d, meta) } func resourceNetworkConnectivityPolicyBasedRouteDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkConnectivityPolicyBasedRoute without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing PolicyBasedRoute %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/networkconnectivity/resource_network_connectivity_policy_based_route_generated_meta.yaml b/google/services/networkconnectivity/resource_network_connectivity_policy_based_route_generated_meta.yaml index a9ea43ad683..e5871b5abc5 100644 --- a/google/services/networkconnectivity/resource_network_connectivity_policy_based_route_generated_meta.yaml +++ b/google/services/networkconnectivity/resource_network_connectivity_policy_based_route_generated_meta.yaml @@ -31,3 +31,5 @@ fields: - api_field: warnings.code - api_field: warnings.data - api_field: warnings.warningMessage + - field: deletion_policy + provider_only: true diff --git a/google/services/networkconnectivity/resource_network_connectivity_regional_endpoint.go b/google/services/networkconnectivity/resource_network_connectivity_regional_endpoint.go index 628b2c656d5..7151432b244 100644 --- a/google/services/networkconnectivity/resource_network_connectivity_regional_endpoint.go +++ b/google/services/networkconnectivity/resource_network_connectivity_regional_endpoint.go @@ -116,6 +116,7 @@ func ResourceNetworkConnectivityRegionalEndpoint() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -241,6 +242,18 @@ Please refer to the field 'effective_labels' for all of the labels present on th Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -414,6 +427,19 @@ func resourceNetworkConnectivityRegionalEndpointRead(d *schema.ResourceData, met log.Printf("[DEBUG] Finished reading NetworkConnectivityRegionalEndpoint %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading RegionalEndpoint: %s", err) } @@ -451,11 +477,18 @@ func resourceNetworkConnectivityRegionalEndpointRead(d *schema.ResourceData, met } func resourceNetworkConnectivityRegionalEndpointUpdate(d *schema.ResourceData, meta interface{}) error { - // Only the root field "labels", "terraform_labels", and virtual fields are mutable + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable return resourceNetworkConnectivityRegionalEndpointRead(d, meta) } func resourceNetworkConnectivityRegionalEndpointDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkConnectivityRegionalEndpoint without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing RegionalEndpoint %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/networkconnectivity/resource_network_connectivity_regional_endpoint_generated_meta.yaml b/google/services/networkconnectivity/resource_network_connectivity_regional_endpoint_generated_meta.yaml index e1ca2297acf..da344a4ab07 100644 --- a/google/services/networkconnectivity/resource_network_connectivity_regional_endpoint_generated_meta.yaml +++ b/google/services/networkconnectivity/resource_network_connectivity_regional_endpoint_generated_meta.yaml @@ -25,3 +25,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/networkconnectivity/resource_network_connectivity_spoke.go b/google/services/networkconnectivity/resource_network_connectivity_spoke.go index a279eed5701..2828f054040 100644 --- a/google/services/networkconnectivity/resource_network_connectivity_spoke.go +++ b/google/services/networkconnectivity/resource_network_connectivity_spoke.go @@ -116,6 +116,7 @@ func ResourceNetworkConnectivitySpoke() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -516,6 +517,18 @@ Please refer to the field 'effective_labels' for all of the labels present on th Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -707,6 +720,19 @@ func resourceNetworkConnectivitySpokeRead(d *schema.ResourceData, meta interface log.Printf("[DEBUG] Finished reading NetworkConnectivitySpoke %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Spoke: %s", err) } @@ -744,6 +770,19 @@ func resourceNetworkConnectivitySpokeRead(d *schema.ResourceData, meta interface } func resourceNetworkConnectivitySpokeUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetworkConnectivitySpoke().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetworkConnectivitySpokeRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -903,6 +942,13 @@ func resourceNetworkConnectivitySpokeUpdate(d *schema.ResourceData, meta interfa } func resourceNetworkConnectivitySpokeDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkConnectivitySpoke without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Spoke %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/networkconnectivity/resource_network_connectivity_spoke_generated_meta.yaml b/google/services/networkconnectivity/resource_network_connectivity_spoke_generated_meta.yaml index b3bc5d37179..a83be22b2c9 100644 --- a/google/services/networkconnectivity/resource_network_connectivity_spoke_generated_meta.yaml +++ b/google/services/networkconnectivity/resource_network_connectivity_spoke_generated_meta.yaml @@ -52,3 +52,5 @@ fields: provider_only: true - api_field: uniqueId - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/networkconnectivityv1/resource_network_connectivity_internal_range.go b/google/services/networkconnectivityv1/resource_network_connectivity_internal_range.go index 35d81d6ee56..e8594ef0b0f 100644 --- a/google/services/networkconnectivityv1/resource_network_connectivity_internal_range.go +++ b/google/services/networkconnectivityv1/resource_network_connectivity_internal_range.go @@ -116,6 +116,7 @@ func ResourceNetworkConnectivityv1InternalRange() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -308,6 +309,18 @@ Other resources mark themselves as users while doing so by creating a reference Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -512,6 +525,19 @@ func resourceNetworkConnectivityv1InternalRangeRead(d *schema.ResourceData, meta log.Printf("[DEBUG] Finished reading NetworkConnectivityv1InternalRange %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading InternalRange: %s", err) } @@ -543,6 +569,19 @@ func resourceNetworkConnectivityv1InternalRangeRead(d *schema.ResourceData, meta } func resourceNetworkConnectivityv1InternalRangeUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetworkConnectivityv1InternalRange().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetworkConnectivityv1InternalRangeRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -726,6 +765,13 @@ func resourceNetworkConnectivityv1InternalRangeUpdate(d *schema.ResourceData, me } func resourceNetworkConnectivityv1InternalRangeDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkConnectivityv1InternalRange without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing InternalRange %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/networkconnectivityv1/resource_network_connectivity_internal_range_generated_meta.yaml b/google/services/networkconnectivityv1/resource_network_connectivity_internal_range_generated_meta.yaml index e2063b66132..bd85167b55c 100644 --- a/google/services/networkconnectivityv1/resource_network_connectivity_internal_range_generated_meta.yaml +++ b/google/services/networkconnectivityv1/resource_network_connectivity_internal_range_generated_meta.yaml @@ -29,3 +29,5 @@ fields: provider_only: true - api_field: usage - api_field: users + - field: deletion_policy + provider_only: true diff --git a/google/services/networkconnectivityv1/resource_network_connectivity_service_connection_policy.go b/google/services/networkconnectivityv1/resource_network_connectivity_service_connection_policy.go index f5b24036604..24b96ddcee0 100644 --- a/google/services/networkconnectivityv1/resource_network_connectivity_service_connection_policy.go +++ b/google/services/networkconnectivityv1/resource_network_connectivity_service_connection_policy.go @@ -116,6 +116,7 @@ func ResourceNetworkConnectivityv1ServiceConnectionPolicy() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -371,6 +372,18 @@ facing or system internal. Possible values: ["CONNECTION_ERROR_TYPE_UNSPECIFIED" Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -538,6 +551,19 @@ func resourceNetworkConnectivityv1ServiceConnectionPolicyRead(d *schema.Resource log.Printf("[DEBUG] Finished reading NetworkConnectivityv1ServiceConnectionPolicy %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading ServiceConnectionPolicy: %s", err) } @@ -575,6 +601,19 @@ func resourceNetworkConnectivityv1ServiceConnectionPolicyRead(d *schema.Resource } func resourceNetworkConnectivityv1ServiceConnectionPolicyUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetworkConnectivityv1ServiceConnectionPolicy().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetworkConnectivityv1ServiceConnectionPolicyRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -708,6 +747,13 @@ func resourceNetworkConnectivityv1ServiceConnectionPolicyUpdate(d *schema.Resour } func resourceNetworkConnectivityv1ServiceConnectionPolicyDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkConnectivityv1ServiceConnectionPolicy without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ServiceConnectionPolicy %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/networkconnectivityv1/resource_network_connectivity_service_connection_policy_generated_meta.yaml b/google/services/networkconnectivityv1/resource_network_connectivity_service_connection_policy_generated_meta.yaml index 9900ef1cb75..16b49d3ea6c 100644 --- a/google/services/networkconnectivityv1/resource_network_connectivity_service_connection_policy_generated_meta.yaml +++ b/google/services/networkconnectivityv1/resource_network_connectivity_service_connection_policy_generated_meta.yaml @@ -40,3 +40,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/networkmanagement/data_source_network_management_connectivity_tests_test.go b/google/services/networkmanagement/data_source_network_management_connectivity_tests_test.go index 538d7f29499..9e233157b6a 100644 --- a/google/services/networkmanagement/data_source_network_management_connectivity_tests_test.go +++ b/google/services/networkmanagement/data_source_network_management_connectivity_tests_test.go @@ -50,6 +50,7 @@ func TestAccNetworkManagementConnectivityTests_basic(t *testing.T) { "project": {}, "terraform_labels.%": {}, "terraform_labels.goog-terraform-provisioned": {}, + "deletion_policy": {}, }, ), ), @@ -65,6 +66,7 @@ func TestAccNetworkManagementConnectivityTests_basic(t *testing.T) { "project": {}, "terraform_labels.%": {}, "terraform_labels.goog-terraform-provisioned": {}, + "deletion_policy": {}, }, ), ), diff --git a/google/services/networkmanagement/resource_network_management_connectivity_test_generated_meta.yaml b/google/services/networkmanagement/resource_network_management_connectivity_test_generated_meta.yaml index 661ef51cd25..23762bbcdd7 100644 --- a/google/services/networkmanagement/resource_network_management_connectivity_test_generated_meta.yaml +++ b/google/services/networkmanagement/resource_network_management_connectivity_test_generated_meta.yaml @@ -40,3 +40,5 @@ fields: - api_field: source.projectId - field: terraform_labels provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/networkmanagement/resource_network_management_connectivity_test_resource.go b/google/services/networkmanagement/resource_network_management_connectivity_test_resource.go index 3a98fcc16b7..6b16050a060 100644 --- a/google/services/networkmanagement/resource_network_management_connectivity_test_resource.go +++ b/google/services/networkmanagement/resource_network_management_connectivity_test_resource.go @@ -116,6 +116,7 @@ func ResourceNetworkManagementConnectivityTest() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -405,6 +406,18 @@ Default value is false.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -585,6 +598,19 @@ func resourceNetworkManagementConnectivityTestRead(d *schema.ResourceData, meta log.Printf("[DEBUG] Finished reading NetworkManagementConnectivityTest %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading ConnectivityTest: %s", err) } @@ -616,6 +642,19 @@ func resourceNetworkManagementConnectivityTestRead(d *schema.ResourceData, meta } func resourceNetworkManagementConnectivityTestUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetworkManagementConnectivityTest().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetworkManagementConnectivityTestRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -799,6 +838,13 @@ func resourceNetworkManagementConnectivityTestUpdate(d *schema.ResourceData, met } func resourceNetworkManagementConnectivityTestDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkManagementConnectivityTest without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ConnectivityTest %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/networkmanagement/resource_network_management_organization_vpc_flow_logs_config.go b/google/services/networkmanagement/resource_network_management_organization_vpc_flow_logs_config.go index cec524b1bdd..6a89b116135 100644 --- a/google/services/networkmanagement/resource_network_management_organization_vpc_flow_logs_config.go +++ b/google/services/networkmanagement/resource_network_management_organization_vpc_flow_logs_config.go @@ -115,6 +115,7 @@ func ResourceNetworkManagementOrganizationVpcFlowLogsConfig() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -263,6 +264,19 @@ Possible values: ENABLED DISABLED`, Computed: true, Description: `Output only. The time the config was updated.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -437,6 +451,20 @@ func resourceNetworkManagementOrganizationVpcFlowLogsConfigRead(d *schema.Resour log.Printf("[DEBUG] Finished reading NetworkManagementOrganizationVpcFlowLogsConfig %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceNetworkManagementOrganizationVpcFlowLogsConfigFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -470,6 +498,18 @@ func resourceNetworkManagementOrganizationVpcFlowLogsConfigRead(d *schema.Resour } func resourceNetworkManagementOrganizationVpcFlowLogsConfigUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetworkManagementOrganizationVpcFlowLogsConfig().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetworkManagementOrganizationVpcFlowLogsConfigRead(d, meta) + } var project string config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) @@ -643,6 +683,13 @@ func resourceNetworkManagementOrganizationVpcFlowLogsConfigUpdate(d *schema.Reso } func resourceNetworkManagementOrganizationVpcFlowLogsConfigDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkManagementOrganizationVpcFlowLogsConfig without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing OrganizationVpcFlowLogsConfig %q from Terraform state without deletion", d.Id()) + return nil + } var project string config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) diff --git a/google/services/networkmanagement/resource_network_management_organization_vpc_flow_logs_config_generated_meta.yaml b/google/services/networkmanagement/resource_network_management_organization_vpc_flow_logs_config_generated_meta.yaml index 76da14befc0..2e2686927f5 100644 --- a/google/services/networkmanagement/resource_network_management_organization_vpc_flow_logs_config_generated_meta.yaml +++ b/google/services/networkmanagement/resource_network_management_organization_vpc_flow_logs_config_generated_meta.yaml @@ -29,3 +29,5 @@ fields: - api_field: updateTime - field: vpc_flow_logs_config_id provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/networkmanagement/resource_network_management_vpc_flow_logs_config.go b/google/services/networkmanagement/resource_network_management_vpc_flow_logs_config.go index 19854858eac..96e932d59f3 100644 --- a/google/services/networkmanagement/resource_network_management_vpc_flow_logs_config.go +++ b/google/services/networkmanagement/resource_network_management_vpc_flow_logs_config.go @@ -116,6 +116,7 @@ func ResourceNetworkManagementVpcFlowLogsConfig() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -282,6 +283,18 @@ TARGET_RESOURCE_DOES_NOT_EXIST`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -485,6 +498,19 @@ func resourceNetworkManagementVpcFlowLogsConfigRead(d *schema.ResourceData, meta log.Printf("[DEBUG] Finished reading NetworkManagementVpcFlowLogsConfig %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading VpcFlowLogsConfig: %s", err) } @@ -522,6 +548,19 @@ func resourceNetworkManagementVpcFlowLogsConfigRead(d *schema.ResourceData, meta } func resourceNetworkManagementVpcFlowLogsConfigUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetworkManagementVpcFlowLogsConfig().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetworkManagementVpcFlowLogsConfigRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -730,6 +769,13 @@ func resourceNetworkManagementVpcFlowLogsConfigUpdate(d *schema.ResourceData, me } func resourceNetworkManagementVpcFlowLogsConfigDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkManagementVpcFlowLogsConfig without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing VpcFlowLogsConfig %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/networkmanagement/resource_network_management_vpc_flow_logs_config_generated_meta.yaml b/google/services/networkmanagement/resource_network_management_vpc_flow_logs_config_generated_meta.yaml index 8e88a9f9e51..c5d8d4a247d 100644 --- a/google/services/networkmanagement/resource_network_management_vpc_flow_logs_config_generated_meta.yaml +++ b/google/services/networkmanagement/resource_network_management_vpc_flow_logs_config_generated_meta.yaml @@ -31,3 +31,5 @@ fields: - field: vpc_flow_logs_config_id provider_only: true - api_field: vpnTunnel + - field: deletion_policy + provider_only: true diff --git a/google/services/networksecurity/resource_network_security_address_group.go b/google/services/networksecurity/resource_network_security_address_group.go index 3106942c6d1..d1f7a021078 100644 --- a/google/services/networksecurity/resource_network_security_address_group.go +++ b/google/services/networksecurity/resource_network_security_address_group.go @@ -115,6 +115,7 @@ func ResourceNetworkSecurityAddressGroup() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -221,6 +222,19 @@ Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z"`, A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -371,6 +385,20 @@ func resourceNetworkSecurityAddressGroupRead(d *schema.ResourceData, meta interf log.Printf("[DEBUG] Finished reading NetworkSecurityAddressGroup %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceNetworkSecurityAddressGroupFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -404,6 +432,18 @@ func resourceNetworkSecurityAddressGroupRead(d *schema.ResourceData, meta interf } func resourceNetworkSecurityAddressGroupUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetworkSecurityAddressGroup().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetworkSecurityAddressGroupRead(d, meta) + } var project string config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) @@ -527,6 +567,13 @@ func resourceNetworkSecurityAddressGroupUpdate(d *schema.ResourceData, meta inte } func resourceNetworkSecurityAddressGroupDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkSecurityAddressGroup without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing AddressGroup %q from Terraform state without deletion", d.Id()) + return nil + } var project string config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) diff --git a/google/services/networksecurity/resource_network_security_address_group_generated_meta.yaml b/google/services/networksecurity/resource_network_security_address_group_generated_meta.yaml index 2fa527c9a0a..ad3c209852b 100644 --- a/google/services/networksecurity/resource_network_security_address_group_generated_meta.yaml +++ b/google/services/networksecurity/resource_network_security_address_group_generated_meta.yaml @@ -24,3 +24,5 @@ fields: provider_only: true - api_field: type - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/networksecurity/resource_network_security_authz_policy.go b/google/services/networksecurity/resource_network_security_authz_policy.go index 11b9df5341f..6eb41983d3e 100644 --- a/google/services/networksecurity/resource_network_security_authz_policy.go +++ b/google/services/networksecurity/resource_network_security_authz_policy.go @@ -116,6 +116,7 @@ func ResourceNetworkSecurityAuthzPolicy() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -1139,6 +1140,18 @@ RESPONSE_HEADERS, RESPONSE_BODY, RESPONSE_TRAILERS) with FULL_DUPLEX_STREAMED bo Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -1318,6 +1331,19 @@ func resourceNetworkSecurityAuthzPolicyRead(d *schema.ResourceData, meta interfa log.Printf("[DEBUG] Finished reading NetworkSecurityAuthzPolicy %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading AuthzPolicy: %s", err) } @@ -1355,6 +1381,19 @@ func resourceNetworkSecurityAuthzPolicyRead(d *schema.ResourceData, meta interfa } func resourceNetworkSecurityAuthzPolicyUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetworkSecurityAuthzPolicy().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetworkSecurityAuthzPolicyRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1513,6 +1552,13 @@ func resourceNetworkSecurityAuthzPolicyUpdate(d *schema.ResourceData, meta inter } func resourceNetworkSecurityAuthzPolicyDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkSecurityAuthzPolicy without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing AuthzPolicy %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/networksecurity/resource_network_security_authz_policy_generated_meta.yaml b/google/services/networksecurity/resource_network_security_authz_policy_generated_meta.yaml index 59ce8fc029b..47ab24994c1 100644 --- a/google/services/networksecurity/resource_network_security_authz_policy_generated_meta.yaml +++ b/google/services/networksecurity/resource_network_security_authz_policy_generated_meta.yaml @@ -104,3 +104,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/networksecurity/resource_network_security_backend_authentication_config.go b/google/services/networksecurity/resource_network_security_backend_authentication_config.go index b7b990cd295..7b358f100fb 100644 --- a/google/services/networksecurity/resource_network_security_backend_authentication_config.go +++ b/google/services/networksecurity/resource_network_security_backend_authentication_config.go @@ -116,6 +116,7 @@ func ResourceNetworkSecurityBackendAuthenticationConfig() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -222,6 +223,18 @@ Validation with these roots is only considered when the TlsSettings.sni field in Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -383,6 +396,19 @@ func resourceNetworkSecurityBackendAuthenticationConfigRead(d *schema.ResourceDa log.Printf("[DEBUG] Finished reading NetworkSecurityBackendAuthenticationConfig %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading BackendAuthenticationConfig: %s", err) } @@ -420,6 +446,19 @@ func resourceNetworkSecurityBackendAuthenticationConfigRead(d *schema.ResourceDa } func resourceNetworkSecurityBackendAuthenticationConfigUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetworkSecurityBackendAuthenticationConfig().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetworkSecurityBackendAuthenticationConfigRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -538,6 +577,13 @@ func resourceNetworkSecurityBackendAuthenticationConfigUpdate(d *schema.Resource } func resourceNetworkSecurityBackendAuthenticationConfigDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkSecurityBackendAuthenticationConfig without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing BackendAuthenticationConfig %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/networksecurity/resource_network_security_backend_authentication_config_generated_meta.yaml b/google/services/networksecurity/resource_network_security_backend_authentication_config_generated_meta.yaml index 09dc6550db2..faf3484b918 100644 --- a/google/services/networksecurity/resource_network_security_backend_authentication_config_generated_meta.yaml +++ b/google/services/networksecurity/resource_network_security_backend_authentication_config_generated_meta.yaml @@ -22,3 +22,5 @@ fields: - api_field: trustConfig - api_field: updateTime - api_field: wellKnownRoots + - field: deletion_policy + provider_only: true diff --git a/google/services/networksecurity/resource_network_security_client_tls_policy.go b/google/services/networksecurity/resource_network_security_client_tls_policy.go index cbe7ffedcfc..19cc952e5c8 100644 --- a/google/services/networksecurity/resource_network_security_client_tls_policy.go +++ b/google/services/networksecurity/resource_network_security_client_tls_policy.go @@ -116,6 +116,7 @@ func ResourceNetworkSecurityClientTlsPolicy() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -286,6 +287,18 @@ The default value is 'global'.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -447,6 +460,19 @@ func resourceNetworkSecurityClientTlsPolicyRead(d *schema.ResourceData, meta int log.Printf("[DEBUG] Finished reading NetworkSecurityClientTlsPolicy %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading ClientTlsPolicy: %s", err) } @@ -484,6 +510,19 @@ func resourceNetworkSecurityClientTlsPolicyRead(d *schema.ResourceData, meta int } func resourceNetworkSecurityClientTlsPolicyUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetworkSecurityClientTlsPolicy().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetworkSecurityClientTlsPolicyRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -622,6 +661,13 @@ func resourceNetworkSecurityClientTlsPolicyUpdate(d *schema.ResourceData, meta i } func resourceNetworkSecurityClientTlsPolicyDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkSecurityClientTlsPolicy without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ClientTlsPolicy %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/networksecurity/resource_network_security_client_tls_policy_generated_meta.yaml b/google/services/networksecurity/resource_network_security_client_tls_policy_generated_meta.yaml index 5ee13dc0152..31a7dc21c33 100644 --- a/google/services/networksecurity/resource_network_security_client_tls_policy_generated_meta.yaml +++ b/google/services/networksecurity/resource_network_security_client_tls_policy_generated_meta.yaml @@ -24,3 +24,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/networksecurity/resource_network_security_dns_threat_detector.go b/google/services/networksecurity/resource_network_security_dns_threat_detector.go index 5c6995e32ee..0d6511577e7 100644 --- a/google/services/networksecurity/resource_network_security_dns_threat_detector.go +++ b/google/services/networksecurity/resource_network_security_dns_threat_detector.go @@ -116,6 +116,7 @@ func ResourceNetworkSecurityDnsThreatDetector() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -213,6 +214,18 @@ Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -358,6 +371,19 @@ func resourceNetworkSecurityDnsThreatDetectorRead(d *schema.ResourceData, meta i log.Printf("[DEBUG] Finished reading NetworkSecurityDnsThreatDetector %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading DnsThreatDetector: %s", err) } @@ -395,6 +421,19 @@ func resourceNetworkSecurityDnsThreatDetectorRead(d *schema.ResourceData, meta i } func resourceNetworkSecurityDnsThreatDetectorUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetworkSecurityDnsThreatDetector().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetworkSecurityDnsThreatDetectorRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -496,6 +535,13 @@ func resourceNetworkSecurityDnsThreatDetectorUpdate(d *schema.ResourceData, meta } func resourceNetworkSecurityDnsThreatDetectorDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkSecurityDnsThreatDetector without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing DnsThreatDetector %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/networksecurity/resource_network_security_dns_threat_detector_generated_meta.yaml b/google/services/networksecurity/resource_network_security_dns_threat_detector_generated_meta.yaml index d56e06c3ca4..d00d97436f9 100644 --- a/google/services/networksecurity/resource_network_security_dns_threat_detector_generated_meta.yaml +++ b/google/services/networksecurity/resource_network_security_dns_threat_detector_generated_meta.yaml @@ -20,3 +20,5 @@ fields: - api_field: provider field: threat_detector_provider - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/networksecurity/resource_network_security_firewall_endpoint.go b/google/services/networksecurity/resource_network_security_firewall_endpoint.go index 9318849d589..c11662db7ff 100644 --- a/google/services/networksecurity/resource_network_security_firewall_endpoint.go +++ b/google/services/networksecurity/resource_network_security_firewall_endpoint.go @@ -115,6 +115,7 @@ func ResourceNetworkSecurityFirewallEndpoint() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -244,6 +245,19 @@ fully configured. Format: projects/{project}/global/networks/{name}.`, Computed: true, Description: `Time the firewall endpoint was updated in UTC.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -382,6 +396,20 @@ func resourceNetworkSecurityFirewallEndpointRead(d *schema.ResourceData, meta in log.Printf("[DEBUG] Finished reading NetworkSecurityFirewallEndpoint %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceNetworkSecurityFirewallEndpointFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -415,6 +443,18 @@ func resourceNetworkSecurityFirewallEndpointRead(d *schema.ResourceData, meta in } func resourceNetworkSecurityFirewallEndpointUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetworkSecurityFirewallEndpoint().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetworkSecurityFirewallEndpointRead(d, meta) + } var project string config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) @@ -528,6 +568,13 @@ func resourceNetworkSecurityFirewallEndpointUpdate(d *schema.ResourceData, meta } func resourceNetworkSecurityFirewallEndpointDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkSecurityFirewallEndpoint without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing FirewallEndpoint %q from Terraform state without deletion", d.Id()) + return nil + } var project string config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) diff --git a/google/services/networksecurity/resource_network_security_firewall_endpoint_association.go b/google/services/networksecurity/resource_network_security_firewall_endpoint_association.go index 7f59985ce80..0e95ce18f2c 100644 --- a/google/services/networksecurity/resource_network_security_firewall_endpoint_association.go +++ b/google/services/networksecurity/resource_network_security_firewall_endpoint_association.go @@ -115,6 +115,7 @@ func ResourceNetworkSecurityFirewallEndpointAssociation() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -232,6 +233,19 @@ Format: projects/{project_id}.`, Computed: true, Description: `Time the firewall endpoint was updated in UTC.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -382,6 +396,20 @@ func resourceNetworkSecurityFirewallEndpointAssociationRead(d *schema.ResourceDa log.Printf("[DEBUG] Finished reading NetworkSecurityFirewallEndpointAssociation %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceNetworkSecurityFirewallEndpointAssociationFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -415,6 +443,18 @@ func resourceNetworkSecurityFirewallEndpointAssociationRead(d *schema.ResourceDa } func resourceNetworkSecurityFirewallEndpointAssociationUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetworkSecurityFirewallEndpointAssociation().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetworkSecurityFirewallEndpointAssociationRead(d, meta) + } var project string config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) @@ -548,6 +588,13 @@ func resourceNetworkSecurityFirewallEndpointAssociationUpdate(d *schema.Resource } func resourceNetworkSecurityFirewallEndpointAssociationDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkSecurityFirewallEndpointAssociation without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing FirewallEndpointAssociation %q from Terraform state without deletion", d.Id()) + return nil + } var project string config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) diff --git a/google/services/networksecurity/resource_network_security_firewall_endpoint_association_generated_meta.yaml b/google/services/networksecurity/resource_network_security_firewall_endpoint_association_generated_meta.yaml index b038be93024..c488a7a64fd 100644 --- a/google/services/networksecurity/resource_network_security_firewall_endpoint_association_generated_meta.yaml +++ b/google/services/networksecurity/resource_network_security_firewall_endpoint_association_generated_meta.yaml @@ -27,3 +27,5 @@ fields: provider_only: true - api_field: tlsInspectionPolicy - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/networksecurity/resource_network_security_firewall_endpoint_generated_meta.yaml b/google/services/networksecurity/resource_network_security_firewall_endpoint_generated_meta.yaml index acc7ae06ab6..57e9b952f31 100644 --- a/google/services/networksecurity/resource_network_security_firewall_endpoint_generated_meta.yaml +++ b/google/services/networksecurity/resource_network_security_firewall_endpoint_generated_meta.yaml @@ -26,3 +26,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/networksecurity/resource_network_security_gateway_security_policy.go b/google/services/networksecurity/resource_network_security_gateway_security_policy.go index 15090b046f2..a91b811e26a 100644 --- a/google/services/networksecurity/resource_network_security_gateway_security_policy.go +++ b/google/services/networksecurity/resource_network_security_gateway_security_policy.go @@ -115,6 +115,7 @@ func ResourceNetworkSecurityGatewaySecurityPolicy() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -189,6 +190,18 @@ Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -332,6 +345,19 @@ func resourceNetworkSecurityGatewaySecurityPolicyRead(d *schema.ResourceData, me log.Printf("[DEBUG] Finished reading NetworkSecurityGatewaySecurityPolicy %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading GatewaySecurityPolicy: %s", err) } @@ -369,6 +395,19 @@ func resourceNetworkSecurityGatewaySecurityPolicyRead(d *schema.ResourceData, me } func resourceNetworkSecurityGatewaySecurityPolicyUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetworkSecurityGatewaySecurityPolicy().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetworkSecurityGatewaySecurityPolicyRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -477,6 +516,13 @@ func resourceNetworkSecurityGatewaySecurityPolicyUpdate(d *schema.ResourceData, } func resourceNetworkSecurityGatewaySecurityPolicyDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkSecurityGatewaySecurityPolicy without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing GatewaySecurityPolicy %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/networksecurity/resource_network_security_gateway_security_policy_generated_meta.yaml b/google/services/networksecurity/resource_network_security_gateway_security_policy_generated_meta.yaml index 43e712aa232..87f8c0a68e5 100644 --- a/google/services/networksecurity/resource_network_security_gateway_security_policy_generated_meta.yaml +++ b/google/services/networksecurity/resource_network_security_gateway_security_policy_generated_meta.yaml @@ -16,3 +16,5 @@ fields: - api_field: selfLink - api_field: tlsInspectionPolicy - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/networksecurity/resource_network_security_gateway_security_policy_rule.go b/google/services/networksecurity/resource_network_security_gateway_security_policy_rule.go index cf66617e5d2..1b40b131ead 100644 --- a/google/services/networksecurity/resource_network_security_gateway_security_policy_rule.go +++ b/google/services/networksecurity/resource_network_security_gateway_security_policy_rule.go @@ -115,6 +115,7 @@ func ResourceNetworkSecurityGatewaySecurityPolicyRule() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -226,6 +227,18 @@ Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -411,6 +424,19 @@ func resourceNetworkSecurityGatewaySecurityPolicyRuleRead(d *schema.ResourceData log.Printf("[DEBUG] Finished reading NetworkSecurityGatewaySecurityPolicyRule %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading GatewaySecurityPolicyRule: %s", err) } @@ -454,6 +480,19 @@ func resourceNetworkSecurityGatewaySecurityPolicyRuleRead(d *schema.ResourceData } func resourceNetworkSecurityGatewaySecurityPolicyRuleUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetworkSecurityGatewaySecurityPolicyRule().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetworkSecurityGatewaySecurityPolicyRuleRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -624,6 +663,13 @@ func resourceNetworkSecurityGatewaySecurityPolicyRuleUpdate(d *schema.ResourceDa } func resourceNetworkSecurityGatewaySecurityPolicyRuleDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkSecurityGatewaySecurityPolicyRule without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing GatewaySecurityPolicyRule %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/networksecurity/resource_network_security_gateway_security_policy_rule_generated_meta.yaml b/google/services/networksecurity/resource_network_security_gateway_security_policy_rule_generated_meta.yaml index 66c2b39f58b..1782e3eb187 100644 --- a/google/services/networksecurity/resource_network_security_gateway_security_policy_rule_generated_meta.yaml +++ b/google/services/networksecurity/resource_network_security_gateway_security_policy_rule_generated_meta.yaml @@ -23,3 +23,5 @@ fields: - api_field: sessionMatcher - api_field: tlsInspectionEnabled - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/networksecurity/resource_network_security_intercept_deployment.go b/google/services/networksecurity/resource_network_security_intercept_deployment.go index e076c75b37d..112ff25d088 100644 --- a/google/services/networksecurity/resource_network_security_intercept_deployment.go +++ b/google/services/networksecurity/resource_network_security_intercept_deployment.go @@ -116,6 +116,7 @@ func ResourceNetworkSecurityInterceptDeployment() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -245,6 +246,18 @@ See https://google.aip.dev/148#timestamps.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -400,6 +413,19 @@ func resourceNetworkSecurityInterceptDeploymentRead(d *schema.ResourceData, meta log.Printf("[DEBUG] Finished reading NetworkSecurityInterceptDeployment %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading InterceptDeployment: %s", err) } @@ -437,6 +463,19 @@ func resourceNetworkSecurityInterceptDeploymentRead(d *schema.ResourceData, meta } func resourceNetworkSecurityInterceptDeploymentUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetworkSecurityInterceptDeployment().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetworkSecurityInterceptDeploymentRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -545,6 +584,13 @@ func resourceNetworkSecurityInterceptDeploymentUpdate(d *schema.ResourceData, me } func resourceNetworkSecurityInterceptDeploymentDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkSecurityInterceptDeployment without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing InterceptDeployment %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/networksecurity/resource_network_security_intercept_deployment_generated_meta.yaml b/google/services/networksecurity/resource_network_security_intercept_deployment_generated_meta.yaml index 368df10b24e..9476977bb0e 100644 --- a/google/services/networksecurity/resource_network_security_intercept_deployment_generated_meta.yaml +++ b/google/services/networksecurity/resource_network_security_intercept_deployment_generated_meta.yaml @@ -24,3 +24,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/networksecurity/resource_network_security_intercept_deployment_group.go b/google/services/networksecurity/resource_network_security_intercept_deployment_group.go index c1320cfde40..a4045d0e78e 100644 --- a/google/services/networksecurity/resource_network_security_intercept_deployment_group.go +++ b/google/services/networksecurity/resource_network_security_intercept_deployment_group.go @@ -116,6 +116,7 @@ func ResourceNetworkSecurityInterceptDeploymentGroup() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -258,6 +259,18 @@ See https://google.aip.dev/148#timestamps.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -428,6 +441,19 @@ func resourceNetworkSecurityInterceptDeploymentGroupRead(d *schema.ResourceData, log.Printf("[DEBUG] Finished reading NetworkSecurityInterceptDeploymentGroup %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading InterceptDeploymentGroup: %s", err) } @@ -465,6 +491,19 @@ func resourceNetworkSecurityInterceptDeploymentGroupRead(d *schema.ResourceData, } func resourceNetworkSecurityInterceptDeploymentGroupUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetworkSecurityInterceptDeploymentGroup().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetworkSecurityInterceptDeploymentGroupRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -573,6 +612,13 @@ func resourceNetworkSecurityInterceptDeploymentGroupUpdate(d *schema.ResourceDat } func resourceNetworkSecurityInterceptDeploymentGroupDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkSecurityInterceptDeploymentGroup without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing InterceptDeploymentGroup %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/networksecurity/resource_network_security_intercept_deployment_group_generated_meta.yaml b/google/services/networksecurity/resource_network_security_intercept_deployment_group_generated_meta.yaml index c892baec3d5..3d7a4dbc1e7 100644 --- a/google/services/networksecurity/resource_network_security_intercept_deployment_group_generated_meta.yaml +++ b/google/services/networksecurity/resource_network_security_intercept_deployment_group_generated_meta.yaml @@ -26,3 +26,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/networksecurity/resource_network_security_intercept_endpoint_group.go b/google/services/networksecurity/resource_network_security_intercept_endpoint_group.go index 76d63e94308..033e003fa57 100644 --- a/google/services/networksecurity/resource_network_security_intercept_endpoint_group.go +++ b/google/services/networksecurity/resource_network_security_intercept_endpoint_group.go @@ -116,6 +116,7 @@ func ResourceNetworkSecurityInterceptEndpointGroup() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -268,6 +269,18 @@ See https://google.aip.dev/148#timestamps.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -472,6 +485,19 @@ func resourceNetworkSecurityInterceptEndpointGroupRead(d *schema.ResourceData, m log.Printf("[DEBUG] Finished reading NetworkSecurityInterceptEndpointGroup %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading InterceptEndpointGroup: %s", err) } @@ -509,6 +535,19 @@ func resourceNetworkSecurityInterceptEndpointGroupRead(d *schema.ResourceData, m } func resourceNetworkSecurityInterceptEndpointGroupUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetworkSecurityInterceptEndpointGroup().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetworkSecurityInterceptEndpointGroupRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -617,6 +656,13 @@ func resourceNetworkSecurityInterceptEndpointGroupUpdate(d *schema.ResourceData, } func resourceNetworkSecurityInterceptEndpointGroupDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkSecurityInterceptEndpointGroup without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing InterceptEndpointGroup %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/networksecurity/resource_network_security_intercept_endpoint_group_association.go b/google/services/networksecurity/resource_network_security_intercept_endpoint_group_association.go index 3a06a219249..06a82076eff 100644 --- a/google/services/networksecurity/resource_network_security_intercept_endpoint_group_association.go +++ b/google/services/networksecurity/resource_network_security_intercept_endpoint_group_association.go @@ -116,6 +116,7 @@ func ResourceNetworkSecurityInterceptEndpointGroupAssociation() *schema.Resource CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -274,6 +275,18 @@ See https://google.aip.dev/148#timestamps.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -444,6 +457,19 @@ func resourceNetworkSecurityInterceptEndpointGroupAssociationRead(d *schema.Reso log.Printf("[DEBUG] Finished reading NetworkSecurityInterceptEndpointGroupAssociation %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading InterceptEndpointGroupAssociation: %s", err) } @@ -481,6 +507,19 @@ func resourceNetworkSecurityInterceptEndpointGroupAssociationRead(d *schema.Reso } func resourceNetworkSecurityInterceptEndpointGroupAssociationUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetworkSecurityInterceptEndpointGroupAssociation().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetworkSecurityInterceptEndpointGroupAssociationRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -579,6 +618,13 @@ func resourceNetworkSecurityInterceptEndpointGroupAssociationUpdate(d *schema.Re } func resourceNetworkSecurityInterceptEndpointGroupAssociationDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkSecurityInterceptEndpointGroupAssociation without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing InterceptEndpointGroupAssociation %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/networksecurity/resource_network_security_intercept_endpoint_group_association_generated_meta.yaml b/google/services/networksecurity/resource_network_security_intercept_endpoint_group_association_generated_meta.yaml index aacf142ae99..517622f3510 100644 --- a/google/services/networksecurity/resource_network_security_intercept_endpoint_group_association_generated_meta.yaml +++ b/google/services/networksecurity/resource_network_security_intercept_endpoint_group_association_generated_meta.yaml @@ -27,3 +27,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/networksecurity/resource_network_security_intercept_endpoint_group_generated_meta.yaml b/google/services/networksecurity/resource_network_security_intercept_endpoint_group_generated_meta.yaml index 0048f3d5de8..b89c57df6f3 100644 --- a/google/services/networksecurity/resource_network_security_intercept_endpoint_group_generated_meta.yaml +++ b/google/services/networksecurity/resource_network_security_intercept_endpoint_group_generated_meta.yaml @@ -29,3 +29,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/networksecurity/resource_network_security_mirroring_deployment.go b/google/services/networksecurity/resource_network_security_mirroring_deployment.go index 6c63b87cc69..db4e5c4e0df 100644 --- a/google/services/networksecurity/resource_network_security_mirroring_deployment.go +++ b/google/services/networksecurity/resource_network_security_mirroring_deployment.go @@ -116,6 +116,7 @@ func ResourceNetworkSecurityMirroringDeployment() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -245,6 +246,18 @@ See https://google.aip.dev/148#timestamps.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -400,6 +413,19 @@ func resourceNetworkSecurityMirroringDeploymentRead(d *schema.ResourceData, meta log.Printf("[DEBUG] Finished reading NetworkSecurityMirroringDeployment %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading MirroringDeployment: %s", err) } @@ -437,6 +463,19 @@ func resourceNetworkSecurityMirroringDeploymentRead(d *schema.ResourceData, meta } func resourceNetworkSecurityMirroringDeploymentUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetworkSecurityMirroringDeployment().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetworkSecurityMirroringDeploymentRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -545,6 +584,13 @@ func resourceNetworkSecurityMirroringDeploymentUpdate(d *schema.ResourceData, me } func resourceNetworkSecurityMirroringDeploymentDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkSecurityMirroringDeployment without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing MirroringDeployment %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/networksecurity/resource_network_security_mirroring_deployment_generated_meta.yaml b/google/services/networksecurity/resource_network_security_mirroring_deployment_generated_meta.yaml index 04b8d05d417..a7be6ca8bc2 100644 --- a/google/services/networksecurity/resource_network_security_mirroring_deployment_generated_meta.yaml +++ b/google/services/networksecurity/resource_network_security_mirroring_deployment_generated_meta.yaml @@ -24,3 +24,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/networksecurity/resource_network_security_mirroring_deployment_group.go b/google/services/networksecurity/resource_network_security_mirroring_deployment_group.go index 7c6076bbd46..564cd80e994 100644 --- a/google/services/networksecurity/resource_network_security_mirroring_deployment_group.go +++ b/google/services/networksecurity/resource_network_security_mirroring_deployment_group.go @@ -116,6 +116,7 @@ func ResourceNetworkSecurityMirroringDeploymentGroup() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -258,6 +259,18 @@ See https://google.aip.dev/148#timestamps.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -428,6 +441,19 @@ func resourceNetworkSecurityMirroringDeploymentGroupRead(d *schema.ResourceData, log.Printf("[DEBUG] Finished reading NetworkSecurityMirroringDeploymentGroup %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading MirroringDeploymentGroup: %s", err) } @@ -465,6 +491,19 @@ func resourceNetworkSecurityMirroringDeploymentGroupRead(d *schema.ResourceData, } func resourceNetworkSecurityMirroringDeploymentGroupUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetworkSecurityMirroringDeploymentGroup().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetworkSecurityMirroringDeploymentGroupRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -573,6 +612,13 @@ func resourceNetworkSecurityMirroringDeploymentGroupUpdate(d *schema.ResourceDat } func resourceNetworkSecurityMirroringDeploymentGroupDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkSecurityMirroringDeploymentGroup without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing MirroringDeploymentGroup %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/networksecurity/resource_network_security_mirroring_deployment_group_generated_meta.yaml b/google/services/networksecurity/resource_network_security_mirroring_deployment_group_generated_meta.yaml index 1dda564b362..aa4e06fe2ed 100644 --- a/google/services/networksecurity/resource_network_security_mirroring_deployment_group_generated_meta.yaml +++ b/google/services/networksecurity/resource_network_security_mirroring_deployment_group_generated_meta.yaml @@ -26,3 +26,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/networksecurity/resource_network_security_mirroring_endpoint.go b/google/services/networksecurity/resource_network_security_mirroring_endpoint.go index 41198a12b13..e64ee30b1ef 100644 --- a/google/services/networksecurity/resource_network_security_mirroring_endpoint.go +++ b/google/services/networksecurity/resource_network_security_mirroring_endpoint.go @@ -116,6 +116,7 @@ func ResourceNetworkSecurityMirroringEndpoint() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -237,6 +238,18 @@ See https://google.aip.dev/148#timestamps.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -386,6 +399,19 @@ func resourceNetworkSecurityMirroringEndpointRead(d *schema.ResourceData, meta i log.Printf("[DEBUG] Finished reading NetworkSecurityMirroringEndpoint %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading MirroringEndpoint: %s", err) } @@ -423,6 +449,19 @@ func resourceNetworkSecurityMirroringEndpointRead(d *schema.ResourceData, meta i } func resourceNetworkSecurityMirroringEndpointUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetworkSecurityMirroringEndpoint().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetworkSecurityMirroringEndpointRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -531,6 +570,13 @@ func resourceNetworkSecurityMirroringEndpointUpdate(d *schema.ResourceData, meta } func resourceNetworkSecurityMirroringEndpointDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkSecurityMirroringEndpoint without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing MirroringEndpoint %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/networksecurity/resource_network_security_mirroring_endpoint_generated_meta.yaml b/google/services/networksecurity/resource_network_security_mirroring_endpoint_generated_meta.yaml index ecd6dc43f63..83fa5fdb58d 100644 --- a/google/services/networksecurity/resource_network_security_mirroring_endpoint_generated_meta.yaml +++ b/google/services/networksecurity/resource_network_security_mirroring_endpoint_generated_meta.yaml @@ -23,3 +23,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/networksecurity/resource_network_security_mirroring_endpoint_group.go b/google/services/networksecurity/resource_network_security_mirroring_endpoint_group.go index 4240c1a6bfe..3c236a50f71 100644 --- a/google/services/networksecurity/resource_network_security_mirroring_endpoint_group.go +++ b/google/services/networksecurity/resource_network_security_mirroring_endpoint_group.go @@ -116,6 +116,7 @@ func ResourceNetworkSecurityMirroringEndpointGroup() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -278,6 +279,18 @@ See https://google.aip.dev/148#timestamps.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -515,6 +528,19 @@ func resourceNetworkSecurityMirroringEndpointGroupRead(d *schema.ResourceData, m log.Printf("[DEBUG] Finished reading NetworkSecurityMirroringEndpointGroup %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading MirroringEndpointGroup: %s", err) } @@ -552,6 +578,19 @@ func resourceNetworkSecurityMirroringEndpointGroupRead(d *schema.ResourceData, m } func resourceNetworkSecurityMirroringEndpointGroupUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetworkSecurityMirroringEndpointGroup().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetworkSecurityMirroringEndpointGroupRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -660,6 +699,13 @@ func resourceNetworkSecurityMirroringEndpointGroupUpdate(d *schema.ResourceData, } func resourceNetworkSecurityMirroringEndpointGroupDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkSecurityMirroringEndpointGroup without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing MirroringEndpointGroup %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/networksecurity/resource_network_security_mirroring_endpoint_group_association.go b/google/services/networksecurity/resource_network_security_mirroring_endpoint_group_association.go index 9129ff5712a..08e7fafffbf 100644 --- a/google/services/networksecurity/resource_network_security_mirroring_endpoint_group_association.go +++ b/google/services/networksecurity/resource_network_security_mirroring_endpoint_group_association.go @@ -116,6 +116,7 @@ func ResourceNetworkSecurityMirroringEndpointGroupAssociation() *schema.Resource CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -274,6 +275,18 @@ See https://google.aip.dev/148#timestamps.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -444,6 +457,19 @@ func resourceNetworkSecurityMirroringEndpointGroupAssociationRead(d *schema.Reso log.Printf("[DEBUG] Finished reading NetworkSecurityMirroringEndpointGroupAssociation %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading MirroringEndpointGroupAssociation: %s", err) } @@ -481,6 +507,19 @@ func resourceNetworkSecurityMirroringEndpointGroupAssociationRead(d *schema.Reso } func resourceNetworkSecurityMirroringEndpointGroupAssociationUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetworkSecurityMirroringEndpointGroupAssociation().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetworkSecurityMirroringEndpointGroupAssociationRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -579,6 +618,13 @@ func resourceNetworkSecurityMirroringEndpointGroupAssociationUpdate(d *schema.Re } func resourceNetworkSecurityMirroringEndpointGroupAssociationDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkSecurityMirroringEndpointGroupAssociation without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing MirroringEndpointGroupAssociation %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/networksecurity/resource_network_security_mirroring_endpoint_group_association_generated_meta.yaml b/google/services/networksecurity/resource_network_security_mirroring_endpoint_group_association_generated_meta.yaml index a5119c0a8a2..73340ee008b 100644 --- a/google/services/networksecurity/resource_network_security_mirroring_endpoint_group_association_generated_meta.yaml +++ b/google/services/networksecurity/resource_network_security_mirroring_endpoint_group_association_generated_meta.yaml @@ -27,3 +27,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/networksecurity/resource_network_security_mirroring_endpoint_group_generated_meta.yaml b/google/services/networksecurity/resource_network_security_mirroring_endpoint_group_generated_meta.yaml index f343d81da4f..3ded622a9cb 100644 --- a/google/services/networksecurity/resource_network_security_mirroring_endpoint_group_generated_meta.yaml +++ b/google/services/networksecurity/resource_network_security_mirroring_endpoint_group_generated_meta.yaml @@ -31,3 +31,5 @@ fields: provider_only: true - api_field: type - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/networksecurity/resource_network_security_security_profile.go b/google/services/networksecurity/resource_network_security_security_profile.go index 321730e8354..a117f679602 100644 --- a/google/services/networksecurity/resource_network_security_security_profile.go +++ b/google/services/networksecurity/resource_network_security_security_profile.go @@ -115,6 +115,7 @@ func ResourceNetworkSecuritySecurityProfile() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -330,6 +331,19 @@ value before proceeding.`, Computed: true, Description: `Time the security profile was updated in UTC.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -582,6 +596,20 @@ func resourceNetworkSecuritySecurityProfileRead(d *schema.ResourceData, meta int log.Printf("[DEBUG] Finished reading NetworkSecuritySecurityProfile %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceNetworkSecuritySecurityProfileFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -615,6 +643,18 @@ func resourceNetworkSecuritySecurityProfileRead(d *schema.ResourceData, meta int } func resourceNetworkSecuritySecurityProfileUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetworkSecuritySecurityProfile().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetworkSecuritySecurityProfileRead(d, meta) + } var project string config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) @@ -758,6 +798,13 @@ func resourceNetworkSecuritySecurityProfileUpdate(d *schema.ResourceData, meta i } func resourceNetworkSecuritySecurityProfileDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkSecuritySecurityProfile without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing SecurityProfile %q from Terraform state without deletion", d.Id()) + return nil + } var project string config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) diff --git a/google/services/networksecurity/resource_network_security_security_profile_generated_meta.yaml b/google/services/networksecurity/resource_network_security_security_profile_generated_meta.yaml index f0314c1c8c9..b010e6b45c8 100644 --- a/google/services/networksecurity/resource_network_security_security_profile_generated_meta.yaml +++ b/google/services/networksecurity/resource_network_security_security_profile_generated_meta.yaml @@ -38,3 +38,5 @@ fields: - api_field: urlFilteringProfile.urlFilters.filteringAction - api_field: urlFilteringProfile.urlFilters.priority - api_field: urlFilteringProfile.urlFilters.urls + - field: deletion_policy + provider_only: true diff --git a/google/services/networksecurity/resource_network_security_security_profile_group.go b/google/services/networksecurity/resource_network_security_security_profile_group.go index 33c13980572..364817b2119 100644 --- a/google/services/networksecurity/resource_network_security_security_profile_group.go +++ b/google/services/networksecurity/resource_network_security_security_profile_group.go @@ -115,6 +115,7 @@ func ResourceNetworkSecuritySecurityProfileGroup() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -227,6 +228,19 @@ value before proceeding.`, Computed: true, Description: `Time the security profile group was updated in UTC.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -383,6 +397,20 @@ func resourceNetworkSecuritySecurityProfileGroupRead(d *schema.ResourceData, met log.Printf("[DEBUG] Finished reading NetworkSecuritySecurityProfileGroup %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceNetworkSecuritySecurityProfileGroupFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -416,6 +444,18 @@ func resourceNetworkSecuritySecurityProfileGroupRead(d *schema.ResourceData, met } func resourceNetworkSecuritySecurityProfileGroupUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetworkSecuritySecurityProfileGroup().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetworkSecuritySecurityProfileGroupRead(d, meta) + } var project string config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) @@ -559,6 +599,13 @@ func resourceNetworkSecuritySecurityProfileGroupUpdate(d *schema.ResourceData, m } func resourceNetworkSecuritySecurityProfileGroupDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkSecuritySecurityProfileGroup without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing SecurityProfileGroup %q from Terraform state without deletion", d.Id()) + return nil + } var project string config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) diff --git a/google/services/networksecurity/resource_network_security_security_profile_group_generated_meta.yaml b/google/services/networksecurity/resource_network_security_security_profile_group_generated_meta.yaml index 1751df84452..56e4240df2a 100644 --- a/google/services/networksecurity/resource_network_security_security_profile_group_generated_meta.yaml +++ b/google/services/networksecurity/resource_network_security_security_profile_group_generated_meta.yaml @@ -26,3 +26,5 @@ fields: - api_field: threatPreventionProfile - api_field: updateTime - api_field: urlFilteringProfile + - field: deletion_policy + provider_only: true diff --git a/google/services/networksecurity/resource_network_security_server_tls_policy.go b/google/services/networksecurity/resource_network_security_server_tls_policy.go index 0c01340a85b..339fa5546fb 100644 --- a/google/services/networksecurity/resource_network_security_server_tls_policy.go +++ b/google/services/networksecurity/resource_network_security_server_tls_policy.go @@ -116,6 +116,7 @@ func ResourceNetworkSecurityServerTlsPolicy() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -318,6 +319,18 @@ Defines a mechanism to provision server identity (public and private keys). Cann Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -479,6 +492,19 @@ func resourceNetworkSecurityServerTlsPolicyRead(d *schema.ResourceData, meta int log.Printf("[DEBUG] Finished reading NetworkSecurityServerTlsPolicy %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading ServerTlsPolicy: %s", err) } @@ -516,6 +542,19 @@ func resourceNetworkSecurityServerTlsPolicyRead(d *schema.ResourceData, meta int } func resourceNetworkSecurityServerTlsPolicyUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetworkSecurityServerTlsPolicy().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetworkSecurityServerTlsPolicyRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -654,6 +693,13 @@ func resourceNetworkSecurityServerTlsPolicyUpdate(d *schema.ResourceData, meta i } func resourceNetworkSecurityServerTlsPolicyDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkSecurityServerTlsPolicy without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ServerTlsPolicy %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/networksecurity/resource_network_security_server_tls_policy_generated_meta.yaml b/google/services/networksecurity/resource_network_security_server_tls_policy_generated_meta.yaml index 34147a636f3..76055d581c6 100644 --- a/google/services/networksecurity/resource_network_security_server_tls_policy_generated_meta.yaml +++ b/google/services/networksecurity/resource_network_security_server_tls_policy_generated_meta.yaml @@ -26,3 +26,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/networksecurity/resource_network_security_tls_inspection_policy.go b/google/services/networksecurity/resource_network_security_tls_inspection_policy.go index 37851e590bf..4540817a3e0 100644 --- a/google/services/networksecurity/resource_network_security_tls_inspection_policy.go +++ b/google/services/networksecurity/resource_network_security_tls_inspection_policy.go @@ -115,6 +115,7 @@ func ResourceNetworkSecurityTlsInspectionPolicy() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -210,6 +211,18 @@ func ResourceNetworkSecurityTlsInspectionPolicy() *schema.Resource { Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -383,6 +396,19 @@ func resourceNetworkSecurityTlsInspectionPolicyRead(d *schema.ResourceData, meta log.Printf("[DEBUG] Finished reading NetworkSecurityTlsInspectionPolicy %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading TlsInspectionPolicy: %s", err) } @@ -420,6 +446,19 @@ func resourceNetworkSecurityTlsInspectionPolicyRead(d *schema.ResourceData, meta } func resourceNetworkSecurityTlsInspectionPolicyUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetworkSecurityTlsInspectionPolicy().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetworkSecurityTlsInspectionPolicyRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -578,6 +617,13 @@ func resourceNetworkSecurityTlsInspectionPolicyUpdate(d *schema.ResourceData, me } func resourceNetworkSecurityTlsInspectionPolicyDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkSecurityTlsInspectionPolicy without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing TlsInspectionPolicy %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/networksecurity/resource_network_security_tls_inspection_policy_generated_meta.yaml b/google/services/networksecurity/resource_network_security_tls_inspection_policy_generated_meta.yaml index 3f9427cd1f3..080bbd16b3d 100644 --- a/google/services/networksecurity/resource_network_security_tls_inspection_policy_generated_meta.yaml +++ b/google/services/networksecurity/resource_network_security_tls_inspection_policy_generated_meta.yaml @@ -20,3 +20,5 @@ fields: - api_field: tlsFeatureProfile - api_field: trustConfig - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/networksecurity/resource_network_security_url_lists.go b/google/services/networksecurity/resource_network_security_url_lists.go index 8c2ad450322..e01405e682b 100644 --- a/google/services/networksecurity/resource_network_security_url_lists.go +++ b/google/services/networksecurity/resource_network_security_url_lists.go @@ -115,6 +115,7 @@ func ResourceNetworkSecurityUrlLists() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -185,6 +186,18 @@ Examples: '2014-10-02T15:01:23Z' and '2014-10-02T15:01:23.045123456Z'.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -328,6 +341,19 @@ func resourceNetworkSecurityUrlListsRead(d *schema.ResourceData, meta interface{ log.Printf("[DEBUG] Finished reading NetworkSecurityUrlLists %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading UrlLists: %s", err) } @@ -365,6 +391,19 @@ func resourceNetworkSecurityUrlListsRead(d *schema.ResourceData, meta interface{ } func resourceNetworkSecurityUrlListsUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetworkSecurityUrlLists().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetworkSecurityUrlListsRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -473,6 +512,13 @@ func resourceNetworkSecurityUrlListsUpdate(d *schema.ResourceData, meta interfac } func resourceNetworkSecurityUrlListsDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkSecurityUrlLists without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing UrlLists %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/networksecurity/resource_network_security_url_lists_generated_meta.yaml b/google/services/networksecurity/resource_network_security_url_lists_generated_meta.yaml index a29cabd766d..c88e2d47dce 100644 --- a/google/services/networksecurity/resource_network_security_url_lists_generated_meta.yaml +++ b/google/services/networksecurity/resource_network_security_url_lists_generated_meta.yaml @@ -15,3 +15,5 @@ fields: provider_only: true - api_field: updateTime - api_field: values + - field: deletion_policy + provider_only: true diff --git a/google/services/networkservices/resource_network_services_authz_extension.go b/google/services/networkservices/resource_network_services_authz_extension.go index df67df8dde7..8da8cb78ccf 100644 --- a/google/services/networkservices/resource_network_services_authz_extension.go +++ b/google/services/networkservices/resource_network_services_authz_extension.go @@ -116,6 +116,7 @@ func ResourceNetworkServicesAuthzExtension() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -274,6 +275,18 @@ Supported values: Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -471,6 +484,19 @@ func resourceNetworkServicesAuthzExtensionRead(d *schema.ResourceData, meta inte log.Printf("[DEBUG] Finished reading NetworkServicesAuthzExtension %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading AuthzExtension: %s", err) } @@ -508,6 +534,19 @@ func resourceNetworkServicesAuthzExtensionRead(d *schema.ResourceData, meta inte } func resourceNetworkServicesAuthzExtensionUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetworkServicesAuthzExtension().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetworkServicesAuthzExtensionRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -706,6 +745,13 @@ func resourceNetworkServicesAuthzExtensionUpdate(d *schema.ResourceData, meta in } func resourceNetworkServicesAuthzExtensionDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkServicesAuthzExtension without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing AuthzExtension %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/networkservices/resource_network_services_authz_extension_generated_meta.yaml b/google/services/networkservices/resource_network_services_authz_extension_generated_meta.yaml index f8aefa67708..19410f22723 100644 --- a/google/services/networkservices/resource_network_services_authz_extension_generated_meta.yaml +++ b/google/services/networkservices/resource_network_services_authz_extension_generated_meta.yaml @@ -26,3 +26,5 @@ fields: - api_field: timeout - api_field: updateTime - api_field: wireFormat + - field: deletion_policy + provider_only: true diff --git a/google/services/networkservices/resource_network_services_edge_cache_keyset.go b/google/services/networkservices/resource_network_services_edge_cache_keyset.go index 8ce622fb0b8..1ff73a6a01d 100644 --- a/google/services/networkservices/resource_network_services_edge_cache_keyset.go +++ b/google/services/networkservices/resource_network_services_edge_cache_keyset.go @@ -116,6 +116,7 @@ func ResourceNetworkServicesEdgeCacheKeyset() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -242,6 +243,18 @@ See RFC 2104, Section 3 for more details on these recommendations.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -394,6 +407,19 @@ func resourceNetworkServicesEdgeCacheKeysetRead(d *schema.ResourceData, meta int log.Printf("[DEBUG] Finished reading NetworkServicesEdgeCacheKeyset %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading EdgeCacheKeyset: %s", err) } @@ -425,6 +451,19 @@ func resourceNetworkServicesEdgeCacheKeysetRead(d *schema.ResourceData, meta int } func resourceNetworkServicesEdgeCacheKeysetUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetworkServicesEdgeCacheKeyset().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetworkServicesEdgeCacheKeysetRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -549,6 +588,13 @@ func resourceNetworkServicesEdgeCacheKeysetUpdate(d *schema.ResourceData, meta i } func resourceNetworkServicesEdgeCacheKeysetDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkServicesEdgeCacheKeyset without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing EdgeCacheKeyset %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/networkservices/resource_network_services_edge_cache_keyset_generated_meta.yaml b/google/services/networkservices/resource_network_services_edge_cache_keyset_generated_meta.yaml index 4b6a347de91..4d1eb72afcf 100644 --- a/google/services/networkservices/resource_network_services_edge_cache_keyset_generated_meta.yaml +++ b/google/services/networkservices/resource_network_services_edge_cache_keyset_generated_meta.yaml @@ -22,3 +22,5 @@ fields: - field: terraform_labels provider_only: true - api_field: validationSharedKeys.secretVersion + - field: deletion_policy + provider_only: true diff --git a/google/services/networkservices/resource_network_services_edge_cache_origin.go b/google/services/networkservices/resource_network_services_edge_cache_origin.go index 07118d33d64..39e15c7576b 100644 --- a/google/services/networkservices/resource_network_services_edge_cache_origin.go +++ b/google/services/networkservices/resource_network_services_edge_cache_origin.go @@ -116,6 +116,7 @@ func ResourceNetworkServicesEdgeCacheOrigin() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -467,6 +468,18 @@ If the response headers have already been written to the connection, the respons Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -671,6 +684,19 @@ func resourceNetworkServicesEdgeCacheOriginRead(d *schema.ResourceData, meta int log.Printf("[DEBUG] Finished reading NetworkServicesEdgeCacheOrigin %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading EdgeCacheOrigin: %s", err) } @@ -702,6 +728,19 @@ func resourceNetworkServicesEdgeCacheOriginRead(d *schema.ResourceData, meta int } func resourceNetworkServicesEdgeCacheOriginUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetworkServicesEdgeCacheOrigin().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetworkServicesEdgeCacheOriginRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -915,6 +954,13 @@ func resourceNetworkServicesEdgeCacheOriginUpdate(d *schema.ResourceData, meta i } func resourceNetworkServicesEdgeCacheOriginDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkServicesEdgeCacheOrigin without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing EdgeCacheOrigin %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/networkservices/resource_network_services_edge_cache_origin_generated_meta.yaml b/google/services/networkservices/resource_network_services_edge_cache_origin_generated_meta.yaml index 9314786711d..37ee914fa63 100644 --- a/google/services/networkservices/resource_network_services_edge_cache_origin_generated_meta.yaml +++ b/google/services/networkservices/resource_network_services_edge_cache_origin_generated_meta.yaml @@ -34,3 +34,5 @@ fields: - api_field: timeout.maxAttemptsTimeout - api_field: timeout.readTimeout - api_field: timeout.responseTimeout + - field: deletion_policy + provider_only: true diff --git a/google/services/networkservices/resource_network_services_edge_cache_service.go b/google/services/networkservices/resource_network_services_edge_cache_service.go index 2fa7381d2ae..6a4707b4a4c 100644 --- a/google/services/networkservices/resource_network_services_edge_cache_service.go +++ b/google/services/networkservices/resource_network_services_edge_cache_service.go @@ -116,6 +116,7 @@ func ResourceNetworkServicesEdgeCacheService() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -1133,6 +1134,18 @@ If not set, the EdgeCacheService has no SSL policy configured, and will default Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -1324,6 +1337,19 @@ func resourceNetworkServicesEdgeCacheServiceRead(d *schema.ResourceData, meta in log.Printf("[DEBUG] Finished reading NetworkServicesEdgeCacheService %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading EdgeCacheService: %s", err) } @@ -1355,6 +1381,19 @@ func resourceNetworkServicesEdgeCacheServiceRead(d *schema.ResourceData, meta in } func resourceNetworkServicesEdgeCacheServiceUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetworkServicesEdgeCacheService().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetworkServicesEdgeCacheServiceRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1543,6 +1582,13 @@ func resourceNetworkServicesEdgeCacheServiceUpdate(d *schema.ResourceData, meta } func resourceNetworkServicesEdgeCacheServiceDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkServicesEdgeCacheService without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing EdgeCacheService %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/networkservices/resource_network_services_edge_cache_service_generated_meta.yaml b/google/services/networkservices/resource_network_services_edge_cache_service_generated_meta.yaml index 967a721b1ec..5dea0a11e80 100644 --- a/google/services/networkservices/resource_network_services_edge_cache_service_generated_meta.yaml +++ b/google/services/networkservices/resource_network_services_edge_cache_service_generated_meta.yaml @@ -165,3 +165,5 @@ fields: - api_field: sslPolicy - field: terraform_labels provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/networkservices/resource_network_services_endpoint_policy.go b/google/services/networkservices/resource_network_services_endpoint_policy.go index f1f613cc253..2cff4636459 100644 --- a/google/services/networkservices/resource_network_services_endpoint_policy.go +++ b/google/services/networkservices/resource_network_services_endpoint_policy.go @@ -116,6 +116,7 @@ func ResourceNetworkServicesEndpointPolicy() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -271,6 +272,18 @@ Please refer to the field 'effective_labels' for all of the labels present on th Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -445,6 +458,19 @@ func resourceNetworkServicesEndpointPolicyRead(d *schema.ResourceData, meta inte log.Printf("[DEBUG] Finished reading NetworkServicesEndpointPolicy %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading EndpointPolicy: %s", err) } @@ -476,6 +502,19 @@ func resourceNetworkServicesEndpointPolicyRead(d *schema.ResourceData, meta inte } func resourceNetworkServicesEndpointPolicyUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetworkServicesEndpointPolicy().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetworkServicesEndpointPolicyRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -639,6 +678,13 @@ func resourceNetworkServicesEndpointPolicyUpdate(d *schema.ResourceData, meta in } func resourceNetworkServicesEndpointPolicyDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkServicesEndpointPolicy without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing EndpointPolicy %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/networkservices/resource_network_services_endpoint_policy_generated_meta.yaml b/google/services/networkservices/resource_network_services_endpoint_policy_generated_meta.yaml index 2bcd023cb2b..117926ed752 100644 --- a/google/services/networkservices/resource_network_services_endpoint_policy_generated_meta.yaml +++ b/google/services/networkservices/resource_network_services_endpoint_policy_generated_meta.yaml @@ -25,3 +25,5 @@ fields: - api_field: trafficPortSelector.ports - api_field: type - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/networkservices/resource_network_services_gateway.go b/google/services/networkservices/resource_network_services_gateway.go index f725b5dd9a4..5c2950e5b9b 100644 --- a/google/services/networkservices/resource_network_services_gateway.go +++ b/google/services/networkservices/resource_network_services_gateway.go @@ -239,6 +239,7 @@ func ResourceNetworkServicesGateway() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -444,6 +445,18 @@ If there is no other gateway of type 'SECURE_WEB_GATEWAY' remaining for that reg Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -671,6 +684,18 @@ func resourceNetworkServicesGatewayRead(d *schema.ResourceData, meta interface{} return fmt.Errorf("Error setting delete_swg_autogen_router_on_destroy: %s", err) } } + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Gateway: %s", err) } @@ -708,6 +733,19 @@ func resourceNetworkServicesGatewayRead(d *schema.ResourceData, meta interface{} } func resourceNetworkServicesGatewayUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetworkServicesGateway().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetworkServicesGatewayRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -891,6 +929,13 @@ func resourceNetworkServicesGatewayUpdate(d *schema.ResourceData, meta interface } func resourceNetworkServicesGatewayDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkServicesGateway without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Gateway %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/networkservices/resource_network_services_gateway_generated_meta.yaml b/google/services/networkservices/resource_network_services_gateway_generated_meta.yaml index 9208bdd8a3d..b6af14611aa 100644 --- a/google/services/networkservices/resource_network_services_gateway_generated_meta.yaml +++ b/google/services/networkservices/resource_network_services_gateway_generated_meta.yaml @@ -35,3 +35,5 @@ fields: provider_only: true - api_field: type - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/networkservices/resource_network_services_grpc_route.go b/google/services/networkservices/resource_network_services_grpc_route.go index e126d783a6f..4b357eb5986 100644 --- a/google/services/networkservices/resource_network_services_grpc_route.go +++ b/google/services/networkservices/resource_network_services_grpc_route.go @@ -125,6 +125,7 @@ func ResourceNetworkServicesGrpcRoute() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -415,6 +416,18 @@ Please refer to the field 'effective_labels' for all of the labels present on th Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -582,6 +595,19 @@ func resourceNetworkServicesGrpcRouteRead(d *schema.ResourceData, meta interface log.Printf("[DEBUG] Finished reading NetworkServicesGrpcRoute %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading GrpcRoute: %s", err) } @@ -619,6 +645,19 @@ func resourceNetworkServicesGrpcRouteRead(d *schema.ResourceData, meta interface } func resourceNetworkServicesGrpcRouteUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetworkServicesGrpcRoute().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetworkServicesGrpcRouteRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -767,6 +806,13 @@ func resourceNetworkServicesGrpcRouteUpdate(d *schema.ResourceData, meta interfa } func resourceNetworkServicesGrpcRouteDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkServicesGrpcRoute without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing GrpcRoute %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/networkservices/resource_network_services_grpc_route_generated_meta.yaml b/google/services/networkservices/resource_network_services_grpc_route_generated_meta.yaml index caf542ae320..1243affb5ed 100644 --- a/google/services/networkservices/resource_network_services_grpc_route_generated_meta.yaml +++ b/google/services/networkservices/resource_network_services_grpc_route_generated_meta.yaml @@ -38,3 +38,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/networkservices/resource_network_services_http_route.go b/google/services/networkservices/resource_network_services_http_route.go index d76a41f08cb..1fc60f4f090 100644 --- a/google/services/networkservices/resource_network_services_http_route.go +++ b/google/services/networkservices/resource_network_services_http_route.go @@ -116,6 +116,7 @@ func ResourceNetworkServicesHttpRoute() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -702,6 +703,18 @@ The attached Mesh should be of a type SIDECAR.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -864,6 +877,19 @@ func resourceNetworkServicesHttpRouteRead(d *schema.ResourceData, meta interface log.Printf("[DEBUG] Finished reading NetworkServicesHttpRoute %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading HttpRoute: %s", err) } @@ -895,6 +921,19 @@ func resourceNetworkServicesHttpRouteRead(d *schema.ResourceData, meta interface } func resourceNetworkServicesHttpRouteUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetworkServicesHttpRoute().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetworkServicesHttpRouteRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1038,6 +1077,13 @@ func resourceNetworkServicesHttpRouteUpdate(d *schema.ResourceData, meta interfa } func resourceNetworkServicesHttpRouteDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkServicesHttpRoute without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing HttpRoute %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/networkservices/resource_network_services_http_route_generated_meta.yaml b/google/services/networkservices/resource_network_services_http_route_generated_meta.yaml index 9390d426472..252998c825f 100644 --- a/google/services/networkservices/resource_network_services_http_route_generated_meta.yaml +++ b/google/services/networkservices/resource_network_services_http_route_generated_meta.yaml @@ -73,3 +73,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/networkservices/resource_network_services_lb_edge_extension.go b/google/services/networkservices/resource_network_services_lb_edge_extension.go index 2bd77cad210..7b814d2bf1d 100644 --- a/google/services/networkservices/resource_network_services_lb_edge_extension.go +++ b/google/services/networkservices/resource_network_services_lb_edge_extension.go @@ -116,6 +116,7 @@ func ResourceNetworkServicesLbEdgeExtension() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -296,6 +297,18 @@ Please refer to the field 'effective_labels' for all of the labels present on th Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -457,6 +470,19 @@ func resourceNetworkServicesLbEdgeExtensionRead(d *schema.ResourceData, meta int log.Printf("[DEBUG] Finished reading NetworkServicesLbEdgeExtension %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading LbEdgeExtension: %s", err) } @@ -494,6 +520,19 @@ func resourceNetworkServicesLbEdgeExtensionRead(d *schema.ResourceData, meta int } func resourceNetworkServicesLbEdgeExtensionUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetworkServicesLbEdgeExtension().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetworkServicesLbEdgeExtensionRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -622,6 +661,13 @@ func resourceNetworkServicesLbEdgeExtensionUpdate(d *schema.ResourceData, meta i } func resourceNetworkServicesLbEdgeExtensionDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkServicesLbEdgeExtension without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing LbEdgeExtension %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/networkservices/resource_network_services_lb_edge_extension_generated_meta.yaml b/google/services/networkservices/resource_network_services_lb_edge_extension_generated_meta.yaml index 86296be5822..6fdcb7eeb97 100644 --- a/google/services/networkservices/resource_network_services_lb_edge_extension_generated_meta.yaml +++ b/google/services/networkservices/resource_network_services_lb_edge_extension_generated_meta.yaml @@ -26,3 +26,5 @@ fields: provider_only: true - field: terraform_labels provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/networkservices/resource_network_services_lb_route_extension.go b/google/services/networkservices/resource_network_services_lb_route_extension.go index 297b6170b4d..4a62f169874 100644 --- a/google/services/networkservices/resource_network_services_lb_route_extension.go +++ b/google/services/networkservices/resource_network_services_lb_route_extension.go @@ -133,6 +133,7 @@ func ResourceNetworkServicesLbRouteExtension() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -361,6 +362,18 @@ Please refer to the field 'effective_labels' for all of the labels present on th Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -522,6 +535,19 @@ func resourceNetworkServicesLbRouteExtensionRead(d *schema.ResourceData, meta in log.Printf("[DEBUG] Finished reading NetworkServicesLbRouteExtension %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading LbRouteExtension: %s", err) } @@ -559,6 +585,19 @@ func resourceNetworkServicesLbRouteExtensionRead(d *schema.ResourceData, meta in } func resourceNetworkServicesLbRouteExtensionUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetworkServicesLbRouteExtension().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetworkServicesLbRouteExtensionRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -687,6 +726,13 @@ func resourceNetworkServicesLbRouteExtensionUpdate(d *schema.ResourceData, meta } func resourceNetworkServicesLbRouteExtensionDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkServicesLbRouteExtension without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing LbRouteExtension %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/networkservices/resource_network_services_lb_route_extension_generated_meta.yaml b/google/services/networkservices/resource_network_services_lb_route_extension_generated_meta.yaml index b0adcec378d..73250308514 100644 --- a/google/services/networkservices/resource_network_services_lb_route_extension_generated_meta.yaml +++ b/google/services/networkservices/resource_network_services_lb_route_extension_generated_meta.yaml @@ -31,3 +31,5 @@ fields: provider_only: true - field: terraform_labels provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/networkservices/resource_network_services_lb_traffic_extension.go b/google/services/networkservices/resource_network_services_lb_traffic_extension.go index 0641bdbddd5..875b19405cf 100644 --- a/google/services/networkservices/resource_network_services_lb_traffic_extension.go +++ b/google/services/networkservices/resource_network_services_lb_traffic_extension.go @@ -116,6 +116,7 @@ func ResourceNetworkServicesLbTrafficExtension() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -322,6 +323,18 @@ Please refer to the field 'effective_labels' for all of the labels present on th Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -483,6 +496,19 @@ func resourceNetworkServicesLbTrafficExtensionRead(d *schema.ResourceData, meta log.Printf("[DEBUG] Finished reading NetworkServicesLbTrafficExtension %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading LbTrafficExtension: %s", err) } @@ -520,6 +546,19 @@ func resourceNetworkServicesLbTrafficExtensionRead(d *schema.ResourceData, meta } func resourceNetworkServicesLbTrafficExtensionUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetworkServicesLbTrafficExtension().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetworkServicesLbTrafficExtensionRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -648,6 +687,13 @@ func resourceNetworkServicesLbTrafficExtensionUpdate(d *schema.ResourceData, met } func resourceNetworkServicesLbTrafficExtensionDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkServicesLbTrafficExtension without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing LbTrafficExtension %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/networkservices/resource_network_services_lb_traffic_extension_generated_meta.yaml b/google/services/networkservices/resource_network_services_lb_traffic_extension_generated_meta.yaml index 970225ce98b..5bf7ebfdec1 100644 --- a/google/services/networkservices/resource_network_services_lb_traffic_extension_generated_meta.yaml +++ b/google/services/networkservices/resource_network_services_lb_traffic_extension_generated_meta.yaml @@ -29,3 +29,5 @@ fields: provider_only: true - field: terraform_labels provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/networkservices/resource_network_services_mesh.go b/google/services/networkservices/resource_network_services_mesh.go index f3583eb6a10..51c5f661333 100644 --- a/google/services/networkservices/resource_network_services_mesh.go +++ b/google/services/networkservices/resource_network_services_mesh.go @@ -125,6 +125,7 @@ func ResourceNetworkServicesMesh() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -221,6 +222,18 @@ Please refer to the field 'effective_labels' for all of the labels present on th Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -370,6 +383,19 @@ func resourceNetworkServicesMeshRead(d *schema.ResourceData, meta interface{}) e log.Printf("[DEBUG] Finished reading NetworkServicesMesh %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Mesh: %s", err) } @@ -407,6 +433,19 @@ func resourceNetworkServicesMeshRead(d *schema.ResourceData, meta interface{}) e } func resourceNetworkServicesMeshUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetworkServicesMesh().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetworkServicesMeshRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -525,6 +564,13 @@ func resourceNetworkServicesMeshUpdate(d *schema.ResourceData, meta interface{}) } func resourceNetworkServicesMeshDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkServicesMesh without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Mesh %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/networkservices/resource_network_services_mesh_generated_meta.yaml b/google/services/networkservices/resource_network_services_mesh_generated_meta.yaml index 1b38f4a4f99..f84fca0287a 100644 --- a/google/services/networkservices/resource_network_services_mesh_generated_meta.yaml +++ b/google/services/networkservices/resource_network_services_mesh_generated_meta.yaml @@ -21,3 +21,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/networkservices/resource_network_services_multicast_consumer_association.go b/google/services/networkservices/resource_network_services_multicast_consumer_association.go index 7c1865b4dd4..557246452d3 100644 --- a/google/services/networkservices/resource_network_services_multicast_consumer_association.go +++ b/google/services/networkservices/resource_network_services_multicast_consumer_association.go @@ -116,6 +116,7 @@ func ResourceNetworkServicesMulticastConsumerAssociation() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -265,6 +266,18 @@ most recently updated.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -420,6 +433,19 @@ func resourceNetworkServicesMulticastConsumerAssociationRead(d *schema.ResourceD log.Printf("[DEBUG] Finished reading NetworkServicesMulticastConsumerAssociation %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading MulticastConsumerAssociation: %s", err) } @@ -457,6 +483,19 @@ func resourceNetworkServicesMulticastConsumerAssociationRead(d *schema.ResourceD } func resourceNetworkServicesMulticastConsumerAssociationUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetworkServicesMulticastConsumerAssociation().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetworkServicesMulticastConsumerAssociationRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -565,6 +604,13 @@ func resourceNetworkServicesMulticastConsumerAssociationUpdate(d *schema.Resourc } func resourceNetworkServicesMulticastConsumerAssociationDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkServicesMulticastConsumerAssociation without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing MulticastConsumerAssociation %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/networkservices/resource_network_services_multicast_consumer_association_generated_meta.yaml b/google/services/networkservices/resource_network_services_multicast_consumer_association_generated_meta.yaml index f35bfeb075c..e71b087423a 100644 --- a/google/services/networkservices/resource_network_services_multicast_consumer_association_generated_meta.yaml +++ b/google/services/networkservices/resource_network_services_multicast_consumer_association_generated_meta.yaml @@ -26,3 +26,5 @@ fields: provider_only: true - api_field: uniqueId - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/networkservices/resource_network_services_multicast_domain.go b/google/services/networkservices/resource_network_services_multicast_domain.go index 096d716a0f7..7ccebefe039 100644 --- a/google/services/networkservices/resource_network_services_multicast_domain.go +++ b/google/services/networkservices/resource_network_services_multicast_domain.go @@ -116,6 +116,7 @@ func ResourceNetworkServicesMulticastDomain() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -300,6 +301,18 @@ updated.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -467,6 +480,19 @@ func resourceNetworkServicesMulticastDomainRead(d *schema.ResourceData, meta int log.Printf("[DEBUG] Finished reading NetworkServicesMulticastDomain %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading MulticastDomain: %s", err) } @@ -504,6 +530,19 @@ func resourceNetworkServicesMulticastDomainRead(d *schema.ResourceData, meta int } func resourceNetworkServicesMulticastDomainUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetworkServicesMulticastDomain().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetworkServicesMulticastDomainRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -612,6 +651,13 @@ func resourceNetworkServicesMulticastDomainUpdate(d *schema.ResourceData, meta i } func resourceNetworkServicesMulticastDomainDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkServicesMulticastDomain without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing MulticastDomain %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/networkservices/resource_network_services_multicast_domain_activation.go b/google/services/networkservices/resource_network_services_multicast_domain_activation.go index e2a16c66f93..dc2fa811d17 100644 --- a/google/services/networkservices/resource_network_services_multicast_domain_activation.go +++ b/google/services/networkservices/resource_network_services_multicast_domain_activation.go @@ -116,6 +116,7 @@ func ResourceNetworkServicesMulticastDomainActivation() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -307,6 +308,18 @@ recently updated.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -468,6 +481,19 @@ func resourceNetworkServicesMulticastDomainActivationRead(d *schema.ResourceData log.Printf("[DEBUG] Finished reading NetworkServicesMulticastDomainActivation %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading MulticastDomainActivation: %s", err) } @@ -505,6 +531,19 @@ func resourceNetworkServicesMulticastDomainActivationRead(d *schema.ResourceData } func resourceNetworkServicesMulticastDomainActivationUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetworkServicesMulticastDomainActivation().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetworkServicesMulticastDomainActivationRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -623,6 +662,13 @@ func resourceNetworkServicesMulticastDomainActivationUpdate(d *schema.ResourceDa } func resourceNetworkServicesMulticastDomainActivationDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkServicesMulticastDomainActivation without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing MulticastDomainActivation %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/networkservices/resource_network_services_multicast_domain_activation_generated_meta.yaml b/google/services/networkservices/resource_network_services_multicast_domain_activation_generated_meta.yaml index d41937b1797..cf16c79871f 100644 --- a/google/services/networkservices/resource_network_services_multicast_domain_activation_generated_meta.yaml +++ b/google/services/networkservices/resource_network_services_multicast_domain_activation_generated_meta.yaml @@ -31,3 +31,5 @@ fields: - api_field: trafficSpec.maxPerGroupSubscribers - api_field: uniqueId - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/networkservices/resource_network_services_multicast_domain_generated_meta.yaml b/google/services/networkservices/resource_network_services_multicast_domain_generated_meta.yaml index 6300cd84e80..992f1e880be 100644 --- a/google/services/networkservices/resource_network_services_multicast_domain_generated_meta.yaml +++ b/google/services/networkservices/resource_network_services_multicast_domain_generated_meta.yaml @@ -30,3 +30,5 @@ fields: - api_field: ullMulticastDomain.preconfiguredUllDomain - api_field: uniqueId - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/networkservices/resource_network_services_multicast_domain_group.go b/google/services/networkservices/resource_network_services_multicast_domain_group.go index 0c1a55de14d..d94ba6cfa8b 100644 --- a/google/services/networkservices/resource_network_services_multicast_domain_group.go +++ b/google/services/networkservices/resource_network_services_multicast_domain_group.go @@ -116,6 +116,7 @@ func ResourceNetworkServicesMulticastDomainGroup() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -247,6 +248,18 @@ recently updated.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -390,6 +403,19 @@ func resourceNetworkServicesMulticastDomainGroupRead(d *schema.ResourceData, met log.Printf("[DEBUG] Finished reading NetworkServicesMulticastDomainGroup %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading MulticastDomainGroup: %s", err) } @@ -427,6 +453,19 @@ func resourceNetworkServicesMulticastDomainGroupRead(d *schema.ResourceData, met } func resourceNetworkServicesMulticastDomainGroupUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetworkServicesMulticastDomainGroup().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetworkServicesMulticastDomainGroupRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -535,6 +574,13 @@ func resourceNetworkServicesMulticastDomainGroupUpdate(d *schema.ResourceData, m } func resourceNetworkServicesMulticastDomainGroupDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkServicesMulticastDomainGroup without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing MulticastDomainGroup %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/networkservices/resource_network_services_multicast_domain_group_generated_meta.yaml b/google/services/networkservices/resource_network_services_multicast_domain_group_generated_meta.yaml index 1dd6dcd0643..2a4b7a99d04 100644 --- a/google/services/networkservices/resource_network_services_multicast_domain_group_generated_meta.yaml +++ b/google/services/networkservices/resource_network_services_multicast_domain_group_generated_meta.yaml @@ -24,3 +24,5 @@ fields: provider_only: true - api_field: uniqueId - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/networkservices/resource_network_services_multicast_group_consumer_activation.go b/google/services/networkservices/resource_network_services_multicast_group_consumer_activation.go index 7789780900f..3b449809270 100644 --- a/google/services/networkservices/resource_network_services_multicast_group_consumer_activation.go +++ b/google/services/networkservices/resource_network_services_multicast_group_consumer_activation.go @@ -116,6 +116,7 @@ func ResourceNetworkServicesMulticastGroupConsumerActivation() *schema.Resource CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -272,6 +273,18 @@ was most recently updated.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -433,6 +446,19 @@ func resourceNetworkServicesMulticastGroupConsumerActivationRead(d *schema.Resou log.Printf("[DEBUG] Finished reading NetworkServicesMulticastGroupConsumerActivation %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading MulticastGroupConsumerActivation: %s", err) } @@ -470,6 +496,19 @@ func resourceNetworkServicesMulticastGroupConsumerActivationRead(d *schema.Resou } func resourceNetworkServicesMulticastGroupConsumerActivationUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetworkServicesMulticastGroupConsumerActivation().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetworkServicesMulticastGroupConsumerActivationRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -588,6 +627,13 @@ func resourceNetworkServicesMulticastGroupConsumerActivationUpdate(d *schema.Res } func resourceNetworkServicesMulticastGroupConsumerActivationDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkServicesMulticastGroupConsumerActivation without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing MulticastGroupConsumerActivation %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/networkservices/resource_network_services_multicast_group_consumer_activation_generated_meta.yaml b/google/services/networkservices/resource_network_services_multicast_group_consumer_activation_generated_meta.yaml index cbe272688b7..2e96e5f123b 100644 --- a/google/services/networkservices/resource_network_services_multicast_group_consumer_activation_generated_meta.yaml +++ b/google/services/networkservices/resource_network_services_multicast_group_consumer_activation_generated_meta.yaml @@ -26,3 +26,5 @@ fields: provider_only: true - api_field: uniqueId - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/networkservices/resource_network_services_multicast_group_producer_activation.go b/google/services/networkservices/resource_network_services_multicast_group_producer_activation.go index d47c240b94f..b7b05c1b624 100644 --- a/google/services/networkservices/resource_network_services_multicast_group_producer_activation.go +++ b/google/services/networkservices/resource_network_services_multicast_group_producer_activation.go @@ -116,6 +116,7 @@ func ResourceNetworkServicesMulticastGroupProducerActivation() *schema.Resource CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -256,6 +257,18 @@ was most recently updated.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -411,6 +424,19 @@ func resourceNetworkServicesMulticastGroupProducerActivationRead(d *schema.Resou log.Printf("[DEBUG] Finished reading NetworkServicesMulticastGroupProducerActivation %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading MulticastGroupProducerActivation: %s", err) } @@ -448,6 +474,19 @@ func resourceNetworkServicesMulticastGroupProducerActivationRead(d *schema.Resou } func resourceNetworkServicesMulticastGroupProducerActivationUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetworkServicesMulticastGroupProducerActivation().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetworkServicesMulticastGroupProducerActivationRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -556,6 +595,13 @@ func resourceNetworkServicesMulticastGroupProducerActivationUpdate(d *schema.Res } func resourceNetworkServicesMulticastGroupProducerActivationDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkServicesMulticastGroupProducerActivation without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing MulticastGroupProducerActivation %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/networkservices/resource_network_services_multicast_group_producer_activation_generated_meta.yaml b/google/services/networkservices/resource_network_services_multicast_group_producer_activation_generated_meta.yaml index 9edf6a85f7c..7b471f75943 100644 --- a/google/services/networkservices/resource_network_services_multicast_group_producer_activation_generated_meta.yaml +++ b/google/services/networkservices/resource_network_services_multicast_group_producer_activation_generated_meta.yaml @@ -25,3 +25,5 @@ fields: provider_only: true - api_field: uniqueId - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/networkservices/resource_network_services_multicast_group_range.go b/google/services/networkservices/resource_network_services_multicast_group_range.go index 8fa72a966df..f5b3886c07c 100644 --- a/google/services/networkservices/resource_network_services_multicast_group_range.go +++ b/google/services/networkservices/resource_network_services_multicast_group_range.go @@ -116,6 +116,7 @@ func ResourceNetworkServicesMulticastGroupRange() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -311,6 +312,18 @@ recently updated.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -490,6 +503,19 @@ func resourceNetworkServicesMulticastGroupRangeRead(d *schema.ResourceData, meta log.Printf("[DEBUG] Finished reading NetworkServicesMulticastGroupRange %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading MulticastGroupRange: %s", err) } @@ -527,6 +553,19 @@ func resourceNetworkServicesMulticastGroupRangeRead(d *schema.ResourceData, meta } func resourceNetworkServicesMulticastGroupRangeUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetworkServicesMulticastGroupRange().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetworkServicesMulticastGroupRangeRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -665,6 +704,13 @@ func resourceNetworkServicesMulticastGroupRangeUpdate(d *schema.ResourceData, me } func resourceNetworkServicesMulticastGroupRangeDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkServicesMulticastGroupRange without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing MulticastGroupRange %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/networkservices/resource_network_services_multicast_group_range_activation.go b/google/services/networkservices/resource_network_services_multicast_group_range_activation.go index 989ef7daba9..55d20f9d1dc 100644 --- a/google/services/networkservices/resource_network_services_multicast_group_range_activation.go +++ b/google/services/networkservices/resource_network_services_multicast_group_range_activation.go @@ -116,6 +116,7 @@ func ResourceNetworkServicesMulticastGroupRangeActivation() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -286,6 +287,18 @@ most recently updated.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -447,6 +460,19 @@ func resourceNetworkServicesMulticastGroupRangeActivationRead(d *schema.Resource log.Printf("[DEBUG] Finished reading NetworkServicesMulticastGroupRangeActivation %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading MulticastGroupRangeActivation: %s", err) } @@ -484,6 +510,19 @@ func resourceNetworkServicesMulticastGroupRangeActivationRead(d *schema.Resource } func resourceNetworkServicesMulticastGroupRangeActivationUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetworkServicesMulticastGroupRangeActivation().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetworkServicesMulticastGroupRangeActivationRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -602,6 +641,13 @@ func resourceNetworkServicesMulticastGroupRangeActivationUpdate(d *schema.Resour } func resourceNetworkServicesMulticastGroupRangeActivationDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkServicesMulticastGroupRangeActivation without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing MulticastGroupRangeActivation %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/networkservices/resource_network_services_multicast_group_range_activation_generated_meta.yaml b/google/services/networkservices/resource_network_services_multicast_group_range_activation_generated_meta.yaml index 385ecf1bda0..82af36fdbf6 100644 --- a/google/services/networkservices/resource_network_services_multicast_group_range_activation_generated_meta.yaml +++ b/google/services/networkservices/resource_network_services_multicast_group_range_activation_generated_meta.yaml @@ -28,3 +28,5 @@ fields: provider_only: true - api_field: uniqueId - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/networkservices/resource_network_services_multicast_group_range_generated_meta.yaml b/google/services/networkservices/resource_network_services_multicast_group_range_generated_meta.yaml index 19b3c3d9453..142c62df567 100644 --- a/google/services/networkservices/resource_network_services_multicast_group_range_generated_meta.yaml +++ b/google/services/networkservices/resource_network_services_multicast_group_range_generated_meta.yaml @@ -30,3 +30,5 @@ fields: provider_only: true - api_field: uniqueId - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/networkservices/resource_network_services_multicast_producer_association.go b/google/services/networkservices/resource_network_services_multicast_producer_association.go index b8b4aa232fd..73380dd8a46 100644 --- a/google/services/networkservices/resource_network_services_multicast_producer_association.go +++ b/google/services/networkservices/resource_network_services_multicast_producer_association.go @@ -116,6 +116,7 @@ func ResourceNetworkServicesMulticastProducerAssociation() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -256,6 +257,18 @@ most recently updated.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -411,6 +424,19 @@ func resourceNetworkServicesMulticastProducerAssociationRead(d *schema.ResourceD log.Printf("[DEBUG] Finished reading NetworkServicesMulticastProducerAssociation %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading MulticastProducerAssociation: %s", err) } @@ -448,6 +474,19 @@ func resourceNetworkServicesMulticastProducerAssociationRead(d *schema.ResourceD } func resourceNetworkServicesMulticastProducerAssociationUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetworkServicesMulticastProducerAssociation().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetworkServicesMulticastProducerAssociationRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -556,6 +595,13 @@ func resourceNetworkServicesMulticastProducerAssociationUpdate(d *schema.Resourc } func resourceNetworkServicesMulticastProducerAssociationDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkServicesMulticastProducerAssociation without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing MulticastProducerAssociation %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/networkservices/resource_network_services_multicast_producer_association_generated_meta.yaml b/google/services/networkservices/resource_network_services_multicast_producer_association_generated_meta.yaml index 1e5c170019d..1a40b496ae1 100644 --- a/google/services/networkservices/resource_network_services_multicast_producer_association_generated_meta.yaml +++ b/google/services/networkservices/resource_network_services_multicast_producer_association_generated_meta.yaml @@ -25,3 +25,5 @@ fields: provider_only: true - api_field: uniqueId - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/networkservices/resource_network_services_service_binding.go b/google/services/networkservices/resource_network_services_service_binding.go index 0781029308e..2e9fcdd7177 100644 --- a/google/services/networkservices/resource_network_services_service_binding.go +++ b/google/services/networkservices/resource_network_services_service_binding.go @@ -125,6 +125,7 @@ func ResourceNetworkServicesServiceBinding() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), DeprecationMessage: "Cloud Service Mesh's integration with Service Directory is going to be deprecated. [Learn more](https://docs.cloud.google.com/service-mesh/docs/service-routing/service-directory-integration-setup). Creating new service binding resources will be disabled.", @@ -207,6 +208,18 @@ Please refer to the field 'effective_labels' for all of the labels present on th Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -351,6 +364,19 @@ func resourceNetworkServicesServiceBindingRead(d *schema.ResourceData, meta inte log.Printf("[DEBUG] Finished reading NetworkServicesServiceBinding %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading ServiceBinding: %s", err) } @@ -382,11 +408,18 @@ func resourceNetworkServicesServiceBindingRead(d *schema.ResourceData, meta inte } func resourceNetworkServicesServiceBindingUpdate(d *schema.ResourceData, meta interface{}) error { - // Only the root field "labels", "terraform_labels", and virtual fields are mutable + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable return resourceNetworkServicesServiceBindingRead(d, meta) } func resourceNetworkServicesServiceBindingDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkServicesServiceBinding without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ServiceBinding %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/networkservices/resource_network_services_service_binding_generated_meta.yaml b/google/services/networkservices/resource_network_services_service_binding_generated_meta.yaml index 526862f9013..7224611121a 100644 --- a/google/services/networkservices/resource_network_services_service_binding_generated_meta.yaml +++ b/google/services/networkservices/resource_network_services_service_binding_generated_meta.yaml @@ -18,3 +18,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/networkservices/resource_network_services_tcp_route.go b/google/services/networkservices/resource_network_services_tcp_route.go index 0060cef50e9..7055870a338 100644 --- a/google/services/networkservices/resource_network_services_tcp_route.go +++ b/google/services/networkservices/resource_network_services_tcp_route.go @@ -116,6 +116,7 @@ func ResourceNetworkServicesTcpRoute() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -287,6 +288,18 @@ The attached Mesh should be of a type SIDECAR`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -443,6 +456,19 @@ func resourceNetworkServicesTcpRouteRead(d *schema.ResourceData, meta interface{ log.Printf("[DEBUG] Finished reading NetworkServicesTcpRoute %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading TcpRoute: %s", err) } @@ -474,6 +500,19 @@ func resourceNetworkServicesTcpRouteRead(d *schema.ResourceData, meta interface{ } func resourceNetworkServicesTcpRouteUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetworkServicesTcpRoute().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetworkServicesTcpRouteRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -607,6 +646,13 @@ func resourceNetworkServicesTcpRouteUpdate(d *schema.ResourceData, meta interfac } func resourceNetworkServicesTcpRouteDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkServicesTcpRoute without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing TcpRoute %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/networkservices/resource_network_services_tcp_route_generated_meta.yaml b/google/services/networkservices/resource_network_services_tcp_route_generated_meta.yaml index 4209c638b29..d42e655ad87 100644 --- a/google/services/networkservices/resource_network_services_tcp_route_generated_meta.yaml +++ b/google/services/networkservices/resource_network_services_tcp_route_generated_meta.yaml @@ -26,3 +26,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/networkservices/resource_network_services_tls_route.go b/google/services/networkservices/resource_network_services_tls_route.go index 47dae26e1c2..73eb337b43f 100644 --- a/google/services/networkservices/resource_network_services_tls_route.go +++ b/google/services/networkservices/resource_network_services_tls_route.go @@ -124,6 +124,7 @@ func ResourceNetworkServicesTlsRoute() *schema.Resource { }, CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -281,6 +282,18 @@ Each target proxy reference should match the pattern: projects/*/locations/globa Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -442,6 +455,19 @@ func resourceNetworkServicesTlsRouteRead(d *schema.ResourceData, meta interface{ log.Printf("[DEBUG] Finished reading NetworkServicesTlsRoute %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading TlsRoute: %s", err) } @@ -479,6 +505,19 @@ func resourceNetworkServicesTlsRouteRead(d *schema.ResourceData, meta interface{ } func resourceNetworkServicesTlsRouteUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetworkServicesTlsRoute().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetworkServicesTlsRouteRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -617,6 +656,13 @@ func resourceNetworkServicesTlsRouteUpdate(d *schema.ResourceData, meta interfac } func resourceNetworkServicesTlsRouteDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkServicesTlsRoute without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing TlsRoute %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/networkservices/resource_network_services_tls_route_generated_meta.yaml b/google/services/networkservices/resource_network_services_tls_route_generated_meta.yaml index d145c2f4d27..ea4fff32030 100644 --- a/google/services/networkservices/resource_network_services_tls_route_generated_meta.yaml +++ b/google/services/networkservices/resource_network_services_tls_route_generated_meta.yaml @@ -22,3 +22,5 @@ fields: - api_field: selfLink - api_field: targetProxies - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/networkservices/resource_network_services_wasm_plugin.go b/google/services/networkservices/resource_network_services_wasm_plugin.go index ee59bb78ce7..ac7da8bb16f 100644 --- a/google/services/networkservices/resource_network_services_wasm_plugin.go +++ b/google/services/networkservices/resource_network_services_wasm_plugin.go @@ -116,6 +116,7 @@ func ResourceNetworkServicesWasmPlugin() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -322,6 +323,18 @@ This field can be specified only if logging is enabled for this plugin.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -483,6 +496,19 @@ func resourceNetworkServicesWasmPluginRead(d *schema.ResourceData, meta interfac log.Printf("[DEBUG] Finished reading NetworkServicesWasmPlugin %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading WasmPlugin: %s", err) } @@ -520,6 +546,19 @@ func resourceNetworkServicesWasmPluginRead(d *schema.ResourceData, meta interfac } func resourceNetworkServicesWasmPluginUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNetworkServicesWasmPlugin().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNetworkServicesWasmPluginRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -658,6 +697,13 @@ func resourceNetworkServicesWasmPluginUpdate(d *schema.ResourceData, meta interf } func resourceNetworkServicesWasmPluginDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NetworkServicesWasmPlugin without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing WasmPlugin %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/networkservices/resource_network_services_wasm_plugin_generated_meta.yaml b/google/services/networkservices/resource_network_services_wasm_plugin_generated_meta.yaml index fd4ef29f50c..6daa0c9cdab 100644 --- a/google/services/networkservices/resource_network_services_wasm_plugin_generated_meta.yaml +++ b/google/services/networkservices/resource_network_services_wasm_plugin_generated_meta.yaml @@ -44,3 +44,5 @@ fields: field: versions.plugin_config_uri - api_field: versions.value.updateTime field: versions.update_time + - field: deletion_policy + provider_only: true diff --git a/google/services/notebooks/resource_notebooks_environment.go b/google/services/notebooks/resource_notebooks_environment.go index 3a3b0a0c007..d7ebbb42b5c 100644 --- a/google/services/notebooks/resource_notebooks_environment.go +++ b/google/services/notebooks/resource_notebooks_environment.go @@ -115,6 +115,7 @@ func ResourceNotebooksEnvironment() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), DeprecationMessage: "`google_notebooks_environment` is deprecated and will be removed in a future major release. Use `google_workbench_instance` instead.", @@ -232,6 +233,18 @@ Format: projects/{project_id}`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -393,6 +406,19 @@ func resourceNotebooksEnvironmentRead(d *schema.ResourceData, meta interface{}) log.Printf("[DEBUG] Finished reading NotebooksEnvironment %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Environment: %s", err) } @@ -430,6 +456,19 @@ func resourceNotebooksEnvironmentRead(d *schema.ResourceData, meta interface{}) } func resourceNotebooksEnvironmentUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNotebooksEnvironment().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNotebooksEnvironmentRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -538,6 +577,13 @@ func resourceNotebooksEnvironmentUpdate(d *schema.ResourceData, meta interface{} } func resourceNotebooksEnvironmentDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NotebooksEnvironment without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Environment %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/notebooks/resource_notebooks_environment_generated_meta.yaml b/google/services/notebooks/resource_notebooks_environment_generated_meta.yaml index 844e6867954..0bd090ff044 100644 --- a/google/services/notebooks/resource_notebooks_environment_generated_meta.yaml +++ b/google/services/notebooks/resource_notebooks_environment_generated_meta.yaml @@ -20,3 +20,5 @@ fields: - api_field: vmImage.imageFamily - api_field: vmImage.imageName - api_field: vmImage.project + - field: deletion_policy + provider_only: true diff --git a/google/services/notebooks/resource_notebooks_instance.go b/google/services/notebooks/resource_notebooks_instance.go index 11ccb3908ea..85286d95587 100644 --- a/google/services/notebooks/resource_notebooks_instance.go +++ b/google/services/notebooks/resource_notebooks_instance.go @@ -223,6 +223,7 @@ func ResourceNotebooksInstance() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), DeprecationMessage: "`google_notebooks_instance` is deprecated and will be removed in a future major release. Use `google_workbench_instance` instead.", @@ -657,6 +658,18 @@ the population of this value.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -970,6 +983,18 @@ func resourceNotebooksInstanceRead(d *schema.ResourceData, meta interface{}) err return fmt.Errorf("Error setting desired_state: %s", err) } } + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Instance: %s", err) } @@ -1007,6 +1032,19 @@ func resourceNotebooksInstanceRead(d *schema.ResourceData, meta interface{}) err } func resourceNotebooksInstanceUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNotebooksInstance().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNotebooksInstanceRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1171,6 +1209,13 @@ func resourceNotebooksInstanceUpdate(d *schema.ResourceData, meta interface{}) e } func resourceNotebooksInstanceDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NotebooksInstance without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Instance %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/notebooks/resource_notebooks_instance_generated_meta.yaml b/google/services/notebooks/resource_notebooks_instance_generated_meta.yaml index 37c12e75714..1badff78ccc 100644 --- a/google/services/notebooks/resource_notebooks_instance_generated_meta.yaml +++ b/google/services/notebooks/resource_notebooks_instance_generated_meta.yaml @@ -56,3 +56,5 @@ fields: - api_field: vmImage.imageFamily - api_field: vmImage.imageName - api_field: vmImage.project + - field: deletion_policy + provider_only: true diff --git a/google/services/notebooks/resource_notebooks_runtime.go b/google/services/notebooks/resource_notebooks_runtime.go index 4408e68359a..4da8b96cb30 100644 --- a/google/services/notebooks/resource_notebooks_runtime.go +++ b/google/services/notebooks/resource_notebooks_runtime.go @@ -138,6 +138,7 @@ func ResourceNotebooksRuntime() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), DeprecationMessage: "`google_notebooks_runtime` is deprecated and will be removed in a future major release. Use `google_workbench_instance` instead.", @@ -747,6 +748,18 @@ sessions stats.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -902,6 +915,19 @@ func resourceNotebooksRuntimeRead(d *schema.ResourceData, meta interface{}) erro log.Printf("[DEBUG] Finished reading NotebooksRuntime %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Runtime: %s", err) } @@ -939,6 +965,19 @@ func resourceNotebooksRuntimeRead(d *schema.ResourceData, meta interface{}) erro } func resourceNotebooksRuntimeUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceNotebooksRuntime().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceNotebooksRuntimeRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1136,6 +1175,13 @@ func resourceNotebooksRuntimeUpdate(d *schema.ResourceData, meta interface{}) er } func resourceNotebooksRuntimeDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy NotebooksRuntime without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Runtime %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/notebooks/resource_notebooks_runtime_generated_meta.yaml b/google/services/notebooks/resource_notebooks_runtime_generated_meta.yaml index 67420c9dc07..9627e7c8c24 100644 --- a/google/services/notebooks/resource_notebooks_runtime_generated_meta.yaml +++ b/google/services/notebooks/resource_notebooks_runtime_generated_meta.yaml @@ -70,3 +70,5 @@ fields: - api_field: virtualMachine.virtualMachineConfig.subnet - api_field: virtualMachine.virtualMachineConfig.tags - api_field: virtualMachine.virtualMachineConfig.zone + - field: deletion_policy + provider_only: true diff --git a/google/services/observability/resource_observability_trace_scope.go b/google/services/observability/resource_observability_trace_scope.go index a88131a144d..07eb766481b 100644 --- a/google/services/observability/resource_observability_trace_scope.go +++ b/google/services/observability/resource_observability_trace_scope.go @@ -115,6 +115,7 @@ func ResourceObservabilityTraceScope() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -197,6 +198,18 @@ projects/my-project/locations/global/traceScopes/my-trace-scope`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -330,6 +343,19 @@ func resourceObservabilityTraceScopeRead(d *schema.ResourceData, meta interface{ log.Printf("[DEBUG] Finished reading ObservabilityTraceScope %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading TraceScope: %s", err) } @@ -367,6 +393,19 @@ func resourceObservabilityTraceScopeRead(d *schema.ResourceData, meta interface{ } func resourceObservabilityTraceScopeUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceObservabilityTraceScope().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceObservabilityTraceScopeRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -468,6 +507,13 @@ func resourceObservabilityTraceScopeUpdate(d *schema.ResourceData, meta interfac } func resourceObservabilityTraceScopeDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ObservabilityTraceScope without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing TraceScope %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/observability/resource_observability_trace_scope_generated_meta.yaml b/google/services/observability/resource_observability_trace_scope_generated_meta.yaml index b791347a73a..33ee546d348 100644 --- a/google/services/observability/resource_observability_trace_scope_generated_meta.yaml +++ b/google/services/observability/resource_observability_trace_scope_generated_meta.yaml @@ -16,3 +16,5 @@ fields: - field: trace_scope_id provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/oracledatabase/resource_oracle_database_autonomous_database.go b/google/services/oracledatabase/resource_oracle_database_autonomous_database.go index 685815abb5e..05e30830c93 100644 --- a/google/services/oracledatabase/resource_oracle_database_autonomous_database.go +++ b/google/services/oracledatabase/resource_oracle_database_autonomous_database.go @@ -116,6 +116,7 @@ func ResourceOracleDatabaseAutonomousDatabase() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -1110,6 +1111,18 @@ projects/{project}/locations/{region}/autonomousDatabases/{autonomous_database}` Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -1307,6 +1320,18 @@ func resourceOracleDatabaseAutonomousDatabaseRead(d *schema.ResourceData, meta i return fmt.Errorf("Error setting deletion_protection: %s", err) } } + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading AutonomousDatabase: %s", err) } @@ -1344,11 +1369,18 @@ func resourceOracleDatabaseAutonomousDatabaseRead(d *schema.ResourceData, meta i } func resourceOracleDatabaseAutonomousDatabaseUpdate(d *schema.ResourceData, meta interface{}) error { - // Only the root field "labels", "terraform_labels", and virtual fields are mutable + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable return resourceOracleDatabaseAutonomousDatabaseRead(d, meta) } func resourceOracleDatabaseAutonomousDatabaseDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy OracleDatabaseAutonomousDatabase without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing AutonomousDatabase %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/oracledatabase/resource_oracle_database_autonomous_database_generated_meta.yaml b/google/services/oracledatabase/resource_oracle_database_autonomous_database_generated_meta.yaml index 8dd59d60e4f..a10b47fa76e 100644 --- a/google/services/oracledatabase/resource_oracle_database_autonomous_database_generated_meta.yaml +++ b/google/services/oracledatabase/resource_oracle_database_autonomous_database_generated_meta.yaml @@ -125,3 +125,5 @@ fields: - api_field: sourceConfig.autonomousDatabase - field: terraform_labels provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/oracledatabase/resource_oracle_database_cloud_exadata_infrastructure.go b/google/services/oracledatabase/resource_oracle_database_cloud_exadata_infrastructure.go index d6a504412b1..3cdba71544a 100644 --- a/google/services/oracledatabase/resource_oracle_database_cloud_exadata_infrastructure.go +++ b/google/services/oracledatabase/resource_oracle_database_cloud_exadata_infrastructure.go @@ -116,6 +116,7 @@ func ResourceOracleDatabaseCloudExadataInfrastructure() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -509,6 +510,18 @@ projects/{project}/locations/{region}/cloudExadataInfrastructures/{cloud_exadata Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -670,6 +683,18 @@ func resourceOracleDatabaseCloudExadataInfrastructureRead(d *schema.ResourceData return fmt.Errorf("Error setting deletion_protection: %s", err) } } + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading CloudExadataInfrastructure: %s", err) } @@ -707,11 +732,18 @@ func resourceOracleDatabaseCloudExadataInfrastructureRead(d *schema.ResourceData } func resourceOracleDatabaseCloudExadataInfrastructureUpdate(d *schema.ResourceData, meta interface{}) error { - // Only the root field "labels", "terraform_labels", and virtual fields are mutable + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable return resourceOracleDatabaseCloudExadataInfrastructureRead(d, meta) } func resourceOracleDatabaseCloudExadataInfrastructureDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy OracleDatabaseCloudExadataInfrastructure without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing CloudExadataInfrastructure %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/oracledatabase/resource_oracle_database_cloud_exadata_infrastructure_generated_meta.yaml b/google/services/oracledatabase/resource_oracle_database_cloud_exadata_infrastructure_generated_meta.yaml index 104d0bac63a..c42043244c8 100644 --- a/google/services/oracledatabase/resource_oracle_database_cloud_exadata_infrastructure_generated_meta.yaml +++ b/google/services/oracledatabase/resource_oracle_database_cloud_exadata_infrastructure_generated_meta.yaml @@ -59,3 +59,5 @@ fields: - api_field: properties.totalStorageSizeGb - field: terraform_labels provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/oracledatabase/resource_oracle_database_cloud_vm_cluster.go b/google/services/oracledatabase/resource_oracle_database_cloud_vm_cluster.go index 079a2240245..4151bb1dda9 100644 --- a/google/services/oracledatabase/resource_oracle_database_cloud_vm_cluster.go +++ b/google/services/oracledatabase/resource_oracle_database_cloud_vm_cluster.go @@ -116,6 +116,7 @@ func ResourceOracleDatabaseCloudVmCluster() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -542,6 +543,18 @@ projects/{project}/locations/{region}/cloudVmClusters/{cloud_vm_cluster}`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -739,6 +752,18 @@ func resourceOracleDatabaseCloudVmClusterRead(d *schema.ResourceData, meta inter return fmt.Errorf("Error setting deletion_protection: %s", err) } } + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading CloudVmCluster: %s", err) } @@ -776,11 +801,18 @@ func resourceOracleDatabaseCloudVmClusterRead(d *schema.ResourceData, meta inter } func resourceOracleDatabaseCloudVmClusterUpdate(d *schema.ResourceData, meta interface{}) error { - // Only the root field "labels", "terraform_labels", and virtual fields are mutable + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable return resourceOracleDatabaseCloudVmClusterRead(d, meta) } func resourceOracleDatabaseCloudVmClusterDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy OracleDatabaseCloudVmCluster without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing CloudVmCluster %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/oracledatabase/resource_oracle_database_cloud_vm_cluster_generated_meta.yaml b/google/services/oracledatabase/resource_oracle_database_cloud_vm_cluster_generated_meta.yaml index 0aa86de41e9..72d177a577f 100644 --- a/google/services/oracledatabase/resource_oracle_database_cloud_vm_cluster_generated_meta.yaml +++ b/google/services/oracledatabase/resource_oracle_database_cloud_vm_cluster_generated_meta.yaml @@ -65,3 +65,5 @@ fields: - api_field: properties.timeZone.version - field: terraform_labels provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/oracledatabase/resource_oracle_database_db_system.go b/google/services/oracledatabase/resource_oracle_database_db_system.go index c32292d3ae6..4ee06c363ac 100644 --- a/google/services/oracledatabase/resource_oracle_database_db_system.go +++ b/google/services/oracledatabase/resource_oracle_database_db_system.go @@ -116,6 +116,7 @@ func ResourceOracleDatabaseDbSystem() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -779,6 +780,18 @@ projects/{project}/locations/{region}/dbSystems/{db_system}`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -952,6 +965,18 @@ func resourceOracleDatabaseDbSystemRead(d *schema.ResourceData, meta interface{} return fmt.Errorf("Error setting deletion_protection: %s", err) } } + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading DbSystem: %s", err) } @@ -989,11 +1014,18 @@ func resourceOracleDatabaseDbSystemRead(d *schema.ResourceData, meta interface{} } func resourceOracleDatabaseDbSystemUpdate(d *schema.ResourceData, meta interface{}) error { - // Only the root field "labels", "terraform_labels", and virtual fields are mutable + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable return resourceOracleDatabaseDbSystemRead(d, meta) } func resourceOracleDatabaseDbSystemDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy OracleDatabaseDbSystem without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing DbSystem %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/oracledatabase/resource_oracle_database_db_system_generated_meta.yaml b/google/services/oracledatabase/resource_oracle_database_db_system_generated_meta.yaml index baf63304be2..79ac3c51cb7 100644 --- a/google/services/oracledatabase/resource_oracle_database_db_system_generated_meta.yaml +++ b/google/services/oracledatabase/resource_oracle_database_db_system_generated_meta.yaml @@ -77,3 +77,5 @@ fields: - api_field: properties.timeZone.id - field: terraform_labels provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/oracledatabase/resource_oracle_database_exadb_vm_cluster.go b/google/services/oracledatabase/resource_oracle_database_exadb_vm_cluster.go index dadf8174cf9..325db246bae 100644 --- a/google/services/oracledatabase/resource_oracle_database_exadb_vm_cluster.go +++ b/google/services/oracledatabase/resource_oracle_database_exadb_vm_cluster.go @@ -116,6 +116,7 @@ func ResourceOracleDatabaseExadbVmCluster() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -451,6 +452,18 @@ projects/{project}/locations/{region}/exadbVmClusters/{exadb_vm_cluster}`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -624,6 +637,18 @@ func resourceOracleDatabaseExadbVmClusterRead(d *schema.ResourceData, meta inter return fmt.Errorf("Error setting deletion_protection: %s", err) } } + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading ExadbVmCluster: %s", err) } @@ -661,6 +686,19 @@ func resourceOracleDatabaseExadbVmClusterRead(d *schema.ResourceData, meta inter } func resourceOracleDatabaseExadbVmClusterUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceOracleDatabaseExadbVmCluster().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceOracleDatabaseExadbVmClusterRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -769,6 +807,13 @@ func resourceOracleDatabaseExadbVmClusterUpdate(d *schema.ResourceData, meta int } func resourceOracleDatabaseExadbVmClusterDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy OracleDatabaseExadbVmCluster without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ExadbVmCluster %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/oracledatabase/resource_oracle_database_exadb_vm_cluster_generated_meta.yaml b/google/services/oracledatabase/resource_oracle_database_exadb_vm_cluster_generated_meta.yaml index 8427f0974ea..c76eb361bc9 100644 --- a/google/services/oracledatabase/resource_oracle_database_exadb_vm_cluster_generated_meta.yaml +++ b/google/services/oracledatabase/resource_oracle_database_exadb_vm_cluster_generated_meta.yaml @@ -49,3 +49,5 @@ fields: - api_field: properties.vmFileSystemStorage.sizeInGbsPerNode - field: terraform_labels provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/oracledatabase/resource_oracle_database_exascale_db_storage_vault.go b/google/services/oracledatabase/resource_oracle_database_exascale_db_storage_vault.go index edfff94539b..ee50b3212e1 100644 --- a/google/services/oracledatabase/resource_oracle_database_exascale_db_storage_vault.go +++ b/google/services/oracledatabase/resource_oracle_database_exascale_db_storage_vault.go @@ -116,6 +116,7 @@ func ResourceOracleDatabaseExascaleDbStorageVault() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -351,6 +352,18 @@ projects/{project}/locations/{location}/exascaleDbStorageVaults/{exascale_db_sto Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -512,6 +525,18 @@ func resourceOracleDatabaseExascaleDbStorageVaultRead(d *schema.ResourceData, me return fmt.Errorf("Error setting deletion_protection: %s", err) } } + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading ExascaleDbStorageVault: %s", err) } @@ -549,11 +574,18 @@ func resourceOracleDatabaseExascaleDbStorageVaultRead(d *schema.ResourceData, me } func resourceOracleDatabaseExascaleDbStorageVaultUpdate(d *schema.ResourceData, meta interface{}) error { - // Only the root field "labels", "terraform_labels", and virtual fields are mutable + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable return resourceOracleDatabaseExascaleDbStorageVaultRead(d, meta) } func resourceOracleDatabaseExascaleDbStorageVaultDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy OracleDatabaseExascaleDbStorageVault without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ExascaleDbStorageVault %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/oracledatabase/resource_oracle_database_exascale_db_storage_vault_generated_meta.yaml b/google/services/oracledatabase/resource_oracle_database_exascale_db_storage_vault_generated_meta.yaml index 1d3801e8c13..4baee3cd5fe 100644 --- a/google/services/oracledatabase/resource_oracle_database_exascale_db_storage_vault_generated_meta.yaml +++ b/google/services/oracledatabase/resource_oracle_database_exascale_db_storage_vault_generated_meta.yaml @@ -36,3 +36,5 @@ fields: - api_field: properties.vmClusterIds - field: terraform_labels provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/oracledatabase/resource_oracle_database_odb_network.go b/google/services/oracledatabase/resource_oracle_database_odb_network.go index 76289019ea5..be045b28a83 100644 --- a/google/services/oracledatabase/resource_oracle_database_odb_network.go +++ b/google/services/oracledatabase/resource_oracle_database_odb_network.go @@ -116,6 +116,7 @@ func ResourceOracleDatabaseOdbNetwork() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -234,6 +235,18 @@ FAILED`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -389,6 +402,18 @@ func resourceOracleDatabaseOdbNetworkRead(d *schema.ResourceData, meta interface return fmt.Errorf("Error setting deletion_protection: %s", err) } } + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading OdbNetwork: %s", err) } @@ -426,11 +451,18 @@ func resourceOracleDatabaseOdbNetworkRead(d *schema.ResourceData, meta interface } func resourceOracleDatabaseOdbNetworkUpdate(d *schema.ResourceData, meta interface{}) error { - // Only the root field "labels", "terraform_labels", and virtual fields are mutable + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable return resourceOracleDatabaseOdbNetworkRead(d, meta) } func resourceOracleDatabaseOdbNetworkDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy OracleDatabaseOdbNetwork without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing OdbNetwork %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/oracledatabase/resource_oracle_database_odb_network_generated_meta.yaml b/google/services/oracledatabase/resource_oracle_database_odb_network_generated_meta.yaml index 01e151fcba6..4466a5cd68f 100644 --- a/google/services/oracledatabase/resource_oracle_database_odb_network_generated_meta.yaml +++ b/google/services/oracledatabase/resource_oracle_database_odb_network_generated_meta.yaml @@ -25,3 +25,5 @@ fields: - api_field: state - field: terraform_labels provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/oracledatabase/resource_oracle_database_odb_subnet.go b/google/services/oracledatabase/resource_oracle_database_odb_subnet.go index d34c58bef10..75486ab3d39 100644 --- a/google/services/oracledatabase/resource_oracle_database_odb_subnet.go +++ b/google/services/oracledatabase/resource_oracle_database_odb_subnet.go @@ -116,6 +116,7 @@ func ResourceOracleDatabaseOdbSubnet() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -238,6 +239,18 @@ FAILED`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -398,6 +411,18 @@ func resourceOracleDatabaseOdbSubnetRead(d *schema.ResourceData, meta interface{ return fmt.Errorf("Error setting deletion_protection: %s", err) } } + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading OdbSubnet: %s", err) } @@ -441,11 +466,18 @@ func resourceOracleDatabaseOdbSubnetRead(d *schema.ResourceData, meta interface{ } func resourceOracleDatabaseOdbSubnetUpdate(d *schema.ResourceData, meta interface{}) error { - // Only the root field "labels", "terraform_labels", and virtual fields are mutable + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable return resourceOracleDatabaseOdbSubnetRead(d, meta) } func resourceOracleDatabaseOdbSubnetDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy OracleDatabaseOdbSubnet without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing OdbSubnet %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/oracledatabase/resource_oracle_database_odb_subnet_generated_meta.yaml b/google/services/oracledatabase/resource_oracle_database_odb_subnet_generated_meta.yaml index 0e8157b623f..13f039742ae 100644 --- a/google/services/oracledatabase/resource_oracle_database_odb_subnet_generated_meta.yaml +++ b/google/services/oracledatabase/resource_oracle_database_odb_subnet_generated_meta.yaml @@ -26,3 +26,5 @@ fields: - api_field: state - field: terraform_labels provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/orgpolicy/resource_org_policy_custom_constraint.go b/google/services/orgpolicy/resource_org_policy_custom_constraint.go index 50fce44398b..66bc3203787 100644 --- a/google/services/orgpolicy/resource_org_policy_custom_constraint.go +++ b/google/services/orgpolicy/resource_org_policy_custom_constraint.go @@ -190,6 +190,19 @@ func ResourceOrgPolicyCustomConstraint() *schema.Resource { Computed: true, Description: `Output only. The timestamp representing when the constraint was last updated.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -336,6 +349,20 @@ func resourceOrgPolicyCustomConstraintRead(d *schema.ResourceData, meta interfac log.Printf("[DEBUG] Finished reading OrgPolicyCustomConstraint %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceOrgPolicyCustomConstraintFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -363,6 +390,19 @@ func resourceOrgPolicyCustomConstraintRead(d *schema.ResourceData, meta interfac } func resourceOrgPolicyCustomConstraintUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceOrgPolicyCustomConstraint().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceOrgPolicyCustomConstraintRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -457,6 +497,13 @@ func resourceOrgPolicyCustomConstraintUpdate(d *schema.ResourceData, meta interf } func resourceOrgPolicyCustomConstraintDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy OrgPolicyCustomConstraint without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing CustomConstraint %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/orgpolicy/resource_org_policy_custom_constraint_generated_meta.yaml b/google/services/orgpolicy/resource_org_policy_custom_constraint_generated_meta.yaml index 8f405a00921..7017c9aba7c 100644 --- a/google/services/orgpolicy/resource_org_policy_custom_constraint_generated_meta.yaml +++ b/google/services/orgpolicy/resource_org_policy_custom_constraint_generated_meta.yaml @@ -17,3 +17,5 @@ fields: provider_only: true - api_field: resourceTypes - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/orgpolicy/resource_org_policy_policy.go b/google/services/orgpolicy/resource_org_policy_policy.go index d404f9b8e83..384d242b170 100644 --- a/google/services/orgpolicy/resource_org_policy_policy.go +++ b/google/services/orgpolicy/resource_org_policy_policy.go @@ -453,6 +453,19 @@ func ResourceOrgPolicyPolicy() *schema.Resource { Computed: true, Description: `Optional. An opaque tag indicating the current state of the policy, used for concurrency control. This 'etag' is computed by the server based on the value of other fields, and may be sent on update and delete requests to ensure the client has an up-to-date value before proceeding.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -589,6 +602,20 @@ func resourceOrgPolicyPolicyRead(d *schema.ResourceData, meta interface{}) error log.Printf("[DEBUG] Finished reading OrgPolicyPolicy %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceOrgPolicyPolicyFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -616,6 +643,19 @@ func resourceOrgPolicyPolicyRead(d *schema.ResourceData, meta interface{}) error } func resourceOrgPolicyPolicyUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceOrgPolicyPolicy().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceOrgPolicyPolicyRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -709,6 +749,13 @@ func resourceOrgPolicyPolicyUpdate(d *schema.ResourceData, meta interface{}) err } func resourceOrgPolicyPolicyDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy OrgPolicyPolicy without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Policy %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/orgpolicy/resource_org_policy_policy_generated_meta.yaml b/google/services/orgpolicy/resource_org_policy_policy_generated_meta.yaml index 011986c6f0c..5eaec8d7fcf 100644 --- a/google/services/orgpolicy/resource_org_policy_policy_generated_meta.yaml +++ b/google/services/orgpolicy/resource_org_policy_policy_generated_meta.yaml @@ -45,3 +45,5 @@ fields: - api_field: spec.rules.values.allowedValues - api_field: spec.rules.values.deniedValues - api_field: spec.updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/osconfig/resource_os_config_os_policy_assignment.go b/google/services/osconfig/resource_os_config_os_policy_assignment.go index 80135c98558..6054ce3e39a 100644 --- a/google/services/osconfig/resource_os_config_os_policy_assignment.go +++ b/google/services/osconfig/resource_os_config_os_policy_assignment.go @@ -50,6 +50,7 @@ func ResourceOSConfigOSPolicyAssignment() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -1080,6 +1081,9 @@ For a given OS policy assignment, there is only one revision with a value of 'tr DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName, Description: "The project for the resource", }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, UseJSONNumber: true, } @@ -1288,10 +1292,19 @@ func resourceOSConfigOSPolicyAssignmentRead(d *schema.ResourceData, meta interfa return fmt.Errorf("Error reading OSPolicyAssignment: %s", err) } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } func resourceOSConfigOSPolicyAssignmentUpdate(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceOSConfigOSPolicyAssignment) { + return ResourceOSConfigOSPolicyAssignment().Read(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1402,6 +1415,13 @@ func resourceOSConfigOSPolicyAssignmentUpdate(d *schema.ResourceData, meta inter } func resourceOSConfigOSPolicyAssignmentDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/osconfig/resource_os_config_os_policy_assignment_meta.yaml b/google/services/osconfig/resource_os_config_os_policy_assignment_meta.yaml index ed7fd7842ea..b1e068e10f1 100644 --- a/google/services/osconfig/resource_os_config_os_policy_assignment_meta.yaml +++ b/google/services/osconfig/resource_os_config_os_policy_assignment_meta.yaml @@ -111,3 +111,5 @@ fields: - api_field: 'rolloutState' - field: 'skip_await_rollout' - api_field: 'uid' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/osconfig/resource_os_config_patch_deployment.go b/google/services/osconfig/resource_os_config_patch_deployment.go index 0af76cb5f72..4dcc3150fbb 100644 --- a/google/services/osconfig/resource_os_config_patch_deployment.go +++ b/google/services/osconfig/resource_os_config_patch_deployment.go @@ -100,6 +100,7 @@ func ResourceOSConfigPatchDeployment() *schema.Resource { return &schema.Resource{ Create: resourceOSConfigPatchDeploymentCreate, Read: resourceOSConfigPatchDeploymentRead, + Update: resourceOSConfigPatchDeploymentUpdate, Delete: resourceOSConfigPatchDeploymentDelete, Importer: &schema.ResourceImporter{ @@ -113,6 +114,7 @@ func ResourceOSConfigPatchDeployment() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -1053,6 +1055,18 @@ A timestamp in RFC3339 UTC "Zulu" format, accurate to nanoseconds. Example: "201 Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -1234,6 +1248,19 @@ func resourceOSConfigPatchDeploymentRead(d *schema.ResourceData, meta interface{ return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading PatchDeployment: %s", err) } @@ -1264,7 +1291,19 @@ func resourceOSConfigPatchDeploymentRead(d *schema.ResourceData, meta interface{ return nil } +func resourceOSConfigPatchDeploymentUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceOSConfigPatchDeploymentRead(d, meta) +} + func resourceOSConfigPatchDeploymentDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy OSConfigPatchDeployment without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing PatchDeployment %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/osconfig/resource_os_config_patch_deployment_generated_meta.yaml b/google/services/osconfig/resource_os_config_patch_deployment_generated_meta.yaml index 617647fe79f..593faf8a104 100644 --- a/google/services/osconfig/resource_os_config_patch_deployment_generated_meta.yaml +++ b/google/services/osconfig/resource_os_config_patch_deployment_generated_meta.yaml @@ -84,3 +84,5 @@ fields: field: rollout.disruption_budget.percentage - api_field: rollout.mode - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/osconfigv2/resource_os_config_v2_policy_orchestrator.go b/google/services/osconfigv2/resource_os_config_v2_policy_orchestrator.go index 03033aa522e..c3f51d416da 100644 --- a/google/services/osconfigv2/resource_os_config_v2_policy_orchestrator.go +++ b/google/services/osconfigv2/resource_os_config_v2_policy_orchestrator.go @@ -116,6 +116,7 @@ func ResourceOSConfigV2PolicyOrchestrator() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -1764,6 +1765,18 @@ orchestrator.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -1926,6 +1939,19 @@ func resourceOSConfigV2PolicyOrchestratorRead(d *schema.ResourceData, meta inter log.Printf("[DEBUG] Finished reading OSConfigV2PolicyOrchestrator %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading PolicyOrchestrator: %s", err) } @@ -1957,6 +1983,19 @@ func resourceOSConfigV2PolicyOrchestratorRead(d *schema.ResourceData, meta inter } func resourceOSConfigV2PolicyOrchestratorUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceOSConfigV2PolicyOrchestrator().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceOSConfigV2PolicyOrchestratorRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -2100,6 +2139,13 @@ func resourceOSConfigV2PolicyOrchestratorUpdate(d *schema.ResourceData, meta int } func resourceOSConfigV2PolicyOrchestratorDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy OSConfigV2PolicyOrchestrator without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing PolicyOrchestrator %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/osconfigv2/resource_os_config_v2_policy_orchestrator_for_folder.go b/google/services/osconfigv2/resource_os_config_v2_policy_orchestrator_for_folder.go index c585c2c8d8f..0e285b2c721 100644 --- a/google/services/osconfigv2/resource_os_config_v2_policy_orchestrator_for_folder.go +++ b/google/services/osconfigv2/resource_os_config_v2_policy_orchestrator_for_folder.go @@ -115,6 +115,7 @@ func ResourceOSConfigV2PolicyOrchestratorForFolder() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -1749,6 +1750,19 @@ orchestrator.`, Computed: true, Description: `Timestamp when the policy orchestrator resource was last modified.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -1900,6 +1914,20 @@ func resourceOSConfigV2PolicyOrchestratorForFolderRead(d *schema.ResourceData, m log.Printf("[DEBUG] Finished reading OSConfigV2PolicyOrchestratorForFolder %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceOSConfigV2PolicyOrchestratorForFolderFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -1927,6 +1955,18 @@ func resourceOSConfigV2PolicyOrchestratorForFolderRead(d *schema.ResourceData, m } func resourceOSConfigV2PolicyOrchestratorForFolderUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceOSConfigV2PolicyOrchestratorForFolder().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceOSConfigV2PolicyOrchestratorForFolderRead(d, meta) + } var project string config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) @@ -2065,6 +2105,13 @@ func resourceOSConfigV2PolicyOrchestratorForFolderUpdate(d *schema.ResourceData, } func resourceOSConfigV2PolicyOrchestratorForFolderDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy OSConfigV2PolicyOrchestratorForFolder without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing PolicyOrchestratorForFolder %q from Terraform state without deletion", d.Id()) + return nil + } var project string config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) diff --git a/google/services/osconfigv2/resource_os_config_v2_policy_orchestrator_for_folder_generated_meta.yaml b/google/services/osconfigv2/resource_os_config_v2_policy_orchestrator_for_folder_generated_meta.yaml index 4cfe947060d..f6903c88bd3 100644 --- a/google/services/osconfigv2/resource_os_config_v2_policy_orchestrator_for_folder_generated_meta.yaml +++ b/google/services/osconfigv2/resource_os_config_v2_policy_orchestrator_for_folder_generated_meta.yaml @@ -155,3 +155,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/osconfigv2/resource_os_config_v2_policy_orchestrator_for_organization.go b/google/services/osconfigv2/resource_os_config_v2_policy_orchestrator_for_organization.go index cb581c6fc13..ccaa3e1eb91 100644 --- a/google/services/osconfigv2/resource_os_config_v2_policy_orchestrator_for_organization.go +++ b/google/services/osconfigv2/resource_os_config_v2_policy_orchestrator_for_organization.go @@ -115,6 +115,7 @@ func ResourceOSConfigV2PolicyOrchestratorForOrganization() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -1779,6 +1780,19 @@ orchestrator.`, Computed: true, Description: `Output only. Timestamp when the policy orchestrator resource was last modified.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -1930,6 +1944,20 @@ func resourceOSConfigV2PolicyOrchestratorForOrganizationRead(d *schema.ResourceD log.Printf("[DEBUG] Finished reading OSConfigV2PolicyOrchestratorForOrganization %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceOSConfigV2PolicyOrchestratorForOrganizationFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -1957,6 +1985,18 @@ func resourceOSConfigV2PolicyOrchestratorForOrganizationRead(d *schema.ResourceD } func resourceOSConfigV2PolicyOrchestratorForOrganizationUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceOSConfigV2PolicyOrchestratorForOrganization().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceOSConfigV2PolicyOrchestratorForOrganizationRead(d, meta) + } var project string config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) @@ -2095,6 +2135,13 @@ func resourceOSConfigV2PolicyOrchestratorForOrganizationUpdate(d *schema.Resourc } func resourceOSConfigV2PolicyOrchestratorForOrganizationDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy OSConfigV2PolicyOrchestratorForOrganization without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing PolicyOrchestratorForOrganization %q from Terraform state without deletion", d.Id()) + return nil + } var project string config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) diff --git a/google/services/osconfigv2/resource_os_config_v2_policy_orchestrator_for_organization_generated_meta.yaml b/google/services/osconfigv2/resource_os_config_v2_policy_orchestrator_for_organization_generated_meta.yaml index 4913a26a23a..f8b67949e96 100644 --- a/google/services/osconfigv2/resource_os_config_v2_policy_orchestrator_for_organization_generated_meta.yaml +++ b/google/services/osconfigv2/resource_os_config_v2_policy_orchestrator_for_organization_generated_meta.yaml @@ -155,3 +155,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/osconfigv2/resource_os_config_v2_policy_orchestrator_generated_meta.yaml b/google/services/osconfigv2/resource_os_config_v2_policy_orchestrator_generated_meta.yaml index 38d7fd5b738..bb8ae56a812 100644 --- a/google/services/osconfigv2/resource_os_config_v2_policy_orchestrator_generated_meta.yaml +++ b/google/services/osconfigv2/resource_os_config_v2_policy_orchestrator_generated_meta.yaml @@ -151,3 +151,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/oslogin/resource_os_login_ssh_public_key.go b/google/services/oslogin/resource_os_login_ssh_public_key.go index 51dbb3e4d2d..f2b7fa76b62 100644 --- a/google/services/oslogin/resource_os_login_ssh_public_key.go +++ b/google/services/oslogin/resource_os_login_ssh_public_key.go @@ -161,6 +161,19 @@ func ResourceOSLoginSSHPublicKey() *schema.Resource { Computed: true, Description: `The SHA-256 fingerprint of the SSH public key.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -317,6 +330,20 @@ func resourceOSLoginSSHPublicKeyRead(d *schema.ResourceData, meta interface{}) e log.Printf("[DEBUG] Finished reading OSLoginSSHPublicKey %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceOSLoginSSHPublicKeyFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -344,6 +371,19 @@ func resourceOSLoginSSHPublicKeyRead(d *schema.ResourceData, meta interface{}) e } func resourceOSLoginSSHPublicKeyUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceOSLoginSSHPublicKey().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceOSLoginSSHPublicKeyRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -424,6 +464,13 @@ func resourceOSLoginSSHPublicKeyUpdate(d *schema.ResourceData, meta interface{}) } func resourceOSLoginSSHPublicKeyDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy OSLoginSSHPublicKey without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing SSHPublicKey %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/oslogin/resource_os_login_ssh_public_key_generated_meta.yaml b/google/services/oslogin/resource_os_login_ssh_public_key_generated_meta.yaml index f3ac4e7eacb..a053dcbd4e6 100644 --- a/google/services/oslogin/resource_os_login_ssh_public_key_generated_meta.yaml +++ b/google/services/oslogin/resource_os_login_ssh_public_key_generated_meta.yaml @@ -14,3 +14,5 @@ fields: provider_only: true - field: user provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/parallelstore/resource_parallelstore_instance.go b/google/services/parallelstore/resource_parallelstore_instance.go index c04f8260814..f2f26bbe496 100644 --- a/google/services/parallelstore/resource_parallelstore_instance.go +++ b/google/services/parallelstore/resource_parallelstore_instance.go @@ -116,6 +116,7 @@ func ResourceParallelstoreInstance() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -318,6 +319,18 @@ and contains the value currently used by the service.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -497,6 +510,19 @@ func resourceParallelstoreInstanceRead(d *schema.ResourceData, meta interface{}) log.Printf("[DEBUG] Finished reading ParallelstoreInstance %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Instance: %s", err) } @@ -534,6 +560,19 @@ func resourceParallelstoreInstanceRead(d *schema.ResourceData, meta interface{}) } func resourceParallelstoreInstanceUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceParallelstoreInstance().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceParallelstoreInstanceRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -672,6 +711,13 @@ func resourceParallelstoreInstanceUpdate(d *schema.ResourceData, meta interface{ } func resourceParallelstoreInstanceDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ParallelstoreInstance without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Instance %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/parallelstore/resource_parallelstore_instance_generated_meta.yaml b/google/services/parallelstore/resource_parallelstore_instance_generated_meta.yaml index 133b256fdf5..739f390c466 100644 --- a/google/services/parallelstore/resource_parallelstore_instance_generated_meta.yaml +++ b/google/services/parallelstore/resource_parallelstore_instance_generated_meta.yaml @@ -31,3 +31,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/parametermanager/data_source_parameter_manager_parameters_test.go b/google/services/parametermanager/data_source_parameter_manager_parameters_test.go index 305980b633a..69aa217f72c 100644 --- a/google/services/parametermanager/data_source_parameter_manager_parameters_test.go +++ b/google/services/parametermanager/data_source_parameter_manager_parameters_test.go @@ -46,8 +46,9 @@ func TestAccDataSourceParameterManagerParameters_basic(t *testing.T) { "data.google_parameter_manager_parameters.parameters-datasource", "google_parameter_manager_parameter.parameters", map[string]struct{}{ - "id": {}, - "project": {}, + "id": {}, + "project": {}, + "deletion_policy": {}, }, ), ), @@ -103,8 +104,9 @@ func TestAccDataSourceParameterManagerParameters_filter(t *testing.T) { "google_parameter_manager_parameter.parameters-1", "google_parameter_manager_parameter.parameters-2", map[string]struct{}{ - "id": {}, - "project": {}, + "id": {}, + "project": {}, + "deletion_policy": {}, }, ), ), diff --git a/google/services/parametermanager/resource_parameter_manager_parameter.go b/google/services/parametermanager/resource_parameter_manager_parameter.go index 5cdfe98b5b9..c0801d716b4 100644 --- a/google/services/parametermanager/resource_parameter_manager_parameter.go +++ b/google/services/parametermanager/resource_parameter_manager_parameter.go @@ -116,6 +116,7 @@ func ResourceParameterManagerParameter() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -239,6 +240,18 @@ new resource. Format: Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -373,6 +386,19 @@ func resourceParameterManagerParameterRead(d *schema.ResourceData, meta interfac log.Printf("[DEBUG] Finished reading ParameterManagerParameter %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Parameter: %s", err) } @@ -404,6 +430,19 @@ func resourceParameterManagerParameterRead(d *schema.ResourceData, meta interfac } func resourceParameterManagerParameterUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceParameterManagerParameter().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceParameterManagerParameterRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -500,6 +539,13 @@ func resourceParameterManagerParameterUpdate(d *schema.ResourceData, meta interf } func resourceParameterManagerParameterDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ParameterManagerParameter without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Parameter %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/parametermanager/resource_parameter_manager_parameter_generated_meta.yaml b/google/services/parametermanager/resource_parameter_manager_parameter_generated_meta.yaml index b5424e3554a..2ca19e782f5 100644 --- a/google/services/parametermanager/resource_parameter_manager_parameter_generated_meta.yaml +++ b/google/services/parametermanager/resource_parameter_manager_parameter_generated_meta.yaml @@ -21,3 +21,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/parametermanager/resource_parameter_manager_parameter_version.go b/google/services/parametermanager/resource_parameter_manager_parameter_version.go index d93bd9b508a..990a0588f66 100644 --- a/google/services/parametermanager/resource_parameter_manager_parameter_version.go +++ b/google/services/parametermanager/resource_parameter_manager_parameter_version.go @@ -162,6 +162,19 @@ func ResourceParameterManagerParameterVersion() *schema.Resource { Computed: true, Description: `The time at which the Parameter Version was updated.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -262,6 +275,20 @@ func resourceParameterManagerParameterVersionRead(d *schema.ResourceData, meta i log.Printf("[DEBUG] Finished reading ParameterManagerParameterVersion %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceParameterManagerParameterVersionFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -271,6 +298,19 @@ func resourceParameterManagerParameterVersionRead(d *schema.ResourceData, meta i } func resourceParameterManagerParameterVersionUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceParameterManagerParameterVersion().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceParameterManagerParameterVersionRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -336,6 +376,13 @@ func resourceParameterManagerParameterVersionUpdate(d *schema.ResourceData, meta } func resourceParameterManagerParameterVersionDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ParameterManagerParameterVersion without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ParameterVersion %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/parametermanager/resource_parameter_manager_parameter_version_generated_meta.yaml b/google/services/parametermanager/resource_parameter_manager_parameter_version_generated_meta.yaml index 433dc6920b1..bfd3ca4265f 100644 --- a/google/services/parametermanager/resource_parameter_manager_parameter_version_generated_meta.yaml +++ b/google/services/parametermanager/resource_parameter_manager_parameter_version_generated_meta.yaml @@ -18,3 +18,5 @@ fields: - field: parameter_version_id provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/parametermanagerregional/data_source_parameter_manager_regional_parameters_test.go b/google/services/parametermanagerregional/data_source_parameter_manager_regional_parameters_test.go index 947b08443de..aae758b0e00 100644 --- a/google/services/parametermanagerregional/data_source_parameter_manager_regional_parameters_test.go +++ b/google/services/parametermanagerregional/data_source_parameter_manager_regional_parameters_test.go @@ -46,8 +46,9 @@ func TestAccDataSourceParameterManagerRegionalRegionalParameters_basic(t *testin "data.google_parameter_manager_regional_parameters.regional-parameters-datasource", "google_parameter_manager_regional_parameter.regional-parameters", map[string]struct{}{ - "id": {}, - "project": {}, + "id": {}, + "project": {}, + "deletion_policy": {}, }, ), ), @@ -105,8 +106,9 @@ func TestAccDataSourceParameterManagerRegionalRegionalParameters_filter(t *testi "google_parameter_manager_regional_parameter.regional-parameters-1", "google_parameter_manager_regional_parameter.regional-parameters-2", map[string]struct{}{ - "id": {}, - "project": {}, + "id": {}, + "project": {}, + "deletion_policy": {}, }, ), ), diff --git a/google/services/parametermanagerregional/resource_parameter_manager_regional_parameter.go b/google/services/parametermanagerregional/resource_parameter_manager_regional_parameter.go index e442da0a6da..140e678bcfc 100644 --- a/google/services/parametermanagerregional/resource_parameter_manager_regional_parameter.go +++ b/google/services/parametermanagerregional/resource_parameter_manager_regional_parameter.go @@ -116,6 +116,7 @@ func ResourceParameterManagerRegionalRegionalParameter() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -248,6 +249,18 @@ resource. Format: Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -387,6 +400,19 @@ func resourceParameterManagerRegionalRegionalParameterRead(d *schema.ResourceDat log.Printf("[DEBUG] Finished reading ParameterManagerRegionalRegionalParameter %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading RegionalParameter: %s", err) } @@ -424,6 +450,19 @@ func resourceParameterManagerRegionalRegionalParameterRead(d *schema.ResourceDat } func resourceParameterManagerRegionalRegionalParameterUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceParameterManagerRegionalRegionalParameter().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceParameterManagerRegionalRegionalParameterRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -525,6 +564,13 @@ func resourceParameterManagerRegionalRegionalParameterUpdate(d *schema.ResourceD } func resourceParameterManagerRegionalRegionalParameterDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ParameterManagerRegionalRegionalParameter without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing RegionalParameter %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/parametermanagerregional/resource_parameter_manager_regional_parameter_generated_meta.yaml b/google/services/parametermanagerregional/resource_parameter_manager_regional_parameter_generated_meta.yaml index c4161ea96f3..05fe78edd25 100644 --- a/google/services/parametermanagerregional/resource_parameter_manager_regional_parameter_generated_meta.yaml +++ b/google/services/parametermanagerregional/resource_parameter_manager_regional_parameter_generated_meta.yaml @@ -23,3 +23,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/parametermanagerregional/resource_parameter_manager_regional_parameter_version.go b/google/services/parametermanagerregional/resource_parameter_manager_regional_parameter_version.go index 40652d7f313..86c3e064a90 100644 --- a/google/services/parametermanagerregional/resource_parameter_manager_regional_parameter_version.go +++ b/google/services/parametermanagerregional/resource_parameter_manager_regional_parameter_version.go @@ -167,6 +167,19 @@ func ResourceParameterManagerRegionalRegionalParameterVersion() *schema.Resource Computed: true, Description: `The time at which the Regional Parameter Version was updated.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -284,6 +297,20 @@ func resourceParameterManagerRegionalRegionalParameterVersionRead(d *schema.Reso log.Printf("[DEBUG] Finished reading ParameterManagerRegionalRegionalParameterVersion %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceParameterManagerRegionalRegionalParameterVersionFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -293,6 +320,19 @@ func resourceParameterManagerRegionalRegionalParameterVersionRead(d *schema.Reso } func resourceParameterManagerRegionalRegionalParameterVersionUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceParameterManagerRegionalRegionalParameterVersion().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceParameterManagerRegionalRegionalParameterVersionRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -358,6 +398,13 @@ func resourceParameterManagerRegionalRegionalParameterVersionUpdate(d *schema.Re } func resourceParameterManagerRegionalRegionalParameterVersionDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ParameterManagerRegionalRegionalParameterVersion without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing RegionalParameterVersion %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/parametermanagerregional/resource_parameter_manager_regional_parameter_version_generated_meta.yaml b/google/services/parametermanagerregional/resource_parameter_manager_regional_parameter_version_generated_meta.yaml index cf1c4184a13..5ffc5e92a92 100644 --- a/google/services/parametermanagerregional/resource_parameter_manager_regional_parameter_version_generated_meta.yaml +++ b/google/services/parametermanagerregional/resource_parameter_manager_regional_parameter_version_generated_meta.yaml @@ -20,3 +20,5 @@ fields: - field: parameter_version_id provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/privateca/resource_privateca_ca_pool.go b/google/services/privateca/resource_privateca_ca_pool.go index 7d2b6587c05..8c0bbc90315 100644 --- a/google/services/privateca/resource_privateca_ca_pool.go +++ b/google/services/privateca/resource_privateca_ca_pool.go @@ -116,6 +116,7 @@ func ResourcePrivatecaCaPool() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -730,6 +731,18 @@ will be published in PEM. Possible values: ["PEM", "DER"]`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -891,6 +904,19 @@ func resourcePrivatecaCaPoolRead(d *schema.ResourceData, meta interface{}) error log.Printf("[DEBUG] Finished reading PrivatecaCaPool %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading CaPool: %s", err) } @@ -928,6 +954,19 @@ func resourcePrivatecaCaPoolRead(d *schema.ResourceData, meta interface{}) error } func resourcePrivatecaCaPoolUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourcePrivatecaCaPool().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourcePrivatecaCaPoolRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1056,6 +1095,13 @@ func resourcePrivatecaCaPoolUpdate(d *schema.ResourceData, meta interface{}) err } func resourcePrivatecaCaPoolDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy PrivatecaCaPool without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing CaPool %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/privateca/resource_privateca_ca_pool_generated_meta.yaml b/google/services/privateca/resource_privateca_ca_pool_generated_meta.yaml index 4a97ab48064..f9c4f3a1687 100644 --- a/google/services/privateca/resource_privateca_ca_pool_generated_meta.yaml +++ b/google/services/privateca/resource_privateca_ca_pool_generated_meta.yaml @@ -70,3 +70,5 @@ fields: - field: terraform_labels provider_only: true - api_field: tier + - field: deletion_policy + provider_only: true diff --git a/google/services/privateca/resource_privateca_certificate.go b/google/services/privateca/resource_privateca_certificate.go index a53b813b862..450d21afa3b 100644 --- a/google/services/privateca/resource_privateca_certificate.go +++ b/google/services/privateca/resource_privateca_certificate.go @@ -116,6 +116,7 @@ func ResourcePrivatecaCertificate() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -1385,6 +1386,18 @@ This is in RFC3339 text format.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -1548,6 +1561,19 @@ func resourcePrivatecaCertificateRead(d *schema.ResourceData, meta interface{}) log.Printf("[DEBUG] Finished reading PrivatecaCertificate %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Certificate: %s", err) } @@ -1591,6 +1617,19 @@ func resourcePrivatecaCertificateRead(d *schema.ResourceData, meta interface{}) } func resourcePrivatecaCertificateUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourcePrivatecaCertificate().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourcePrivatecaCertificateRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1687,6 +1726,13 @@ func resourcePrivatecaCertificateUpdate(d *schema.ResourceData, meta interface{} } func resourcePrivatecaCertificateDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy PrivatecaCertificate without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Certificate %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/privateca/resource_privateca_certificate_authority.go b/google/services/privateca/resource_privateca_certificate_authority.go index c21c05e6a4b..da7e923f166 100644 --- a/google/services/privateca/resource_privateca_certificate_authority.go +++ b/google/services/privateca/resource_privateca_certificate_authority.go @@ -134,6 +134,7 @@ func ResourcePrivatecaCertificateAuthority() *schema.Resource { resourcePrivateCaCACustomDiff, tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -969,6 +970,18 @@ Possible values: ENABLED, DISABLED, STAGED.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -1197,6 +1210,18 @@ func resourcePrivatecaCertificateAuthorityRead(d *schema.ResourceData, meta inte return fmt.Errorf("Error setting deletion_protection: %s", err) } } + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading CertificateAuthority: %s", err) } @@ -1240,6 +1265,19 @@ func resourcePrivatecaCertificateAuthorityRead(d *schema.ResourceData, meta inte } func resourcePrivatecaCertificateAuthorityUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourcePrivatecaCertificateAuthority().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourcePrivatecaCertificateAuthorityRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1421,6 +1459,13 @@ func resourcePrivatecaCertificateAuthorityUpdate(d *schema.ResourceData, meta in } func resourcePrivatecaCertificateAuthorityDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy PrivatecaCertificateAuthority without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing CertificateAuthority %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/privateca/resource_privateca_certificate_authority_generated_meta.yaml b/google/services/privateca/resource_privateca_certificate_authority_generated_meta.yaml index 19093db66e6..6a2f5da3410 100644 --- a/google/services/privateca/resource_privateca_certificate_authority_generated_meta.yaml +++ b/google/services/privateca/resource_privateca_certificate_authority_generated_meta.yaml @@ -93,3 +93,5 @@ fields: - api_field: updateTime - api_field: userDefinedAccessUrls.aiaIssuingCertificateUrls - api_field: userDefinedAccessUrls.crlAccessUrls + - field: deletion_policy + provider_only: true diff --git a/google/services/privateca/resource_privateca_certificate_generated_meta.yaml b/google/services/privateca/resource_privateca_certificate_generated_meta.yaml index ed922513d5d..f5014ad6c1e 100644 --- a/google/services/privateca/resource_privateca_certificate_generated_meta.yaml +++ b/google/services/privateca/resource_privateca_certificate_generated_meta.yaml @@ -139,3 +139,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/privateca/resource_privateca_certificate_template.go b/google/services/privateca/resource_privateca_certificate_template.go index 58b6c667681..40d014e8bb7 100644 --- a/google/services/privateca/resource_privateca_certificate_template.go +++ b/google/services/privateca/resource_privateca_certificate_template.go @@ -116,6 +116,7 @@ func ResourcePrivatecaCertificateTemplate() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -636,6 +637,18 @@ leading period (like '.example.com')`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -803,6 +816,19 @@ func resourcePrivatecaCertificateTemplateRead(d *schema.ResourceData, meta inter log.Printf("[DEBUG] Finished reading PrivatecaCertificateTemplate %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading CertificateTemplate: %s", err) } @@ -840,6 +866,19 @@ func resourcePrivatecaCertificateTemplateRead(d *schema.ResourceData, meta inter } func resourcePrivatecaCertificateTemplateUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourcePrivatecaCertificateTemplate().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourcePrivatecaCertificateTemplateRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -988,6 +1027,13 @@ func resourcePrivatecaCertificateTemplateUpdate(d *schema.ResourceData, meta int } func resourcePrivatecaCertificateTemplateDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy PrivatecaCertificateTemplate without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing CertificateTemplate %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/privateca/resource_privateca_certificate_template_generated_meta.yaml b/google/services/privateca/resource_privateca_certificate_template_generated_meta.yaml index 3c12aa95faa..568e8aca984 100644 --- a/google/services/privateca/resource_privateca_certificate_template_generated_meta.yaml +++ b/google/services/privateca/resource_privateca_certificate_template_generated_meta.yaml @@ -64,3 +64,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/privilegedaccessmanager/resource_privileged_access_manager_entitlement.go b/google/services/privilegedaccessmanager/resource_privileged_access_manager_entitlement.go index 2eabcdeb4fd..2a0c2f42b17 100644 --- a/google/services/privilegedaccessmanager/resource_privileged_access_manager_entitlement.go +++ b/google/services/privilegedaccessmanager/resource_privileged_access_manager_entitlement.go @@ -425,6 +425,19 @@ Formats: organizations/{organization-number}/locations/{region}/entitlements/{en Description: `Output only. Update time stamp. A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -586,6 +599,20 @@ func resourcePrivilegedAccessManagerEntitlementRead(d *schema.ResourceData, meta log.Printf("[DEBUG] Finished reading PrivilegedAccessManagerEntitlement %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourcePrivilegedAccessManagerEntitlementFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -619,6 +646,19 @@ func resourcePrivilegedAccessManagerEntitlementRead(d *schema.ResourceData, meta } func resourcePrivilegedAccessManagerEntitlementUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourcePrivilegedAccessManagerEntitlement().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourcePrivilegedAccessManagerEntitlementRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -774,6 +814,13 @@ func resourcePrivilegedAccessManagerEntitlementUpdate(d *schema.ResourceData, me } func resourcePrivilegedAccessManagerEntitlementDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy PrivilegedAccessManagerEntitlement without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Entitlement %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/privilegedaccessmanager/resource_privileged_access_manager_entitlement_generated_meta.yaml b/google/services/privilegedaccessmanager/resource_privileged_access_manager_entitlement_generated_meta.yaml index 31d2133db74..b11b87efd08 100644 --- a/google/services/privilegedaccessmanager/resource_privileged_access_manager_entitlement_generated_meta.yaml +++ b/google/services/privilegedaccessmanager/resource_privileged_access_manager_entitlement_generated_meta.yaml @@ -36,3 +36,5 @@ fields: - api_field: requesterJustificationConfig.unstructured - api_field: state - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/pubsub/resource_pubsub_schema.go b/google/services/pubsub/resource_pubsub_schema.go index 5e74c472401..71f10d504fe 100644 --- a/google/services/pubsub/resource_pubsub_schema.go +++ b/google/services/pubsub/resource_pubsub_schema.go @@ -115,6 +115,7 @@ func ResourcePubsubSchema() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -168,6 +169,18 @@ error indicating that the limit has been reached require manually Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -343,6 +356,19 @@ func resourcePubsubSchemaRead(d *schema.ResourceData, meta interface{}) error { log.Printf("[DEBUG] Finished reading PubsubSchema %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Schema: %s", err) } @@ -374,6 +400,19 @@ func resourcePubsubSchemaRead(d *schema.ResourceData, meta interface{}) error { } func resourcePubsubSchemaUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourcePubsubSchema().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourcePubsubSchemaRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -462,6 +501,13 @@ func resourcePubsubSchemaUpdate(d *schema.ResourceData, meta interface{}) error } func resourcePubsubSchemaDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy PubsubSchema without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Schema %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/pubsub/resource_pubsub_schema_generated_meta.yaml b/google/services/pubsub/resource_pubsub_schema_generated_meta.yaml index e55702252ad..f502860334e 100644 --- a/google/services/pubsub/resource_pubsub_schema_generated_meta.yaml +++ b/google/services/pubsub/resource_pubsub_schema_generated_meta.yaml @@ -10,3 +10,5 @@ fields: - api_field: definition - api_field: name - api_field: type + - field: deletion_policy + provider_only: true diff --git a/google/services/pubsub/resource_pubsub_subscription.go b/google/services/pubsub/resource_pubsub_subscription.go index d441a1c4285..f4fa81335d8 100644 --- a/google/services/pubsub/resource_pubsub_subscription.go +++ b/google/services/pubsub/resource_pubsub_subscription.go @@ -150,6 +150,7 @@ func ResourcePubsubSubscription() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -767,6 +768,18 @@ resource.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -1036,6 +1049,19 @@ func resourcePubsubSubscriptionRead(d *schema.ResourceData, meta interface{}) er log.Printf("[DEBUG] Finished reading PubsubSubscription %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Subscription: %s", err) } @@ -1067,6 +1093,19 @@ func resourcePubsubSubscriptionRead(d *schema.ResourceData, meta interface{}) er } func resourcePubsubSubscriptionUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourcePubsubSubscription().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourcePubsubSubscriptionRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1277,6 +1316,13 @@ func resourcePubsubSubscriptionUpdate(d *schema.ResourceData, meta interface{}) } func resourcePubsubSubscriptionDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy PubsubSubscription without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Subscription %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/pubsub/resource_pubsub_subscription_generated_meta.yaml b/google/services/pubsub/resource_pubsub_subscription_generated_meta.yaml index 14a9bf3ee07..1966d3c36ec 100644 --- a/google/services/pubsub/resource_pubsub_subscription_generated_meta.yaml +++ b/google/services/pubsub/resource_pubsub_subscription_generated_meta.yaml @@ -55,3 +55,5 @@ fields: - field: terraform_labels provider_only: true - api_field: topic + - field: deletion_policy + provider_only: true diff --git a/google/services/pubsub/resource_pubsub_topic.go b/google/services/pubsub/resource_pubsub_topic.go index 38a7c715822..cdff2ba028e 100644 --- a/google/services/pubsub/resource_pubsub_topic.go +++ b/google/services/pubsub/resource_pubsub_topic.go @@ -116,6 +116,7 @@ func ResourcePubsubTopic() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -643,6 +644,18 @@ resource.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -867,6 +880,19 @@ func resourcePubsubTopicRead(d *schema.ResourceData, meta interface{}) error { log.Printf("[DEBUG] Finished reading PubsubTopic %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Topic: %s", err) } @@ -898,6 +924,19 @@ func resourcePubsubTopicRead(d *schema.ResourceData, meta interface{}) error { } func resourcePubsubTopicUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourcePubsubTopic().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourcePubsubTopicRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1050,6 +1089,13 @@ func resourcePubsubTopicUpdate(d *schema.ResourceData, meta interface{}) error { } func resourcePubsubTopicDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy PubsubTopic without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Topic %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/pubsub/resource_pubsub_topic_generated_meta.yaml b/google/services/pubsub/resource_pubsub_topic_generated_meta.yaml index c979aa30cec..5fea19a285a 100644 --- a/google/services/pubsub/resource_pubsub_topic_generated_meta.yaml +++ b/google/services/pubsub/resource_pubsub_topic_generated_meta.yaml @@ -53,3 +53,5 @@ fields: - api_field: tags - field: terraform_labels provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/pubsublite/resource_pubsub_lite_reservation.go b/google/services/pubsublite/resource_pubsub_lite_reservation.go index 50ff45ffd69..c6ddc05b1a7 100644 --- a/google/services/pubsublite/resource_pubsub_lite_reservation.go +++ b/google/services/pubsublite/resource_pubsub_lite_reservation.go @@ -115,6 +115,7 @@ func ResourcePubsubLiteReservation() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), DeprecationMessage: "[Pubsub Lite is deprecated and will be turned down effective March 18, 2026](https://cloud.google.com/pubsub/lite/docs/release-notes#June_17_2024). The resource will be removed in a future major release, please use `google_pubsub_reservation` instead.", @@ -168,6 +169,18 @@ messages.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -295,6 +308,19 @@ func resourcePubsubLiteReservationRead(d *schema.ResourceData, meta interface{}) log.Printf("[DEBUG] Finished reading PubsubLiteReservation %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Reservation: %s", err) } @@ -332,6 +358,19 @@ func resourcePubsubLiteReservationRead(d *schema.ResourceData, meta interface{}) } func resourcePubsubLiteReservationUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourcePubsubLiteReservation().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourcePubsubLiteReservationRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -423,6 +462,13 @@ func resourcePubsubLiteReservationUpdate(d *schema.ResourceData, meta interface{ } func resourcePubsubLiteReservationDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy PubsubLiteReservation without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Reservation %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/pubsublite/resource_pubsub_lite_reservation_generated_meta.yaml b/google/services/pubsublite/resource_pubsub_lite_reservation_generated_meta.yaml index ecfaf478ad0..5247b15394f 100644 --- a/google/services/pubsublite/resource_pubsub_lite_reservation_generated_meta.yaml +++ b/google/services/pubsublite/resource_pubsub_lite_reservation_generated_meta.yaml @@ -12,3 +12,5 @@ fields: - field: region provider_only: true - api_field: throughputCapacity + - field: deletion_policy + provider_only: true diff --git a/google/services/pubsublite/resource_pubsub_lite_subscription.go b/google/services/pubsublite/resource_pubsub_lite_subscription.go index 4568890f517..f5a8805d286 100644 --- a/google/services/pubsublite/resource_pubsub_lite_subscription.go +++ b/google/services/pubsublite/resource_pubsub_lite_subscription.go @@ -115,6 +115,7 @@ func ResourcePubsubLiteSubscription() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), DeprecationMessage: "[Pubsub Lite is deprecated and will be turned down effective March 18, 2026](https://cloud.google.com/pubsub/lite/docs/release-notes#June_17_2024). The resource will be removed in a future major release, please use `google_pubsub_subscription` instead.", @@ -189,6 +190,18 @@ func ResourcePubsubLiteSubscription() *schema.Resource { Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -327,6 +340,19 @@ func resourcePubsubLiteSubscriptionRead(d *schema.ResourceData, meta interface{} log.Printf("[DEBUG] Finished reading PubsubLiteSubscription %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Subscription: %s", err) } @@ -364,6 +390,19 @@ func resourcePubsubLiteSubscriptionRead(d *schema.ResourceData, meta interface{} } func resourcePubsubLiteSubscriptionUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourcePubsubLiteSubscription().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourcePubsubLiteSubscriptionRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -460,6 +499,13 @@ func resourcePubsubLiteSubscriptionUpdate(d *schema.ResourceData, meta interface } func resourcePubsubLiteSubscriptionDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy PubsubLiteSubscription without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Subscription %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/pubsublite/resource_pubsub_lite_subscription_generated_meta.yaml b/google/services/pubsublite/resource_pubsub_lite_subscription_generated_meta.yaml index 08ee33e3a0e..984ec88fe86 100644 --- a/google/services/pubsublite/resource_pubsub_lite_subscription_generated_meta.yaml +++ b/google/services/pubsublite/resource_pubsub_lite_subscription_generated_meta.yaml @@ -15,3 +15,5 @@ fields: - api_field: topic - field: zone provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/pubsublite/resource_pubsub_lite_topic.go b/google/services/pubsublite/resource_pubsub_lite_topic.go index a163d8cb161..b702d042f0b 100644 --- a/google/services/pubsublite/resource_pubsub_lite_topic.go +++ b/google/services/pubsublite/resource_pubsub_lite_topic.go @@ -115,6 +115,7 @@ func ResourcePubsubLiteTopic() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), DeprecationMessage: "[Pubsub Lite is deprecated and will be turned down effective March 18, 2026](https://cloud.google.com/pubsub/lite/docs/release-notes#June_17_2024). The resource will be removed in a future major release, please use `google_pubsub_topic` instead.", @@ -242,6 +243,18 @@ Example: "3.5s".`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -386,6 +399,19 @@ func resourcePubsubLiteTopicRead(d *schema.ResourceData, meta interface{}) error log.Printf("[DEBUG] Finished reading PubsubLiteTopic %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Topic: %s", err) } @@ -423,6 +449,19 @@ func resourcePubsubLiteTopicRead(d *schema.ResourceData, meta interface{}) error } func resourcePubsubLiteTopicUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourcePubsubLiteTopic().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourcePubsubLiteTopicRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -539,6 +578,13 @@ func resourcePubsubLiteTopicUpdate(d *schema.ResourceData, meta interface{}) err } func resourcePubsubLiteTopicDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy PubsubLiteTopic without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Topic %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/pubsublite/resource_pubsub_lite_topic_generated_meta.yaml b/google/services/pubsublite/resource_pubsub_lite_topic_generated_meta.yaml index 941d9fe64a6..6c16b5e57ca 100644 --- a/google/services/pubsublite/resource_pubsub_lite_topic_generated_meta.yaml +++ b/google/services/pubsublite/resource_pubsub_lite_topic_generated_meta.yaml @@ -19,3 +19,5 @@ fields: - api_field: retentionConfig.period - field: zone provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/recaptchaenterprise/resource_recaptcha_enterprise_key.go b/google/services/recaptchaenterprise/resource_recaptcha_enterprise_key.go index 975a9388e7d..4f33283d30a 100644 --- a/google/services/recaptchaenterprise/resource_recaptcha_enterprise_key.go +++ b/google/services/recaptchaenterprise/resource_recaptcha_enterprise_key.go @@ -52,6 +52,7 @@ func ResourceRecaptchaEnterpriseKey() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, tpgresource.SetLabelsDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -145,6 +146,9 @@ func ResourceRecaptchaEnterpriseKey() *schema.Resource { Computed: true, Description: "The combination of labels configured directly on the resource and default labels configured on the provider.", }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, } } @@ -471,9 +475,18 @@ func resourceRecaptchaEnterpriseKeyRead(d *schema.ResourceData, meta interface{} return fmt.Errorf("error setting terraform_labels in state: %s", err) } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } func resourceRecaptchaEnterpriseKeyUpdate(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceRecaptchaEnterpriseKey) { + return ResourceRecaptchaEnterpriseKey().Read(d, meta) + } + config := meta.(*transport_tpg.Config) project, err := tpgresource.GetProject(d, config) if err != nil { @@ -525,6 +538,13 @@ func resourceRecaptchaEnterpriseKeyUpdate(d *schema.ResourceData, meta interface } func resourceRecaptchaEnterpriseKeyDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) project, err := tpgresource.GetProject(d, config) if err != nil { diff --git a/google/services/recaptchaenterprise/resource_recaptcha_enterprise_key_meta.yaml b/google/services/recaptchaenterprise/resource_recaptcha_enterprise_key_meta.yaml index bb37c904fa3..f1605bbe1c7 100644 --- a/google/services/recaptchaenterprise/resource_recaptcha_enterprise_key_meta.yaml +++ b/google/services/recaptchaenterprise/resource_recaptcha_enterprise_key_meta.yaml @@ -28,6 +28,8 @@ fields: - api_field: 'webSettings.allowedDomains' - api_field: 'webSettings.challengeSecurityPreference' - api_field: 'webSettings.integrationType' + - field: 'deletion_policy' + provider_only: true - api_field: 'webSettings.challengeSettings.defaultSettings.scoreThreshold' - field: 'web_settings.challenge_settings.action_settings.action' provider_only: true diff --git a/google/services/redis/resource_redis_cluster.go b/google/services/redis/resource_redis_cluster.go index ad8e422945b..ee68ae81dfa 100644 --- a/google/services/redis/resource_redis_cluster.go +++ b/google/services/redis/resource_redis_cluster.go @@ -117,6 +117,7 @@ func ResourceRedisCluster() *schema.Resource { tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, tpgresource.DefaultProviderRegion, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -899,6 +900,18 @@ resolution and up to nine fractional digits.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -1167,6 +1180,19 @@ func resourceRedisClusterRead(d *schema.ResourceData, meta interface{}) error { return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Cluster: %s", err) } @@ -1212,6 +1238,19 @@ func resourceRedisClusterRead(d *schema.ResourceData, meta interface{}) error { } func resourceRedisClusterUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceRedisCluster().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceRedisClusterRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1455,6 +1494,13 @@ func resourceRedisClusterUpdate(d *schema.ResourceData, meta interface{}) error } func resourceRedisClusterDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy RedisCluster without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Cluster %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/redis/resource_redis_cluster_generated_meta.yaml b/google/services/redis/resource_redis_cluster_generated_meta.yaml index 31bcc66543a..f1118d8ccb5 100644 --- a/google/services/redis/resource_redis_cluster_generated_meta.yaml +++ b/google/services/redis/resource_redis_cluster_generated_meta.yaml @@ -80,3 +80,5 @@ fields: - api_field: uid - api_field: zoneDistributionConfig.mode - api_field: zoneDistributionConfig.zone + - field: deletion_policy + provider_only: true diff --git a/google/services/redis/resource_redis_cluster_user_created_connections.go b/google/services/redis/resource_redis_cluster_user_created_connections.go index d37d9f57013..c83598e4223 100644 --- a/google/services/redis/resource_redis_cluster_user_created_connections.go +++ b/google/services/redis/resource_redis_cluster_user_created_connections.go @@ -115,6 +115,7 @@ func ResourceRedisClusterUserCreatedConnections() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -238,6 +239,18 @@ service attachment.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -375,6 +388,19 @@ func resourceRedisClusterUserCreatedConnectionsRead(d *schema.ResourceData, meta log.Printf("[DEBUG] Finished reading RedisClusterUserCreatedConnections %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading ClusterUserCreatedConnections: %s", err) } @@ -412,6 +438,19 @@ func resourceRedisClusterUserCreatedConnectionsRead(d *schema.ResourceData, meta } func resourceRedisClusterUserCreatedConnectionsUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceRedisClusterUserCreatedConnections().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceRedisClusterUserCreatedConnectionsRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -510,6 +549,13 @@ func resourceRedisClusterUserCreatedConnectionsUpdate(d *schema.ResourceData, me } func resourceRedisClusterUserCreatedConnectionsDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy RedisClusterUserCreatedConnections without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ClusterUserCreatedConnections %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/redis/resource_redis_cluster_user_created_connections_generated_meta.yaml b/google/services/redis/resource_redis_cluster_user_created_connections_generated_meta.yaml index fb65757c64e..40b22ddc816 100644 --- a/google/services/redis/resource_redis_cluster_user_created_connections_generated_meta.yaml +++ b/google/services/redis/resource_redis_cluster_user_created_connections_generated_meta.yaml @@ -19,3 +19,5 @@ fields: provider_only: true - field: region provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/redis/resource_redis_instance.go b/google/services/redis/resource_redis_instance.go index cad51825ddc..ab2f8b0ac23 100644 --- a/google/services/redis/resource_redis_instance.go +++ b/google/services/redis/resource_redis_instance.go @@ -155,6 +155,7 @@ func ResourceRedisInstance() *schema.Resource { customdiff.ForceNewIfChange("redis_version", isRedisVersionDecreasing), tpgresource.DefaultProviderProject, tpgresource.SetLabelsDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -680,6 +681,18 @@ When the field is set to false, deleting the instance is allowed.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -955,6 +968,18 @@ func resourceRedisInstanceRead(d *schema.ResourceData, meta interface{}) error { } // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Instance: %s", err) } @@ -1000,6 +1025,19 @@ func resourceRedisInstanceRead(d *schema.ResourceData, meta interface{}) error { } func resourceRedisInstanceUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceRedisInstance().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceRedisInstanceRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1252,6 +1290,13 @@ func resourceRedisInstanceUpdate(d *schema.ResourceData, meta interface{}) error } func resourceRedisInstanceDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy RedisInstance without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Instance %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/redis/resource_redis_instance_generated_meta.yaml b/google/services/redis/resource_redis_instance_generated_meta.yaml index c5576fec7ca..7f81cf7c045 100644 --- a/google/services/redis/resource_redis_instance_generated_meta.yaml +++ b/google/services/redis/resource_redis_instance_generated_meta.yaml @@ -66,3 +66,5 @@ fields: provider_only: true - api_field: tier - api_field: transitEncryptionMode + - field: deletion_policy + provider_only: true diff --git a/google/services/resourcemanager/data_source_google_folder.go b/google/services/resourcemanager/data_source_google_folder.go index 6355fe59e05..831a4b60cbc 100644 --- a/google/services/resourcemanager/data_source_google_folder.go +++ b/google/services/resourcemanager/data_source_google_folder.go @@ -80,6 +80,10 @@ func DataSourceGoogleFolder() *schema.Resource { Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Computed: true, + }, }, } } diff --git a/google/services/resourcemanager/list_google_service_account.go b/google/services/resourcemanager/list_google_service_account.go index 422ede81fc6..e228c7a39b4 100644 --- a/google/services/resourcemanager/list_google_service_account.go +++ b/google/services/resourcemanager/list_google_service_account.go @@ -107,7 +107,7 @@ func flattenGoogleServiceAccountListItem(res map[string]interface{}, d *schema.R return err } d.SetId(sa.Name) - return populateResourceData(d, &sa) + return populateResourceData(d, &sa, config) } func ListServiceAccounts(config *transport_tpg.Config, project string, callback func(rd *schema.ResourceData) error) error { diff --git a/google/services/resourcemanager/resource_google_billing_subaccount.go b/google/services/resourcemanager/resource_google_billing_subaccount.go index 1998bb3236c..8ff2e08b230 100644 --- a/google/services/resourcemanager/resource_google_billing_subaccount.go +++ b/google/services/resourcemanager/resource_google_billing_subaccount.go @@ -21,8 +21,8 @@ import ( "strings" "time" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "github.com/hashicorp/terraform-provider-google/google/registry" cloudbilling_tpg "github.com/hashicorp/terraform-provider-google/google/services/cloudbilling" @@ -42,6 +42,10 @@ func ResourceBillingSubaccount() *schema.Resource { State: schema.ImportStatePassthrough, }, + CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy(""), + ), + Schema: map[string]*schema.Schema{ "display_name": { Type: schema.TypeString, @@ -53,12 +57,9 @@ func ResourceBillingSubaccount() *schema.Resource { ForceNew: true, DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName, }, - "deletion_policy": { - Type: schema.TypeString, - Optional: true, - Default: "", - ValidateFunc: validation.StringInSlice([]string{"RENAME_ON_DESTROY", ""}, false), - }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry(""), + //UDP schema end "billing_account_id": { Type: schema.TypeString, Computed: true, @@ -131,10 +132,19 @@ func resourceBillingSubaccountRead(d *schema.ResourceData, meta interface{}) err return fmt.Errorf("Error setting billing_account_id: %s", err) } + if err := tpgresource.DeletionPolicyReadDefault(d, config, ""); err != nil { + return err + } + return nil } func resourceBillingSubaccountUpdate(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceBillingSubaccount) { + return ResourceBillingSubaccount().Read(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -154,6 +164,13 @@ func resourceBillingSubaccountUpdate(d *schema.ResourceData, meta interface{}) e } func resourceBillingSubaccountDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/resourcemanager/resource_google_billing_subaccount_meta.yaml b/google/services/resourcemanager/resource_google_billing_subaccount_meta.yaml index 436a56e2c60..13ccbe578df 100644 --- a/google/services/resourcemanager/resource_google_billing_subaccount_meta.yaml +++ b/google/services/resourcemanager/resource_google_billing_subaccount_meta.yaml @@ -8,7 +8,9 @@ api_resource_type_kind: 'BillingAccount' fields: - field: 'billing_account_id' - field: 'deletion_policy' + provider_only: true - api_field: 'displayName' - api_field: 'masterBillingAccount' - api_field: 'name' - api_field: 'open' + diff --git a/google/services/resourcemanager/resource_google_folder.go b/google/services/resourcemanager/resource_google_folder.go index d64153e3cb9..68f1ac8214f 100644 --- a/google/services/resourcemanager/resource_google_folder.go +++ b/google/services/resourcemanager/resource_google_folder.go @@ -22,6 +22,7 @@ import ( "strings" "time" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-provider-google/google/registry" @@ -43,6 +44,10 @@ func ResourceGoogleFolder() *schema.Resource { State: resourceGoogleFolderImportState, }, + CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), + ), + Timeouts: &schema.ResourceTimeout{ Create: schema.DefaultTimeout(4 * time.Minute), Update: schema.DefaultTimeout(4 * time.Minute), @@ -109,6 +114,9 @@ func ResourceGoogleFolder() *schema.Resource { Computed: true, Description: `The Management Project associated with the folder's configured capabilities.`, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, UseJSONNumber: true, } @@ -217,6 +225,10 @@ func resourceGoogleFolderRead(d *schema.ResourceData, meta interface{}) error { return fmt.Errorf("Error setting management_project: %s", err) } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } @@ -227,7 +239,7 @@ func resourceGoogleFolderUpdate(d *schema.ResourceData, meta interface{}) error return err } - clientSideFields := map[string]bool{"deletion_protection": true} + clientSideFields := map[string]bool{"deletion_protection": true, "deletion_policy": true} clientSideOnly := true for field := range ResourceGoogleFolder().Schema { if d.HasChange(field) && !clientSideFields[field] { @@ -290,6 +302,13 @@ func resourceGoogleFolderUpdate(d *schema.ResourceData, meta interface{}) error } func resourceGoogleFolderDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/resourcemanager/resource_google_folder_meta.yaml b/google/services/resourcemanager/resource_google_folder_meta.yaml index a0f359c1b74..fdd9565a7c0 100644 --- a/google/services/resourcemanager/resource_google_folder_meta.yaml +++ b/google/services/resourcemanager/resource_google_folder_meta.yaml @@ -16,3 +16,5 @@ fields: - api_field: 'name' - api_field: 'parent' - api_field: 'tags' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/resourcemanager/resource_google_folder_organization_policy.go b/google/services/resourcemanager/resource_google_folder_organization_policy.go index 05ca309bb2a..7492c9f94d4 100644 --- a/google/services/resourcemanager/resource_google_folder_organization_policy.go +++ b/google/services/resourcemanager/resource_google_folder_organization_policy.go @@ -20,6 +20,7 @@ import ( "fmt" "time" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-provider-google/google/registry" rmClient "github.com/hashicorp/terraform-provider-google/google/services/resourcemanager/client" @@ -46,6 +47,10 @@ func ResourceGoogleFolderOrganizationPolicy() *schema.Resource { Delete: schema.DefaultTimeout(4 * time.Minute), }, + CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), + ), + Schema: tpgresource.MergeSchemas( schemaOrganizationPolicy, map[string]*schema.Schema{ @@ -55,6 +60,9 @@ func ResourceGoogleFolderOrganizationPolicy() *schema.Resource { ForceNew: true, Description: `The resource name of the folder to set the policy for. Its format is folders/{folder_id}.`, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, ), UseJSONNumber: true, @@ -141,10 +149,19 @@ func resourceGoogleFolderOrganizationPolicyRead(d *schema.ResourceData, meta int return fmt.Errorf("Error setting update_time: %s", err) } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } func resourceGoogleFolderOrganizationPolicyUpdate(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceGoogleFolderOrganizationPolicy) { + return ResourceGoogleFolderOrganizationPolicy().Read(d, meta) + } + if isOrganizationPolicyUnset(d) { return resourceGoogleFolderOrganizationPolicyDelete(d, meta) } @@ -157,6 +174,13 @@ func resourceGoogleFolderOrganizationPolicyUpdate(d *schema.ResourceData, meta i } func resourceGoogleFolderOrganizationPolicyDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/resourcemanager/resource_google_folder_organization_policy_meta.yaml b/google/services/resourcemanager/resource_google_folder_organization_policy_meta.yaml index 6a06787f341..fccbda8b232 100644 --- a/google/services/resourcemanager/resource_google_folder_organization_policy_meta.yaml +++ b/google/services/resourcemanager/resource_google_folder_organization_policy_meta.yaml @@ -19,3 +19,5 @@ fields: - field: 'restore_policy.default' - api_field: 'updateTime' - field: 'version' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/resourcemanager/resource_google_organization_iam_custom_role.go b/google/services/resourcemanager/resource_google_organization_iam_custom_role.go index 9507226fd04..76a01969058 100644 --- a/google/services/resourcemanager/resource_google_organization_iam_custom_role.go +++ b/google/services/resourcemanager/resource_google_organization_iam_custom_role.go @@ -19,6 +19,7 @@ package resourcemanager import ( "fmt" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "github.com/hashicorp/terraform-provider-google/google/registry" @@ -49,6 +50,10 @@ func ResourceGoogleOrganizationIamCustomRole() *schema.Resource { State: schema.ImportStatePassthrough, }, + CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), + ), + Schema: map[string]*schema.Schema{ "role_id": { Type: schema.TypeString, @@ -98,6 +103,9 @@ func ResourceGoogleOrganizationIamCustomRole() *schema.Resource { Computed: true, Description: `The name of the role in the format organizations/{{org_id}}/roles/{{role_id}}. Like id, this field can be used as a reference in other resources such as IAM role bindings.`, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, UseJSONNumber: true, } @@ -196,10 +204,19 @@ func resourceGoogleOrganizationIamCustomRoleRead(d *schema.ResourceData, meta in return fmt.Errorf("Error setting deleted: %s", err) } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } func resourceGoogleOrganizationIamCustomRoleUpdate(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceGoogleOrganizationIamCustomRole) { + return ResourceGoogleOrganizationIamCustomRole().Read(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -240,6 +257,13 @@ func resourceGoogleOrganizationIamCustomRoleUpdate(d *schema.ResourceData, meta } func resourceGoogleOrganizationIamCustomRoleDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/resourcemanager/resource_google_organization_iam_custom_role_meta.yaml b/google/services/resourcemanager/resource_google_organization_iam_custom_role_meta.yaml index 20dd62fc1c0..24de3fd7d63 100644 --- a/google/services/resourcemanager/resource_google_organization_iam_custom_role_meta.yaml +++ b/google/services/resourcemanager/resource_google_organization_iam_custom_role_meta.yaml @@ -14,3 +14,5 @@ fields: - field: 'role_id' - api_field: 'stage' - api_field: 'title' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/resourcemanager/resource_google_organization_policy.go b/google/services/resourcemanager/resource_google_organization_policy.go index 712b47e7900..975f4d5b8bc 100644 --- a/google/services/resourcemanager/resource_google_organization_policy.go +++ b/google/services/resourcemanager/resource_google_organization_policy.go @@ -21,6 +21,7 @@ import ( "strings" "time" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-provider-google/google/registry" @@ -181,6 +182,10 @@ func ResourceGoogleOrganizationPolicy() *schema.Resource { Delete: schema.DefaultTimeout(4 * time.Minute), }, + CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), + ), + Schema: tpgresource.MergeSchemas( schemaOrganizationPolicy, map[string]*schema.Schema{ @@ -189,6 +194,9 @@ func ResourceGoogleOrganizationPolicy() *schema.Resource { Required: true, ForceNew: true, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }), UseJSONNumber: true, } @@ -251,10 +259,19 @@ func resourceGoogleOrganizationPolicyRead(d *schema.ResourceData, meta interface return fmt.Errorf("Error setting restore_policy: %s", err) } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } func resourceGoogleOrganizationPolicyUpdate(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceGoogleOrganizationPolicy) { + return ResourceGoogleOrganizationPolicy().Read(d, meta) + } + if isOrganizationPolicyUnset(d) { return resourceGoogleOrganizationPolicyDelete(d, meta) } @@ -267,6 +284,13 @@ func resourceGoogleOrganizationPolicyUpdate(d *schema.ResourceData, meta interfa } func resourceGoogleOrganizationPolicyDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/resourcemanager/resource_google_organization_policy_meta.yaml b/google/services/resourcemanager/resource_google_organization_policy_meta.yaml index bb3a047901b..81aef42e5e0 100644 --- a/google/services/resourcemanager/resource_google_organization_policy_meta.yaml +++ b/google/services/resourcemanager/resource_google_organization_policy_meta.yaml @@ -19,3 +19,5 @@ fields: - field: 'restore_policy.default' - api_field: 'updateTime' - field: 'version' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/resourcemanager/resource_google_project.go b/google/services/resourcemanager/resource_google_project.go index 9b38978bb7e..17a62c7ef3f 100644 --- a/google/services/resourcemanager/resource_google_project.go +++ b/google/services/resourcemanager/resource_google_project.go @@ -62,6 +62,7 @@ func ResourceGoogleProject() *schema.Resource { Delete: resourceGoogleProjectDelete, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("PREVENT"), tpgresource.SetLabelsDiff, ), @@ -88,8 +89,8 @@ func ResourceGoogleProject() *schema.Resource { }, "deletion_policy": { Type: schema.TypeString, + Computed: true, Optional: true, - Default: "PREVENT", Description: `The deletion policy for the Project. Setting PREVENT will protect the project against any destroy actions caused by a terraform apply or terraform destroy. Setting ABANDON allows the resource to be abandoned rather than deleted. Possible values are: "PREVENT", "ABANDON", "DELETE"`, ValidateFunc: validation.StringInSlice([]string{"PREVENT", "ABANDON", "DELETE"}, false), @@ -339,11 +340,11 @@ func resourceGoogleProjectRead(d *schema.ResourceData, meta interface{}) error { return nil } // Explicitly set client-side fields to default values if unset - if _, ok := d.GetOkExists("deletion_policy"); !ok { - if err := d.Set("deletion_policy", "PREVENT"); err != nil { - return fmt.Errorf("Error setting deletion_policy: %s", err) - } + + if err := tpgresource.DeletionPolicyReadDefault(d, config, "PREVENT"); err != nil { + return err } + if err := d.Set("project_id", pid); err != nil { return fmt.Errorf("Error setting project_id: %s", err) } diff --git a/google/services/resourcemanager/resource_google_project_iam_custom_role.go b/google/services/resourcemanager/resource_google_project_iam_custom_role.go index 493428a073e..fe88e79103b 100644 --- a/google/services/resourcemanager/resource_google_project_iam_custom_role.go +++ b/google/services/resourcemanager/resource_google_project_iam_custom_role.go @@ -44,6 +44,7 @@ func ResourceGoogleProjectIamCustomRole() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -96,6 +97,9 @@ func ResourceGoogleProjectIamCustomRole() *schema.Resource { Computed: true, Description: `The name of the role in the format projects/{{project}}/roles/{{role_id}}. Like id, this field can be used as a reference in other resources such as IAM role bindings.`, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, UseJSONNumber: true, } @@ -196,10 +200,19 @@ func resourceGoogleProjectIamCustomRoleRead(d *schema.ResourceData, meta interfa return fmt.Errorf("Error setting project: %s", err) } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } func resourceGoogleProjectIamCustomRoleUpdate(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceGoogleProjectIamCustomRole) { + return ResourceGoogleProjectIamCustomRole().Read(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -239,6 +252,13 @@ func resourceGoogleProjectIamCustomRoleUpdate(d *schema.ResourceData, meta inter } func resourceGoogleProjectIamCustomRoleDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/resourcemanager/resource_google_project_iam_custom_role_meta.yaml b/google/services/resourcemanager/resource_google_project_iam_custom_role_meta.yaml index 75c54995f8f..10a80c138d4 100644 --- a/google/services/resourcemanager/resource_google_project_iam_custom_role_meta.yaml +++ b/google/services/resourcemanager/resource_google_project_iam_custom_role_meta.yaml @@ -14,3 +14,5 @@ fields: - field: 'role_id' - api_field: 'stage' - api_field: 'title' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/resourcemanager/resource_google_project_organization_policy.go b/google/services/resourcemanager/resource_google_project_organization_policy.go index 878f04a6be6..645b3edb729 100644 --- a/google/services/resourcemanager/resource_google_project_organization_policy.go +++ b/google/services/resourcemanager/resource_google_project_organization_policy.go @@ -20,6 +20,7 @@ import ( "fmt" "time" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-provider-google/google/registry" rmClient "github.com/hashicorp/terraform-provider-google/google/services/resourcemanager/client" @@ -46,6 +47,10 @@ func ResourceGoogleProjectOrganizationPolicy() *schema.Resource { Delete: schema.DefaultTimeout(4 * time.Minute), }, + CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), + ), + Schema: tpgresource.MergeSchemas( schemaOrganizationPolicy, map[string]*schema.Schema{ @@ -55,6 +60,9 @@ func ResourceGoogleProjectOrganizationPolicy() *schema.Resource { ForceNew: true, Description: `The project ID.`, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, ), UseJSONNumber: true, @@ -138,10 +146,19 @@ func resourceGoogleProjectOrganizationPolicyRead(d *schema.ResourceData, meta in return fmt.Errorf("Error setting update_time: %s", err) } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } func resourceGoogleProjectOrganizationPolicyUpdate(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceGoogleProjectOrganizationPolicy) { + return ResourceGoogleProjectOrganizationPolicy().Read(d, meta) + } + if isOrganizationPolicyUnset(d) { return resourceGoogleProjectOrganizationPolicyDelete(d, meta) } @@ -154,6 +171,13 @@ func resourceGoogleProjectOrganizationPolicyUpdate(d *schema.ResourceData, meta } func resourceGoogleProjectOrganizationPolicyDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/resourcemanager/resource_google_project_organization_policy_meta.yaml b/google/services/resourcemanager/resource_google_project_organization_policy_meta.yaml index 693d56f083e..ef60612ce03 100644 --- a/google/services/resourcemanager/resource_google_project_organization_policy_meta.yaml +++ b/google/services/resourcemanager/resource_google_project_organization_policy_meta.yaml @@ -19,3 +19,5 @@ fields: - field: 'restore_policy.default' - api_field: 'updateTime' - field: 'version' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/resourcemanager/resource_google_project_service.go b/google/services/resourcemanager/resource_google_project_service.go index d2dbf4002e6..a347f02c230 100644 --- a/google/services/resourcemanager/resource_google_project_service.go +++ b/google/services/resourcemanager/resource_google_project_service.go @@ -108,6 +108,7 @@ func ResourceGoogleProjectService() *schema.Resource { }, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), tpgresource.DefaultProviderProject, ), @@ -135,6 +136,9 @@ func ResourceGoogleProjectService() *schema.Resource { Type: schema.TypeBool, Optional: true, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, UseJSONNumber: true, } @@ -246,12 +250,23 @@ func resourceGoogleProjectServiceRead(d *schema.ResourceData, meta interface{}) return nil } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + log.Printf("[DEBUG] service %s not in enabled services for project %s, removing from state", srv, project) d.SetId("") return nil } func resourceGoogleProjectServiceDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) if disable := d.Get("disable_on_destroy"); !(disable.(bool)) { diff --git a/google/services/resourcemanager/resource_google_project_service_meta.yaml b/google/services/resourcemanager/resource_google_project_service_meta.yaml index 55df1644215..124787bed2e 100644 --- a/google/services/resourcemanager/resource_google_project_service_meta.yaml +++ b/google/services/resourcemanager/resource_google_project_service_meta.yaml @@ -12,3 +12,5 @@ fields: - field: 'disable_on_destroy' - field: 'project' - field: 'service' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/resourcemanager/resource_google_service_account.go b/google/services/resourcemanager/resource_google_service_account.go index 832b24993a8..2c585eb10c6 100644 --- a/google/services/resourcemanager/resource_google_service_account.go +++ b/google/services/resourcemanager/resource_google_service_account.go @@ -51,6 +51,7 @@ func ResourceGoogleServiceAccount() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, resourceServiceAccountCustomDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -127,6 +128,9 @@ func ResourceGoogleServiceAccount() *schema.Resource { Computed: false, Description: `If set to true, skip service account creation if a service account with the same email already exists.`, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, UseJSONNumber: true, } @@ -173,7 +177,7 @@ func resourceGoogleServiceAccountCreate(d *schema.ResourceData, meta interface{} } d.SetId(sa.Name) - return populateResourceData(d, sa) + return populateResourceData(d, sa, config) }, Timeout: d.Timeout(schema.TimeoutCreate), ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{ @@ -188,7 +192,7 @@ func resourceGoogleServiceAccountCreate(d *schema.ResourceData, meta interface{} } d.SetId(sa.Name) - populateResourceData(d, sa) + populateResourceData(d, sa, config) // We poll until the resource is found due to eventual consistency issue // on part of the api https://cloud.google.com/iam/docs/overview#consistency. @@ -243,10 +247,10 @@ func resourceGoogleServiceAccountRead(d *schema.ResourceData, meta interface{}) return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("Service Account %q", d.Id())) } - return populateResourceData(d, sa) + return populateResourceData(d, sa, config) } -func populateResourceData(d *schema.ResourceData, sa *iam.ServiceAccount) error { +func populateResourceData(d *schema.ResourceData, sa *iam.ServiceAccount, config *transport_tpg.Config) error { if err := d.Set("email", sa.Email); err != nil { return fmt.Errorf("Error setting email: %s", err) } @@ -275,6 +279,10 @@ func populateResourceData(d *schema.ResourceData, sa *iam.ServiceAccount) error return fmt.Errorf("Error setting member: %s", err) } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return tpgresource.SetResourceIdentityAttributes(d, map[string]interface{}{ "email": sa.Email, "project": sa.ProjectId, @@ -282,6 +290,13 @@ func populateResourceData(d *schema.ResourceData, sa *iam.ServiceAccount) error } func resourceGoogleServiceAccountDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -301,6 +316,11 @@ func resourceGoogleServiceAccountDelete(d *schema.ResourceData, meta interface{} } func resourceGoogleServiceAccountUpdate(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceGoogleServiceAccount) { + return ResourceGoogleServiceAccount().Read(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/resourcemanager/resource_google_service_account_key.go b/google/services/resourcemanager/resource_google_service_account_key.go index 87d672c76cb..6470aba425a 100644 --- a/google/services/resourcemanager/resource_google_service_account_key.go +++ b/google/services/resourcemanager/resource_google_service_account_key.go @@ -26,6 +26,7 @@ import ( "github.com/hashicorp/terraform-provider-google/google/tpgresource" transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "google.golang.org/api/iam/v1" @@ -35,7 +36,13 @@ func ResourceGoogleServiceAccountKey() *schema.Resource { return &schema.Resource{ Create: resourceGoogleServiceAccountKeyCreate, Read: resourceGoogleServiceAccountKeyRead, + Update: resourceGoogleServiceAccountKeyUpdate, Delete: resourceGoogleServiceAccountKeyDelete, + + CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), + ), + Schema: map[string]*schema.Schema{ // Required "service_account_id": { @@ -109,6 +116,9 @@ func ResourceGoogleServiceAccountKey() *schema.Resource { Computed: true, Description: `The key can be used before this timestamp. A timestamp in RFC3339 UTC "Zulu" format, accurate to nanoseconds. Example: "2014-10-02T15:01:23.045123456Z".`, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, UseJSONNumber: true, } @@ -207,10 +217,30 @@ func resourceGoogleServiceAccountKeyRead(d *schema.ResourceData, meta interface{ if err := d.Set("public_key", sak.PublicKeyData); err != nil { return fmt.Errorf("Error setting public_key: %s", err) } + + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } +// UDP update start +func resourceGoogleServiceAccountKeyUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceGoogleServiceAccountKeyRead(d, meta) +} + +//UDP update end + func resourceGoogleServiceAccountKeyDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/resourcemanager/resource_google_service_account_key_meta.yaml b/google/services/resourcemanager/resource_google_service_account_key_meta.yaml index 4e5a42915ee..9a20fec89ff 100644 --- a/google/services/resourcemanager/resource_google_service_account_key_meta.yaml +++ b/google/services/resourcemanager/resource_google_service_account_key_meta.yaml @@ -17,3 +17,5 @@ fields: - field: 'service_account_id' - field: 'valid_after' - field: 'valid_before' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/resourcemanager/resource_google_service_account_meta.yaml b/google/services/resourcemanager/resource_google_service_account_meta.yaml index 148a780213b..1d92df4f610 100644 --- a/google/services/resourcemanager/resource_google_service_account_meta.yaml +++ b/google/services/resourcemanager/resource_google_service_account_meta.yaml @@ -18,3 +18,5 @@ fields: - api_field: 'name' - field: 'project' - api_field: 'uniqueId' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/resourcemanager/resource_resource_manager_lien.go b/google/services/resourcemanager/resource_resource_manager_lien.go index bf32c28fa21..9372e9a3a43 100644 --- a/google/services/resourcemanager/resource_resource_manager_lien.go +++ b/google/services/resourcemanager/resource_resource_manager_lien.go @@ -106,6 +106,7 @@ func ResourceResourceManagerLien() *schema.Resource { return &schema.Resource{ Create: resourceResourceManagerLienCreate, Read: resourceResourceManagerLienRead, + Update: resourceResourceManagerLienUpdate, Delete: resourceResourceManagerLienDelete, Importer: &schema.ResourceImporter{ @@ -184,6 +185,19 @@ e.g. ['resourcemanager.projects.delete']`, Computed: true, Description: `A system-generated unique identifier for this Lien.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -342,6 +356,20 @@ func resourceResourceManagerLienRead(d *schema.ResourceData, meta interface{}) e return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceResourceManagerLienFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -368,7 +396,19 @@ func resourceResourceManagerLienRead(d *schema.ResourceData, meta interface{}) e return nil } +func resourceResourceManagerLienUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceResourceManagerLienRead(d, meta) +} + func resourceResourceManagerLienDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ResourceManagerLien without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Lien %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/resourcemanager/resource_resource_manager_lien_generated_meta.yaml b/google/services/resourcemanager/resource_resource_manager_lien_generated_meta.yaml index c1bb214277e..e1de4e9b408 100644 --- a/google/services/resourcemanager/resource_resource_manager_lien_generated_meta.yaml +++ b/google/services/resourcemanager/resource_resource_manager_lien_generated_meta.yaml @@ -13,3 +13,5 @@ fields: - api_field: parent - api_field: reason - api_field: restrictions + - field: deletion_policy + provider_only: true diff --git a/google/services/resourcemanagerv3/resource_resource_manager_capability.go b/google/services/resourcemanagerv3/resource_resource_manager_capability.go index 824c84efb42..7f06d4e8172 100644 --- a/google/services/resourcemanagerv3/resource_resource_manager_capability.go +++ b/google/services/resourcemanagerv3/resource_resource_manager_capability.go @@ -295,6 +295,7 @@ func resourceResourceManagerV3CapabilityRead(d *schema.ResourceData, meta interf } func resourceResourceManagerV3CapabilityUpdate(d *schema.ResourceData, meta interface{}) error { + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/secretmanager/data_source_secret_manager_secrets_test.go b/google/services/secretmanager/data_source_secret_manager_secrets_test.go index 67afc7bf58c..a93bd3dae8f 100644 --- a/google/services/secretmanager/data_source_secret_manager_secrets_test.go +++ b/google/services/secretmanager/data_source_secret_manager_secrets_test.go @@ -46,8 +46,9 @@ func TestAccDataSourceSecretManagerSecrets_basic(t *testing.T) { "data.google_secret_manager_secrets.foo", "google_secret_manager_secret.foo", map[string]struct{}{ - "id": {}, - "project": {}, + "id": {}, + "project": {}, + "deletion_policy": {}, }, ), ), @@ -112,8 +113,9 @@ func TestAccDataSourceSecretManagerSecrets_filter(t *testing.T) { "google_secret_manager_secret.foo", "google_secret_manager_secret.bar", map[string]struct{}{ - "id": {}, - "project": {}, + "id": {}, + "project": {}, + "deletion_policy": {}, }, ), ), diff --git a/google/services/secretmanager/resource_secret_manager_secret.go b/google/services/secretmanager/resource_secret_manager_secret.go index f8bdaba0c3c..680ff4c6b31 100644 --- a/google/services/secretmanager/resource_secret_manager_secret.go +++ b/google/services/secretmanager/resource_secret_manager_secret.go @@ -144,6 +144,7 @@ func ResourceSecretManagerSecret() *schema.Resource { tpgresource.SetLabelsDiff, tpgresource.SetAnnotationsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -431,6 +432,18 @@ or 'terraform destroy' that would delete the secret will fail.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -613,6 +626,18 @@ func resourceSecretManagerSecretRead(d *schema.ResourceData, meta interface{}) e return fmt.Errorf("Error setting deletion_protection: %s", err) } } + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Secret: %s", err) } @@ -644,6 +669,19 @@ func resourceSecretManagerSecretRead(d *schema.ResourceData, meta interface{}) e } func resourceSecretManagerSecretUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceSecretManagerSecret().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceSecretManagerSecretRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -823,6 +861,13 @@ func resourceSecretManagerSecretUpdate(d *schema.ResourceData, meta interface{}) } func resourceSecretManagerSecretDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy SecretManagerSecret without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Secret %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/secretmanager/resource_secret_manager_secret_generated_meta.yaml b/google/services/secretmanager/resource_secret_manager_secret_generated_meta.yaml index 1b16e2c9478..08a9fe2a7ee 100644 --- a/google/services/secretmanager/resource_secret_manager_secret_generated_meta.yaml +++ b/google/services/secretmanager/resource_secret_manager_secret_generated_meta.yaml @@ -35,3 +35,5 @@ fields: - api_field: ttl - api_field: versionAliases - api_field: versionDestroyTtl + - field: deletion_policy + provider_only: true diff --git a/google/services/secretmanager/resource_secret_manager_secret_version.go b/google/services/secretmanager/resource_secret_manager_secret_version.go index edcc6955c7e..ed9027b7a92 100644 --- a/google/services/secretmanager/resource_secret_manager_secret_version.go +++ b/google/services/secretmanager/resource_secret_manager_secret_version.go @@ -214,23 +214,19 @@ the provider project is used`, Computed: true, Description: `The version of the Secret.`, }, - "deletion_policy": { - Type: schema.TypeString, - Optional: true, - Description: `The deletion policy for the secret version. Setting 'ABANDON' allows the resource -to be abandoned rather than deleted. Setting 'DISABLE' allows the resource to be -disabled rather than deleted. Default is 'DELETE'. Possible values are: - * DELETE - * DISABLE - * ABANDON`, - Default: "DELETE", - }, "is_secret_data_base64": { Type: schema.TypeBool, Optional: true, ForceNew: true, Description: `If set to 'true', the secret data is expected to be base64-encoded string and would be sent as is.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `This field uses a custom implementation please refer to documentation under /hashicorp/terraform-provider-google-beta/website/docs/r/secret_manager_secret_version.html.markdown for specifics`, + }, }, UseJSONNumber: true, } @@ -405,8 +401,15 @@ func resourceSecretManagerSecretVersionRead(d *schema.ResourceData, meta interfa // Explicitly set virtual fields to default values if unset if _, ok := d.GetOkExists("deletion_policy"); !ok { - if err := d.Set("deletion_policy", "DELETE"); err != nil { - return fmt.Errorf("Error setting deletion_policy: %s", err) + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } } } @@ -419,6 +422,19 @@ func resourceSecretManagerSecretVersionRead(d *schema.ResourceData, meta interfa } func resourceSecretManagerSecretVersionUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceSecretManagerSecretVersion().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceSecretManagerSecretVersionRead(d, meta) + } + config := meta.(*transport_tpg.Config) err := setEnabled(d.Get("enabled"), d, config) if err != nil { @@ -429,6 +445,13 @@ func resourceSecretManagerSecretVersionUpdate(d *schema.ResourceData, meta inter } func resourceSecretManagerSecretVersionDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy SecretManagerSecretVersion without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing SecretVersion %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -451,10 +474,7 @@ func resourceSecretManagerSecretVersionDelete(d *schema.ResourceData, meta inter headers := make(http.Header) deletionPolicy := d.Get("deletion_policy") - - if deletionPolicy == "ABANDON" { - return nil - } else if deletionPolicy == "DISABLE" { + if deletionPolicy == "DISABLE" { url, err = tpgresource.ReplaceVars(d, config, "{{SecretManagerBasePath}}{{name}}:disable") if err != nil { return err diff --git a/google/services/secretmanager/resource_secret_manager_secret_version_generated_meta.yaml b/google/services/secretmanager/resource_secret_manager_secret_version_generated_meta.yaml index a52e94fd5c3..28be2471bdc 100644 --- a/google/services/secretmanager/resource_secret_manager_secret_version_generated_meta.yaml +++ b/google/services/secretmanager/resource_secret_manager_secret_version_generated_meta.yaml @@ -12,8 +12,6 @@ api_variant_patterns: - projects/{project}/secrets/{secret}/versions/{version} fields: - api_field: createTime - - field: deletion_policy - provider_only: true - api_field: destroyTime - api_field: state field: enabled @@ -31,3 +29,5 @@ fields: - field: secret_data_wo_version provider_only: true - api_field: version + - field: deletion_policy + provider_only: true diff --git a/google/services/secretmanagerregional/data_source_secret_manager_regional_secrets_test.go b/google/services/secretmanagerregional/data_source_secret_manager_regional_secrets_test.go index 8864cf7c5ee..e6ed62be1d1 100644 --- a/google/services/secretmanagerregional/data_source_secret_manager_regional_secrets_test.go +++ b/google/services/secretmanagerregional/data_source_secret_manager_regional_secrets_test.go @@ -47,8 +47,9 @@ func TestAccDataSourceSecretManagerRegionalRegionalSecrets_basic(t *testing.T) { "data.google_secret_manager_regional_secrets.foo", "google_secret_manager_regional_secret.foo", map[string]struct{}{ - "id": {}, - "project": {}, + "id": {}, + "project": {}, + "deletion_policy": {}, }, ), ), @@ -105,8 +106,9 @@ func TestAccDataSourceSecretManagerRegionalRegionalSecrets_filter(t *testing.T) "google_secret_manager_regional_secret.foo", "google_secret_manager_regional_secret.bar", map[string]struct{}{ - "id": {}, - "project": {}, + "id": {}, + "project": {}, + "deletion_policy": {}, }, ), ), diff --git a/google/services/secretmanagerregional/resource_secret_manager_regional_secret.go b/google/services/secretmanagerregional/resource_secret_manager_regional_secret.go index c00d86d0569..59283ca25c7 100644 --- a/google/services/secretmanagerregional/resource_secret_manager_regional_secret.go +++ b/google/services/secretmanagerregional/resource_secret_manager_regional_secret.go @@ -117,6 +117,7 @@ func ResourceSecretManagerRegionalRegionalSecret() *schema.Resource { tpgresource.SetLabelsDiff, tpgresource.SetAnnotationsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -351,6 +352,18 @@ or 'terraform destroy' that would delete the federation will fail.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -538,6 +551,18 @@ func resourceSecretManagerRegionalRegionalSecretRead(d *schema.ResourceData, met return fmt.Errorf("Error setting deletion_protection: %s", err) } } + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading RegionalSecret: %s", err) } @@ -575,6 +600,19 @@ func resourceSecretManagerRegionalRegionalSecretRead(d *schema.ResourceData, met } func resourceSecretManagerRegionalRegionalSecretUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceSecretManagerRegionalRegionalSecret().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceSecretManagerRegionalRegionalSecretRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -750,6 +788,13 @@ func resourceSecretManagerRegionalRegionalSecretUpdate(d *schema.ResourceData, m } func resourceSecretManagerRegionalRegionalSecretDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy SecretManagerRegionalRegionalSecret without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing RegionalSecret %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/secretmanagerregional/resource_secret_manager_regional_secret_generated_meta.yaml b/google/services/secretmanagerregional/resource_secret_manager_regional_secret_generated_meta.yaml index 2c9a330bbdc..e20b6c533ad 100644 --- a/google/services/secretmanagerregional/resource_secret_manager_regional_secret_generated_meta.yaml +++ b/google/services/secretmanagerregional/resource_secret_manager_regional_secret_generated_meta.yaml @@ -32,3 +32,5 @@ fields: - api_field: ttl - api_field: versionAliases - api_field: versionDestroyTtl + - field: deletion_policy + provider_only: true diff --git a/google/services/secretmanagerregional/resource_secret_manager_regional_secret_version.go b/google/services/secretmanagerregional/resource_secret_manager_regional_secret_version.go index ac09c1304dc..4e00f7bb11f 100644 --- a/google/services/secretmanagerregional/resource_secret_manager_regional_secret_version.go +++ b/google/services/secretmanagerregional/resource_secret_manager_regional_secret_version.go @@ -209,23 +209,19 @@ func ResourceSecretManagerRegionalRegionalSecretVersion() *schema.Resource { Computed: true, Description: `The version of the Regional Secret.`, }, - "deletion_policy": { - Type: schema.TypeString, - Optional: true, - Description: `The deletion policy for the regional secret version. Setting 'ABANDON' allows the resource -to be abandoned rather than deleted. Setting 'DISABLE' allows the resource to be -disabled rather than deleted. Default is 'DELETE'. Possible values are: - * DELETE - * DISABLE - * ABANDON`, - Default: "DELETE", - }, "is_secret_data_base64": { Type: schema.TypeBool, Optional: true, ForceNew: true, Description: `If set to 'true', the secret data is expected to be base64-encoded string and would be sent as is.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `This field uses a custom implementation please refer to documentation under /hashicorp/terraform-provider-google-beta/website/docs/r/secret_manager_regional_regional_secret_version.html.markdown for specifics`, + }, }, UseJSONNumber: true, } @@ -402,8 +398,15 @@ func resourceSecretManagerRegionalRegionalSecretVersionRead(d *schema.ResourceDa // Explicitly set virtual fields to default values if unset if _, ok := d.GetOkExists("deletion_policy"); !ok { - if err := d.Set("deletion_policy", "DELETE"); err != nil { - return fmt.Errorf("Error setting deletion_policy: %s", err) + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } } } @@ -416,6 +419,19 @@ func resourceSecretManagerRegionalRegionalSecretVersionRead(d *schema.ResourceDa } func resourceSecretManagerRegionalRegionalSecretVersionUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceSecretManagerRegionalRegionalSecretVersion().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceSecretManagerRegionalRegionalSecretVersionRead(d, meta) + } + config := meta.(*transport_tpg.Config) err := setEnabled(d.Get("enabled"), d, config) if err != nil { @@ -426,6 +442,13 @@ func resourceSecretManagerRegionalRegionalSecretVersionUpdate(d *schema.Resource } func resourceSecretManagerRegionalRegionalSecretVersionDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy SecretManagerRegionalRegionalSecretVersion without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing RegionalSecretVersion %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -449,9 +472,7 @@ func resourceSecretManagerRegionalRegionalSecretVersionDelete(d *schema.Resource headers := make(http.Header) deletionPolicy := d.Get("deletion_policy") - if deletionPolicy == "ABANDON" { - return nil - } else if deletionPolicy == "DISABLE" { + if deletionPolicy == "DISABLE" { url, err = tpgresource.ReplaceVars(d, config, "{{SecretManagerRegionalBasePath}}{{name}}:disable") if err != nil { return err diff --git a/google/services/secretmanagerregional/resource_secret_manager_regional_secret_version_generated_meta.yaml b/google/services/secretmanagerregional/resource_secret_manager_regional_secret_version_generated_meta.yaml index b2bedf8668f..2c1c1886189 100644 --- a/google/services/secretmanagerregional/resource_secret_manager_regional_secret_version_generated_meta.yaml +++ b/google/services/secretmanagerregional/resource_secret_manager_regional_secret_version_generated_meta.yaml @@ -11,8 +11,6 @@ cai_asset_name_formats: fields: - api_field: createTime - api_field: customerManagedEncryption.kmsKeyVersionName - - field: deletion_policy - provider_only: true - api_field: destroyTime - api_field: state field: enabled @@ -26,3 +24,5 @@ fields: - api_field: payload.data field: secret_data - api_field: version + - field: deletion_policy + provider_only: true diff --git a/google/services/securesourcemanager/resource_secure_source_manager_branch_rule.go b/google/services/securesourcemanager/resource_secure_source_manager_branch_rule.go index 54e371ac412..d79ba342a13 100644 --- a/google/services/securesourcemanager/resource_secure_source_manager_branch_rule.go +++ b/google/services/securesourcemanager/resource_secure_source_manager_branch_rule.go @@ -115,6 +115,7 @@ func ResourceSecureSourceManagerBranchRule() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -226,6 +227,18 @@ func ResourceSecureSourceManagerBranchRule() *schema.Resource { Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -410,6 +423,19 @@ func resourceSecureSourceManagerBranchRuleRead(d *schema.ResourceData, meta inte log.Printf("[DEBUG] Finished reading SecureSourceManagerBranchRule %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading BranchRule: %s", err) } @@ -453,6 +479,19 @@ func resourceSecureSourceManagerBranchRuleRead(d *schema.ResourceData, meta inte } func resourceSecureSourceManagerBranchRuleUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceSecureSourceManagerBranchRule().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceSecureSourceManagerBranchRuleRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -619,6 +658,13 @@ func resourceSecureSourceManagerBranchRuleUpdate(d *schema.ResourceData, meta in } func resourceSecureSourceManagerBranchRuleDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy SecureSourceManagerBranchRule without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing BranchRule %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/securesourcemanager/resource_secure_source_manager_branch_rule_generated_meta.yaml b/google/services/securesourcemanager/resource_secure_source_manager_branch_rule_generated_meta.yaml index 9f0b1b3403b..6c27e0c737c 100644 --- a/google/services/securesourcemanager/resource_secure_source_manager_branch_rule_generated_meta.yaml +++ b/google/services/securesourcemanager/resource_secure_source_manager_branch_rule_generated_meta.yaml @@ -25,3 +25,5 @@ fields: - api_field: requirePullRequest - api_field: uid - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/securesourcemanager/resource_secure_source_manager_hook.go b/google/services/securesourcemanager/resource_secure_source_manager_hook.go index 7ad78050142..7b212cc9c1d 100644 --- a/google/services/securesourcemanager/resource_secure_source_manager_hook.go +++ b/google/services/securesourcemanager/resource_secure_source_manager_hook.go @@ -115,6 +115,7 @@ func ResourceSecureSourceManagerHook() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -233,6 +234,18 @@ See https://pkg.go.dev/github.com/gobwas/glob documentation.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -399,6 +412,19 @@ func resourceSecureSourceManagerHookRead(d *schema.ResourceData, meta interface{ log.Printf("[DEBUG] Finished reading SecureSourceManagerHook %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Hook: %s", err) } @@ -442,6 +468,19 @@ func resourceSecureSourceManagerHookRead(d *schema.ResourceData, meta interface{ } func resourceSecureSourceManagerHookUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceSecureSourceManagerHook().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceSecureSourceManagerHookRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -578,6 +617,13 @@ func resourceSecureSourceManagerHookUpdate(d *schema.ResourceData, meta interfac } func resourceSecureSourceManagerHookDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy SecureSourceManagerHook without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Hook %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/securesourcemanager/resource_secure_source_manager_hook_generated_meta.yaml b/google/services/securesourcemanager/resource_secure_source_manager_hook_generated_meta.yaml index c3a35816686..87b297b785f 100644 --- a/google/services/securesourcemanager/resource_secure_source_manager_hook_generated_meta.yaml +++ b/google/services/securesourcemanager/resource_secure_source_manager_hook_generated_meta.yaml @@ -22,3 +22,5 @@ fields: - api_field: targetUri - api_field: uid - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/securesourcemanager/resource_secure_source_manager_instance.go b/google/services/securesourcemanager/resource_secure_source_manager_instance.go index 4109a7d9956..89fcd4baab0 100644 --- a/google/services/securesourcemanager/resource_secure_source_manager_instance.go +++ b/google/services/securesourcemanager/resource_secure_source_manager_instance.go @@ -116,6 +116,7 @@ func ResourceSecureSourceManagerInstance() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("PREVENT"), ), Identity: &schema.ResourceIdentity{ @@ -324,24 +325,23 @@ If unset, defaults to the Google OIDC IdP.`, Computed: true, Description: `Time the Instance was updated in UTC.`, }, - "deletion_policy": { + "project": { Type: schema.TypeString, Optional: true, - Description: `The deletion policy for the instance. Setting 'ABANDON' allows the resource -to be abandoned, rather than deleted. Setting 'DELETE' deletes the resource -and all its contents. Setting 'PREVENT' prevents the resource from accidental -deletion by erroring out during plan. -Default is 'PREVENT'. Possible values are: - * DELETE - * PREVENT - * ABANDON`, - Default: "PREVENT", + Computed: true, + ForceNew: true, }, - "project": { + "deletion_policy": { Type: schema.TypeString, Optional: true, Computed: true, - ForceNew: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "PREVENT". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, }, }, UseJSONNumber: true, @@ -500,8 +500,15 @@ func resourceSecureSourceManagerInstanceRead(d *schema.ResourceData, meta interf // Explicitly set virtual fields to default values if unset if _, ok := d.GetOkExists("deletion_policy"); !ok { - if err := d.Set("deletion_policy", "PREVENT"); err != nil { - return fmt.Errorf("Error setting deletion_policy: %s", err) + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "PREVENT"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } } } if err := d.Set("project", project); err != nil { @@ -541,11 +548,18 @@ func resourceSecureSourceManagerInstanceRead(d *schema.ResourceData, meta interf } func resourceSecureSourceManagerInstanceUpdate(d *schema.ResourceData, meta interface{}) error { - // Only the root field "labels", "terraform_labels", and virtual fields are mutable + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable return resourceSecureSourceManagerInstanceRead(d, meta) } func resourceSecureSourceManagerInstanceDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy SecureSourceManagerInstance without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Instance %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -625,11 +639,6 @@ func resourceSecureSourceManagerInstanceImport(d *schema.ResourceData, meta inte } d.SetId(id) - // Explicitly set virtual fields to default values on import - if err := d.Set("deletion_policy", "PREVENT"); err != nil { - return nil, fmt.Errorf("Error setting deletion_policy: %s", err) - } - return []*schema.ResourceData{d}, nil } diff --git a/google/services/securesourcemanager/resource_secure_source_manager_instance_generated_meta.yaml b/google/services/securesourcemanager/resource_secure_source_manager_instance_generated_meta.yaml index 00f3eb6f15b..2957d9c2050 100644 --- a/google/services/securesourcemanager/resource_secure_source_manager_instance_generated_meta.yaml +++ b/google/services/securesourcemanager/resource_secure_source_manager_instance_generated_meta.yaml @@ -8,8 +8,6 @@ api_version: v1 api_resource_type_kind: Instance fields: - api_field: createTime - - field: deletion_policy - provider_only: true - field: effective_labels provider_only: true - api_field: hostConfig.api @@ -37,3 +35,5 @@ fields: provider_only: true - api_field: updateTime - api_field: workforceIdentityFederationConfig.enabled + - field: deletion_policy + provider_only: true diff --git a/google/services/securesourcemanager/resource_secure_source_manager_repository.go b/google/services/securesourcemanager/resource_secure_source_manager_repository.go index 0d495947441..61d139f3c60 100644 --- a/google/services/securesourcemanager/resource_secure_source_manager_repository.go +++ b/google/services/securesourcemanager/resource_secure_source_manager_repository.go @@ -115,6 +115,7 @@ func ResourceSecureSourceManagerRepository() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("PREVENT"), ), Identity: &schema.ResourceIdentity{ @@ -250,24 +251,23 @@ Valid values can be viewed at https://cloud.google.com/secure-source-manager/doc }, }, }, - "deletion_policy": { + "project": { Type: schema.TypeString, Optional: true, - Description: `The deletion policy for the repository. Setting 'ABANDON' allows the resource -to be abandoned, rather than deleted. Setting 'DELETE' deletes the resource -and all its contents. Setting 'PREVENT' prevents the resource from accidental deletion -by erroring out during plan. -Default is 'PREVENT'. Possible values are: - * DELETE - * PREVENT - * ABANDON`, - Default: "PREVENT", + Computed: true, + ForceNew: true, }, - "project": { + "deletion_policy": { Type: schema.TypeString, Optional: true, Computed: true, - ForceNew: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "PREVENT". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, }, }, UseJSONNumber: true, @@ -420,8 +420,15 @@ func resourceSecureSourceManagerRepositoryRead(d *schema.ResourceData, meta inte // Explicitly set virtual fields to default values if unset if _, ok := d.GetOkExists("deletion_policy"); !ok { - if err := d.Set("deletion_policy", "PREVENT"); err != nil { - return fmt.Errorf("Error setting deletion_policy: %s", err) + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "PREVENT"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } } } if err := d.Set("project", project); err != nil { @@ -461,6 +468,19 @@ func resourceSecureSourceManagerRepositoryRead(d *schema.ResourceData, meta inte } func resourceSecureSourceManagerRepositoryUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceSecureSourceManagerRepository().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceSecureSourceManagerRepositoryRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -559,6 +579,13 @@ func resourceSecureSourceManagerRepositoryUpdate(d *schema.ResourceData, meta in } func resourceSecureSourceManagerRepositoryDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy SecureSourceManagerRepository without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Repository %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -585,13 +612,6 @@ func resourceSecureSourceManagerRepositoryDelete(d *schema.ResourceData, meta in } headers := make(http.Header) - deletionPolicy := d.Get("deletion_policy") - - if deletionPolicy == "ABANDON" { - return nil - } else if deletionPolicy == "PREVENT" { - return fmt.Errorf(`cannot destroy resource without setting deletion_policy="DELETE"`) - } log.Printf("[DEBUG] Deleting Repository %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ @@ -638,11 +658,6 @@ func resourceSecureSourceManagerRepositoryImport(d *schema.ResourceData, meta in } d.SetId(id) - // Explicitly set virtual fields to default values on import - if err := d.Set("deletion_policy", "PREVENT"); err != nil { - return nil, fmt.Errorf("Error setting deletion_policy: %s", err) - } - return []*schema.ResourceData{d}, nil } diff --git a/google/services/securesourcemanager/resource_secure_source_manager_repository_generated_meta.yaml b/google/services/securesourcemanager/resource_secure_source_manager_repository_generated_meta.yaml index 1fbbd1d4239..75a96624cb4 100644 --- a/google/services/securesourcemanager/resource_secure_source_manager_repository_generated_meta.yaml +++ b/google/services/securesourcemanager/resource_secure_source_manager_repository_generated_meta.yaml @@ -8,8 +8,6 @@ api_version: v1 api_resource_type_kind: Repository fields: - api_field: createTime - - field: deletion_policy - provider_only: true - api_field: description - api_field: initialConfig.defaultBranch - api_field: initialConfig.gitignores @@ -26,3 +24,5 @@ fields: - api_field: uris.api - api_field: uris.gitHttps - api_field: uris.html + - field: deletion_policy + provider_only: true diff --git a/google/services/securitycenter/resource_scc_event_threat_detection_custom_module.go b/google/services/securitycenter/resource_scc_event_threat_detection_custom_module.go index 97bef88601a..ef87497adf6 100644 --- a/google/services/securitycenter/resource_scc_event_threat_detection_custom_module.go +++ b/google/services/securitycenter/resource_scc_event_threat_detection_custom_module.go @@ -183,6 +183,19 @@ Its format is "organizations/{organization}/eventThreatDetectionSettings/customM A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -324,6 +337,20 @@ func resourceSecurityCenterEventThreatDetectionCustomModuleRead(d *schema.Resour log.Printf("[DEBUG] Finished reading SecurityCenterEventThreatDetectionCustomModule %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceSecurityCenterEventThreatDetectionCustomModuleFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -351,6 +378,19 @@ func resourceSecurityCenterEventThreatDetectionCustomModuleRead(d *schema.Resour } func resourceSecurityCenterEventThreatDetectionCustomModuleUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceSecurityCenterEventThreatDetectionCustomModule().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceSecurityCenterEventThreatDetectionCustomModuleRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -458,6 +498,13 @@ func resourceSecurityCenterEventThreatDetectionCustomModuleUpdate(d *schema.Reso } func resourceSecurityCenterEventThreatDetectionCustomModuleDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy SecurityCenterEventThreatDetectionCustomModule without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing EventThreatDetectionCustomModule %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/securitycenter/resource_scc_event_threat_detection_custom_module_generated_meta.yaml b/google/services/securitycenter/resource_scc_event_threat_detection_custom_module_generated_meta.yaml index 42cdd43406d..5136f4a78f5 100644 --- a/google/services/securitycenter/resource_scc_event_threat_detection_custom_module_generated_meta.yaml +++ b/google/services/securitycenter/resource_scc_event_threat_detection_custom_module_generated_meta.yaml @@ -19,3 +19,5 @@ fields: provider_only: true - api_field: type - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/securitycenter/resource_scc_folder_custom_module.go b/google/services/securitycenter/resource_scc_folder_custom_module.go index 44699bb790b..a7c240d7e09 100644 --- a/google/services/securitycenter/resource_scc_folder_custom_module.go +++ b/google/services/securitycenter/resource_scc_folder_custom_module.go @@ -323,6 +323,19 @@ The id {customModule} is server-generated and is not user settable. It will be a A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -458,6 +471,20 @@ func resourceSecurityCenterFolderCustomModuleRead(d *schema.ResourceData, meta i log.Printf("[DEBUG] Finished reading SecurityCenterFolderCustomModule %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceSecurityCenterFolderCustomModuleFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -485,6 +512,19 @@ func resourceSecurityCenterFolderCustomModuleRead(d *schema.ResourceData, meta i } func resourceSecurityCenterFolderCustomModuleUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceSecurityCenterFolderCustomModule().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceSecurityCenterFolderCustomModuleRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -582,6 +622,13 @@ func resourceSecurityCenterFolderCustomModuleUpdate(d *schema.ResourceData, meta } func resourceSecurityCenterFolderCustomModuleDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy SecurityCenterFolderCustomModule without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing FolderCustomModule %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/securitycenter/resource_scc_folder_custom_module_generated_meta.yaml b/google/services/securitycenter/resource_scc_folder_custom_module_generated_meta.yaml index e748be6d82b..6690572d1f7 100644 --- a/google/services/securitycenter/resource_scc_folder_custom_module_generated_meta.yaml +++ b/google/services/securitycenter/resource_scc_folder_custom_module_generated_meta.yaml @@ -30,3 +30,5 @@ fields: - api_field: lastEditor - api_field: name - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/securitycenter/resource_scc_folder_notification_config.go b/google/services/securitycenter/resource_scc_folder_notification_config.go index 0bc71181110..f78b7c7d1d1 100644 --- a/google/services/securitycenter/resource_scc_folder_notification_config.go +++ b/google/services/securitycenter/resource_scc_folder_notification_config.go @@ -208,6 +208,19 @@ for information on how to write a filter.`, Description: `The service account that needs "pubsub.topics.publish" permission to publish to the Pub/Sub topic.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -330,6 +343,20 @@ func resourceSecurityCenterFolderNotificationConfigRead(d *schema.ResourceData, log.Printf("[DEBUG] Finished reading SecurityCenterFolderNotificationConfig %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceSecurityCenterFolderNotificationConfigFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -357,6 +384,19 @@ func resourceSecurityCenterFolderNotificationConfigRead(d *schema.ResourceData, } func resourceSecurityCenterFolderNotificationConfigUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceSecurityCenterFolderNotificationConfig().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceSecurityCenterFolderNotificationConfigRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -457,6 +497,13 @@ func resourceSecurityCenterFolderNotificationConfigUpdate(d *schema.ResourceData } func resourceSecurityCenterFolderNotificationConfigDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy SecurityCenterFolderNotificationConfig without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing FolderNotificationConfig %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/securitycenter/resource_scc_folder_notification_config_generated_meta.yaml b/google/services/securitycenter/resource_scc_folder_notification_config_generated_meta.yaml index 50fe149bfcc..ca57ff34abe 100644 --- a/google/services/securitycenter/resource_scc_folder_notification_config_generated_meta.yaml +++ b/google/services/securitycenter/resource_scc_folder_notification_config_generated_meta.yaml @@ -18,3 +18,5 @@ fields: - api_field: pubsubTopic - api_field: serviceAccount - api_field: streamingConfig.filter + - field: deletion_policy + provider_only: true diff --git a/google/services/securitycenter/resource_scc_folder_scc_big_query_export.go b/google/services/securitycenter/resource_scc_folder_scc_big_query_export.go index 577b8a6e33d..7b10509e35b 100644 --- a/google/services/securitycenter/resource_scc_folder_scc_big_query_export.go +++ b/google/services/securitycenter/resource_scc_folder_scc_big_query_export.go @@ -219,6 +219,19 @@ This field is provided in responses, and is ignored when provided in create requ A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -341,6 +354,20 @@ func resourceSecurityCenterFolderSccBigQueryExportRead(d *schema.ResourceData, m log.Printf("[DEBUG] Finished reading SecurityCenterFolderSccBigQueryExport %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceSecurityCenterFolderSccBigQueryExportFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -368,6 +395,19 @@ func resourceSecurityCenterFolderSccBigQueryExportRead(d *schema.ResourceData, m } func resourceSecurityCenterFolderSccBigQueryExportUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceSecurityCenterFolderSccBigQueryExport().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceSecurityCenterFolderSccBigQueryExportRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -468,6 +508,13 @@ func resourceSecurityCenterFolderSccBigQueryExportUpdate(d *schema.ResourceData, } func resourceSecurityCenterFolderSccBigQueryExportDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy SecurityCenterFolderSccBigQueryExport without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing FolderSccBigQueryExport %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/securitycenter/resource_scc_folder_scc_big_query_export_generated_meta.yaml b/google/services/securitycenter/resource_scc_folder_scc_big_query_export_generated_meta.yaml index d1b9c0d48a3..b83e9972f6a 100644 --- a/google/services/securitycenter/resource_scc_folder_scc_big_query_export_generated_meta.yaml +++ b/google/services/securitycenter/resource_scc_folder_scc_big_query_export_generated_meta.yaml @@ -21,3 +21,5 @@ fields: - api_field: name - api_field: principal - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/securitycenter/resource_scc_mute_config.go b/google/services/securitycenter/resource_scc_mute_config.go index 64974efc2f1..8ce5a01717d 100644 --- a/google/services/securitycenter/resource_scc_mute_config.go +++ b/google/services/securitycenter/resource_scc_mute_config.go @@ -201,6 +201,19 @@ or projects/{project}/muteConfigs/{configId}`, updated. This field is set by the server and will be ignored if provided on config creation or update.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -330,6 +343,20 @@ func resourceSecurityCenterMuteConfigRead(d *schema.ResourceData, meta interface log.Printf("[DEBUG] Finished reading SecurityCenterMuteConfig %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceSecurityCenterMuteConfigFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -351,6 +378,19 @@ func resourceSecurityCenterMuteConfigRead(d *schema.ResourceData, meta interface } func resourceSecurityCenterMuteConfigUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceSecurityCenterMuteConfig().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceSecurityCenterMuteConfigRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -456,6 +496,13 @@ func resourceSecurityCenterMuteConfigUpdate(d *schema.ResourceData, meta interfa } func resourceSecurityCenterMuteConfigDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy SecurityCenterMuteConfig without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing MuteConfig %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/securitycenter/resource_scc_mute_config_generated_meta.yaml b/google/services/securitycenter/resource_scc_mute_config_generated_meta.yaml index e075b2ae235..9b4e3363f1c 100644 --- a/google/services/securitycenter/resource_scc_mute_config_generated_meta.yaml +++ b/google/services/securitycenter/resource_scc_mute_config_generated_meta.yaml @@ -23,3 +23,5 @@ fields: provider_only: true - api_field: type - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/securitycenter/resource_scc_notification_config.go b/google/services/securitycenter/resource_scc_notification_config.go index 32c5e6638e6..410a549b6af 100644 --- a/google/services/securitycenter/resource_scc_notification_config.go +++ b/google/services/securitycenter/resource_scc_notification_config.go @@ -190,6 +190,19 @@ for information on how to write a filter.`, Description: `The service account that needs "pubsub.topics.publish" permission to publish to the Pub/Sub topic.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -302,6 +315,20 @@ func resourceSecurityCenterNotificationConfigRead(d *schema.ResourceData, meta i log.Printf("[DEBUG] Finished reading SecurityCenterNotificationConfig %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceSecurityCenterNotificationConfigFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -311,6 +338,19 @@ func resourceSecurityCenterNotificationConfigRead(d *schema.ResourceData, meta i } func resourceSecurityCenterNotificationConfigUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceSecurityCenterNotificationConfig().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceSecurityCenterNotificationConfigRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -396,6 +436,13 @@ func resourceSecurityCenterNotificationConfigUpdate(d *schema.ResourceData, meta } func resourceSecurityCenterNotificationConfigDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy SecurityCenterNotificationConfig without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing NotificationConfig %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/securitycenter/resource_scc_notification_config_generated_meta.yaml b/google/services/securitycenter/resource_scc_notification_config_generated_meta.yaml index c7e82ed03c7..79a8fdb7a72 100644 --- a/google/services/securitycenter/resource_scc_notification_config_generated_meta.yaml +++ b/google/services/securitycenter/resource_scc_notification_config_generated_meta.yaml @@ -18,3 +18,5 @@ fields: - api_field: pubsubTopic - api_field: serviceAccount - api_field: streamingConfig.filter + - field: deletion_policy + provider_only: true diff --git a/google/services/securitycenter/resource_scc_organization_custom_module.go b/google/services/securitycenter/resource_scc_organization_custom_module.go index f5ab678727e..0cf41568afe 100644 --- a/google/services/securitycenter/resource_scc_organization_custom_module.go +++ b/google/services/securitycenter/resource_scc_organization_custom_module.go @@ -323,6 +323,19 @@ The id {customModule} is server-generated and is not user settable. It will be a A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -458,6 +471,20 @@ func resourceSecurityCenterOrganizationCustomModuleRead(d *schema.ResourceData, log.Printf("[DEBUG] Finished reading SecurityCenterOrganizationCustomModule %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceSecurityCenterOrganizationCustomModuleFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -485,6 +512,19 @@ func resourceSecurityCenterOrganizationCustomModuleRead(d *schema.ResourceData, } func resourceSecurityCenterOrganizationCustomModuleUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceSecurityCenterOrganizationCustomModule().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceSecurityCenterOrganizationCustomModuleRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -582,6 +622,13 @@ func resourceSecurityCenterOrganizationCustomModuleUpdate(d *schema.ResourceData } func resourceSecurityCenterOrganizationCustomModuleDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy SecurityCenterOrganizationCustomModule without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing OrganizationCustomModule %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/securitycenter/resource_scc_organization_custom_module_generated_meta.yaml b/google/services/securitycenter/resource_scc_organization_custom_module_generated_meta.yaml index b943c97dccd..81ec1adcdb5 100644 --- a/google/services/securitycenter/resource_scc_organization_custom_module_generated_meta.yaml +++ b/google/services/securitycenter/resource_scc_organization_custom_module_generated_meta.yaml @@ -30,3 +30,5 @@ fields: - field: organization provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/securitycenter/resource_scc_organization_scc_big_query_export.go b/google/services/securitycenter/resource_scc_organization_scc_big_query_export.go index ba21b35e951..3ac8d932f94 100644 --- a/google/services/securitycenter/resource_scc_organization_scc_big_query_export.go +++ b/google/services/securitycenter/resource_scc_organization_scc_big_query_export.go @@ -220,6 +220,19 @@ This field is provided in responses, and is ignored when provided in create requ A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -342,6 +355,20 @@ func resourceSecurityCenterOrganizationSccBigQueryExportRead(d *schema.ResourceD log.Printf("[DEBUG] Finished reading SecurityCenterOrganizationSccBigQueryExport %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceSecurityCenterOrganizationSccBigQueryExportFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -369,6 +396,19 @@ func resourceSecurityCenterOrganizationSccBigQueryExportRead(d *schema.ResourceD } func resourceSecurityCenterOrganizationSccBigQueryExportUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceSecurityCenterOrganizationSccBigQueryExport().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceSecurityCenterOrganizationSccBigQueryExportRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -469,6 +509,13 @@ func resourceSecurityCenterOrganizationSccBigQueryExportUpdate(d *schema.Resourc } func resourceSecurityCenterOrganizationSccBigQueryExportDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy SecurityCenterOrganizationSccBigQueryExport without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing OrganizationSccBigQueryExport %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/securitycenter/resource_scc_organization_scc_big_query_export_generated_meta.yaml b/google/services/securitycenter/resource_scc_organization_scc_big_query_export_generated_meta.yaml index 7fae62348c6..6e04e50b85e 100644 --- a/google/services/securitycenter/resource_scc_organization_scc_big_query_export_generated_meta.yaml +++ b/google/services/securitycenter/resource_scc_organization_scc_big_query_export_generated_meta.yaml @@ -21,3 +21,5 @@ fields: provider_only: true - api_field: principal - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/securitycenter/resource_scc_project_custom_module.go b/google/services/securitycenter/resource_scc_project_custom_module.go index 3fd0eb6d5f4..1f2482eeca7 100644 --- a/google/services/securitycenter/resource_scc_project_custom_module.go +++ b/google/services/securitycenter/resource_scc_project_custom_module.go @@ -115,6 +115,7 @@ func ResourceSecurityCenterProjectCustomModule() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -327,6 +328,18 @@ up to nine fractional digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T1 Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -474,6 +487,19 @@ func resourceSecurityCenterProjectCustomModuleRead(d *schema.ResourceData, meta log.Printf("[DEBUG] Finished reading SecurityCenterProjectCustomModule %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading ProjectCustomModule: %s", err) } @@ -505,6 +531,19 @@ func resourceSecurityCenterProjectCustomModuleRead(d *schema.ResourceData, meta } func resourceSecurityCenterProjectCustomModuleUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceSecurityCenterProjectCustomModule().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceSecurityCenterProjectCustomModuleRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -608,6 +647,13 @@ func resourceSecurityCenterProjectCustomModuleUpdate(d *schema.ResourceData, met } func resourceSecurityCenterProjectCustomModuleDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy SecurityCenterProjectCustomModule without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ProjectCustomModule %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/securitycenter/resource_scc_project_custom_module_generated_meta.yaml b/google/services/securitycenter/resource_scc_project_custom_module_generated_meta.yaml index ceadd2befec..7813831ba08 100644 --- a/google/services/securitycenter/resource_scc_project_custom_module_generated_meta.yaml +++ b/google/services/securitycenter/resource_scc_project_custom_module_generated_meta.yaml @@ -28,3 +28,5 @@ fields: - api_field: lastEditor - api_field: name - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/securitycenter/resource_scc_project_notification_config.go b/google/services/securitycenter/resource_scc_project_notification_config.go index bd4ce63dc37..c97e9560c16 100644 --- a/google/services/securitycenter/resource_scc_project_notification_config.go +++ b/google/services/securitycenter/resource_scc_project_notification_config.go @@ -115,6 +115,7 @@ func ResourceSecurityCenterProjectNotificationConfig() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -193,6 +194,18 @@ publish to the Pub/Sub topic.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -317,6 +330,19 @@ func resourceSecurityCenterProjectNotificationConfigRead(d *schema.ResourceData, log.Printf("[DEBUG] Finished reading SecurityCenterProjectNotificationConfig %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading ProjectNotificationConfig: %s", err) } @@ -330,6 +356,19 @@ func resourceSecurityCenterProjectNotificationConfigRead(d *schema.ResourceData, } func resourceSecurityCenterProjectNotificationConfigUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceSecurityCenterProjectNotificationConfig().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceSecurityCenterProjectNotificationConfigRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -421,6 +460,13 @@ func resourceSecurityCenterProjectNotificationConfigUpdate(d *schema.ResourceDat } func resourceSecurityCenterProjectNotificationConfigDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy SecurityCenterProjectNotificationConfig without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ProjectNotificationConfig %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/securitycenter/resource_scc_project_notification_config_generated_meta.yaml b/google/services/securitycenter/resource_scc_project_notification_config_generated_meta.yaml index 1b5ad929b3e..30411bbcf1c 100644 --- a/google/services/securitycenter/resource_scc_project_notification_config_generated_meta.yaml +++ b/google/services/securitycenter/resource_scc_project_notification_config_generated_meta.yaml @@ -16,3 +16,5 @@ fields: - api_field: pubsubTopic - api_field: serviceAccount - api_field: streamingConfig.filter + - field: deletion_policy + provider_only: true diff --git a/google/services/securitycenter/resource_scc_project_scc_big_query_export.go b/google/services/securitycenter/resource_scc_project_scc_big_query_export.go index 67f2284a244..9e9a095c020 100644 --- a/google/services/securitycenter/resource_scc_project_scc_big_query_export.go +++ b/google/services/securitycenter/resource_scc_project_scc_big_query_export.go @@ -115,6 +115,7 @@ func ResourceSecurityCenterProjectSccBigQueryExport() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -223,6 +224,18 @@ Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -357,6 +370,19 @@ func resourceSecurityCenterProjectSccBigQueryExportRead(d *schema.ResourceData, log.Printf("[DEBUG] Finished reading SecurityCenterProjectSccBigQueryExport %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading ProjectSccBigQueryExport: %s", err) } @@ -388,6 +414,19 @@ func resourceSecurityCenterProjectSccBigQueryExportRead(d *schema.ResourceData, } func resourceSecurityCenterProjectSccBigQueryExportUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceSecurityCenterProjectSccBigQueryExport().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceSecurityCenterProjectSccBigQueryExportRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -494,6 +533,13 @@ func resourceSecurityCenterProjectSccBigQueryExportUpdate(d *schema.ResourceData } func resourceSecurityCenterProjectSccBigQueryExportDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy SecurityCenterProjectSccBigQueryExport without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ProjectSccBigQueryExport %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/securitycenter/resource_scc_project_scc_big_query_export_generated_meta.yaml b/google/services/securitycenter/resource_scc_project_scc_big_query_export_generated_meta.yaml index 04921b6d4b3..c1465cb8f38 100644 --- a/google/services/securitycenter/resource_scc_project_scc_big_query_export_generated_meta.yaml +++ b/google/services/securitycenter/resource_scc_project_scc_big_query_export_generated_meta.yaml @@ -19,3 +19,5 @@ fields: - api_field: name - api_field: principal - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/securitycenter/resource_scc_source.go b/google/services/securitycenter/resource_scc_source.go index 690b0092f27..d470d1992f9 100644 --- a/google/services/securitycenter/resource_scc_source.go +++ b/google/services/securitycenter/resource_scc_source.go @@ -311,6 +311,7 @@ func resourceSecurityCenterSourceRead(d *schema.ResourceData, meta interface{}) } func resourceSecurityCenterSourceUpdate(d *schema.ResourceData, meta interface{}) error { + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/securitycentermanagement/resource_scc_management_folder_security_health_analytics_custom_module.go b/google/services/securitycentermanagement/resource_scc_management_folder_security_health_analytics_custom_module.go index 5008eaabfc6..b2e038a32b5 100644 --- a/google/services/securitycentermanagement/resource_scc_management_folder_security_health_analytics_custom_module.go +++ b/google/services/securitycentermanagement/resource_scc_management_folder_security_health_analytics_custom_module.go @@ -334,6 +334,19 @@ The id {securityHealthAnalyticsCustomModule} is server-generated and is not user A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -474,6 +487,20 @@ func resourceSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleRe log.Printf("[DEBUG] Finished reading SecurityCenterManagementFolderSecurityHealthAnalyticsCustomModule %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -507,6 +534,19 @@ func resourceSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleRe } func resourceSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModule().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -609,6 +649,13 @@ func resourceSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleUp } func resourceSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy SecurityCenterManagementFolderSecurityHealthAnalyticsCustomModule without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing FolderSecurityHealthAnalyticsCustomModule %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/securitycentermanagement/resource_scc_management_folder_security_health_analytics_custom_module_generated_meta.yaml b/google/services/securitycentermanagement/resource_scc_management_folder_security_health_analytics_custom_module_generated_meta.yaml index 14678b4a065..cbbae2224b2 100644 --- a/google/services/securitycentermanagement/resource_scc_management_folder_security_health_analytics_custom_module_generated_meta.yaml +++ b/google/services/securitycentermanagement/resource_scc_management_folder_security_health_analytics_custom_module_generated_meta.yaml @@ -32,3 +32,5 @@ fields: provider_only: true - api_field: name - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/securitycentermanagement/resource_scc_management_organization_event_threat_detection_custom_module.go b/google/services/securitycentermanagement/resource_scc_management_organization_event_threat_detection_custom_module.go index 3b1277625c5..a8f29ef1fa6 100644 --- a/google/services/securitycentermanagement/resource_scc_management_organization_event_threat_detection_custom_module.go +++ b/google/services/securitycentermanagement/resource_scc_management_organization_event_threat_detection_custom_module.go @@ -194,6 +194,19 @@ Its format is "organizations/{organization}/locations/{location}/eventThreatDete A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -340,6 +353,20 @@ func resourceSecurityCenterManagementOrganizationEventThreatDetectionCustomModul log.Printf("[DEBUG] Finished reading SecurityCenterManagementOrganizationEventThreatDetectionCustomModule %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceSecurityCenterManagementOrganizationEventThreatDetectionCustomModuleFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -373,6 +400,19 @@ func resourceSecurityCenterManagementOrganizationEventThreatDetectionCustomModul } func resourceSecurityCenterManagementOrganizationEventThreatDetectionCustomModuleUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceSecurityCenterManagementOrganizationEventThreatDetectionCustomModule().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceSecurityCenterManagementOrganizationEventThreatDetectionCustomModuleRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -485,6 +525,13 @@ func resourceSecurityCenterManagementOrganizationEventThreatDetectionCustomModul } func resourceSecurityCenterManagementOrganizationEventThreatDetectionCustomModuleDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy SecurityCenterManagementOrganizationEventThreatDetectionCustomModule without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing OrganizationEventThreatDetectionCustomModule %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/securitycentermanagement/resource_scc_management_organization_event_threat_detection_custom_module_generated_meta.yaml b/google/services/securitycentermanagement/resource_scc_management_organization_event_threat_detection_custom_module_generated_meta.yaml index 9710ddc0e2e..358dcff8489 100644 --- a/google/services/securitycentermanagement/resource_scc_management_organization_event_threat_detection_custom_module_generated_meta.yaml +++ b/google/services/securitycentermanagement/resource_scc_management_organization_event_threat_detection_custom_module_generated_meta.yaml @@ -21,3 +21,5 @@ fields: provider_only: true - api_field: type - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/securitycentermanagement/resource_scc_management_organization_security_health_analytics_custom_module.go b/google/services/securitycentermanagement/resource_scc_management_organization_security_health_analytics_custom_module.go index 700fce6a08c..bb768fd5916 100644 --- a/google/services/securitycentermanagement/resource_scc_management_organization_security_health_analytics_custom_module.go +++ b/google/services/securitycentermanagement/resource_scc_management_organization_security_health_analytics_custom_module.go @@ -334,6 +334,19 @@ The id {securityHealthAnalyticsCustomModule} is server-generated and is not user A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -474,6 +487,20 @@ func resourceSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomMo log.Printf("[DEBUG] Finished reading SecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModule %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -507,6 +534,19 @@ func resourceSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomMo } func resourceSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModule().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -609,6 +649,13 @@ func resourceSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomMo } func resourceSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy SecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModule without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing OrganizationSecurityHealthAnalyticsCustomModule %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/securitycentermanagement/resource_scc_management_organization_security_health_analytics_custom_module_generated_meta.yaml b/google/services/securitycentermanagement/resource_scc_management_organization_security_health_analytics_custom_module_generated_meta.yaml index ddb8f130155..ec2e424cb36 100644 --- a/google/services/securitycentermanagement/resource_scc_management_organization_security_health_analytics_custom_module_generated_meta.yaml +++ b/google/services/securitycentermanagement/resource_scc_management_organization_security_health_analytics_custom_module_generated_meta.yaml @@ -32,3 +32,5 @@ fields: - field: organization provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/securitycentermanagement/resource_scc_management_project_security_health_analytics_custom_module.go b/google/services/securitycentermanagement/resource_scc_management_project_security_health_analytics_custom_module.go index b1f1bdd7f13..8a82153aa25 100644 --- a/google/services/securitycentermanagement/resource_scc_management_project_security_health_analytics_custom_module.go +++ b/google/services/securitycentermanagement/resource_scc_management_project_security_health_analytics_custom_module.go @@ -115,6 +115,7 @@ func ResourceSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModule( CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -338,6 +339,18 @@ up to nine fractional digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T1 Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -490,6 +503,19 @@ func resourceSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleR log.Printf("[DEBUG] Finished reading SecurityCenterManagementProjectSecurityHealthAnalyticsCustomModule %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading ProjectSecurityHealthAnalyticsCustomModule: %s", err) } @@ -527,6 +553,19 @@ func resourceSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleR } func resourceSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModule().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -635,6 +674,13 @@ func resourceSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleU } func resourceSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy SecurityCenterManagementProjectSecurityHealthAnalyticsCustomModule without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ProjectSecurityHealthAnalyticsCustomModule %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/securitycentermanagement/resource_scc_management_project_security_health_analytics_custom_module_generated_meta.yaml b/google/services/securitycentermanagement/resource_scc_management_project_security_health_analytics_custom_module_generated_meta.yaml index e1ec95ee996..ec5584a7b5c 100644 --- a/google/services/securitycentermanagement/resource_scc_management_project_security_health_analytics_custom_module_generated_meta.yaml +++ b/google/services/securitycentermanagement/resource_scc_management_project_security_health_analytics_custom_module_generated_meta.yaml @@ -30,3 +30,5 @@ fields: provider_only: true - api_field: name - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/securitycenterv2/resource_scc_v2_folder_mute_config.go b/google/services/securitycenterv2/resource_scc_v2_folder_mute_config.go index 43705b5ad30..b2fb4073807 100644 --- a/google/services/securitycenterv2/resource_scc_v2_folder_mute_config.go +++ b/google/services/securitycenterv2/resource_scc_v2_folder_mute_config.go @@ -204,6 +204,19 @@ or projects/{project}/locations/global/muteConfigs/{configId}`, updated. This field is set by the server and will be ignored if provided on config creation or update.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -331,6 +344,20 @@ func resourceSecurityCenterV2FolderMuteConfigRead(d *schema.ResourceData, meta i log.Printf("[DEBUG] Finished reading SecurityCenterV2FolderMuteConfig %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceSecurityCenterV2FolderMuteConfigFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -364,6 +391,19 @@ func resourceSecurityCenterV2FolderMuteConfigRead(d *schema.ResourceData, meta i } func resourceSecurityCenterV2FolderMuteConfigUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceSecurityCenterV2FolderMuteConfig().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceSecurityCenterV2FolderMuteConfigRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -469,6 +509,13 @@ func resourceSecurityCenterV2FolderMuteConfigUpdate(d *schema.ResourceData, meta } func resourceSecurityCenterV2FolderMuteConfigDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy SecurityCenterV2FolderMuteConfig without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing FolderMuteConfig %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/securitycenterv2/resource_scc_v2_folder_mute_config_generated_meta.yaml b/google/services/securitycenterv2/resource_scc_v2_folder_mute_config_generated_meta.yaml index eef5acc8c97..3296eb5f9da 100644 --- a/google/services/securitycenterv2/resource_scc_v2_folder_mute_config_generated_meta.yaml +++ b/google/services/securitycenterv2/resource_scc_v2_folder_mute_config_generated_meta.yaml @@ -22,3 +22,5 @@ fields: - api_field: name - api_field: type - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/securitycenterv2/resource_scc_v2_folder_notification_config.go b/google/services/securitycenterv2/resource_scc_v2_folder_notification_config.go index e060653f8a1..cc5d69ee2c7 100644 --- a/google/services/securitycenterv2/resource_scc_v2_folder_notification_config.go +++ b/google/services/securitycenterv2/resource_scc_v2_folder_notification_config.go @@ -219,6 +219,19 @@ for information on how to write a filter.`, Description: `The service account that needs "pubsub.topics.publish" permission to publish to the Pub/Sub topic.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -346,6 +359,20 @@ func resourceSecurityCenterV2FolderNotificationConfigRead(d *schema.ResourceData log.Printf("[DEBUG] Finished reading SecurityCenterV2FolderNotificationConfig %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceSecurityCenterV2FolderNotificationConfigFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -379,6 +406,19 @@ func resourceSecurityCenterV2FolderNotificationConfigRead(d *schema.ResourceData } func resourceSecurityCenterV2FolderNotificationConfigUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceSecurityCenterV2FolderNotificationConfig().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceSecurityCenterV2FolderNotificationConfigRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -484,6 +524,13 @@ func resourceSecurityCenterV2FolderNotificationConfigUpdate(d *schema.ResourceDa } func resourceSecurityCenterV2FolderNotificationConfigDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy SecurityCenterV2FolderNotificationConfig without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing FolderNotificationConfig %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/securitycenterv2/resource_scc_v2_folder_notification_config_generated_meta.yaml b/google/services/securitycenterv2/resource_scc_v2_folder_notification_config_generated_meta.yaml index d3f754b06e0..b03053412fa 100644 --- a/google/services/securitycenterv2/resource_scc_v2_folder_notification_config_generated_meta.yaml +++ b/google/services/securitycenterv2/resource_scc_v2_folder_notification_config_generated_meta.yaml @@ -20,3 +20,5 @@ fields: - api_field: pubsubTopic - api_field: serviceAccount - api_field: streamingConfig.filter + - field: deletion_policy + provider_only: true diff --git a/google/services/securitycenterv2/resource_scc_v2_folder_scc_big_query_export.go b/google/services/securitycenterv2/resource_scc_v2_folder_scc_big_query_export.go index f5b9c6d4bb9..172b69977c5 100644 --- a/google/services/securitycenterv2/resource_scc_v2_folder_scc_big_query_export.go +++ b/google/services/securitycenterv2/resource_scc_v2_folder_scc_big_query_export.go @@ -233,6 +233,19 @@ This field is provided in responses, and is ignored when provided in create requ A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -360,6 +373,20 @@ func resourceSecurityCenterV2FolderSccBigQueryExportRead(d *schema.ResourceData, log.Printf("[DEBUG] Finished reading SecurityCenterV2FolderSccBigQueryExport %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceSecurityCenterV2FolderSccBigQueryExportFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -393,6 +420,19 @@ func resourceSecurityCenterV2FolderSccBigQueryExportRead(d *schema.ResourceData, } func resourceSecurityCenterV2FolderSccBigQueryExportUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceSecurityCenterV2FolderSccBigQueryExport().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceSecurityCenterV2FolderSccBigQueryExportRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -498,6 +538,13 @@ func resourceSecurityCenterV2FolderSccBigQueryExportUpdate(d *schema.ResourceDat } func resourceSecurityCenterV2FolderSccBigQueryExportDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy SecurityCenterV2FolderSccBigQueryExport without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing FolderSccBigQueryExport %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/securitycenterv2/resource_scc_v2_folder_scc_big_query_export_generated_meta.yaml b/google/services/securitycenterv2/resource_scc_v2_folder_scc_big_query_export_generated_meta.yaml index acf5e5914ad..be51add612d 100644 --- a/google/services/securitycenterv2/resource_scc_v2_folder_scc_big_query_export_generated_meta.yaml +++ b/google/services/securitycenterv2/resource_scc_v2_folder_scc_big_query_export_generated_meta.yaml @@ -23,3 +23,5 @@ fields: - api_field: name - api_field: principal - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/securitycenterv2/resource_scc_v2_organization_mute_config.go b/google/services/securitycenterv2/resource_scc_v2_organization_mute_config.go index 3bafad864b9..028e05f803a 100644 --- a/google/services/securitycenterv2/resource_scc_v2_organization_mute_config.go +++ b/google/services/securitycenterv2/resource_scc_v2_organization_mute_config.go @@ -204,6 +204,19 @@ or projects/{project}/locations/global/muteConfigs/{configId}`, updated. This field is set by the server and will be ignored if provided on config creation or update.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -331,6 +344,20 @@ func resourceSecurityCenterV2OrganizationMuteConfigRead(d *schema.ResourceData, log.Printf("[DEBUG] Finished reading SecurityCenterV2OrganizationMuteConfig %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceSecurityCenterV2OrganizationMuteConfigFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -364,6 +391,19 @@ func resourceSecurityCenterV2OrganizationMuteConfigRead(d *schema.ResourceData, } func resourceSecurityCenterV2OrganizationMuteConfigUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceSecurityCenterV2OrganizationMuteConfig().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceSecurityCenterV2OrganizationMuteConfigRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -469,6 +509,13 @@ func resourceSecurityCenterV2OrganizationMuteConfigUpdate(d *schema.ResourceData } func resourceSecurityCenterV2OrganizationMuteConfigDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy SecurityCenterV2OrganizationMuteConfig without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing OrganizationMuteConfig %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/securitycenterv2/resource_scc_v2_organization_mute_config_generated_meta.yaml b/google/services/securitycenterv2/resource_scc_v2_organization_mute_config_generated_meta.yaml index dd08f8d5e1b..8950c6422ec 100644 --- a/google/services/securitycenterv2/resource_scc_v2_organization_mute_config_generated_meta.yaml +++ b/google/services/securitycenterv2/resource_scc_v2_organization_mute_config_generated_meta.yaml @@ -22,3 +22,5 @@ fields: provider_only: true - api_field: type - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/securitycenterv2/resource_scc_v2_organization_notification_config.go b/google/services/securitycenterv2/resource_scc_v2_organization_notification_config.go index ba99d3519ea..75d86a6fafb 100644 --- a/google/services/securitycenterv2/resource_scc_v2_organization_notification_config.go +++ b/google/services/securitycenterv2/resource_scc_v2_organization_notification_config.go @@ -212,6 +212,19 @@ for information on how to write a filter.`, Description: `The service account that needs "pubsub.topics.publish" permission to publish to the Pub/Sub topic.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -335,6 +348,20 @@ func resourceSecurityCenterV2OrganizationNotificationConfigRead(d *schema.Resour log.Printf("[DEBUG] Finished reading SecurityCenterV2OrganizationNotificationConfig %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceSecurityCenterV2OrganizationNotificationConfigFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -356,6 +383,19 @@ func resourceSecurityCenterV2OrganizationNotificationConfigRead(d *schema.Resour } func resourceSecurityCenterV2OrganizationNotificationConfigUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceSecurityCenterV2OrganizationNotificationConfig().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceSecurityCenterV2OrganizationNotificationConfigRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -451,6 +491,13 @@ func resourceSecurityCenterV2OrganizationNotificationConfigUpdate(d *schema.Reso } func resourceSecurityCenterV2OrganizationNotificationConfigDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy SecurityCenterV2OrganizationNotificationConfig without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing OrganizationNotificationConfig %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/securitycenterv2/resource_scc_v2_organization_notification_config_generated_meta.yaml b/google/services/securitycenterv2/resource_scc_v2_organization_notification_config_generated_meta.yaml index f25837cafda..8ffc9789102 100644 --- a/google/services/securitycenterv2/resource_scc_v2_organization_notification_config_generated_meta.yaml +++ b/google/services/securitycenterv2/resource_scc_v2_organization_notification_config_generated_meta.yaml @@ -22,3 +22,5 @@ fields: - api_field: pubsubTopic - api_field: serviceAccount - api_field: streamingConfig.filter + - field: deletion_policy + provider_only: true diff --git a/google/services/securitycenterv2/resource_scc_v2_organization_scc_big_query_export.go b/google/services/securitycenterv2/resource_scc_v2_organization_scc_big_query_export.go index 928280be643..492e284d674 100644 --- a/google/services/securitycenterv2/resource_scc_v2_organization_scc_big_query_export.go +++ b/google/services/securitycenterv2/resource_scc_v2_organization_scc_big_query_export.go @@ -231,6 +231,19 @@ This field is set by the server and will be ignored if provided on export creati A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -364,6 +377,20 @@ func resourceSecurityCenterV2OrganizationSccBigQueryExportRead(d *schema.Resourc log.Printf("[DEBUG] Finished reading SecurityCenterV2OrganizationSccBigQueryExport %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceSecurityCenterV2OrganizationSccBigQueryExportFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -397,6 +424,19 @@ func resourceSecurityCenterV2OrganizationSccBigQueryExportRead(d *schema.Resourc } func resourceSecurityCenterV2OrganizationSccBigQueryExportUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceSecurityCenterV2OrganizationSccBigQueryExport().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceSecurityCenterV2OrganizationSccBigQueryExportRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -512,6 +552,13 @@ func resourceSecurityCenterV2OrganizationSccBigQueryExportUpdate(d *schema.Resou } func resourceSecurityCenterV2OrganizationSccBigQueryExportDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy SecurityCenterV2OrganizationSccBigQueryExport without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing OrganizationSccBigQueryExport %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/securitycenterv2/resource_scc_v2_organization_scc_big_query_export_generated_meta.yaml b/google/services/securitycenterv2/resource_scc_v2_organization_scc_big_query_export_generated_meta.yaml index 26848c20171..0bb14b4f01a 100644 --- a/google/services/securitycenterv2/resource_scc_v2_organization_scc_big_query_export_generated_meta.yaml +++ b/google/services/securitycenterv2/resource_scc_v2_organization_scc_big_query_export_generated_meta.yaml @@ -23,3 +23,5 @@ fields: provider_only: true - api_field: principal - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/securitycenterv2/resource_scc_v2_organization_scc_big_query_exports.go b/google/services/securitycenterv2/resource_scc_v2_organization_scc_big_query_exports.go index eb1b5a5ab8e..c1f8934283c 100644 --- a/google/services/securitycenterv2/resource_scc_v2_organization_scc_big_query_exports.go +++ b/google/services/securitycenterv2/resource_scc_v2_organization_scc_big_query_exports.go @@ -233,6 +233,19 @@ This field is set by the server and will be ignored if provided on export creati A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -366,6 +379,20 @@ func resourceSecurityCenterV2OrganizationSccBigQueryExportsRead(d *schema.Resour log.Printf("[DEBUG] Finished reading SecurityCenterV2OrganizationSccBigQueryExports %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceSecurityCenterV2OrganizationSccBigQueryExportsFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -399,6 +426,19 @@ func resourceSecurityCenterV2OrganizationSccBigQueryExportsRead(d *schema.Resour } func resourceSecurityCenterV2OrganizationSccBigQueryExportsUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceSecurityCenterV2OrganizationSccBigQueryExports().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceSecurityCenterV2OrganizationSccBigQueryExportsRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -514,6 +554,13 @@ func resourceSecurityCenterV2OrganizationSccBigQueryExportsUpdate(d *schema.Reso } func resourceSecurityCenterV2OrganizationSccBigQueryExportsDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy SecurityCenterV2OrganizationSccBigQueryExports without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing OrganizationSccBigQueryExports %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/securitycenterv2/resource_scc_v2_organization_scc_big_query_exports_generated_meta.yaml b/google/services/securitycenterv2/resource_scc_v2_organization_scc_big_query_exports_generated_meta.yaml index dc27a659867..006d16ee376 100644 --- a/google/services/securitycenterv2/resource_scc_v2_organization_scc_big_query_exports_generated_meta.yaml +++ b/google/services/securitycenterv2/resource_scc_v2_organization_scc_big_query_exports_generated_meta.yaml @@ -23,3 +23,5 @@ fields: provider_only: true - api_field: principal - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/securitycenterv2/resource_scc_v2_organization_source.go b/google/services/securitycenterv2/resource_scc_v2_organization_source.go index 6902d3028b3..5f87ecc8b90 100644 --- a/google/services/securitycenterv2/resource_scc_v2_organization_source.go +++ b/google/services/securitycenterv2/resource_scc_v2_organization_source.go @@ -311,6 +311,7 @@ func resourceSecurityCenterV2OrganizationSourceRead(d *schema.ResourceData, meta } func resourceSecurityCenterV2OrganizationSourceUpdate(d *schema.ResourceData, meta interface{}) error { + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/securitycenterv2/resource_scc_v2_project_mute_config.go b/google/services/securitycenterv2/resource_scc_v2_project_mute_config.go index eab308984c4..ad65f165c74 100644 --- a/google/services/securitycenterv2/resource_scc_v2_project_mute_config.go +++ b/google/services/securitycenterv2/resource_scc_v2_project_mute_config.go @@ -115,6 +115,7 @@ func ResourceSecurityCenterV2ProjectMuteConfig() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -207,6 +208,18 @@ provided on config creation or update.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -346,6 +359,19 @@ func resourceSecurityCenterV2ProjectMuteConfigRead(d *schema.ResourceData, meta log.Printf("[DEBUG] Finished reading SecurityCenterV2ProjectMuteConfig %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading ProjectMuteConfig: %s", err) } @@ -383,6 +409,19 @@ func resourceSecurityCenterV2ProjectMuteConfigRead(d *schema.ResourceData, meta } func resourceSecurityCenterV2ProjectMuteConfigUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceSecurityCenterV2ProjectMuteConfig().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceSecurityCenterV2ProjectMuteConfigRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -494,6 +533,13 @@ func resourceSecurityCenterV2ProjectMuteConfigUpdate(d *schema.ResourceData, met } func resourceSecurityCenterV2ProjectMuteConfigDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy SecurityCenterV2ProjectMuteConfig without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ProjectMuteConfig %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/securitycenterv2/resource_scc_v2_project_mute_config_generated_meta.yaml b/google/services/securitycenterv2/resource_scc_v2_project_mute_config_generated_meta.yaml index e34c999935d..b412a9c5b0b 100644 --- a/google/services/securitycenterv2/resource_scc_v2_project_mute_config_generated_meta.yaml +++ b/google/services/securitycenterv2/resource_scc_v2_project_mute_config_generated_meta.yaml @@ -20,3 +20,5 @@ fields: - api_field: name - api_field: type - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/securitycenterv2/resource_scc_v2_project_notification_config.go b/google/services/securitycenterv2/resource_scc_v2_project_notification_config.go index d625ea06dc7..9223d05cf41 100644 --- a/google/services/securitycenterv2/resource_scc_v2_project_notification_config.go +++ b/google/services/securitycenterv2/resource_scc_v2_project_notification_config.go @@ -115,6 +115,7 @@ func ResourceSecurityCenterV2ProjectNotificationConfig() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -200,6 +201,18 @@ publish to the Pub/Sub topic.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -324,6 +337,19 @@ func resourceSecurityCenterV2ProjectNotificationConfigRead(d *schema.ResourceDat log.Printf("[DEBUG] Finished reading SecurityCenterV2ProjectNotificationConfig %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading ProjectNotificationConfig: %s", err) } @@ -337,6 +363,19 @@ func resourceSecurityCenterV2ProjectNotificationConfigRead(d *schema.ResourceDat } func resourceSecurityCenterV2ProjectNotificationConfigUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceSecurityCenterV2ProjectNotificationConfig().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceSecurityCenterV2ProjectNotificationConfigRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -428,6 +467,13 @@ func resourceSecurityCenterV2ProjectNotificationConfigUpdate(d *schema.ResourceD } func resourceSecurityCenterV2ProjectNotificationConfigDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy SecurityCenterV2ProjectNotificationConfig without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ProjectNotificationConfig %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/securitycenterv2/resource_scc_v2_project_notification_config_generated_meta.yaml b/google/services/securitycenterv2/resource_scc_v2_project_notification_config_generated_meta.yaml index 7988454d44e..c9648f2c701 100644 --- a/google/services/securitycenterv2/resource_scc_v2_project_notification_config_generated_meta.yaml +++ b/google/services/securitycenterv2/resource_scc_v2_project_notification_config_generated_meta.yaml @@ -18,3 +18,5 @@ fields: - api_field: pubsubTopic - api_field: serviceAccount - api_field: streamingConfig.filter + - field: deletion_policy + provider_only: true diff --git a/google/services/securitycenterv2/resource_scc_v2_project_scc_big_query_export.go b/google/services/securitycenterv2/resource_scc_v2_project_scc_big_query_export.go index 730a05fcdb2..8f60fbc16fa 100644 --- a/google/services/securitycenterv2/resource_scc_v2_project_scc_big_query_export.go +++ b/google/services/securitycenterv2/resource_scc_v2_project_scc_big_query_export.go @@ -115,6 +115,7 @@ func ResourceSecurityCenterV2ProjectSccBigQueryExport() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -234,6 +235,18 @@ Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -373,6 +386,19 @@ func resourceSecurityCenterV2ProjectSccBigQueryExportRead(d *schema.ResourceData log.Printf("[DEBUG] Finished reading SecurityCenterV2ProjectSccBigQueryExport %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading ProjectSccBigQueryExport: %s", err) } @@ -410,6 +436,19 @@ func resourceSecurityCenterV2ProjectSccBigQueryExportRead(d *schema.ResourceData } func resourceSecurityCenterV2ProjectSccBigQueryExportUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceSecurityCenterV2ProjectSccBigQueryExport().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceSecurityCenterV2ProjectSccBigQueryExportRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -521,6 +560,13 @@ func resourceSecurityCenterV2ProjectSccBigQueryExportUpdate(d *schema.ResourceDa } func resourceSecurityCenterV2ProjectSccBigQueryExportDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy SecurityCenterV2ProjectSccBigQueryExport without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ProjectSccBigQueryExport %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/securitycenterv2/resource_scc_v2_project_scc_big_query_export_generated_meta.yaml b/google/services/securitycenterv2/resource_scc_v2_project_scc_big_query_export_generated_meta.yaml index 0d07993c8d7..43a254a0f70 100644 --- a/google/services/securitycenterv2/resource_scc_v2_project_scc_big_query_export_generated_meta.yaml +++ b/google/services/securitycenterv2/resource_scc_v2_project_scc_big_query_export_generated_meta.yaml @@ -21,3 +21,5 @@ fields: - api_field: name - api_field: principal - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/securityposture/resource_securityposture_posture.go b/google/services/securityposture/resource_securityposture_posture.go index 7c0cf89b5c9..c4680a8b2f1 100644 --- a/google/services/securityposture/resource_securityposture_posture.go +++ b/google/services/securityposture/resource_securityposture_posture.go @@ -126,6 +126,7 @@ func ResourceSecurityposturePosture() *schema.Resource { CustomizeDiff: customdiff.All( revisionIdCustomizeDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -714,6 +715,19 @@ with other field updates. Possible values: ["DEPRECATED", "DRAFT", "ACTIVE"]`, Computed: true, Description: `Time the Posture was updated in UTC.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -857,6 +871,20 @@ func resourceSecurityposturePostureRead(d *schema.ResourceData, meta interface{} log.Printf("[DEBUG] Finished reading SecurityposturePosture %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceSecurityposturePostureFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -890,6 +918,19 @@ func resourceSecurityposturePostureRead(d *schema.ResourceData, meta interface{} } func resourceSecurityposturePostureUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceSecurityposturePosture().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceSecurityposturePostureRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1012,6 +1053,13 @@ func resourceSecurityposturePostureUpdate(d *schema.ResourceData, meta interface } func resourceSecurityposturePostureDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy SecurityposturePosture without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Posture %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/securityposture/resource_securityposture_posture_deployment.go b/google/services/securityposture/resource_securityposture_posture_deployment.go index 95964eb2223..03739d01140 100644 --- a/google/services/securityposture/resource_securityposture_posture_deployment.go +++ b/google/services/securityposture/resource_securityposture_posture_deployment.go @@ -233,6 +233,19 @@ ACTIVE, CREATE_FAILED, UPDATE_FAILED, DELETE_FAILED.`, Computed: true, Description: `Time the posture deployment was updated in UTC.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -376,6 +389,20 @@ func resourceSecurityposturePostureDeploymentRead(d *schema.ResourceData, meta i log.Printf("[DEBUG] Finished reading SecurityposturePostureDeployment %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceSecurityposturePostureDeploymentFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -409,6 +436,19 @@ func resourceSecurityposturePostureDeploymentRead(d *schema.ResourceData, meta i } func resourceSecurityposturePostureDeploymentUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceSecurityposturePostureDeployment().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceSecurityposturePostureDeploymentRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -521,6 +561,13 @@ func resourceSecurityposturePostureDeploymentUpdate(d *schema.ResourceData, meta } func resourceSecurityposturePostureDeploymentDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy SecurityposturePostureDeployment without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing PostureDeployment %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/securityposture/resource_securityposture_posture_deployment_generated_meta.yaml b/google/services/securityposture/resource_securityposture_posture_deployment_generated_meta.yaml index ace3ea73d71..48a6d017eae 100644 --- a/google/services/securityposture/resource_securityposture_posture_deployment_generated_meta.yaml +++ b/google/services/securityposture/resource_securityposture_posture_deployment_generated_meta.yaml @@ -30,3 +30,5 @@ fields: - api_field: state - api_field: targetResource - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/securityposture/resource_securityposture_posture_generated_meta.yaml b/google/services/securityposture/resource_securityposture_posture_generated_meta.yaml index 0d496c01e33..1e33437c041 100644 --- a/google/services/securityposture/resource_securityposture_posture_generated_meta.yaml +++ b/google/services/securityposture/resource_securityposture_posture_generated_meta.yaml @@ -71,3 +71,5 @@ fields: - api_field: revisionId - api_field: state - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/servicedirectory/resource_service_directory_endpoint.go b/google/services/servicedirectory/resource_service_directory_endpoint.go index e4ffa5bfcc6..4a9d34c8221 100644 --- a/google/services/servicedirectory/resource_service_directory_endpoint.go +++ b/google/services/servicedirectory/resource_service_directory_endpoint.go @@ -162,6 +162,19 @@ range of [0, 65535]. If unspecified, the default is 0.`, Description: `The resource name for the endpoint in the format 'projects/*/locations/*/namespaces/*/services/*/endpoints/*'.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -297,6 +310,20 @@ func resourceServiceDirectoryEndpointRead(d *schema.ResourceData, meta interface return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceServiceDirectoryEndpointFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -306,6 +333,19 @@ func resourceServiceDirectoryEndpointRead(d *schema.ResourceData, meta interface } func resourceServiceDirectoryEndpointUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceServiceDirectoryEndpoint().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceServiceDirectoryEndpointRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -393,6 +433,13 @@ func resourceServiceDirectoryEndpointUpdate(d *schema.ResourceData, meta interfa } func resourceServiceDirectoryEndpointDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ServiceDirectoryEndpoint without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Endpoint %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/servicedirectory/resource_service_directory_endpoint_generated_meta.yaml b/google/services/servicedirectory/resource_service_directory_endpoint_generated_meta.yaml index 26e01237408..b449d82170d 100644 --- a/google/services/servicedirectory/resource_service_directory_endpoint_generated_meta.yaml +++ b/google/services/servicedirectory/resource_service_directory_endpoint_generated_meta.yaml @@ -16,3 +16,5 @@ fields: - api_field: port - field: service provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/servicedirectory/resource_service_directory_namespace.go b/google/services/servicedirectory/resource_service_directory_namespace.go index 58100a0aa5a..e569ea99734 100644 --- a/google/services/servicedirectory/resource_service_directory_namespace.go +++ b/google/services/servicedirectory/resource_service_directory_namespace.go @@ -116,6 +116,7 @@ func ResourceServiceDirectoryNamespace() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -170,6 +171,18 @@ in the format 'projects/*/locations/*/namespaces/*'.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -282,6 +295,19 @@ func resourceServiceDirectoryNamespaceRead(d *schema.ResourceData, meta interfac log.Printf("[DEBUG] Finished reading ServiceDirectoryNamespace %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Namespace: %s", err) } @@ -295,6 +321,19 @@ func resourceServiceDirectoryNamespaceRead(d *schema.ResourceData, meta interfac } func resourceServiceDirectoryNamespaceUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceServiceDirectoryNamespace().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceServiceDirectoryNamespaceRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -366,6 +405,13 @@ func resourceServiceDirectoryNamespaceUpdate(d *schema.ResourceData, meta interf } func resourceServiceDirectoryNamespaceDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ServiceDirectoryNamespace without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Namespace %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/servicedirectory/resource_service_directory_namespace_generated_meta.yaml b/google/services/servicedirectory/resource_service_directory_namespace_generated_meta.yaml index a136086b4d3..d21465b3195 100644 --- a/google/services/servicedirectory/resource_service_directory_namespace_generated_meta.yaml +++ b/google/services/servicedirectory/resource_service_directory_namespace_generated_meta.yaml @@ -17,3 +17,5 @@ fields: provider_only: true - field: terraform_labels provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/servicedirectory/resource_service_directory_service.go b/google/services/servicedirectory/resource_service_directory_service.go index f0aab725274..b15015a4b31 100644 --- a/google/services/servicedirectory/resource_service_directory_service.go +++ b/google/services/servicedirectory/resource_service_directory_service.go @@ -142,6 +142,19 @@ Metadata that goes beyond any these limits will be rejected.`, Description: `The resource name for the service in the format 'projects/*/locations/*/namespaces/*/services/*'.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -259,6 +272,20 @@ func resourceServiceDirectoryServiceRead(d *schema.ResourceData, meta interface{ return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceServiceDirectoryServiceFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -268,6 +295,19 @@ func resourceServiceDirectoryServiceRead(d *schema.ResourceData, meta interface{ } func resourceServiceDirectoryServiceUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceServiceDirectoryService().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceServiceDirectoryServiceRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -335,6 +375,13 @@ func resourceServiceDirectoryServiceUpdate(d *schema.ResourceData, meta interfac } func resourceServiceDirectoryServiceDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy ServiceDirectoryService without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Service %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/servicedirectory/resource_service_directory_service_generated_meta.yaml b/google/services/servicedirectory/resource_service_directory_service_generated_meta.yaml index 306f5d2172f..984d2d5aa11 100644 --- a/google/services/servicedirectory/resource_service_directory_service_generated_meta.yaml +++ b/google/services/servicedirectory/resource_service_directory_service_generated_meta.yaml @@ -13,3 +13,5 @@ fields: provider_only: true - field: service_id provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/servicemanagement/resource_endpoints_service.go b/google/services/servicemanagement/resource_endpoints_service.go index c4033dc852d..39d6deedb69 100644 --- a/google/services/servicemanagement/resource_endpoints_service.go +++ b/google/services/servicemanagement/resource_endpoints_service.go @@ -28,6 +28,7 @@ import ( "strings" "time" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-provider-google/google/registry" "github.com/hashicorp/terraform-provider-google/google/tpgresource" @@ -164,8 +165,14 @@ func ResourceEndpointsService() *schema.Resource { }, }, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, - CustomizeDiff: predictServiceId, + CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), + predictServiceId, + ), UseJSONNumber: true, } } @@ -300,6 +307,11 @@ func expandEndpointServiceConfigSource(d *schema.ResourceData, meta interface{}) } func resourceEndpointsServiceUpdate(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceEndpointsService) { + return ResourceEndpointsService().Read(d, meta) + } + // This update is not quite standard for a terraform resource. Instead of // using the go client library to send an HTTP request to update something // serverside, we have to push a new configuration, wait for it to be @@ -370,6 +382,13 @@ func resourceEndpointsServiceUpdate(d *schema.ResourceData, meta interface{}) er } func resourceEndpointsServiceDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -414,6 +433,10 @@ func resourceEndpointsServiceRead(d *schema.ResourceData, meta interface{}) erro return fmt.Errorf("Error setting endpoints: %s", err) } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } diff --git a/google/services/servicemanagement/resource_endpoints_service_meta.yaml b/google/services/servicemanagement/resource_endpoints_service_meta.yaml index 561ed1145b5..dcab542636e 100644 --- a/google/services/servicemanagement/resource_endpoints_service_meta.yaml +++ b/google/services/servicemanagement/resource_endpoints_service_meta.yaml @@ -22,3 +22,5 @@ fields: - field: 'project' - field: 'protoc_output_base64' - api_field: 'serviceName' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/servicenetworking/data_source_google_service_networking_peered_dns_domain.go b/google/services/servicenetworking/data_source_google_service_networking_peered_dns_domain.go index d027a64b258..17d590d1fce 100644 --- a/google/services/servicenetworking/data_source_google_service_networking_peered_dns_domain.go +++ b/google/services/servicenetworking/data_source_google_service_networking_peered_dns_domain.go @@ -17,6 +17,8 @@ package servicenetworking import ( + "github.com/hashicorp/terraform-provider-google/google/tpgresource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-provider-google/google/registry" ) @@ -49,6 +51,9 @@ func DataSourceGoogleServiceNetworkingPeeredDNSDomain() *schema.Resource { Type: schema.TypeString, Computed: true, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, } } diff --git a/google/services/servicenetworking/resource_google_service_networking_peered_dns_domain.go b/google/services/servicenetworking/resource_google_service_networking_peered_dns_domain.go index cee4f83dbeb..4449d504faf 100644 --- a/google/services/servicenetworking/resource_google_service_networking_peered_dns_domain.go +++ b/google/services/servicenetworking/resource_google_service_networking_peered_dns_domain.go @@ -37,6 +37,7 @@ func ResourceGoogleServiceNetworkingPeeredDNSDomain() *schema.Resource { return &schema.Resource{ Create: resourceGoogleServiceNetworkingPeeredDNSDomainCreate, Read: resourceGoogleServiceNetworkingPeeredDNSDomainRead, + Update: resourceGoogleServiceNetworkingPeeredDNSDomainUpdate, Delete: resourceGoogleServiceNetworkingPeeredDNSDomainDelete, Importer: &schema.ResourceImporter{ @@ -51,6 +52,7 @@ func ResourceGoogleServiceNetworkingPeeredDNSDomain() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -90,6 +92,9 @@ func ResourceGoogleServiceNetworkingPeeredDNSDomain() *schema.Resource { Type: schema.TypeString, Computed: true, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, UseJSONNumber: true, } @@ -230,10 +235,29 @@ func resourceGoogleServiceNetworkingPeeredDNSDomainRead(d *schema.ResourceData, return fmt.Errorf("Error setting parent: %s", err) } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } +// UDP update start +func resourceGoogleServiceNetworkingPeeredDNSDomainUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceGoogleServiceNetworkingPeeredDNSDomainRead(d, meta) +} + +//UDP update end + func resourceGoogleServiceNetworkingPeeredDNSDomainDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/servicenetworking/resource_google_service_networking_peered_dns_domain_meta.yaml b/google/services/servicenetworking/resource_google_service_networking_peered_dns_domain_meta.yaml index 9d58a039d3a..4cbaa0c4516 100644 --- a/google/services/servicenetworking/resource_google_service_networking_peered_dns_domain_meta.yaml +++ b/google/services/servicenetworking/resource_google_service_networking_peered_dns_domain_meta.yaml @@ -12,3 +12,5 @@ fields: - field: 'parent' - field: 'project' - field: 'service' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/servicenetworking/resource_service_networking_connection.go b/google/services/servicenetworking/resource_service_networking_connection.go index c54527a8ad1..a9fb12b0560 100644 --- a/google/services/servicenetworking/resource_service_networking_connection.go +++ b/google/services/servicenetworking/resource_service_networking_connection.go @@ -32,8 +32,8 @@ import ( transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" "github.com/hashicorp/errwrap" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "google.golang.org/api/servicenetworking/v1" ) @@ -53,6 +53,9 @@ func ResourceServiceNetworkingConnection() *schema.Resource { Importer: &schema.ResourceImporter{ State: resourceServiceNetworkingConnectionImportState, }, + CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), + ), Timeouts: &schema.ResourceTimeout{ Create: schema.DefaultTimeout(10 * time.Minute), @@ -87,12 +90,9 @@ func ResourceServiceNetworkingConnection() *schema.Resource { DiffSuppressFunc: stringListDiffSuppress, Description: `Named IP address range(s) of PEERING type reserved for this service provider. Note that invoking this method with a different range when connection is already established will not reallocate already provisioned service producer subnetworks.`, }, - "deletion_policy": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringInSlice([]string{"ABANDON", ""}, false), - Description: `When set to ABANDON, terraform will abandon management of the resource instead of deleting it. Prevents terraform apply failures with CloudSQL. Note: The resource will still exist.`, - }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end "peering": { Type: schema.TypeString, Computed: true, @@ -255,10 +255,19 @@ func resourceServiceNetworkingConnectionRead(d *schema.ResourceData, meta interf return fmt.Errorf("Error setting reserved_peering_ranges: %s", err) } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } func resourceServiceNetworkingConnectionUpdate(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceServiceNetworkingConnection) { + return ResourceServiceNetworkingConnection().Read(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -316,8 +325,9 @@ func resourceServiceNetworkingConnectionUpdate(d *schema.ResourceData, meta inte func resourceServiceNetworkingConnectionDelete(d *schema.ResourceData, meta interface{}) error { config := meta.(*transport_tpg.Config) - if deletionPolicy := d.Get("deletion_policy"); deletionPolicy == "ABANDON" { - log.Printf("[WARN] The service networking connection has been abandoned") + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { return nil } diff --git a/google/services/servicenetworking/resource_service_networking_connection_meta.yaml b/google/services/servicenetworking/resource_service_networking_connection_meta.yaml index ad66ed83c4a..7c300295c48 100644 --- a/google/services/servicenetworking/resource_service_networking_connection_meta.yaml +++ b/google/services/servicenetworking/resource_service_networking_connection_meta.yaml @@ -7,6 +7,7 @@ api_version: 'v1' api_resource_type_kind: 'Connection' fields: - field: 'deletion_policy' + provider_only: true - api_field: 'network' - api_field: 'peering' - api_field: 'reservedPeeringRanges' diff --git a/google/services/servicenetworking/resource_service_networking_vpc_service_controls.go b/google/services/servicenetworking/resource_service_networking_vpc_service_controls.go index 0742b3d6463..0b32bb78357 100644 --- a/google/services/servicenetworking/resource_service_networking_vpc_service_controls.go +++ b/google/services/servicenetworking/resource_service_networking_vpc_service_controls.go @@ -333,6 +333,7 @@ func resourceServiceNetworkingVPCServiceControlsRead(d *schema.ResourceData, met } func resourceServiceNetworkingVPCServiceControlsUpdate(d *schema.ResourceData, meta interface{}) error { + config := meta.(*transport_tpg.Config) return resourceServiceNetworkingVPCServiceControlsSet(d, meta, config) } diff --git a/google/services/siteverification/resource_site_verification_owner.go b/google/services/siteverification/resource_site_verification_owner.go index ff5af247c1a..ddbae52c9f1 100644 --- a/google/services/siteverification/resource_site_verification_owner.go +++ b/google/services/siteverification/resource_site_verification_owner.go @@ -32,6 +32,7 @@ func ResourceSiteVerificationOwner() *schema.Resource { return &schema.Resource{ Create: resourceSiteVerificationOwnerCreate, Read: resourceSiteVerificationOwnerRead, + Update: resourceSiteVerificationOwnerUpdate, Delete: resourceSiteVerificationOwnerDelete, Importer: &schema.ResourceImporter{ @@ -57,6 +58,9 @@ func ResourceSiteVerificationOwner() *schema.Resource { DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName, Description: `The id of the Web Resource to add this owner to, in the form "webResource/".`, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, UseJSONNumber: true, } @@ -196,10 +200,29 @@ func resourceSiteVerificationOwnerRead(d *schema.ResourceData, meta interface{}) return nil } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } +// UDP update start +func resourceSiteVerificationOwnerUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceSiteVerificationOwnerRead(d, meta) +} + +//UDP update end + func resourceSiteVerificationOwnerDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/siteverification/resource_site_verification_owner_meta.yaml b/google/services/siteverification/resource_site_verification_owner_meta.yaml index a545baa0482..48b66da6095 100644 --- a/google/services/siteverification/resource_site_verification_owner_meta.yaml +++ b/google/services/siteverification/resource_site_verification_owner_meta.yaml @@ -8,3 +8,5 @@ api_resource_type_kind: 'WebResource' fields: - field: 'email' - field: 'web_resource_id' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/siteverification/resource_site_verification_web_resource.go b/google/services/siteverification/resource_site_verification_web_resource.go index dd183b7c7e8..81ecd253fee 100644 --- a/google/services/siteverification/resource_site_verification_web_resource.go +++ b/google/services/siteverification/resource_site_verification_web_resource.go @@ -100,6 +100,7 @@ func ResourceSiteVerificationWebResource() *schema.Resource { return &schema.Resource{ Create: resourceSiteVerificationWebResourceCreate, Read: resourceSiteVerificationWebResourceRead, + Update: resourceSiteVerificationWebResourceUpdate, Delete: resourceSiteVerificationWebResourceDelete, Importer: &schema.ResourceImporter{ @@ -174,6 +175,19 @@ for example verified owners of the containing domain—are not included in this Computed: true, Description: `The string used to identify this web resource.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -295,6 +309,20 @@ func resourceSiteVerificationWebResourceRead(d *schema.ResourceData, meta interf log.Printf("[DEBUG] Finished reading SiteVerificationWebResource %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceSiteVerificationWebResourceFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -315,7 +343,19 @@ func resourceSiteVerificationWebResourceRead(d *schema.ResourceData, meta interf return nil } +func resourceSiteVerificationWebResourceUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceSiteVerificationWebResourceRead(d, meta) +} + func resourceSiteVerificationWebResourceDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy SiteVerificationWebResource without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing WebResource %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/siteverification/resource_site_verification_web_resource_generated_meta.yaml b/google/services/siteverification/resource_site_verification_web_resource_generated_meta.yaml index 7ad9bc9458c..cd8ae066d7d 100644 --- a/google/services/siteverification/resource_site_verification_web_resource_generated_meta.yaml +++ b/google/services/siteverification/resource_site_verification_web_resource_generated_meta.yaml @@ -14,3 +14,5 @@ fields: provider_only: true - api_field: id field: web_resource_id + - field: deletion_policy + provider_only: true diff --git a/google/services/sourcerepo/resource_sourcerepo_repository.go b/google/services/sourcerepo/resource_sourcerepo_repository.go index abfb5ff8b37..76be290de4e 100644 --- a/google/services/sourcerepo/resource_sourcerepo_repository.go +++ b/google/services/sourcerepo/resource_sourcerepo_repository.go @@ -176,6 +176,7 @@ func ResourceSourceRepoRepository() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -259,6 +260,18 @@ If unspecified, it defaults to the compute engine default service account.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -407,6 +420,19 @@ func resourceSourceRepoRepositoryRead(d *schema.ResourceData, meta interface{}) log.Printf("[DEBUG] Finished reading SourceRepoRepository %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Repository: %s", err) } @@ -438,6 +464,19 @@ func resourceSourceRepoRepositoryRead(d *schema.ResourceData, meta interface{}) } func resourceSourceRepoRepositoryUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceSourceRepoRepository().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceSourceRepoRepositoryRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -529,6 +568,13 @@ func resourceSourceRepoRepositoryUpdate(d *schema.ResourceData, meta interface{} } func resourceSourceRepoRepositoryDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy SourceRepoRepository without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Repository %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/sourcerepo/resource_sourcerepo_repository_generated_meta.yaml b/google/services/sourcerepo/resource_sourcerepo_repository_generated_meta.yaml index 3715d0af636..a3db2cab1f4 100644 --- a/google/services/sourcerepo/resource_sourcerepo_repository_generated_meta.yaml +++ b/google/services/sourcerepo/resource_sourcerepo_repository_generated_meta.yaml @@ -16,3 +16,5 @@ fields: field: pubsub_configs.service_account_email - api_field: size - api_field: url + - field: deletion_policy + provider_only: true diff --git a/google/services/spanner/resource_spanner_backup_schedule.go b/google/services/spanner/resource_spanner_backup_schedule.go index 4ec3e974a4f..ac7ee21238c 100644 --- a/google/services/spanner/resource_spanner_backup_schedule.go +++ b/google/services/spanner/resource_spanner_backup_schedule.go @@ -115,6 +115,7 @@ func ResourceSpannerBackupSchedule() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -273,6 +274,18 @@ database at the version time. Allowed frequencies are 12 hour, 1 day, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -452,6 +465,19 @@ func resourceSpannerBackupScheduleRead(d *schema.ResourceData, meta interface{}) return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading BackupSchedule: %s", err) } @@ -495,6 +521,19 @@ func resourceSpannerBackupScheduleRead(d *schema.ResourceData, meta interface{}) } func resourceSpannerBackupScheduleUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceSpannerBackupSchedule().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceSpannerBackupScheduleRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -633,6 +672,13 @@ func resourceSpannerBackupScheduleUpdate(d *schema.ResourceData, meta interface{ } func resourceSpannerBackupScheduleDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy SpannerBackupSchedule without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing BackupSchedule %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/spanner/resource_spanner_backup_schedule_generated_meta.yaml b/google/services/spanner/resource_spanner_backup_schedule_generated_meta.yaml index 956536beb67..06be3c30a53 100644 --- a/google/services/spanner/resource_spanner_backup_schedule_generated_meta.yaml +++ b/google/services/spanner/resource_spanner_backup_schedule_generated_meta.yaml @@ -19,3 +19,5 @@ fields: - api_field: name - api_field: retentionDuration - api_field: spec.cronSpec.text + - field: deletion_policy + provider_only: true diff --git a/google/services/spanner/resource_spanner_database.go b/google/services/spanner/resource_spanner_database.go index bd4109ca169..a52bd032b85 100644 --- a/google/services/spanner/resource_spanner_database.go +++ b/google/services/spanner/resource_spanner_database.go @@ -192,6 +192,7 @@ func ResourceSpannerDatabase() *schema.Resource { resourceSpannerDBDdlCustomDiff, resourceSpannerEncryptionConfigCustomDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -340,6 +341,18 @@ from the tz database. Default value is "America/Los_angeles".`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -651,6 +664,18 @@ func resourceSpannerDatabaseRead(d *schema.ResourceData, meta interface{}) error return fmt.Errorf("Error setting deletion_protection: %s", err) } } + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Database: %s", err) } @@ -688,6 +713,19 @@ func resourceSpannerDatabaseRead(d *schema.ResourceData, meta interface{}) error } func resourceSpannerDatabaseUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceSpannerDatabase().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceSpannerDatabaseRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -885,6 +923,13 @@ func resourceSpannerDatabaseUpdate(d *schema.ResourceData, meta interface{}) err } func resourceSpannerDatabaseDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy SpannerDatabase without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Database %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/spanner/resource_spanner_database_generated_meta.yaml b/google/services/spanner/resource_spanner_database_generated_meta.yaml index ad6057176aa..85b26d223f2 100644 --- a/google/services/spanner/resource_spanner_database_generated_meta.yaml +++ b/google/services/spanner/resource_spanner_database_generated_meta.yaml @@ -23,3 +23,5 @@ fields: - api_field: name - api_field: state - api_field: versionRetentionPeriod + - field: deletion_policy + provider_only: true diff --git a/google/services/spanner/resource_spanner_instance.go b/google/services/spanner/resource_spanner_instance.go index a14d38beeb0..7c283a7b5af 100644 --- a/google/services/spanner/resource_spanner_instance.go +++ b/google/services/spanner/resource_spanner_instance.go @@ -173,6 +173,7 @@ func ResourceSpannerInstance() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -507,6 +508,18 @@ This must be set to true if you created a backup manually in the console.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -746,6 +759,18 @@ func resourceSpannerInstanceRead(d *schema.ResourceData, meta interface{}) error return fmt.Errorf("Error setting force_destroy: %s", err) } } + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Instance: %s", err) } @@ -777,6 +802,19 @@ func resourceSpannerInstanceRead(d *schema.ResourceData, meta interface{}) error } func resourceSpannerInstanceUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceSpannerInstance().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceSpannerInstanceRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -911,6 +949,13 @@ func resourceSpannerInstanceUpdate(d *schema.ResourceData, meta interface{}) err } func resourceSpannerInstanceDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy SpannerInstance without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Instance %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/spanner/resource_spanner_instance_config.go b/google/services/spanner/resource_spanner_instance_config.go index e8a16573b36..f0c27e235ec 100644 --- a/google/services/spanner/resource_spanner_instance_config.go +++ b/google/services/spanner/resource_spanner_instance_config.go @@ -160,6 +160,7 @@ func ResourceSpannerInstanceConfig() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -247,6 +248,18 @@ form projects//instanceConfigs/[a-z][-a-z0-9]*`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -475,6 +488,19 @@ func resourceSpannerInstanceConfigRead(d *schema.ResourceData, meta interface{}) return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading InstanceConfig: %s", err) } @@ -506,6 +532,19 @@ func resourceSpannerInstanceConfigRead(d *schema.ResourceData, meta interface{}) } func resourceSpannerInstanceConfigUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceSpannerInstanceConfig().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceSpannerInstanceConfigRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -614,6 +653,13 @@ func resourceSpannerInstanceConfigUpdate(d *schema.ResourceData, meta interface{ } func resourceSpannerInstanceConfigDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy SpannerInstanceConfig without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing InstanceConfig %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/spanner/resource_spanner_instance_config_generated_meta.yaml b/google/services/spanner/resource_spanner_instance_config_generated_meta.yaml index 737fe5e4c59..cc9330ccecd 100644 --- a/google/services/spanner/resource_spanner_instance_config_generated_meta.yaml +++ b/google/services/spanner/resource_spanner_instance_config_generated_meta.yaml @@ -19,3 +19,5 @@ fields: - api_field: replicas.type - field: terraform_labels provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/spanner/resource_spanner_instance_generated_meta.yaml b/google/services/spanner/resource_spanner_instance_generated_meta.yaml index 48dd50484f9..d8ef3bd68f1 100644 --- a/google/services/spanner/resource_spanner_instance_generated_meta.yaml +++ b/google/services/spanner/resource_spanner_instance_generated_meta.yaml @@ -42,3 +42,5 @@ fields: - api_field: state - field: terraform_labels provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/spanner/resource_spanner_instance_partition.go b/google/services/spanner/resource_spanner_instance_partition.go index b65ff749305..f765b604e2f 100644 --- a/google/services/spanner/resource_spanner_instance_partition.go +++ b/google/services/spanner/resource_spanner_instance_partition.go @@ -115,6 +115,7 @@ func ResourceSpannerInstancePartition() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -304,6 +305,18 @@ READY: The instance partition has been allocated resources and is ready for use. Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -476,6 +489,19 @@ func resourceSpannerInstancePartitionRead(d *schema.ResourceData, meta interface log.Printf("[DEBUG] Finished reading SpannerInstancePartition %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading InstancePartition: %s", err) } @@ -513,6 +539,19 @@ func resourceSpannerInstancePartitionRead(d *schema.ResourceData, meta interface } func resourceSpannerInstancePartitionUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceSpannerInstancePartition().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceSpannerInstancePartitionRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -678,6 +717,13 @@ func resourceSpannerInstancePartitionUpdate(d *schema.ResourceData, meta interfa } func resourceSpannerInstancePartitionDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy SpannerInstancePartition without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing InstancePartition %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/spanner/resource_spanner_instance_partition_generated_meta.yaml b/google/services/spanner/resource_spanner_instance_partition_generated_meta.yaml index eb5b3fe4a26..dd79de8e908 100644 --- a/google/services/spanner/resource_spanner_instance_partition_generated_meta.yaml +++ b/google/services/spanner/resource_spanner_instance_partition_generated_meta.yaml @@ -22,3 +22,5 @@ fields: - api_field: nodeCount - api_field: processingUnits - api_field: state + - field: deletion_policy + provider_only: true diff --git a/google/services/sql/data_source_sql_database_instances_test.go b/google/services/sql/data_source_sql_database_instances_test.go index 0d06ba934d0..30eee6d075f 100644 --- a/google/services/sql/data_source_sql_database_instances_test.go +++ b/google/services/sql/data_source_sql_database_instances_test.go @@ -49,6 +49,7 @@ func TestAccDataSourceSqlDatabaseInstances_basic(t *testing.T) { map[string]struct{}{ "deletion_protection": {}, "id": {}, + "deletion_policy": {}, }, ), ), @@ -79,6 +80,7 @@ func TestAccDataSourceSqlDatabaseInstances_databaseVersionFilter(t *testing.T) { map[string]struct{}{ "deletion_protection": {}, "id": {}, + "deletion_policy": {}, }, ), ), @@ -109,6 +111,7 @@ func TestAccDataSourceSqlDatabaseInstances_regionFilter(t *testing.T) { map[string]struct{}{ "deletion_protection": {}, "id": {}, + "deletion_policy": {}, }, ), ), @@ -140,6 +143,7 @@ func TestAccDataSourceSqlDatabaseInstances_tierFilter(t *testing.T) { "deletion_protection": {}, "id": {}, "settings.0.version": {}, + "deletion_policy": {}, }, ), ), diff --git a/google/services/sql/resource_sql_database.go b/google/services/sql/resource_sql_database.go index 1683caf96b5..3e5de8981d2 100644 --- a/google/services/sql/resource_sql_database.go +++ b/google/services/sql/resource_sql_database.go @@ -115,6 +115,7 @@ func ResourceSQLDatabase() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -176,15 +177,6 @@ and Postgres' [Collation Support](https://www.postgresql.org/docs/9.6/static/col for more details and supported values. Postgres databases only support a value of 'en_US.UTF8' at creation time.`, }, - "deletion_policy": { - Type: schema.TypeString, - Optional: true, - Description: `The deletion policy for the database. Setting ABANDON allows the resource -to be abandoned rather than deleted. This is useful for Postgres, where databases cannot be -deleted from the API if there are users other than cloudsqlsuperuser with access. Possible -values are: "ABANDON", "DELETE". Defaults to "DELETE".`, - Default: "DELETE", - }, "project": { Type: schema.TypeString, Optional: true, @@ -195,6 +187,18 @@ values are: "ABANDON", "DELETE". Defaults to "DELETE".`, Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -390,8 +394,15 @@ func resourceSQLDatabaseRead(d *schema.ResourceData, meta interface{}) error { // Explicitly set virtual fields to default values if unset if _, ok := d.GetOkExists("deletion_policy"); !ok { - if err := d.Set("deletion_policy", "DELETE"); err != nil { - return fmt.Errorf("Error setting deletion_policy: %s", err) + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } } } if err := d.Set("project", project); err != nil { @@ -431,6 +442,19 @@ func resourceSQLDatabaseRead(d *schema.ResourceData, meta interface{}) error { } func resourceSQLDatabaseUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceSQLDatabase().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceSQLDatabaseRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -540,6 +564,13 @@ func resourceSQLDatabaseUpdate(d *schema.ResourceData, meta interface{}) error { } func resourceSQLDatabaseDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy SQLDatabase without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Database %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -573,11 +604,6 @@ func resourceSQLDatabaseDelete(d *schema.ResourceData, meta interface{}) error { } headers := make(http.Header) - if deletionPolicy := d.Get("deletion_policy"); deletionPolicy == "ABANDON" { - // Allows for database to be abandoned without deletion to avoid deletion failing - // for Postgres databases in some circumstances due to existing SQL users - return nil - } log.Printf("[DEBUG] Deleting Database %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ @@ -624,11 +650,6 @@ func resourceSQLDatabaseImport(d *schema.ResourceData, meta interface{}) ([]*sch } d.SetId(id) - // Explicitly set virtual fields to default values on import - if err := d.Set("deletion_policy", "DELETE"); err != nil { - return nil, fmt.Errorf("Error setting deletion_policy: %s", err) - } - return []*schema.ResourceData{d}, nil } diff --git a/google/services/sql/resource_sql_database_generated_meta.yaml b/google/services/sql/resource_sql_database_generated_meta.yaml index 868ffab0228..bf2303969ad 100644 --- a/google/services/sql/resource_sql_database_generated_meta.yaml +++ b/google/services/sql/resource_sql_database_generated_meta.yaml @@ -9,8 +9,8 @@ api_resource_type_kind: Database fields: - api_field: charset - api_field: collation - - field: deletion_policy - provider_only: true - api_field: instance - api_field: name - api_field: selfLink + - field: deletion_policy + provider_only: true diff --git a/google/services/sql/resource_sql_database_instance.go b/google/services/sql/resource_sql_database_instance.go index 370897878db..5bb884fe59e 100644 --- a/google/services/sql/resource_sql_database_instance.go +++ b/google/services/sql/resource_sql_database_instance.go @@ -249,6 +249,7 @@ func ResourceSqlDatabaseInstance() *schema.Resource { pitrSupportDbCustomizeDiff, nodeCountCustomDiff, autoUpgradeEnabledCustomizeDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -1492,6 +1493,9 @@ API (for read pools, effective_availability_type may differ from availability_ty }, }, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, UseJSONNumber: true, } @@ -2413,6 +2417,10 @@ func resourceSqlDatabaseInstanceRead(d *schema.ResourceData, meta interface{}) e } d.SetId(instance.Name) + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } @@ -2425,6 +2433,11 @@ const ( ) func resourceSqlDatabaseInstanceUpdate(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceSqlDatabaseInstance) { + return ResourceSqlDatabaseInstance().Read(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -2918,6 +2931,13 @@ func serverCertificateRotationModeDiffSuppress(_, oldMode, newMode string, _ *sc } func resourceSqlDatabaseInstanceDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/sql/resource_sql_database_instance_meta.yaml b/google/services/sql/resource_sql_database_instance_meta.yaml index 10a78b6c9bb..126cbed870c 100644 --- a/google/services/sql/resource_sql_database_instance_meta.yaml +++ b/google/services/sql/resource_sql_database_instance_meta.yaml @@ -198,3 +198,5 @@ fields: - api_field: 'settings.userLabels' - api_field: 'settings.settingsVersion' field: 'settings.version' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/sql/resource_sql_source_representation_instance.go b/google/services/sql/resource_sql_source_representation_instance.go index 1daa63f3e69..3e91c87fd8a 100644 --- a/google/services/sql/resource_sql_source_representation_instance.go +++ b/google/services/sql/resource_sql_source_representation_instance.go @@ -100,6 +100,7 @@ func ResourceSQLSourceRepresentationInstance() *schema.Resource { return &schema.Resource{ Create: resourceSQLSourceRepresentationInstanceCreate, Read: resourceSQLSourceRepresentationInstanceRead, + Update: resourceSQLSourceRepresentationInstanceUpdate, Delete: resourceSQLSourceRepresentationInstanceDelete, Importer: &schema.ResourceImporter{ @@ -113,6 +114,7 @@ func ResourceSQLSourceRepresentationInstance() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -214,6 +216,18 @@ If it is not provided, the provider region is used.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -381,6 +395,19 @@ func resourceSQLSourceRepresentationInstanceRead(d *schema.ResourceData, meta in return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading SourceRepresentationInstance: %s", err) } @@ -411,7 +438,19 @@ func resourceSQLSourceRepresentationInstanceRead(d *schema.ResourceData, meta in return nil } +func resourceSQLSourceRepresentationInstanceUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceSQLSourceRepresentationInstanceRead(d, meta) +} + func resourceSQLSourceRepresentationInstanceDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy SQLSourceRepresentationInstance without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing SourceRepresentationInstance %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/sql/resource_sql_source_representation_instance_generated_meta.yaml b/google/services/sql/resource_sql_source_representation_instance_generated_meta.yaml index a202eb1234f..69e9ef9b0c6 100644 --- a/google/services/sql/resource_sql_source_representation_instance_generated_meta.yaml +++ b/google/services/sql/resource_sql_source_representation_instance_generated_meta.yaml @@ -26,3 +26,5 @@ fields: - api_field: region - api_field: onPremisesConfiguration.username field: username + - field: deletion_policy + provider_only: true diff --git a/google/services/sql/resource_sql_ssl_cert.go b/google/services/sql/resource_sql_ssl_cert.go index aba20236ae6..6c1df900cf3 100644 --- a/google/services/sql/resource_sql_ssl_cert.go +++ b/google/services/sql/resource_sql_ssl_cert.go @@ -34,6 +34,7 @@ func ResourceSqlSslCert() *schema.Resource { return &schema.Resource{ Create: resourceSqlSslCertCreate, Read: resourceSqlSslCertRead, + Update: resourceSqlSslCertUpdate, Delete: resourceSqlSslCertDelete, SchemaVersion: 1, @@ -45,6 +46,7 @@ func ResourceSqlSslCert() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -114,6 +116,9 @@ func ResourceSqlSslCert() *schema.Resource { Computed: true, Description: `The SHA1 Fingerprint of the certificate.`, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, UseJSONNumber: true, } @@ -223,10 +228,30 @@ func resourceSqlSslCertRead(d *schema.ResourceData, meta interface{}) error { } d.SetId(fmt.Sprintf("projects/%s/instances/%s/sslCerts/%s", project, instance, fingerprint)) + + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } +// UDP update start +func resourceSqlSslCertUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceSqlSslCertRead(d, meta) +} + +//UDP update end + func resourceSqlSslCertDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/sql/resource_sql_ssl_cert_meta.yaml b/google/services/sql/resource_sql_ssl_cert_meta.yaml index 7f6b3d39515..42e9b3a0b99 100644 --- a/google/services/sql/resource_sql_ssl_cert_meta.yaml +++ b/google/services/sql/resource_sql_ssl_cert_meta.yaml @@ -16,3 +16,5 @@ fields: - field: 'project' - field: 'server_ca_cert' - api_field: 'sha1Fingerprint' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/sql/resource_sql_user.go b/google/services/sql/resource_sql_user.go index c614df5cd39..717e748f088 100644 --- a/google/services/sql/resource_sql_user.go +++ b/google/services/sql/resource_sql_user.go @@ -30,7 +30,6 @@ import ( "github.com/hashicorp/errwrap" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" sqladmin "google.golang.org/api/sqladmin/v1beta4" ) @@ -77,6 +76,7 @@ func ResourceSqlUser() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), SchemaVersion: 1, @@ -216,14 +216,9 @@ func ResourceSqlUser() *schema.Resource { Description: `The ID of the project in which the resource belongs. If it is not provided, the provider project is used.`, }, - "deletion_policy": { - Type: schema.TypeString, - Optional: true, - Description: `The deletion policy for the user. Setting ABANDON allows the resource - to be abandoned rather than deleted. This is useful for Postgres, where users cannot be deleted from the API if they - have been granted SQL roles. Possible values are: "ABANDON".`, - ValidateFunc: validation.StringInSlice([]string{"ABANDON", ""}, false), - }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end "database_roles": { Type: schema.TypeList, Optional: true, @@ -464,6 +459,11 @@ func resourceSqlUserRead(d *schema.ResourceData, meta interface{}) error { } d.SetId(fmt.Sprintf("%s/%s/%s", user.Name, user.Host, user.Instance)) + + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } @@ -507,6 +507,11 @@ func flattenPasswordStatus(status *sqladmin.PasswordStatus) interface{} { } func resourceSqlUserUpdate(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceSqlUser) { + return ResourceSqlUser().Read(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -590,9 +595,9 @@ func resourceSqlUserUpdate(d *schema.ResourceData, meta interface{}) error { func resourceSqlUserDelete(d *schema.ResourceData, meta interface{}) error { config := meta.(*transport_tpg.Config) - if deletionPolicy := d.Get("deletion_policy"); deletionPolicy == "ABANDON" { - // Allows for user to be abandoned without deletion to avoid deletion failing - // for Postgres users in some circumstances due to existing SQL roles + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { return nil } diff --git a/google/services/sql/resource_sql_user_meta.yaml b/google/services/sql/resource_sql_user_meta.yaml index e65afe8c1d4..56f74b7c6bd 100644 --- a/google/services/sql/resource_sql_user_meta.yaml +++ b/google/services/sql/resource_sql_user_meta.yaml @@ -7,6 +7,7 @@ api_version: 'v1beta4' api_resource_type_kind: 'User' fields: - field: 'deletion_policy' + provider_only: true - api_field: 'host' - api_field: 'instance' - api_field: 'name' diff --git a/google/services/storage/resource_storage_anywhere_cache.go b/google/services/storage/resource_storage_anywhere_cache.go index 2689792d88c..4495777a1e1 100644 --- a/google/services/storage/resource_storage_anywhere_cache.go +++ b/google/services/storage/resource_storage_anywhere_cache.go @@ -189,6 +189,19 @@ func ResourceStorageAnywhereCache() *schema.Resource { Computed: true, Description: `The modification time of the cache instance metadata in RFC 3339 format.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -356,6 +369,20 @@ func resourceStorageAnywhereCacheRead(d *schema.ResourceData, meta interface{}) log.Printf("[DEBUG] Finished reading StorageAnywhereCache %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceStorageAnywhereCacheFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -383,6 +410,19 @@ func resourceStorageAnywhereCacheRead(d *schema.ResourceData, meta interface{}) } func resourceStorageAnywhereCacheUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceStorageAnywhereCache().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceStorageAnywhereCacheRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -471,6 +511,13 @@ func resourceStorageAnywhereCacheUpdate(d *schema.ResourceData, meta interface{} } func resourceStorageAnywhereCacheDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy StorageAnywhereCache without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing AnywhereCache %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/storage/resource_storage_anywhere_cache_generated_meta.yaml b/google/services/storage/resource_storage_anywhere_cache_generated_meta.yaml index 7104a6e5d32..17402536250 100644 --- a/google/services/storage/resource_storage_anywhere_cache_generated_meta.yaml +++ b/google/services/storage/resource_storage_anywhere_cache_generated_meta.yaml @@ -18,3 +18,5 @@ fields: - api_field: ttl - api_field: updateTime - api_field: zone + - field: deletion_policy + provider_only: true diff --git a/google/services/storage/resource_storage_bucket.go b/google/services/storage/resource_storage_bucket.go index c262860df3d..0e7bc284c24 100644 --- a/google/services/storage/resource_storage_bucket.go +++ b/google/services/storage/resource_storage_bucket.go @@ -80,6 +80,7 @@ func ResourceStorageBucket() *schema.Resource { CustomizeDiff: customdiff.All( customdiff.ForceNewIfChange("retention_policy.0.is_locked", isPolicyLocked), tpgresource.SetLabelsDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Timeouts: &schema.ResourceTimeout{ @@ -711,6 +712,9 @@ func ResourceStorageBucket() *schema.Resource { return false }, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, UseJSONNumber: true, } @@ -1023,6 +1027,11 @@ func resourceStorageBucketCreate(d *schema.ResourceData, meta interface{}) error } func resourceStorageBucketUpdate(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceStorageBucket) { + return ResourceStorageBucket().Read(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1224,6 +1233,13 @@ func resourceStorageBucketRead(d *schema.ResourceData, meta interface{}) error { } func resourceStorageBucketDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -2523,6 +2539,10 @@ func setStorageBucket(d *schema.ResourceData, config *transport_tpg.Config, res return fmt.Errorf("Error setting ip_filter: %s", err) } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + d.SetId(res.Id) return nil } diff --git a/google/services/storage/resource_storage_bucket_access_control.go b/google/services/storage/resource_storage_bucket_access_control.go index f152d9db5f1..458f0c78729 100644 --- a/google/services/storage/resource_storage_bucket_access_control.go +++ b/google/services/storage/resource_storage_bucket_access_control.go @@ -176,6 +176,19 @@ Examples: Computed: true, Description: `The email address associated with the entity.`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -305,6 +318,20 @@ func resourceStorageBucketAccessControlRead(d *schema.ResourceData, meta interfa log.Printf("[DEBUG] Finished reading StorageBucketAccessControl %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceStorageBucketAccessControlFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -332,6 +359,19 @@ func resourceStorageBucketAccessControlRead(d *schema.ResourceData, meta interfa } func resourceStorageBucketAccessControlUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceStorageBucketAccessControl().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceStorageBucketAccessControlRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -416,6 +456,13 @@ func resourceStorageBucketAccessControlUpdate(d *schema.ResourceData, meta inter } func resourceStorageBucketAccessControlDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy StorageBucketAccessControl without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing BucketAccessControl %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/storage/resource_storage_bucket_access_control_generated_meta.yaml b/google/services/storage/resource_storage_bucket_access_control_generated_meta.yaml index 9c2c2182598..929886bfd2d 100644 --- a/google/services/storage/resource_storage_bucket_access_control_generated_meta.yaml +++ b/google/services/storage/resource_storage_bucket_access_control_generated_meta.yaml @@ -12,3 +12,5 @@ fields: - api_field: email - api_field: entity - api_field: role + - field: deletion_policy + provider_only: true diff --git a/google/services/storage/resource_storage_bucket_acl.go b/google/services/storage/resource_storage_bucket_acl.go index 4c0de7b4b83..c980b4f1b0d 100644 --- a/google/services/storage/resource_storage_bucket_acl.go +++ b/google/services/storage/resource_storage_bucket_acl.go @@ -27,6 +27,7 @@ import ( "github.com/hashicorp/terraform-provider-google/google/tpgresource" transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "google.golang.org/api/storage/v1" @@ -34,11 +35,14 @@ import ( func ResourceStorageBucketAcl() *schema.Resource { return &schema.Resource{ - Create: resourceStorageBucketAclCreate, - Read: resourceStorageBucketAclRead, - Update: resourceStorageBucketAclUpdate, - Delete: resourceStorageBucketAclDelete, - CustomizeDiff: resourceStorageRoleEntityCustomizeDiff, + Create: resourceStorageBucketAclCreate, + Read: resourceStorageBucketAclRead, + Update: resourceStorageBucketAclUpdate, + Delete: resourceStorageBucketAclDelete, + CustomizeDiff: customdiff.All( + resourceStorageRoleEntityCustomizeDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), + ), Schema: map[string]*schema.Schema{ "bucket": { @@ -70,6 +74,9 @@ func ResourceStorageBucketAcl() *schema.Resource { ConflictsWith: []string{"predefined_acl"}, Description: `List of role/entity pairs in the form ROLE:entity. See GCS Bucket ACL documentation for more details. Must be set if predefined_acl is not.`, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, UseJSONNumber: true, } @@ -291,10 +298,19 @@ func resourceStorageBucketAclRead(d *schema.ResourceData, meta interface{}) erro } } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } func resourceStorageBucketAclUpdate(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceStorageBucketAcl) { + return ResourceStorageBucketAcl().Read(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -391,6 +407,13 @@ func resourceStorageBucketAclUpdate(d *schema.ResourceData, meta interface{}) er } func resourceStorageBucketAclDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/storage/resource_storage_bucket_acl_meta.yaml b/google/services/storage/resource_storage_bucket_acl_meta.yaml index d2e67bc0367..e3f4073059d 100644 --- a/google/services/storage/resource_storage_bucket_acl_meta.yaml +++ b/google/services/storage/resource_storage_bucket_acl_meta.yaml @@ -10,3 +10,5 @@ fields: - field: 'default_acl' - field: 'predefined_acl' - field: 'role_entity' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/storage/resource_storage_bucket_meta.yaml b/google/services/storage/resource_storage_bucket_meta.yaml index bd62f7b7db3..47f99ba3a3e 100644 --- a/google/services/storage/resource_storage_bucket_meta.yaml +++ b/google/services/storage/resource_storage_bucket_meta.yaml @@ -100,3 +100,5 @@ fields: - api_field: 'versioning.enabled' - api_field: 'website.mainPageSuffix' - api_field: 'website.notFoundPage' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/storage/resource_storage_bucket_object.go b/google/services/storage/resource_storage_bucket_object.go index 1ada30e7454..fe587d8a451 100644 --- a/google/services/storage/resource_storage_bucket_object.go +++ b/google/services/storage/resource_storage_bucket_object.go @@ -32,7 +32,6 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "crypto/sha256" "encoding/base64" @@ -52,6 +51,7 @@ func ResourceStorageBucketObject() *schema.Resource { CustomizeDiff: customdiff.All( resourceStorageBucketObjectCustomizeDiff, validateContexts, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Timeouts: &schema.ResourceTimeout{ @@ -368,12 +368,9 @@ func ResourceStorageBucketObject() *schema.Resource { Description: `A url reference to download this object.`, }, - "deletion_policy": { - Type: schema.TypeString, - Optional: true, - Description: `The deletion policy for the object. Setting ABANDON allows the resource to be abandoned rather than deleted when removed from your Terraform configuration.`, - ValidateFunc: validation.StringInSlice([]string{"ABANDON"}, false), - }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, UseJSONNumber: true, } @@ -481,6 +478,11 @@ func resourceStorageBucketObjectCreate(d *schema.ResourceData, meta interface{}) } func resourceStorageBucketObjectUpdate(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceStorageBucketObject) { + return ResourceStorageBucketObject().Read(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -638,12 +640,23 @@ func resourceStorageBucketObjectRead(d *schema.ResourceData, meta interface{}) e return fmt.Errorf("Error reading Contexts: %s", err) } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + d.SetId(objectGetID(res)) return nil } func resourceStorageBucketObjectDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/storage/resource_storage_default_object_access_control.go b/google/services/storage/resource_storage_default_object_access_control.go index e5740630cd5..05af5153961 100644 --- a/google/services/storage/resource_storage_default_object_access_control.go +++ b/google/services/storage/resource_storage_default_object_access_control.go @@ -203,6 +203,19 @@ func ResourceStorageDefaultObjectAccessControl() *schema.Resource { }, }, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -338,6 +351,20 @@ func resourceStorageDefaultObjectAccessControlRead(d *schema.ResourceData, meta log.Printf("[DEBUG] Finished reading StorageDefaultObjectAccessControl %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceStorageDefaultObjectAccessControlFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -365,6 +392,19 @@ func resourceStorageDefaultObjectAccessControlRead(d *schema.ResourceData, meta } func resourceStorageDefaultObjectAccessControlUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceStorageDefaultObjectAccessControl().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceStorageDefaultObjectAccessControlRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -455,6 +495,13 @@ func resourceStorageDefaultObjectAccessControlUpdate(d *schema.ResourceData, met } func resourceStorageDefaultObjectAccessControlDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy StorageDefaultObjectAccessControl without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing DefaultObjectAccessControl %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/storage/resource_storage_default_object_access_control_generated_meta.yaml b/google/services/storage/resource_storage_default_object_access_control_generated_meta.yaml index ee6c08af37e..ed29e18b3de 100644 --- a/google/services/storage/resource_storage_default_object_access_control_generated_meta.yaml +++ b/google/services/storage/resource_storage_default_object_access_control_generated_meta.yaml @@ -17,3 +17,5 @@ fields: - api_field: projectTeam.projectNumber - api_field: projectTeam.team - api_field: role + - field: deletion_policy + provider_only: true diff --git a/google/services/storage/resource_storage_default_object_acl.go b/google/services/storage/resource_storage_default_object_acl.go index b54e3c5efe0..bad2ac4c789 100644 --- a/google/services/storage/resource_storage_default_object_acl.go +++ b/google/services/storage/resource_storage_default_object_acl.go @@ -19,6 +19,7 @@ package storage import ( "fmt" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-provider-google/google/registry" "github.com/hashicorp/terraform-provider-google/google/tpgresource" @@ -33,6 +34,10 @@ func ResourceStorageDefaultObjectAcl() *schema.Resource { Update: resourceStorageDefaultObjectAclCreateUpdate, Delete: resourceStorageDefaultObjectAclDelete, + CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), + ), + Schema: map[string]*schema.Schema{ "bucket": { Type: schema.TypeString, @@ -49,12 +54,21 @@ func ResourceStorageDefaultObjectAcl() *schema.Resource { ValidateFunc: validateRoleEntityPair, }, }, + + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, UseJSONNumber: true, } } func resourceStorageDefaultObjectAclCreateUpdate(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceStorageDefaultObjectAcl) { + return ResourceStorageDefaultObjectAcl().Read(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -125,11 +139,22 @@ func resourceStorageDefaultObjectAclRead(d *schema.ResourceData, meta interface{ return err } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + d.SetId(bucket) return nil } func resourceStorageDefaultObjectAclDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/storage/resource_storage_default_object_acl_meta.yaml b/google/services/storage/resource_storage_default_object_acl_meta.yaml index 5ef8330a193..5736469e9af 100644 --- a/google/services/storage/resource_storage_default_object_acl_meta.yaml +++ b/google/services/storage/resource_storage_default_object_acl_meta.yaml @@ -8,3 +8,5 @@ api_resource_type_kind: 'ObjectAccessControl' fields: - field: 'bucket' - field: 'role_entity' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/storage/resource_storage_folder.go b/google/services/storage/resource_storage_folder.go index c550b432f49..5d37946087d 100644 --- a/google/services/storage/resource_storage_folder.go +++ b/google/services/storage/resource_storage_folder.go @@ -183,6 +183,18 @@ trailing '/'. For example, 'example_dir/example_dir2/', 'example@#/', 'a-b/d-f/' Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -299,6 +311,18 @@ func resourceStorageFolderRead(d *schema.ResourceData, meta interface{}) error { return fmt.Errorf("Error setting force_destroy: %s", err) } } + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } err = ResourceStorageFolderFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { @@ -327,6 +351,19 @@ func resourceStorageFolderRead(d *schema.ResourceData, meta interface{}) error { } func resourceStorageFolderUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceStorageFolder().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceStorageFolderRead(d, meta) + } + config := meta.(*transport_tpg.Config) _ = config // we can only get here if force_destroy was updated @@ -359,6 +396,13 @@ func resourceStorageFolderUpdate(d *schema.ResourceData, meta interface{}) error } func resourceStorageFolderDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy StorageFolder without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Folder %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/storage/resource_storage_folder_generated_meta.yaml b/google/services/storage/resource_storage_folder_generated_meta.yaml index 659968603d9..c4d8d6be8dd 100644 --- a/google/services/storage/resource_storage_folder_generated_meta.yaml +++ b/google/services/storage/resource_storage_folder_generated_meta.yaml @@ -16,3 +16,5 @@ fields: - api_field: name - api_field: updateTime - api_field: selfLink + - field: deletion_policy + provider_only: true diff --git a/google/services/storage/resource_storage_hmac_key.go b/google/services/storage/resource_storage_hmac_key.go index d8d6d4635b1..1b2a920f207 100644 --- a/google/services/storage/resource_storage_hmac_key.go +++ b/google/services/storage/resource_storage_hmac_key.go @@ -115,6 +115,7 @@ func ResourceStorageHmacKey() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -177,6 +178,18 @@ func ResourceStorageHmacKey() *schema.Resource { Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -405,6 +418,19 @@ func resourceStorageHmacKeyRead(d *schema.ResourceData, meta interface{}) error return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading HmacKey: %s", err) } @@ -436,6 +462,19 @@ func resourceStorageHmacKeyRead(d *schema.ResourceData, meta interface{}) error } func resourceStorageHmacKeyUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceStorageHmacKey().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceStorageHmacKeyRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -536,6 +575,13 @@ func resourceStorageHmacKeyUpdate(d *schema.ResourceData, meta interface{}) erro } func resourceStorageHmacKeyDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy StorageHmacKey without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing HmacKey %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/storage/resource_storage_hmac_key_generated_meta.yaml b/google/services/storage/resource_storage_hmac_key_generated_meta.yaml index ca33e730dd6..d9a547751e0 100644 --- a/google/services/storage/resource_storage_hmac_key_generated_meta.yaml +++ b/google/services/storage/resource_storage_hmac_key_generated_meta.yaml @@ -13,3 +13,5 @@ fields: - api_field: state - api_field: timeCreated - api_field: updated + - field: deletion_policy + provider_only: true diff --git a/google/services/storage/resource_storage_managed_folder.go b/google/services/storage/resource_storage_managed_folder.go index f7ae6ad628d..f7ec7f18d81 100644 --- a/google/services/storage/resource_storage_managed_folder.go +++ b/google/services/storage/resource_storage_managed_folder.go @@ -177,6 +177,18 @@ same name.`, Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -299,6 +311,18 @@ func resourceStorageManagedFolderRead(d *schema.ResourceData, meta interface{}) return fmt.Errorf("Error setting force_destroy: %s", err) } } + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } err = ResourceStorageManagedFolderFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { @@ -327,6 +351,19 @@ func resourceStorageManagedFolderRead(d *schema.ResourceData, meta interface{}) } func resourceStorageManagedFolderUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceStorageManagedFolder().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceStorageManagedFolderRead(d, meta) + } + config := meta.(*transport_tpg.Config) _ = config @@ -360,6 +397,13 @@ func resourceStorageManagedFolderUpdate(d *schema.ResourceData, meta interface{} } func resourceStorageManagedFolderDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy StorageManagedFolder without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ManagedFolder %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/storage/resource_storage_managed_folder_generated_meta.yaml b/google/services/storage/resource_storage_managed_folder_generated_meta.yaml index 90ebc3da256..af7d4670a74 100644 --- a/google/services/storage/resource_storage_managed_folder_generated_meta.yaml +++ b/google/services/storage/resource_storage_managed_folder_generated_meta.yaml @@ -15,3 +15,5 @@ fields: - api_field: name - api_field: updateTime - api_field: selfLink + - field: deletion_policy + provider_only: true diff --git a/google/services/storage/resource_storage_object_access_control.go b/google/services/storage/resource_storage_object_access_control.go index ad5a03fc386..4bd0706a644 100644 --- a/google/services/storage/resource_storage_object_access_control.go +++ b/google/services/storage/resource_storage_object_access_control.go @@ -207,6 +207,19 @@ func ResourceStorageObjectAccessControl() *schema.Resource { }, }, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -347,6 +360,20 @@ func resourceStorageObjectAccessControlRead(d *schema.ResourceData, meta interfa log.Printf("[DEBUG] Finished reading StorageObjectAccessControl %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceStorageObjectAccessControlFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -380,6 +407,19 @@ func resourceStorageObjectAccessControlRead(d *schema.ResourceData, meta interfa } func resourceStorageObjectAccessControlUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceStorageObjectAccessControl().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceStorageObjectAccessControlRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -475,6 +515,13 @@ func resourceStorageObjectAccessControlUpdate(d *schema.ResourceData, meta inter } func resourceStorageObjectAccessControlDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy StorageObjectAccessControl without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ObjectAccessControl %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/storage/resource_storage_object_access_control_generated_meta.yaml b/google/services/storage/resource_storage_object_access_control_generated_meta.yaml index 7226c77a2a6..8614ad2caca 100644 --- a/google/services/storage/resource_storage_object_access_control_generated_meta.yaml +++ b/google/services/storage/resource_storage_object_access_control_generated_meta.yaml @@ -17,3 +17,5 @@ fields: - api_field: projectTeam.projectNumber - api_field: projectTeam.team - api_field: role + - field: deletion_policy + provider_only: true diff --git a/google/services/storage/resource_storage_object_acl.go b/google/services/storage/resource_storage_object_acl.go index d7130e56ca9..f562cf214d3 100644 --- a/google/services/storage/resource_storage_object_acl.go +++ b/google/services/storage/resource_storage_object_acl.go @@ -25,6 +25,7 @@ import ( "github.com/hashicorp/terraform-provider-google/google/tpgresource" transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "google.golang.org/api/storage/v1" @@ -32,11 +33,14 @@ import ( func ResourceStorageObjectAcl() *schema.Resource { return &schema.Resource{ - Create: resourceStorageObjectAclCreate, - Read: resourceStorageObjectAclRead, - Update: resourceStorageObjectAclUpdate, - Delete: resourceStorageObjectAclDelete, - CustomizeDiff: resourceStorageObjectAclDiff, + Create: resourceStorageObjectAclCreate, + Read: resourceStorageObjectAclRead, + Update: resourceStorageObjectAclUpdate, + Delete: resourceStorageObjectAclDelete, + CustomizeDiff: customdiff.All( + resourceStorageObjectAclDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), + ), Schema: map[string]*schema.Schema{ "bucket": { @@ -68,6 +72,10 @@ func ResourceStorageObjectAcl() *schema.Resource { }, ConflictsWith: []string{"predefined_acl"}, }, + + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, UseJSONNumber: true, } @@ -214,11 +222,20 @@ func resourceStorageObjectAclRead(d *schema.ResourceData, meta interface{}) erro return err } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + d.SetId(getObjectAclId(object)) return nil } func resourceStorageObjectAclUpdate(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceStorageObjectAcl) { + return ResourceStorageObjectAcl().Read(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -277,6 +294,13 @@ func resourceStorageObjectAclUpdate(d *schema.ResourceData, meta interface{}) er } func resourceStorageObjectAclDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/storage/resource_storage_object_acl_meta.yaml b/google/services/storage/resource_storage_object_acl_meta.yaml index c7ad77cf205..c3df252ea4a 100644 --- a/google/services/storage/resource_storage_object_acl_meta.yaml +++ b/google/services/storage/resource_storage_object_acl_meta.yaml @@ -10,3 +10,5 @@ fields: - field: 'object' - field: 'predefined_acl' - field: 'role_entity' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/storagebatchoperations/resource_storage_batch_operations_job.go b/google/services/storagebatchoperations/resource_storage_batch_operations_job.go index 3cd988bb16e..749160bbc37 100644 --- a/google/services/storagebatchoperations/resource_storage_batch_operations_job.go +++ b/google/services/storagebatchoperations/resource_storage_batch_operations_job.go @@ -115,6 +115,7 @@ func ResourceStorageBatchOperationsJob() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -374,6 +375,18 @@ func ResourceStorageBatchOperationsJob() *schema.Resource { Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -536,6 +549,18 @@ func resourceStorageBatchOperationsJobRead(d *schema.ResourceData, meta interfac return fmt.Errorf("Error setting delete_protection: %s", err) } } + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Job: %s", err) } @@ -567,6 +592,19 @@ func resourceStorageBatchOperationsJobRead(d *schema.ResourceData, meta interfac } func resourceStorageBatchOperationsJobUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceStorageBatchOperationsJob().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceStorageBatchOperationsJobRead(d, meta) + } + config := meta.(*transport_tpg.Config) _ = config // we can only get here if delete_protection was updated @@ -581,6 +619,13 @@ func resourceStorageBatchOperationsJobUpdate(d *schema.ResourceData, meta interf } func resourceStorageBatchOperationsJobDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy StorageBatchOperationsJob without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Job %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/storagebatchoperations/resource_storage_batch_operations_job_generated_meta.yaml b/google/services/storagebatchoperations/resource_storage_batch_operations_job_generated_meta.yaml index bf70fda616e..b757fbd365a 100644 --- a/google/services/storagebatchoperations/resource_storage_batch_operations_job_generated_meta.yaml +++ b/google/services/storagebatchoperations/resource_storage_batch_operations_job_generated_meta.yaml @@ -30,3 +30,5 @@ fields: - api_field: scheduleTime - api_field: state - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/storagecontrol/resource_storage_control_folder_intelligence_config.go b/google/services/storagecontrol/resource_storage_control_folder_intelligence_config.go index 01ca0e83a05..e471063537a 100644 --- a/google/services/storagecontrol/resource_storage_control_folder_intelligence_config.go +++ b/google/services/storagecontrol/resource_storage_control_folder_intelligence_config.go @@ -423,6 +423,7 @@ func resourceStorageControlFolderIntelligenceConfigRead(d *schema.ResourceData, } func resourceStorageControlFolderIntelligenceConfigUpdate(d *schema.ResourceData, meta interface{}) error { + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/storagecontrol/resource_storage_control_organization_intelligence_config.go b/google/services/storagecontrol/resource_storage_control_organization_intelligence_config.go index 235983e3d08..44c62266074 100644 --- a/google/services/storagecontrol/resource_storage_control_organization_intelligence_config.go +++ b/google/services/storagecontrol/resource_storage_control_organization_intelligence_config.go @@ -423,6 +423,7 @@ func resourceStorageControlOrganizationIntelligenceConfigRead(d *schema.Resource } func resourceStorageControlOrganizationIntelligenceConfigUpdate(d *schema.ResourceData, meta interface{}) error { + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/storagecontrol/resource_storage_control_project_intelligence_config.go b/google/services/storagecontrol/resource_storage_control_project_intelligence_config.go index 698d1c4f595..1c77600c380 100644 --- a/google/services/storagecontrol/resource_storage_control_project_intelligence_config.go +++ b/google/services/storagecontrol/resource_storage_control_project_intelligence_config.go @@ -520,6 +520,7 @@ func resourceStorageControlProjectIntelligenceConfigRead(d *schema.ResourceData, } func resourceStorageControlProjectIntelligenceConfigUpdate(d *schema.ResourceData, meta interface{}) error { + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/storageinsights/resource_storage_insights_dataset_config.go b/google/services/storageinsights/resource_storage_insights_dataset_config.go index 1e764f371dc..2574b6986d8 100644 --- a/google/services/storageinsights/resource_storage_insights_dataset_config.go +++ b/google/services/storageinsights/resource_storage_insights_dataset_config.go @@ -115,6 +115,7 @@ func ResourceStorageInsightsDatasetConfig() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -412,6 +413,18 @@ so users must set this field to false to unlink the dataset and destroy the data Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -661,6 +674,18 @@ func resourceStorageInsightsDatasetConfigRead(d *schema.ResourceData, meta inter return fmt.Errorf("Error setting link_dataset: %s", err) } } + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading DatasetConfig: %s", err) } @@ -698,6 +723,19 @@ func resourceStorageInsightsDatasetConfigRead(d *schema.ResourceData, meta inter } func resourceStorageInsightsDatasetConfigUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceStorageInsightsDatasetConfig().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceStorageInsightsDatasetConfigRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -960,6 +998,13 @@ func resourceStorageInsightsDatasetConfigUpdate(d *schema.ResourceData, meta int } func resourceStorageInsightsDatasetConfigDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy StorageInsightsDatasetConfig without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing DatasetConfig %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/storageinsights/resource_storage_insights_dataset_config_generated_meta.yaml b/google/services/storageinsights/resource_storage_insights_dataset_config_generated_meta.yaml index 60f403697bd..8e163583745 100644 --- a/google/services/storageinsights/resource_storage_insights_dataset_config_generated_meta.yaml +++ b/google/services/storageinsights/resource_storage_insights_dataset_config_generated_meta.yaml @@ -36,3 +36,5 @@ fields: - api_field: sourceProjects.projectNumbers - api_field: uid - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/storageinsights/resource_storage_insights_report_config.go b/google/services/storageinsights/resource_storage_insights_report_config.go index a52cf7f6ee3..be550b07f2d 100644 --- a/google/services/storageinsights/resource_storage_insights_report_config.go +++ b/google/services/storageinsights/resource_storage_insights_report_config.go @@ -115,6 +115,7 @@ func ResourceStorageInsightsReportConfig() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -326,6 +327,18 @@ must be in the same location.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -489,6 +502,18 @@ func resourceStorageInsightsReportConfigRead(d *schema.ResourceData, meta interf return fmt.Errorf("Error setting force_destroy: %s", err) } } + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading ReportConfig: %s", err) } @@ -526,6 +551,19 @@ func resourceStorageInsightsReportConfigRead(d *schema.ResourceData, meta interf } func resourceStorageInsightsReportConfigUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceStorageInsightsReportConfig().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceStorageInsightsReportConfigRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -659,6 +697,13 @@ func resourceStorageInsightsReportConfigUpdate(d *schema.ResourceData, meta inte } func resourceStorageInsightsReportConfigDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy StorageInsightsReportConfig without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ReportConfig %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/storageinsights/resource_storage_insights_report_config_generated_meta.yaml b/google/services/storageinsights/resource_storage_insights_report_config_generated_meta.yaml index bc2ce4a91d4..6c79fc0c907 100644 --- a/google/services/storageinsights/resource_storage_insights_report_config_generated_meta.yaml +++ b/google/services/storageinsights/resource_storage_insights_report_config_generated_meta.yaml @@ -28,3 +28,5 @@ fields: - api_field: objectMetadataReportOptions.storageDestinationOptions.destinationPath - api_field: objectMetadataReportOptions.storageFilters.bucket - api_field: parquetOptions + - field: deletion_policy + provider_only: true diff --git a/google/services/storagetransfer/resource_storage_transfer_agent_pool.go b/google/services/storagetransfer/resource_storage_transfer_agent_pool.go index bc8968c5234..9526e27801c 100644 --- a/google/services/storagetransfer/resource_storage_transfer_agent_pool.go +++ b/google/services/storagetransfer/resource_storage_transfer_agent_pool.go @@ -136,6 +136,7 @@ func ResourceStorageTransferAgentPool() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -204,6 +205,18 @@ As expressed by the regular expression: ^(?!goog)[a-z]([a-z0-9-._~]*[a-z0-9])?$. Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -336,6 +349,19 @@ func resourceStorageTransferAgentPoolRead(d *schema.ResourceData, meta interface log.Printf("[DEBUG] Finished reading StorageTransferAgentPool %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading AgentPool: %s", err) } @@ -367,6 +393,19 @@ func resourceStorageTransferAgentPoolRead(d *schema.ResourceData, meta interface } func resourceStorageTransferAgentPoolUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceStorageTransferAgentPool().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceStorageTransferAgentPoolRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -466,6 +505,13 @@ func resourceStorageTransferAgentPoolUpdate(d *schema.ResourceData, meta interfa } func resourceStorageTransferAgentPoolDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy StorageTransferAgentPool without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing AgentPool %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/storagetransfer/resource_storage_transfer_agent_pool_generated_meta.yaml b/google/services/storagetransfer/resource_storage_transfer_agent_pool_generated_meta.yaml index 194d05074a9..f9b0bd798da 100644 --- a/google/services/storagetransfer/resource_storage_transfer_agent_pool_generated_meta.yaml +++ b/google/services/storagetransfer/resource_storage_transfer_agent_pool_generated_meta.yaml @@ -12,3 +12,5 @@ fields: - field: name provider_only: true - api_field: state + - field: deletion_policy + provider_only: true diff --git a/google/services/storagetransfer/resource_storage_transfer_job.go b/google/services/storagetransfer/resource_storage_transfer_job.go index c8bec2456eb..de6806428de 100644 --- a/google/services/storagetransfer/resource_storage_transfer_job.go +++ b/google/services/storagetransfer/resource_storage_transfer_job.go @@ -138,6 +138,7 @@ func ResourceStorageTransferJob() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -458,6 +459,9 @@ func ResourceStorageTransferJob() *schema.Resource { Computed: true, Description: `When the Transfer Job was deleted.`, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, UseJSONNumber: true, } @@ -1147,10 +1151,19 @@ func resourceStorageTransferJobRead(d *schema.ResourceData, meta interface{}) er return err } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } func resourceStorageTransferJobUpdate(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceStorageTransferJob) { + return ResourceStorageTransferJob().Read(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1264,6 +1277,13 @@ func resourceStorageTransferJobUpdate(d *schema.ResourceData, meta interface{}) } func resourceStorageTransferJobDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/storagetransfer/resource_storage_transfer_job_meta.yaml b/google/services/storagetransfer/resource_storage_transfer_job_meta.yaml index 3a679877830..c8d9d57c17c 100644 --- a/google/services/storagetransfer/resource_storage_transfer_job_meta.yaml +++ b/google/services/storagetransfer/resource_storage_transfer_job_meta.yaml @@ -111,3 +111,5 @@ fields: - api_field: 'transferSpec.transferOptions.metadataOptions.uid' - api_field: 'transferSpec.transferOptions.overwriteObjectsAlreadyExistingInSink' - api_field: 'transferSpec.transferOptions.overwriteWhen' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/tags/resource_tags_location_tag_binding.go b/google/services/tags/resource_tags_location_tag_binding.go index 9920095504d..794cd30f5f0 100644 --- a/google/services/tags/resource_tags_location_tag_binding.go +++ b/google/services/tags/resource_tags_location_tag_binding.go @@ -29,6 +29,7 @@ import ( transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" "google.golang.org/api/googleapi" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -36,6 +37,7 @@ func ResourceTagsLocationTagBinding() *schema.Resource { return &schema.Resource{ Create: resourceTagsLocationTagBindingCreate, Read: resourceTagsLocationTagBindingRead, + Update: resourceTagsLocationTagBindingUpdate, Delete: resourceTagsLocationTagBindingDelete, Importer: &schema.ResourceImporter{ @@ -47,6 +49,10 @@ func ResourceTagsLocationTagBinding() *schema.Resource { Delete: schema.DefaultTimeout(20 * time.Minute), }, + CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), + ), + Schema: map[string]*schema.Schema{ "parent": { Type: schema.TypeString, @@ -73,6 +79,9 @@ Examples: US, EU, asia-northeast1. The default value is US.`, Computed: true, Description: `The generated id for the TagBinding. This is a string of the form 'tagBindings/{full-resource-name}/{tag-value-name}' or 'tagBindings/{full-resource-name}/{tag-key-name}'`, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, UseJSONNumber: true, } @@ -289,10 +298,29 @@ func resourceTagsLocationTagBindingRead(d *schema.ResourceData, meta interface{} log.Printf("[DEBUG] Read: Existing tag_value in state: %s.", d.Get("tag_value").(string)) } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } +// UDP update start +func resourceTagsLocationTagBindingUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceTagsLocationTagBindingRead(d, meta) +} + +//UDP update end + func resourceTagsLocationTagBindingDelete(d *schema.ResourceData, meta interface{}) error { + + if ok, err := tpgresource.DeletionPolicyPreDelete(d); err != nil { + return err + } else if ok { + return nil + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/tags/resource_tags_location_tag_binding_meta.yaml b/google/services/tags/resource_tags_location_tag_binding_meta.yaml index 0236b9583a8..608df4a8980 100644 --- a/google/services/tags/resource_tags_location_tag_binding_meta.yaml +++ b/google/services/tags/resource_tags_location_tag_binding_meta.yaml @@ -12,3 +12,5 @@ fields: - api_field: 'name' - api_field: 'parent' - api_field: 'tagValue' + - field: 'deletion_policy' + provider_only: true diff --git a/google/services/tags/resource_tags_tag_binding.go b/google/services/tags/resource_tags_tag_binding.go index 81993038621..8318defc91b 100644 --- a/google/services/tags/resource_tags_tag_binding.go +++ b/google/services/tags/resource_tags_tag_binding.go @@ -100,6 +100,7 @@ func ResourceTagsTagBinding() *schema.Resource { return &schema.Resource{ Create: resourceTagsTagBindingCreate, Read: resourceTagsTagBindingRead, + Update: resourceTagsTagBindingUpdate, Delete: resourceTagsTagBindingDelete, Importer: &schema.ResourceImporter{ @@ -144,6 +145,19 @@ func ResourceTagsTagBinding() *schema.Resource { Computed: true, Description: `The generated id for the TagBinding. This is a string of the form 'tagBindings/{full-resource-name}/{tag-value-name}' or 'tagBindings/{full-resource-name}/{tag-key-name}'`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -359,6 +373,20 @@ func resourceTagsTagBindingRead(d *schema.ResourceData, meta interface{}) error log.Printf("[DEBUG] Read: Existing tag_value in state: %s.", d.Get("tag_value").(string)) } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceTagsTagBindingFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -379,7 +407,19 @@ func resourceTagsTagBindingRead(d *schema.ResourceData, meta interface{}) error return nil } +func resourceTagsTagBindingUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceTagsTagBindingRead(d, meta) +} + func resourceTagsTagBindingDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy TagsTagBinding without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing TagBinding %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/tags/resource_tags_tag_binding_generated_meta.yaml b/google/services/tags/resource_tags_tag_binding_generated_meta.yaml index 41a79c6d2f7..bef520ac2fa 100644 --- a/google/services/tags/resource_tags_tag_binding_generated_meta.yaml +++ b/google/services/tags/resource_tags_tag_binding_generated_meta.yaml @@ -10,3 +10,5 @@ fields: - api_field: name - api_field: parent - api_field: tagValue + - field: deletion_policy + provider_only: true diff --git a/google/services/tags/resource_tags_tag_key.go b/google/services/tags/resource_tags_tag_key.go index d3adf29404e..95cf5bb5ae1 100644 --- a/google/services/tags/resource_tags_tag_key.go +++ b/google/services/tags/resource_tags_tag_key.go @@ -199,6 +199,19 @@ A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to n A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -365,6 +378,20 @@ func resourceTagsTagKeyRead(d *schema.ResourceData, meta interface{}) error { log.Printf("[DEBUG] Finished reading TagsTagKey %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceTagsTagKeyFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -386,6 +413,19 @@ func resourceTagsTagKeyRead(d *schema.ResourceData, meta interface{}) error { } func resourceTagsTagKeyUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceTagsTagKey().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceTagsTagKeyRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -485,6 +525,13 @@ func resourceTagsTagKeyUpdate(d *schema.ResourceData, meta interface{}) error { } func resourceTagsTagKeyDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy TagsTagKey without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing TagKey %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/tags/resource_tags_tag_key_generated_meta.yaml b/google/services/tags/resource_tags_tag_key_generated_meta.yaml index 04c1bbc0bfd..a8f49ad68e6 100644 --- a/google/services/tags/resource_tags_tag_key_generated_meta.yaml +++ b/google/services/tags/resource_tags_tag_key_generated_meta.yaml @@ -17,3 +17,5 @@ fields: - api_field: purposeData - api_field: shortName - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/tags/resource_tags_tag_value.go b/google/services/tags/resource_tags_tag_value.go index 61499a540cd..a2f79dba1b1 100644 --- a/google/services/tags/resource_tags_tag_value.go +++ b/google/services/tags/resource_tags_tag_value.go @@ -173,6 +173,19 @@ A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to n Description: `Output only. Update time. A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -321,6 +334,20 @@ func resourceTagsTagValueRead(d *schema.ResourceData, meta interface{}) error { log.Printf("[DEBUG] Finished reading TagsTagValue %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceTagsTagValueFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -342,6 +369,19 @@ func resourceTagsTagValueRead(d *schema.ResourceData, meta interface{}) error { } func resourceTagsTagValueUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceTagsTagValue().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceTagsTagValueRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -431,6 +471,13 @@ func resourceTagsTagValueUpdate(d *schema.ResourceData, meta interface{}) error } func resourceTagsTagValueDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy TagsTagValue without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing TagValue %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/tags/resource_tags_tag_value_generated_meta.yaml b/google/services/tags/resource_tags_tag_value_generated_meta.yaml index 2bcd81246f9..e5254fd90ef 100644 --- a/google/services/tags/resource_tags_tag_value_generated_meta.yaml +++ b/google/services/tags/resource_tags_tag_value_generated_meta.yaml @@ -14,3 +14,5 @@ fields: - api_field: parent - api_field: shortName - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/transcoder/resource_transcoder_job.go b/google/services/transcoder/resource_transcoder_job.go index b35839d15c6..684cf66ad8b 100644 --- a/google/services/transcoder/resource_transcoder_job.go +++ b/google/services/transcoder/resource_transcoder_job.go @@ -116,6 +116,7 @@ func ResourceTranscoderJob() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -870,6 +871,18 @@ The default is preset/web-hd, which is the only supported preset.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -1010,6 +1023,19 @@ func resourceTranscoderJobRead(d *schema.ResourceData, meta interface{}) error { log.Printf("[DEBUG] Finished reading TranscoderJob %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Job: %s", err) } @@ -1041,11 +1067,18 @@ func resourceTranscoderJobRead(d *schema.ResourceData, meta interface{}) error { } func resourceTranscoderJobUpdate(d *schema.ResourceData, meta interface{}) error { - // Only the root field "labels", "terraform_labels", and virtual fields are mutable + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable return resourceTranscoderJobRead(d, meta) } func resourceTranscoderJobDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy TranscoderJob without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Job %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/transcoder/resource_transcoder_job_generated_meta.yaml b/google/services/transcoder/resource_transcoder_job_generated_meta.yaml index ef9f437fc7d..110488c2387 100644 --- a/google/services/transcoder/resource_transcoder_job_generated_meta.yaml +++ b/google/services/transcoder/resource_transcoder_job_generated_meta.yaml @@ -73,3 +73,5 @@ fields: - api_field: templateId - field: terraform_labels provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/transcoder/resource_transcoder_job_template.go b/google/services/transcoder/resource_transcoder_job_template.go index f76aa1a2341..1fa216a4359 100644 --- a/google/services/transcoder/resource_transcoder_job_template.go +++ b/google/services/transcoder/resource_transcoder_job_template.go @@ -116,6 +116,7 @@ func ResourceTranscoderJobTemplate() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -852,6 +853,18 @@ Please refer to the field 'effective_labels' for all of the labels present on th Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -985,6 +998,19 @@ func resourceTranscoderJobTemplateRead(d *schema.ResourceData, meta interface{}) log.Printf("[DEBUG] Finished reading TranscoderJobTemplate %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading JobTemplate: %s", err) } @@ -1022,11 +1048,18 @@ func resourceTranscoderJobTemplateRead(d *schema.ResourceData, meta interface{}) } func resourceTranscoderJobTemplateUpdate(d *schema.ResourceData, meta interface{}) error { - // Only the root field "labels", "terraform_labels", and virtual fields are mutable + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable return resourceTranscoderJobTemplateRead(d, meta) } func resourceTranscoderJobTemplateDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy TranscoderJobTemplate without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing JobTemplate %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/transcoder/resource_transcoder_job_template_generated_meta.yaml b/google/services/transcoder/resource_transcoder_job_template_generated_meta.yaml index 84d3da2a1cd..10a13377b6a 100644 --- a/google/services/transcoder/resource_transcoder_job_template_generated_meta.yaml +++ b/google/services/transcoder/resource_transcoder_job_template_generated_meta.yaml @@ -70,3 +70,5 @@ fields: - api_field: name - field: terraform_labels provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/vectorsearch/resource_vector_search_collection.go b/google/services/vectorsearch/resource_vector_search_collection.go index 43520368364..85a236376c3 100644 --- a/google/services/vectorsearch/resource_vector_search_collection.go +++ b/google/services/vectorsearch/resource_vector_search_collection.go @@ -116,6 +116,7 @@ func ResourceVectorSearchCollection() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -322,6 +323,18 @@ contain one or more references to fields in the DataObject, e.g.: Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -489,6 +502,19 @@ func resourceVectorSearchCollectionRead(d *schema.ResourceData, meta interface{} log.Printf("[DEBUG] Finished reading VectorSearchCollection %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Collection: %s", err) } @@ -526,6 +552,19 @@ func resourceVectorSearchCollectionRead(d *schema.ResourceData, meta interface{} } func resourceVectorSearchCollectionUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceVectorSearchCollection().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceVectorSearchCollectionRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -664,6 +703,13 @@ func resourceVectorSearchCollectionUpdate(d *schema.ResourceData, meta interface } func resourceVectorSearchCollectionDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy VectorSearchCollection without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Collection %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/vectorsearch/resource_vector_search_collection_generated_meta.yaml b/google/services/vectorsearch/resource_vector_search_collection_generated_meta.yaml index a6b1dddc50a..754606a46d2 100644 --- a/google/services/vectorsearch/resource_vector_search_collection_generated_meta.yaml +++ b/google/services/vectorsearch/resource_vector_search_collection_generated_meta.yaml @@ -37,3 +37,5 @@ fields: field: vector_schema.dense_vector.vertex_embedding_config.text_template - api_field: vectorSchema.value.sparseVector field: vector_schema.sparse_vector + - field: deletion_policy + provider_only: true diff --git a/google/services/vertexai/resource_vertex_ai_cache_config.go b/google/services/vertexai/resource_vertex_ai_cache_config.go index 60724cd8f81..85b9affb54d 100644 --- a/google/services/vertexai/resource_vertex_ai_cache_config.go +++ b/google/services/vertexai/resource_vertex_ai_cache_config.go @@ -301,6 +301,7 @@ func resourceVertexAICacheConfigRead(d *schema.ResourceData, meta interface{}) e } func resourceVertexAICacheConfigUpdate(d *schema.ResourceData, meta interface{}) error { + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/vertexai/resource_vertex_ai_dataset.go b/google/services/vertexai/resource_vertex_ai_dataset.go index d289592754b..c48ecb8cba3 100644 --- a/google/services/vertexai/resource_vertex_ai_dataset.go +++ b/google/services/vertexai/resource_vertex_ai_dataset.go @@ -112,6 +112,7 @@ func ResourceVertexAIDataset() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -218,6 +219,18 @@ Please refer to the field 'effective_labels' for all of the labels present on th Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -387,6 +400,19 @@ func resourceVertexAIDatasetRead(d *schema.ResourceData, meta interface{}) error log.Printf("[DEBUG] Finished reading VertexAIDataset %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Dataset: %s", err) } @@ -424,6 +450,19 @@ func resourceVertexAIDatasetRead(d *schema.ResourceData, meta interface{}) error } func resourceVertexAIDatasetUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceVertexAIDataset().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceVertexAIDatasetRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -525,6 +564,13 @@ func resourceVertexAIDatasetUpdate(d *schema.ResourceData, meta interface{}) err } func resourceVertexAIDatasetDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy VertexAIDataset without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Dataset %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/vertexai/resource_vertex_ai_dataset_generated_meta.yaml b/google/services/vertexai/resource_vertex_ai_dataset_generated_meta.yaml index 9ee46e75ddf..b1d810fbf61 100644 --- a/google/services/vertexai/resource_vertex_ai_dataset_generated_meta.yaml +++ b/google/services/vertexai/resource_vertex_ai_dataset_generated_meta.yaml @@ -22,3 +22,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/vertexai/resource_vertex_ai_deployment_resource_pool.go b/google/services/vertexai/resource_vertex_ai_deployment_resource_pool.go index 64390ce440f..313283c6322 100644 --- a/google/services/vertexai/resource_vertex_ai_deployment_resource_pool.go +++ b/google/services/vertexai/resource_vertex_ai_deployment_resource_pool.go @@ -100,6 +100,7 @@ func ResourceVertexAIDeploymentResourcePool() *schema.Resource { return &schema.Resource{ Create: resourceVertexAIDeploymentResourcePoolCreate, Read: resourceVertexAIDeploymentResourcePoolRead, + Update: resourceVertexAIDeploymentResourcePoolUpdate, Delete: resourceVertexAIDeploymentResourcePoolDelete, Importer: &schema.ResourceImporter{ @@ -113,6 +114,7 @@ func ResourceVertexAIDeploymentResourcePool() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -236,6 +238,18 @@ func ResourceVertexAIDeploymentResourcePool() *schema.Resource { Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -384,6 +398,19 @@ func resourceVertexAIDeploymentResourcePoolRead(d *schema.ResourceData, meta int log.Printf("[DEBUG] Finished reading VertexAIDeploymentResourcePool %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading DeploymentResourcePool: %s", err) } @@ -420,7 +447,19 @@ func resourceVertexAIDeploymentResourcePoolRead(d *schema.ResourceData, meta int return nil } +func resourceVertexAIDeploymentResourcePoolUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceVertexAIDeploymentResourcePoolRead(d, meta) +} + func resourceVertexAIDeploymentResourcePoolDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy VertexAIDeploymentResourcePool without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing DeploymentResourcePool %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/vertexai/resource_vertex_ai_deployment_resource_pool_generated_meta.yaml b/google/services/vertexai/resource_vertex_ai_deployment_resource_pool_generated_meta.yaml index d0eef7ab587..4aaf5cb2d2b 100644 --- a/google/services/vertexai/resource_vertex_ai_deployment_resource_pool_generated_meta.yaml +++ b/google/services/vertexai/resource_vertex_ai_deployment_resource_pool_generated_meta.yaml @@ -18,3 +18,5 @@ fields: - api_field: name - field: region provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/vertexai/resource_vertex_ai_endpoint.go b/google/services/vertexai/resource_vertex_ai_endpoint.go index a35ca9ce686..de91da8acbf 100644 --- a/google/services/vertexai/resource_vertex_ai_endpoint.go +++ b/google/services/vertexai/resource_vertex_ai_endpoint.go @@ -116,6 +116,7 @@ func ResourceVertexAIEndpoint() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -530,6 +531,18 @@ the 'deployModel' [example](https://cloud.google.com/vertex-ai/docs/general/depl Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -715,6 +728,19 @@ func resourceVertexAIEndpointRead(d *schema.ResourceData, meta interface{}) erro log.Printf("[DEBUG] Finished reading VertexAIEndpoint %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Endpoint: %s", err) } @@ -752,6 +778,19 @@ func resourceVertexAIEndpointRead(d *schema.ResourceData, meta interface{}) erro } func resourceVertexAIEndpointUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceVertexAIEndpoint().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceVertexAIEndpointRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -903,6 +942,13 @@ func resourceVertexAIEndpointUpdate(d *schema.ResourceData, meta interface{}) er } func resourceVertexAIEndpointDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy VertexAIEndpoint without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Endpoint %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/vertexai/resource_vertex_ai_endpoint_generated_meta.yaml b/google/services/vertexai/resource_vertex_ai_endpoint_generated_meta.yaml index 1b061303e78..b7e1a6af3b8 100644 --- a/google/services/vertexai/resource_vertex_ai_endpoint_generated_meta.yaml +++ b/google/services/vertexai/resource_vertex_ai_endpoint_generated_meta.yaml @@ -65,3 +65,5 @@ fields: - api_field: trafficSplit json: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/vertexai/resource_vertex_ai_endpoint_with_model_garden_deployment.go b/google/services/vertexai/resource_vertex_ai_endpoint_with_model_garden_deployment.go index 047f50529aa..42b0c6b8307 100644 --- a/google/services/vertexai/resource_vertex_ai_endpoint_with_model_garden_deployment.go +++ b/google/services/vertexai/resource_vertex_ai_endpoint_with_model_garden_deployment.go @@ -100,6 +100,7 @@ func ResourceVertexAIEndpointWithModelGardenDeployment() *schema.Resource { return &schema.Resource{ Create: resourceVertexAIEndpointWithModelGardenDeploymentCreate, Read: resourceVertexAIEndpointWithModelGardenDeploymentRead, + Update: resourceVertexAIEndpointWithModelGardenDeploymentUpdate, Delete: resourceVertexAIEndpointWithModelGardenDeploymentDelete, Timeouts: &schema.ResourceTimeout{ @@ -109,6 +110,7 @@ func ResourceVertexAIEndpointWithModelGardenDeployment() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -1448,6 +1450,18 @@ https://cloud.google.com/vertex-ai/docs/reference/rest/v1/projects.locations.end Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -1709,7 +1723,19 @@ func resourceVertexAIEndpointWithModelGardenDeploymentRead(d *schema.ResourceDat return nil } +func resourceVertexAIEndpointWithModelGardenDeploymentUpdate(d *schema.ResourceData, meta interface{}) error { + // Only the root field "deletion_policy", "labels", "terraform_labels", and virtual fields are mutable + return resourceVertexAIEndpointWithModelGardenDeploymentRead(d, meta) +} + func resourceVertexAIEndpointWithModelGardenDeploymentDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy VertexAIEndpointWithModelGardenDeployment without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing EndpointWithModelGardenDeployment %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/vertexai/resource_vertex_ai_endpoint_with_model_garden_deployment_generated_meta.yaml b/google/services/vertexai/resource_vertex_ai_endpoint_with_model_garden_deployment_generated_meta.yaml index 8e31446b7fe..089711f4dc3 100644 --- a/google/services/vertexai/resource_vertex_ai_endpoint_with_model_garden_deployment_generated_meta.yaml +++ b/google/services/vertexai/resource_vertex_ai_endpoint_with_model_garden_deployment_generated_meta.yaml @@ -106,3 +106,5 @@ fields: - api_field: modelConfig.huggingFaceCacheEnabled - api_field: modelConfig.modelDisplayName - api_field: publisherModelName + - field: deletion_policy + provider_only: true diff --git a/google/services/vertexai/resource_vertex_ai_feature_group.go b/google/services/vertexai/resource_vertex_ai_feature_group.go index 5eb6702ec8f..a105d349590 100644 --- a/google/services/vertexai/resource_vertex_ai_feature_group.go +++ b/google/services/vertexai/resource_vertex_ai_feature_group.go @@ -116,6 +116,7 @@ func ResourceVertexAIFeatureGroup() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -236,6 +237,18 @@ Please refer to the field 'effective_labels' for all of the labels present on th Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -391,6 +404,19 @@ func resourceVertexAIFeatureGroupRead(d *schema.ResourceData, meta interface{}) log.Printf("[DEBUG] Finished reading VertexAIFeatureGroup %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading FeatureGroup: %s", err) } @@ -428,6 +454,19 @@ func resourceVertexAIFeatureGroupRead(d *schema.ResourceData, meta interface{}) } func resourceVertexAIFeatureGroupUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceVertexAIFeatureGroup().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceVertexAIFeatureGroupRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -556,6 +595,13 @@ func resourceVertexAIFeatureGroupUpdate(d *schema.ResourceData, meta interface{} } func resourceVertexAIFeatureGroupDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy VertexAIFeatureGroup without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing FeatureGroup %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/vertexai/resource_vertex_ai_feature_group_feature.go b/google/services/vertexai/resource_vertex_ai_feature_group_feature.go index 47186e55fb3..f3a97d21785 100644 --- a/google/services/vertexai/resource_vertex_ai_feature_group_feature.go +++ b/google/services/vertexai/resource_vertex_ai_feature_group_feature.go @@ -116,6 +116,7 @@ func ResourceVertexAIFeatureGroupFeature() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -213,6 +214,18 @@ Please refer to the field 'effective_labels' for all of the labels present on th Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -367,6 +380,19 @@ func resourceVertexAIFeatureGroupFeatureRead(d *schema.ResourceData, meta interf log.Printf("[DEBUG] Finished reading VertexAIFeatureGroupFeature %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading FeatureGroupFeature: %s", err) } @@ -410,6 +436,19 @@ func resourceVertexAIFeatureGroupFeatureRead(d *schema.ResourceData, meta interf } func resourceVertexAIFeatureGroupFeatureUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceVertexAIFeatureGroupFeature().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceVertexAIFeatureGroupFeatureRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -533,6 +572,13 @@ func resourceVertexAIFeatureGroupFeatureUpdate(d *schema.ResourceData, meta inte } func resourceVertexAIFeatureGroupFeatureDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy VertexAIFeatureGroupFeature without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing FeatureGroupFeature %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/vertexai/resource_vertex_ai_feature_group_feature_generated_meta.yaml b/google/services/vertexai/resource_vertex_ai_feature_group_feature_generated_meta.yaml index 2fe439dfe3f..60fddb2e0ad 100644 --- a/google/services/vertexai/resource_vertex_ai_feature_group_feature_generated_meta.yaml +++ b/google/services/vertexai/resource_vertex_ai_feature_group_feature_generated_meta.yaml @@ -24,3 +24,5 @@ fields: provider_only: true - api_field: updateTime - api_field: versionColumnName + - field: deletion_policy + provider_only: true diff --git a/google/services/vertexai/resource_vertex_ai_feature_group_generated_meta.yaml b/google/services/vertexai/resource_vertex_ai_feature_group_generated_meta.yaml index 1d2215d1864..923d7649982 100644 --- a/google/services/vertexai/resource_vertex_ai_feature_group_generated_meta.yaml +++ b/google/services/vertexai/resource_vertex_ai_feature_group_generated_meta.yaml @@ -21,3 +21,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/vertexai/resource_vertex_ai_feature_online_store.go b/google/services/vertexai/resource_vertex_ai_feature_online_store.go index 94f1d28694b..2a2ea0b8d43 100644 --- a/google/services/vertexai/resource_vertex_ai_feature_online_store.go +++ b/google/services/vertexai/resource_vertex_ai_feature_online_store.go @@ -116,6 +116,7 @@ func ResourceVertexAIFeatureOnlineStore() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -327,6 +328,18 @@ Please refer to the field 'effective_labels' for all of the labels present on th Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -494,6 +507,18 @@ func resourceVertexAIFeatureOnlineStoreRead(d *schema.ResourceData, meta interfa return fmt.Errorf("Error setting force_destroy: %s", err) } } + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading FeatureOnlineStore: %s", err) } @@ -531,6 +556,19 @@ func resourceVertexAIFeatureOnlineStoreRead(d *schema.ResourceData, meta interfa } func resourceVertexAIFeatureOnlineStoreUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceVertexAIFeatureOnlineStore().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceVertexAIFeatureOnlineStoreRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -669,6 +707,13 @@ func resourceVertexAIFeatureOnlineStoreUpdate(d *schema.ResourceData, meta inter } func resourceVertexAIFeatureOnlineStoreDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy VertexAIFeatureOnlineStore without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing FeatureOnlineStore %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/vertexai/resource_vertex_ai_feature_online_store_featureview.go b/google/services/vertexai/resource_vertex_ai_feature_online_store_featureview.go index 7f481353480..6a6e76e2687 100644 --- a/google/services/vertexai/resource_vertex_ai_feature_online_store_featureview.go +++ b/google/services/vertexai/resource_vertex_ai_feature_online_store_featureview.go @@ -116,6 +116,7 @@ func ResourceVertexAIFeatureOnlineStoreFeatureview() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -291,6 +292,18 @@ To explicitly set a timezone to the cron tab, apply a prefix in the cron tab: "C Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -451,6 +464,19 @@ func resourceVertexAIFeatureOnlineStoreFeatureviewRead(d *schema.ResourceData, m log.Printf("[DEBUG] Finished reading VertexAIFeatureOnlineStoreFeatureview %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading FeatureOnlineStoreFeatureview: %s", err) } @@ -494,6 +520,19 @@ func resourceVertexAIFeatureOnlineStoreFeatureviewRead(d *schema.ResourceData, m } func resourceVertexAIFeatureOnlineStoreFeatureviewUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceVertexAIFeatureOnlineStoreFeatureview().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceVertexAIFeatureOnlineStoreFeatureviewRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -620,6 +659,13 @@ func resourceVertexAIFeatureOnlineStoreFeatureviewUpdate(d *schema.ResourceData, } func resourceVertexAIFeatureOnlineStoreFeatureviewDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy VertexAIFeatureOnlineStoreFeatureview without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing FeatureOnlineStoreFeatureview %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/vertexai/resource_vertex_ai_feature_online_store_featureview_generated_meta.yaml b/google/services/vertexai/resource_vertex_ai_feature_online_store_featureview_generated_meta.yaml index 6a0c58b9715..9430f815d09 100644 --- a/google/services/vertexai/resource_vertex_ai_feature_online_store_featureview_generated_meta.yaml +++ b/google/services/vertexai/resource_vertex_ai_feature_online_store_featureview_generated_meta.yaml @@ -27,3 +27,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/vertexai/resource_vertex_ai_feature_online_store_generated_meta.yaml b/google/services/vertexai/resource_vertex_ai_feature_online_store_generated_meta.yaml index 4cf5125a994..3a4a51f073e 100644 --- a/google/services/vertexai/resource_vertex_ai_feature_online_store_generated_meta.yaml +++ b/google/services/vertexai/resource_vertex_ai_feature_online_store_generated_meta.yaml @@ -33,3 +33,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/vertexai/resource_vertex_ai_featurestore.go b/google/services/vertexai/resource_vertex_ai_featurestore.go index 163e1d35563..bf37c7d812b 100644 --- a/google/services/vertexai/resource_vertex_ai_featurestore.go +++ b/google/services/vertexai/resource_vertex_ai_featurestore.go @@ -116,6 +116,7 @@ func ResourceVertexAIFeaturestore() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -257,6 +258,18 @@ Please refer to the field 'effective_labels' for all of the labels present on th Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -412,6 +425,18 @@ func resourceVertexAIFeaturestoreRead(d *schema.ResourceData, meta interface{}) return fmt.Errorf("Error setting force_destroy: %s", err) } } + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Featurestore: %s", err) } @@ -449,6 +474,19 @@ func resourceVertexAIFeaturestoreRead(d *schema.ResourceData, meta interface{}) } func resourceVertexAIFeaturestoreUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceVertexAIFeaturestore().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceVertexAIFeaturestoreRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -567,6 +605,13 @@ func resourceVertexAIFeaturestoreUpdate(d *schema.ResourceData, meta interface{} } func resourceVertexAIFeaturestoreDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy VertexAIFeaturestore without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Featurestore %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/vertexai/resource_vertex_ai_featurestore_entitytype.go b/google/services/vertexai/resource_vertex_ai_featurestore_entitytype.go index 2a072580d5e..60ebc2ec8e7 100644 --- a/google/services/vertexai/resource_vertex_ai_featurestore_entitytype.go +++ b/google/services/vertexai/resource_vertex_ai_featurestore_entitytype.go @@ -115,6 +115,7 @@ func ResourceVertexAIFeaturestoreEntitytype() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -294,6 +295,19 @@ If both FeaturestoreMonitoringConfig.SnapshotAnalysis.monitoring_interval_days a Computed: true, Description: "The region of the EntityType.", }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -441,6 +455,20 @@ func resourceVertexAIFeaturestoreEntitytypeRead(d *schema.ResourceData, meta int log.Printf("[DEBUG] Finished reading VertexAIFeaturestoreEntitytype %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceVertexAIFeaturestoreEntitytypeFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -468,6 +496,19 @@ func resourceVertexAIFeaturestoreEntitytypeRead(d *schema.ResourceData, meta int } func resourceVertexAIFeaturestoreEntitytypeUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceVertexAIFeaturestoreEntitytype().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceVertexAIFeaturestoreEntitytypeRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -573,6 +614,13 @@ func resourceVertexAIFeaturestoreEntitytypeUpdate(d *schema.ResourceData, meta i } func resourceVertexAIFeaturestoreEntitytypeDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy VertexAIFeaturestoreEntitytype without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing FeaturestoreEntitytype %q from Terraform state without deletion", d.Id()) + return nil + } var project string config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) diff --git a/google/services/vertexai/resource_vertex_ai_featurestore_entitytype_feature.go b/google/services/vertexai/resource_vertex_ai_featurestore_entitytype_feature.go index a7cdda99870..fd20fe325c4 100644 --- a/google/services/vertexai/resource_vertex_ai_featurestore_entitytype_feature.go +++ b/google/services/vertexai/resource_vertex_ai_featurestore_entitytype_feature.go @@ -115,6 +115,7 @@ func ResourceVertexAIFeaturestoreEntitytypeFeature() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -203,6 +204,19 @@ Please refer to the field 'effective_labels' for all of the labels present on th Computed: true, Description: "The region of the feature", }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -350,6 +364,20 @@ func resourceVertexAIFeaturestoreEntitytypeFeatureRead(d *schema.ResourceData, m log.Printf("[DEBUG] Finished reading VertexAIFeaturestoreEntitytypeFeature %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceVertexAIFeaturestoreEntitytypeFeatureFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -377,6 +405,19 @@ func resourceVertexAIFeaturestoreEntitytypeFeatureRead(d *schema.ResourceData, m } func resourceVertexAIFeaturestoreEntitytypeFeatureUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceVertexAIFeaturestoreEntitytypeFeature().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceVertexAIFeaturestoreEntitytypeFeatureRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -472,6 +513,13 @@ func resourceVertexAIFeaturestoreEntitytypeFeatureUpdate(d *schema.ResourceData, } func resourceVertexAIFeaturestoreEntitytypeFeatureDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy VertexAIFeaturestoreEntitytypeFeature without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing FeaturestoreEntitytypeFeature %q from Terraform state without deletion", d.Id()) + return nil + } var project string config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) diff --git a/google/services/vertexai/resource_vertex_ai_featurestore_entitytype_feature_generated_meta.yaml b/google/services/vertexai/resource_vertex_ai_featurestore_entitytype_feature_generated_meta.yaml index 7c860a41750..a88c9623b43 100644 --- a/google/services/vertexai/resource_vertex_ai_featurestore_entitytype_feature_generated_meta.yaml +++ b/google/services/vertexai/resource_vertex_ai_featurestore_entitytype_feature_generated_meta.yaml @@ -23,3 +23,5 @@ fields: provider_only: true - api_field: updateTime - api_field: valueType + - field: deletion_policy + provider_only: true diff --git a/google/services/vertexai/resource_vertex_ai_featurestore_entitytype_generated_meta.yaml b/google/services/vertexai/resource_vertex_ai_featurestore_entitytype_generated_meta.yaml index 2cec3c70707..6dd9f661ce0 100644 --- a/google/services/vertexai/resource_vertex_ai_featurestore_entitytype_generated_meta.yaml +++ b/google/services/vertexai/resource_vertex_ai_featurestore_entitytype_generated_meta.yaml @@ -27,3 +27,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/vertexai/resource_vertex_ai_featurestore_generated_meta.yaml b/google/services/vertexai/resource_vertex_ai_featurestore_generated_meta.yaml index 8b49774fa74..24ccb9eba7c 100644 --- a/google/services/vertexai/resource_vertex_ai_featurestore_generated_meta.yaml +++ b/google/services/vertexai/resource_vertex_ai_featurestore_generated_meta.yaml @@ -25,3 +25,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/vertexai/resource_vertex_ai_index.go b/google/services/vertexai/resource_vertex_ai_index.go index 4865a97f68b..48d51756f5d 100644 --- a/google/services/vertexai/resource_vertex_ai_index.go +++ b/google/services/vertexai/resource_vertex_ai_index.go @@ -116,6 +116,7 @@ func ResourceVertexAIIndex() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -403,6 +404,18 @@ Please refer to the field 'effective_labels' for all of the labels present on th Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -584,6 +597,19 @@ func resourceVertexAIIndexRead(d *schema.ResourceData, meta interface{}) error { log.Printf("[DEBUG] Finished reading VertexAIIndex %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Index: %s", err) } @@ -621,6 +647,19 @@ func resourceVertexAIIndexRead(d *schema.ResourceData, meta interface{}) error { } func resourceVertexAIIndexUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceVertexAIIndex().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceVertexAIIndexRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -768,6 +807,13 @@ func resourceVertexAIIndexUpdate(d *schema.ResourceData, meta interface{}) error } func resourceVertexAIIndexDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy VertexAIIndex without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Index %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/vertexai/resource_vertex_ai_index_endpoint.go b/google/services/vertexai/resource_vertex_ai_index_endpoint.go index 5b4c44736d9..f0fd21d414d 100644 --- a/google/services/vertexai/resource_vertex_ai_index_endpoint.go +++ b/google/services/vertexai/resource_vertex_ai_index_endpoint.go @@ -116,6 +116,7 @@ func ResourceVertexAIIndexEndpoint() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -291,6 +292,18 @@ Where '{project}' is a project number, as in '12345', and '{network}' is network Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -478,6 +491,19 @@ func resourceVertexAIIndexEndpointRead(d *schema.ResourceData, meta interface{}) log.Printf("[DEBUG] Finished reading VertexAIIndexEndpoint %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading IndexEndpoint: %s", err) } @@ -515,6 +541,19 @@ func resourceVertexAIIndexEndpointRead(d *schema.ResourceData, meta interface{}) } func resourceVertexAIIndexEndpointUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceVertexAIIndexEndpoint().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceVertexAIIndexEndpointRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -626,6 +665,13 @@ func resourceVertexAIIndexEndpointUpdate(d *schema.ResourceData, meta interface{ } func resourceVertexAIIndexEndpointDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy VertexAIIndexEndpoint without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing IndexEndpoint %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/vertexai/resource_vertex_ai_index_endpoint_deployed_index.go b/google/services/vertexai/resource_vertex_ai_index_endpoint_deployed_index.go index 45cd21e0279..66d35dc1f4f 100644 --- a/google/services/vertexai/resource_vertex_ai_index_endpoint_deployed_index.go +++ b/google/services/vertexai/resource_vertex_ai_index_endpoint_deployed_index.go @@ -355,6 +355,19 @@ A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to n }, }, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -525,6 +538,20 @@ func resourceVertexAIIndexEndpointDeployedIndexRead(d *schema.ResourceData, meta return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceVertexAIIndexEndpointDeployedIndexFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -534,6 +561,18 @@ func resourceVertexAIIndexEndpointDeployedIndexRead(d *schema.ResourceData, meta } func resourceVertexAIIndexEndpointDeployedIndexUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceVertexAIIndexEndpointDeployedIndex().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceVertexAIIndexEndpointDeployedIndexRead(d, meta) + } var project string config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) @@ -646,6 +685,13 @@ func resourceVertexAIIndexEndpointDeployedIndexUpdate(d *schema.ResourceData, me } func resourceVertexAIIndexEndpointDeployedIndexDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy VertexAIIndexEndpointDeployedIndex without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing IndexEndpointDeployedIndex %q from Terraform state without deletion", d.Id()) + return nil + } var project string config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) diff --git a/google/services/vertexai/resource_vertex_ai_index_endpoint_deployed_index_generated_meta.yaml b/google/services/vertexai/resource_vertex_ai_index_endpoint_deployed_index_generated_meta.yaml index 149ecdd90bf..53e9421ec9b 100644 --- a/google/services/vertexai/resource_vertex_ai_index_endpoint_deployed_index_generated_meta.yaml +++ b/google/services/vertexai/resource_vertex_ai_index_endpoint_deployed_index_generated_meta.yaml @@ -32,3 +32,5 @@ fields: - field: region provider_only: true - api_field: reservedIpRanges + - field: deletion_policy + provider_only: true diff --git a/google/services/vertexai/resource_vertex_ai_index_endpoint_generated_meta.yaml b/google/services/vertexai/resource_vertex_ai_index_endpoint_generated_meta.yaml index dea88f9760c..e902d7fe281 100644 --- a/google/services/vertexai/resource_vertex_ai_index_endpoint_generated_meta.yaml +++ b/google/services/vertexai/resource_vertex_ai_index_endpoint_generated_meta.yaml @@ -28,3 +28,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/vertexai/resource_vertex_ai_index_generated_meta.yaml b/google/services/vertexai/resource_vertex_ai_index_generated_meta.yaml index 6cc3c39e831..d8ab8982ebd 100644 --- a/google/services/vertexai/resource_vertex_ai_index_generated_meta.yaml +++ b/google/services/vertexai/resource_vertex_ai_index_generated_meta.yaml @@ -37,3 +37,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/vertexai/resource_vertex_ai_rag_engine_config.go b/google/services/vertexai/resource_vertex_ai_rag_engine_config.go index 8426ca66efd..bc0f65535c6 100644 --- a/google/services/vertexai/resource_vertex_ai_rag_engine_config.go +++ b/google/services/vertexai/resource_vertex_ai_rag_engine_config.go @@ -115,6 +115,7 @@ func ResourceVertexAIRagEngineConfig() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -197,6 +198,18 @@ NOTE: Once deleted the data cannot be recovered. To start using RAG Engine again Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -329,6 +342,19 @@ func resourceVertexAIRagEngineConfigRead(d *schema.ResourceData, meta interface{ log.Printf("[DEBUG] Finished reading VertexAIRagEngineConfig %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading RagEngineConfig: %s", err) } @@ -360,6 +386,19 @@ func resourceVertexAIRagEngineConfigRead(d *schema.ResourceData, meta interface{ } func resourceVertexAIRagEngineConfigUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceVertexAIRagEngineConfig().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceVertexAIRagEngineConfigRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -439,6 +478,13 @@ func resourceVertexAIRagEngineConfigUpdate(d *schema.ResourceData, meta interfac } func resourceVertexAIRagEngineConfigDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy VertexAIRagEngineConfig without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing RagEngineConfig %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/vertexai/resource_vertex_ai_rag_engine_config_generated_meta.yaml b/google/services/vertexai/resource_vertex_ai_rag_engine_config_generated_meta.yaml index f6d846146b2..1622a7e55f7 100644 --- a/google/services/vertexai/resource_vertex_ai_rag_engine_config_generated_meta.yaml +++ b/google/services/vertexai/resource_vertex_ai_rag_engine_config_generated_meta.yaml @@ -13,3 +13,5 @@ fields: - api_field: ragManagedDbConfig.unprovisioned - field: region provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/vertexai/resource_vertex_ai_reasoning_engine.go b/google/services/vertexai/resource_vertex_ai_reasoning_engine.go index 2c69b34f9a5..c3da64c1162 100644 --- a/google/services/vertexai/resource_vertex_ai_reasoning_engine.go +++ b/google/services/vertexai/resource_vertex_ai_reasoning_engine.go @@ -116,6 +116,7 @@ func ResourceVertexAIReasoningEngine() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -566,18 +567,18 @@ projects/{project}/locations/{location}/reasoningEngines/{reasoningEngine}`, Description: `The timestamp of when the Index was last updated in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits.`, }, - "deletion_policy": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: verify.ValidateEnum([]string{"FORCE", ""}), - Description: `Optional. The deletion policy for the reasoning engine. Setting this to FORCE allows the reasoning engine to be deleted regardless of child undeleted resources. Possible values: ["FORCE"]`, - }, "project": { Type: schema.TypeString, Optional: true, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `This field uses a custom implementation please refer to documentation under /hashicorp/terraform-provider-google-beta/website/docs/r/vertex_ai_reasoning_engine.html.markdown for specifics`, + }, }, UseJSONNumber: true, } @@ -816,6 +817,18 @@ func resourceVertexAIReasoningEngineRead(d *schema.ResourceData, meta interface{ log.Printf("[DEBUG] Finished reading VertexAIReasoningEngine %q: %#v", d.Id(), res) // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading ReasoningEngine: %s", err) } @@ -853,6 +866,19 @@ func resourceVertexAIReasoningEngineRead(d *schema.ResourceData, meta interface{ } func resourceVertexAIReasoningEngineUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceVertexAIReasoningEngine().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceVertexAIReasoningEngineRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -983,6 +1009,13 @@ func resourceVertexAIReasoningEngineUpdate(d *schema.ResourceData, meta interfac } func resourceVertexAIReasoningEngineDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy VertexAIReasoningEngine without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ReasoningEngine %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/vertexai/resource_vertex_ai_reasoning_engine_generated_meta.yaml b/google/services/vertexai/resource_vertex_ai_reasoning_engine_generated_meta.yaml index ca75b827aee..dc29def469e 100644 --- a/google/services/vertexai/resource_vertex_ai_reasoning_engine_generated_meta.yaml +++ b/google/services/vertexai/resource_vertex_ai_reasoning_engine_generated_meta.yaml @@ -8,8 +8,6 @@ api_version: v1 api_resource_type_kind: ReasoningEngine fields: - api_field: createTime - - field: deletion_policy - provider_only: true - api_field: description - api_field: displayName - field: effective_labels @@ -55,3 +53,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/vertexai/resource_vertex_ai_tensorboard.go b/google/services/vertexai/resource_vertex_ai_tensorboard.go index 60ab9ec028b..f945dc37f95 100644 --- a/google/services/vertexai/resource_vertex_ai_tensorboard.go +++ b/google/services/vertexai/resource_vertex_ai_tensorboard.go @@ -116,6 +116,7 @@ func ResourceVertexAITensorboard() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -231,6 +232,18 @@ Please refer to the field 'effective_labels' for all of the labels present on th Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -400,6 +413,19 @@ func resourceVertexAITensorboardRead(d *schema.ResourceData, meta interface{}) e log.Printf("[DEBUG] Finished reading VertexAITensorboard %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Tensorboard: %s", err) } @@ -437,6 +463,19 @@ func resourceVertexAITensorboardRead(d *schema.ResourceData, meta interface{}) e } func resourceVertexAITensorboardUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceVertexAITensorboard().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceVertexAITensorboardRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -555,6 +594,13 @@ func resourceVertexAITensorboardUpdate(d *schema.ResourceData, meta interface{}) } func resourceVertexAITensorboardDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy VertexAITensorboard without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Tensorboard %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/vertexai/resource_vertex_ai_tensorboard_generated_meta.yaml b/google/services/vertexai/resource_vertex_ai_tensorboard_generated_meta.yaml index fc9030fa5c9..5fa3abe930e 100644 --- a/google/services/vertexai/resource_vertex_ai_tensorboard_generated_meta.yaml +++ b/google/services/vertexai/resource_vertex_ai_tensorboard_generated_meta.yaml @@ -22,3 +22,5 @@ fields: - field: terraform_labels provider_only: true - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/vmwareengine/resource_vmwareengine_cluster.go b/google/services/vmwareengine/resource_vmwareengine_cluster.go index 495b0ee8c88..e8a191efafb 100644 --- a/google/services/vmwareengine/resource_vmwareengine_cluster.go +++ b/google/services/vmwareengine/resource_vmwareengine_cluster.go @@ -602,6 +602,19 @@ There can only be one management cluster in a private cloud and it has to be the A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -751,6 +764,20 @@ func resourceVmwareengineClusterRead(d *schema.ResourceData, meta interface{}) e log.Printf("[DEBUG] Finished reading VmwareengineCluster %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceVmwareengineClusterFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -778,6 +805,18 @@ func resourceVmwareengineClusterRead(d *schema.ResourceData, meta interface{}) e } func resourceVmwareengineClusterUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceVmwareengineCluster().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceVmwareengineClusterRead(d, meta) + } var project string config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) @@ -913,6 +952,13 @@ func resourceVmwareengineClusterUpdate(d *schema.ResourceData, meta interface{}) } func resourceVmwareengineClusterDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy VmwareengineCluster without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Cluster %q from Terraform state without deletion", d.Id()) + return nil + } var project string config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) diff --git a/google/services/vmwareengine/resource_vmwareengine_cluster_generated_meta.yaml b/google/services/vmwareengine/resource_vmwareengine_cluster_generated_meta.yaml index c143d9759a1..568ba2d5b4b 100644 --- a/google/services/vmwareengine/resource_vmwareengine_cluster_generated_meta.yaml +++ b/google/services/vmwareengine/resource_vmwareengine_cluster_generated_meta.yaml @@ -53,3 +53,5 @@ fields: - api_field: state - api_field: uid - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/vmwareengine/resource_vmwareengine_datastore.go b/google/services/vmwareengine/resource_vmwareengine_datastore.go index 85cfe8c9854..afe92ee9f6f 100644 --- a/google/services/vmwareengine/resource_vmwareengine_datastore.go +++ b/google/services/vmwareengine/resource_vmwareengine_datastore.go @@ -115,6 +115,7 @@ func ResourceVmwareengineDatastore() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -275,6 +276,18 @@ SOFT_DELETED`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -418,6 +431,19 @@ func resourceVmwareengineDatastoreRead(d *schema.ResourceData, meta interface{}) log.Printf("[DEBUG] Finished reading VmwareengineDatastore %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Datastore: %s", err) } @@ -455,6 +481,19 @@ func resourceVmwareengineDatastoreRead(d *schema.ResourceData, meta interface{}) } func resourceVmwareengineDatastoreUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceVmwareengineDatastore().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceVmwareengineDatastoreRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -563,6 +602,13 @@ func resourceVmwareengineDatastoreUpdate(d *schema.ResourceData, meta interface{ } func resourceVmwareengineDatastoreDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy VmwareengineDatastore without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Datastore %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/vmwareengine/resource_vmwareengine_datastore_generated_meta.yaml b/google/services/vmwareengine/resource_vmwareengine_datastore_generated_meta.yaml index 57e5f6747c4..178f4fd8017 100644 --- a/google/services/vmwareengine/resource_vmwareengine_datastore_generated_meta.yaml +++ b/google/services/vmwareengine/resource_vmwareengine_datastore_generated_meta.yaml @@ -23,3 +23,5 @@ fields: - api_field: state - api_field: uid - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/vmwareengine/resource_vmwareengine_external_access_rule.go b/google/services/vmwareengine/resource_vmwareengine_external_access_rule.go index ff5b8d8f6c3..8510d2aa78c 100644 --- a/google/services/vmwareengine/resource_vmwareengine_external_access_rule.go +++ b/google/services/vmwareengine/resource_vmwareengine_external_access_rule.go @@ -248,6 +248,19 @@ up to nine fractional digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T1 A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -411,6 +424,20 @@ func resourceVmwareengineExternalAccessRuleRead(d *schema.ResourceData, meta int log.Printf("[DEBUG] Finished reading VmwareengineExternalAccessRule %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceVmwareengineExternalAccessRuleFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -438,6 +465,18 @@ func resourceVmwareengineExternalAccessRuleRead(d *schema.ResourceData, meta int } func resourceVmwareengineExternalAccessRuleUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceVmwareengineExternalAccessRule().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceVmwareengineExternalAccessRuleRead(d, meta) + } var project string config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) @@ -596,6 +635,13 @@ func resourceVmwareengineExternalAccessRuleUpdate(d *schema.ResourceData, meta i } func resourceVmwareengineExternalAccessRuleDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy VmwareengineExternalAccessRule without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ExternalAccessRule %q from Terraform state without deletion", d.Id()) + return nil + } var project string config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) diff --git a/google/services/vmwareengine/resource_vmwareengine_external_access_rule_generated_meta.yaml b/google/services/vmwareengine/resource_vmwareengine_external_access_rule_generated_meta.yaml index 4182e0c0a10..2f1c7d0bba2 100644 --- a/google/services/vmwareengine/resource_vmwareengine_external_access_rule_generated_meta.yaml +++ b/google/services/vmwareengine/resource_vmwareengine_external_access_rule_generated_meta.yaml @@ -25,3 +25,5 @@ fields: - api_field: state - api_field: uid - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/vmwareengine/resource_vmwareengine_external_address.go b/google/services/vmwareengine/resource_vmwareengine_external_address.go index 677609e924b..88bdf700058 100644 --- a/google/services/vmwareengine/resource_vmwareengine_external_address.go +++ b/google/services/vmwareengine/resource_vmwareengine_external_address.go @@ -186,6 +186,19 @@ up to nine fractional digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T1 A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".`, }, + + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -315,6 +328,20 @@ func resourceVmwareengineExternalAddressRead(d *schema.ResourceData, meta interf log.Printf("[DEBUG] Finished reading VmwareengineExternalAddress %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + err = ResourceVmwareengineExternalAddressFlatten(d, meta, res, config, userAgent, billingProject, url, headers) if err != nil { return err @@ -342,6 +369,18 @@ func resourceVmwareengineExternalAddressRead(d *schema.ResourceData, meta interf } func resourceVmwareengineExternalAddressUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceVmwareengineExternalAddress().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceVmwareengineExternalAddressRead(d, meta) + } var project string config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) @@ -441,6 +480,13 @@ func resourceVmwareengineExternalAddressUpdate(d *schema.ResourceData, meta inte } func resourceVmwareengineExternalAddressDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy VmwareengineExternalAddress without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing ExternalAddress %q from Terraform state without deletion", d.Id()) + return nil + } var project string config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) diff --git a/google/services/vmwareengine/resource_vmwareengine_external_address_generated_meta.yaml b/google/services/vmwareengine/resource_vmwareengine_external_address_generated_meta.yaml index d06eabcaca5..d084c49cb1a 100644 --- a/google/services/vmwareengine/resource_vmwareengine_external_address_generated_meta.yaml +++ b/google/services/vmwareengine/resource_vmwareengine_external_address_generated_meta.yaml @@ -18,3 +18,5 @@ fields: - api_field: state - api_field: uid - api_field: updateTime + - field: deletion_policy + provider_only: true diff --git a/google/services/vmwareengine/resource_vmwareengine_network.go b/google/services/vmwareengine/resource_vmwareengine_network.go index 142db1201f9..332a1082ce3 100644 --- a/google/services/vmwareengine/resource_vmwareengine_network.go +++ b/google/services/vmwareengine/resource_vmwareengine_network.go @@ -115,6 +115,7 @@ func ResourceVmwareengineNetwork() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -222,6 +223,18 @@ For example: projects/123123/global/networks/my-network`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -365,6 +378,19 @@ func resourceVmwareengineNetworkRead(d *schema.ResourceData, meta interface{}) e log.Printf("[DEBUG] Finished reading VmwareengineNetwork %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Network: %s", err) } @@ -402,6 +428,19 @@ func resourceVmwareengineNetworkRead(d *schema.ResourceData, meta interface{}) e } func resourceVmwareengineNetworkUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceVmwareengineNetwork().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceVmwareengineNetworkRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -500,6 +539,13 @@ func resourceVmwareengineNetworkUpdate(d *schema.ResourceData, meta interface{}) } func resourceVmwareengineNetworkDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy VmwareengineNetwork without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Network %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/vmwareengine/resource_vmwareengine_network_generated_meta.yaml b/google/services/vmwareengine/resource_vmwareengine_network_generated_meta.yaml index 8e97932f89c..7ff012464dd 100644 --- a/google/services/vmwareengine/resource_vmwareengine_network_generated_meta.yaml +++ b/google/services/vmwareengine/resource_vmwareengine_network_generated_meta.yaml @@ -20,3 +20,5 @@ fields: - api_field: updateTime - api_field: vpcNetworks.network - api_field: vpcNetworks.type + - field: deletion_policy + provider_only: true diff --git a/google/services/vmwareengine/resource_vmwareengine_network_peering.go b/google/services/vmwareengine/resource_vmwareengine_network_peering.go index 772bee9318e..8bf2fe5d512 100644 --- a/google/services/vmwareengine/resource_vmwareengine_network_peering.go +++ b/google/services/vmwareengine/resource_vmwareengine_network_peering.go @@ -122,6 +122,7 @@ func ResourceVmwareengineNetworkPeering() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -242,6 +243,18 @@ projects/{project_number}/locations/{location}/vmwareEngineNetworks/{vmwareEngin Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -416,6 +429,19 @@ func resourceVmwareengineNetworkPeeringRead(d *schema.ResourceData, meta interfa log.Printf("[DEBUG] Finished reading VmwareengineNetworkPeering %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading NetworkPeering: %s", err) } @@ -447,6 +473,19 @@ func resourceVmwareengineNetworkPeeringRead(d *schema.ResourceData, meta interfa } func resourceVmwareengineNetworkPeeringUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceVmwareengineNetworkPeering().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceVmwareengineNetworkPeeringRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -568,6 +607,13 @@ func resourceVmwareengineNetworkPeeringUpdate(d *schema.ResourceData, meta inter } func resourceVmwareengineNetworkPeeringDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy VmwareengineNetworkPeering without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing NetworkPeering %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/vmwareengine/resource_vmwareengine_network_peering_generated_meta.yaml b/google/services/vmwareengine/resource_vmwareengine_network_peering_generated_meta.yaml index 2c41071a33a..0d7af266733 100644 --- a/google/services/vmwareengine/resource_vmwareengine_network_peering_generated_meta.yaml +++ b/google/services/vmwareengine/resource_vmwareengine_network_peering_generated_meta.yaml @@ -23,3 +23,5 @@ fields: - api_field: updateTime - api_field: vmwareEngineNetwork - api_field: vmwareEngineNetworkCanonical + - field: deletion_policy + provider_only: true diff --git a/google/services/vmwareengine/resource_vmwareengine_network_policy.go b/google/services/vmwareengine/resource_vmwareengine_network_policy.go index ff8df21b387..156f43d8da7 100644 --- a/google/services/vmwareengine/resource_vmwareengine_network_policy.go +++ b/google/services/vmwareengine/resource_vmwareengine_network_policy.go @@ -115,6 +115,7 @@ func ResourceVmwareengineNetworkPolicy() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -249,6 +250,18 @@ projects/{project_number}/locations/{location}/vmwareEngineNetworks/{vmwareEngin Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -410,6 +423,19 @@ func resourceVmwareengineNetworkPolicyRead(d *schema.ResourceData, meta interfac log.Printf("[DEBUG] Finished reading VmwareengineNetworkPolicy %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading NetworkPolicy: %s", err) } @@ -447,6 +473,19 @@ func resourceVmwareengineNetworkPolicyRead(d *schema.ResourceData, meta interfac } func resourceVmwareengineNetworkPolicyUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceVmwareengineNetworkPolicy().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceVmwareengineNetworkPolicyRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -549,6 +588,13 @@ func resourceVmwareengineNetworkPolicyUpdate(d *schema.ResourceData, meta interf } func resourceVmwareengineNetworkPolicyDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy VmwareengineNetworkPolicy without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing NetworkPolicy %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/vmwareengine/resource_vmwareengine_network_policy_generated_meta.yaml b/google/services/vmwareengine/resource_vmwareengine_network_policy_generated_meta.yaml index d9f26da5913..314cb9d1dc7 100644 --- a/google/services/vmwareengine/resource_vmwareengine_network_policy_generated_meta.yaml +++ b/google/services/vmwareengine/resource_vmwareengine_network_policy_generated_meta.yaml @@ -22,3 +22,5 @@ fields: - api_field: updateTime - api_field: vmwareEngineNetwork - api_field: vmwareEngineNetworkCanonical + - field: deletion_policy + provider_only: true diff --git a/google/services/vmwareengine/resource_vmwareengine_private_cloud.go b/google/services/vmwareengine/resource_vmwareengine_private_cloud.go index eb62311d774..8639cea180f 100644 --- a/google/services/vmwareengine/resource_vmwareengine_private_cloud.go +++ b/google/services/vmwareengine/resource_vmwareengine_private_cloud.go @@ -195,6 +195,7 @@ func ResourceVmwareenginePrivateCloud() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -630,6 +631,18 @@ Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -870,6 +883,18 @@ func resourceVmwareenginePrivateCloudRead(d *schema.ResourceData, meta interface } // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading PrivateCloud: %s", err) } @@ -907,6 +932,19 @@ func resourceVmwareenginePrivateCloudRead(d *schema.ResourceData, meta interface } func resourceVmwareenginePrivateCloudUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceVmwareenginePrivateCloud().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceVmwareenginePrivateCloudRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1059,6 +1097,13 @@ func resourceVmwareenginePrivateCloudUpdate(d *schema.ResourceData, meta interfa } func resourceVmwareenginePrivateCloudDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy VmwareenginePrivateCloud without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing PrivateCloud %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/vmwareengine/resource_vmwareengine_private_cloud_generated_meta.yaml b/google/services/vmwareengine/resource_vmwareengine_private_cloud_generated_meta.yaml index 73ba7f5ef70..18273fe0348 100644 --- a/google/services/vmwareengine/resource_vmwareengine_private_cloud_generated_meta.yaml +++ b/google/services/vmwareengine/resource_vmwareengine_private_cloud_generated_meta.yaml @@ -70,3 +70,5 @@ fields: - api_field: vcenter.internalIp - api_field: vcenter.state - api_field: vcenter.version + - field: deletion_policy + provider_only: true diff --git a/google/services/vpcaccess/resource_vpc_access_connector.go b/google/services/vpcaccess/resource_vpc_access_connector.go index 60c1298cb81..9d52f364237 100644 --- a/google/services/vpcaccess/resource_vpc_access_connector.go +++ b/google/services/vpcaccess/resource_vpc_access_connector.go @@ -126,6 +126,7 @@ func ResourceVPCAccessConnector() *schema.Resource { customdiff.ForceNewIfChange("min_instances", isInstanceShrinkage), customdiff.ForceNewIfChange("max_instances", isInstanceShrinkage), tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -275,6 +276,18 @@ https://compute.googleapis.com/compute/v1/projects/{project}/regions/{region}/su Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -482,6 +495,19 @@ func resourceVPCAccessConnectorRead(d *schema.ResourceData, meta interface{}) er return nil } + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Connector: %s", err) } @@ -519,6 +545,19 @@ func resourceVPCAccessConnectorRead(d *schema.ResourceData, meta interface{}) er } func resourceVPCAccessConnectorUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceVPCAccessConnector().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceVPCAccessConnectorRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -657,6 +696,13 @@ func resourceVPCAccessConnectorUpdate(d *schema.ResourceData, meta interface{}) } func resourceVPCAccessConnectorDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy VPCAccessConnector without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Connector %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/vpcaccess/resource_vpc_access_connector_generated_meta.yaml b/google/services/vpcaccess/resource_vpc_access_connector_generated_meta.yaml index c58e24acb5f..58096874824 100644 --- a/google/services/vpcaccess/resource_vpc_access_connector_generated_meta.yaml +++ b/google/services/vpcaccess/resource_vpc_access_connector_generated_meta.yaml @@ -22,3 +22,5 @@ fields: - api_field: state - api_field: subnet.name - api_field: subnet.projectId + - field: deletion_policy + provider_only: true diff --git a/google/services/workbench/resource_workbench_instance.go b/google/services/workbench/resource_workbench_instance.go index 68c61f03944..9fefe0001e4 100644 --- a/google/services/workbench/resource_workbench_instance.go +++ b/google/services/workbench/resource_workbench_instance.go @@ -442,6 +442,7 @@ func ResourceWorkbenchInstance() *schema.Resource { workbenchMetadataCustomizeDiff, tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -1049,6 +1050,18 @@ The milliseconds portion (".SSS") is optional.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -1238,6 +1251,18 @@ func resourceWorkbenchInstanceRead(d *schema.ResourceData, meta interface{}) err return fmt.Errorf("Error setting desired_state: %s", err) } } + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Instance: %s", err) } @@ -1275,6 +1300,19 @@ func resourceWorkbenchInstanceRead(d *schema.ResourceData, meta interface{}) err } func resourceWorkbenchInstanceUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceWorkbenchInstance().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceWorkbenchInstanceRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1541,6 +1579,13 @@ func resourceWorkbenchInstanceUpdate(d *schema.ResourceData, meta interface{}) e } func resourceWorkbenchInstanceDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy WorkbenchInstance without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Instance %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/workbench/resource_workbench_instance_generated_meta.yaml b/google/services/workbench/resource_workbench_instance_generated_meta.yaml index 3f247b25721..35d8d11b7cc 100644 --- a/google/services/workbench/resource_workbench_instance_generated_meta.yaml +++ b/google/services/workbench/resource_workbench_instance_generated_meta.yaml @@ -73,3 +73,5 @@ fields: - api_field: upgradeHistory.targetVersion - api_field: upgradeHistory.version - api_field: upgradeHistory.vmImage + - field: deletion_policy + provider_only: true diff --git a/google/services/workflows/resource_workflows_workflow.go b/google/services/workflows/resource_workflows_workflow.go index f81e8d9840b..52a13f2ad01 100644 --- a/google/services/workflows/resource_workflows_workflow.go +++ b/google/services/workflows/resource_workflows_workflow.go @@ -121,6 +121,7 @@ func ResourceWorkflowsWorkflow() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -289,6 +290,18 @@ When the field is set to false, deleting the workflow is allowed.`, Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -508,6 +521,18 @@ func resourceWorkflowsWorkflowRead(d *schema.ResourceData, meta interface{}) err return fmt.Errorf("Error setting deletion_protection: %s", err) } } + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Workflow: %s", err) } @@ -545,6 +570,19 @@ func resourceWorkflowsWorkflowRead(d *schema.ResourceData, meta interface{}) err } func resourceWorkflowsWorkflowUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceWorkflowsWorkflow().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceWorkflowsWorkflowRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -718,6 +756,13 @@ func resourceWorkflowsWorkflowUpdate(d *schema.ResourceData, meta interface{}) e } func resourceWorkflowsWorkflowDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy WorkflowsWorkflow without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Workflow %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/workflows/resource_workflows_workflow_generated_meta.yaml b/google/services/workflows/resource_workflows_workflow_generated_meta.yaml index e518cc1d8da..0776e24a537 100644 --- a/google/services/workflows/resource_workflows_workflow_generated_meta.yaml +++ b/google/services/workflows/resource_workflows_workflow_generated_meta.yaml @@ -29,3 +29,5 @@ fields: provider_only: true - api_field: updateTime - api_field: userEnvVars + - field: deletion_policy + provider_only: true diff --git a/google/services/workstations/resource_workstations_workstation.go b/google/services/workstations/resource_workstations_workstation.go index dcf46729f0f..c281b40f4c5 100644 --- a/google/services/workstations/resource_workstations_workstation.go +++ b/google/services/workstations/resource_workstations_workstation.go @@ -117,6 +117,7 @@ func ResourceWorkstationsWorkstation() *schema.Resource { tpgresource.SetLabelsDiff, tpgresource.SetAnnotationsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -263,6 +264,18 @@ To send traffic to a different port, clients may prefix the host with the destin Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -434,6 +447,19 @@ func resourceWorkstationsWorkstationRead(d *schema.ResourceData, meta interface{ log.Printf("[DEBUG] Finished reading WorkstationsWorkstation %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading Workstation: %s", err) } @@ -483,6 +509,19 @@ func resourceWorkstationsWorkstationRead(d *schema.ResourceData, meta interface{ } func resourceWorkstationsWorkstationUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceWorkstationsWorkstation().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceWorkstationsWorkstationRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -621,6 +660,13 @@ func resourceWorkstationsWorkstationUpdate(d *schema.ResourceData, meta interfac } func resourceWorkstationsWorkstationDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy WorkstationsWorkstation without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing Workstation %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/workstations/resource_workstations_workstation_cluster.go b/google/services/workstations/resource_workstations_workstation_cluster.go index bee4bdcf7f4..e9e0f100019 100644 --- a/google/services/workstations/resource_workstations_workstation_cluster.go +++ b/google/services/workstations/resource_workstations_workstation_cluster.go @@ -117,6 +117,7 @@ func ResourceWorkstationsWorkstationCluster() *schema.Resource { tpgresource.SetLabelsDiff, tpgresource.SetAnnotationsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -343,6 +344,18 @@ May be sent on update and delete requests to ensure that the client has an up-to Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -528,6 +541,19 @@ func resourceWorkstationsWorkstationClusterRead(d *schema.ResourceData, meta int log.Printf("[DEBUG] Finished reading WorkstationsWorkstationCluster %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading WorkstationCluster: %s", err) } @@ -565,6 +591,19 @@ func resourceWorkstationsWorkstationClusterRead(d *schema.ResourceData, meta int } func resourceWorkstationsWorkstationClusterUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceWorkstationsWorkstationCluster().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceWorkstationsWorkstationClusterRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -713,6 +752,13 @@ func resourceWorkstationsWorkstationClusterUpdate(d *schema.ResourceData, meta i } func resourceWorkstationsWorkstationClusterDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy WorkstationsWorkstationCluster without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing WorkstationCluster %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/workstations/resource_workstations_workstation_cluster_generated_meta.yaml b/google/services/workstations/resource_workstations_workstation_cluster_generated_meta.yaml index 326b63cd89f..8ad355ff568 100644 --- a/google/services/workstations/resource_workstations_workstation_cluster_generated_meta.yaml +++ b/google/services/workstations/resource_workstations_workstation_cluster_generated_meta.yaml @@ -37,3 +37,5 @@ fields: - api_field: uid - field: workstation_cluster_id provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/workstations/resource_workstations_workstation_config.go b/google/services/workstations/resource_workstations_workstation_config.go index f9abebaca58..d343af924dd 100644 --- a/google/services/workstations/resource_workstations_workstation_config.go +++ b/google/services/workstations/resource_workstations_workstation_config.go @@ -117,6 +117,7 @@ func ResourceWorkstationsWorkstationConfig() *schema.Resource { tpgresource.SetLabelsDiff, tpgresource.SetAnnotationsDiff, tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -783,6 +784,18 @@ May be sent on update and delete requests to ensure that the client has an up-to Computed: true, ForceNew: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + }, }, UseJSONNumber: true, } @@ -1021,6 +1034,19 @@ func resourceWorkstationsWorkstationConfigRead(d *schema.ResourceData, meta inte log.Printf("[DEBUG] Finished reading WorkstationsWorkstationConfig %q: %#v", d.Id(), res) + // Explicitly set virtual fields to default values if unset + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", "DELETE"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading WorkstationConfig: %s", err) } @@ -1064,6 +1090,19 @@ func resourceWorkstationsWorkstationConfigRead(d *schema.ResourceData, meta inte } func resourceWorkstationsWorkstationConfigUpdate(d *schema.ResourceData, meta interface{}) error { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range ResourceWorkstationsWorkstationConfig().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resourceWorkstationsWorkstationConfigRead(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -1325,6 +1364,13 @@ func resourceWorkstationsWorkstationConfigUpdate(d *schema.ResourceData, meta in } func resourceWorkstationsWorkstationConfigDelete(d *schema.ResourceData, meta interface{}) error { + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy WorkstationsWorkstationConfig without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing WorkstationConfig %q from Terraform state without deletion", d.Id()) + return nil + } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { diff --git a/google/services/workstations/resource_workstations_workstation_config_generated_meta.yaml b/google/services/workstations/resource_workstations_workstation_config_generated_meta.yaml index b2356e192b3..12d72a7be9d 100644 --- a/google/services/workstations/resource_workstations_workstation_config_generated_meta.yaml +++ b/google/services/workstations/resource_workstations_workstation_config_generated_meta.yaml @@ -86,3 +86,5 @@ fields: provider_only: true - field: workstation_config_id provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/services/workstations/resource_workstations_workstation_generated_meta.yaml b/google/services/workstations/resource_workstations_workstation_generated_meta.yaml index a5524fe6b90..016e2037775 100644 --- a/google/services/workstations/resource_workstations_workstation_generated_meta.yaml +++ b/google/services/workstations/resource_workstations_workstation_generated_meta.yaml @@ -31,3 +31,5 @@ fields: provider_only: true - field: workstation_id provider_only: true + - field: deletion_policy + provider_only: true diff --git a/google/tpgresource/utils.go b/google/tpgresource/utils.go index d6c1267fe6d..63e0745d57f 100644 --- a/google/tpgresource/utils.go +++ b/google/tpgresource/utils.go @@ -170,6 +170,88 @@ func GetZoneFromDiff(d *schema.ResourceDiff, config *transport_tpg.Config) (stri return "", fmt.Errorf("%s: required field is not set", "zone") } +// getDeletionPolicyFromDiff reads the "deletion_policy" field from the given diff and falls +// back to the provider's value if not given. If the provider's value is not +// given, an error is returned. +func GetDeletionPolicyFromDiff(d *schema.ResourceDiff, config *transport_tpg.Config, resourceDefault string) (string, error) { + //if IsNull() value, then the value has not been manually configured + if d.GetRawConfig().GetAttr("deletion_policy").IsNull() { + if config.DeletionPolicy != "" { + log.Printf("[DEBUG] `deletion_policy` detected as not set within resource configuration. Falling back to configured provider default, %s", config.DeletionPolicy) + return config.DeletionPolicy, nil + } + //return the provided resource default as the final backup + log.Printf("[DEBUG] `deletion_policy` detected as not set within resource or provider configuration. Falling back to resource default, %s", resourceDefault) + return resourceDefault, nil + } + //if not null, then use/maintain usage of manually configured value + // + //this has to happen after a check for the null is made, + //as "GetOk" will always return a value once the resource is set, preventing changes + res, ok := d.GetOk("deletion_policy") + if ok { + return res.(string), nil + } + return "", fmt.Errorf("An error has occured during %s configuration. Please report this issue to the provider developers.", "`deletion_policy`") +} + +func DeletionPolicySchemaEntry(resourceDefault string) *schema.Schema { + return &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: fmt.Sprintf(`Whether Terraform will be prevented from destroying the instance. Defaults to "%s". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, resourceDefault), + } +} + +func DeletionPolicyReadDefault(d *schema.ResourceData, config *transport_tpg.Config, resourceDefault string) error { + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != "" { + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } else { + if err := d.Set("deletion_policy", resourceDefault); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } + return nil +} + +func DeletionPolicyPreUpdate(d *schema.ResourceData, resourceSchema func() *schema.Resource) bool { + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range resourceSchema().Schema { + if d.HasChange(field) && !clientSideFields[field] { + return false + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return true + } + return false +} + +func DeletionPolicyPreDelete(d *schema.ResourceData) (bool, error) { + if d.Get("deletion_policy").(string) == "PREVENT" { + return true, fmt.Errorf("cannot destroy %q without setting deletion_policy=\"DELETE\" and running `terraform apply`", d.Id()) + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing %q from Terraform state without deletion", d.Id()) + return true, nil + } + return false, nil +} + func GetRouterLockName(region string, router string) string { return fmt.Sprintf("router/%s/%s", region, router) } @@ -917,6 +999,20 @@ func DefaultProviderZone(_ context.Context, diff *schema.ResourceDiff, meta inte return nil } +func DefaultProviderDeletionPolicy(resourceDefault string) schema.CustomizeDiffFunc { + return func(_ context.Context, diff *schema.ResourceDiff, meta interface{}) error { + config := meta.(*transport_tpg.Config) + if dpolicy := diff.Get("deletion_policy"); dpolicy != nil { + dpolicy, err := GetDeletionPolicyFromDiff(diff, config, resourceDefault) + err = diff.SetNew("deletion_policy", dpolicy) + if err != nil { + return err + } + } + return nil + } +} + // id.UniqueId() returns a timestamp + incremental hash // This function truncates the timestamp to provide a prefix + 9 using // YYmmdd + last 3 digits of the incremental hash diff --git a/google/transport/config.go b/google/transport/config.go index 4644650a43f..f8e7617fc4e 100644 --- a/google/transport/config.go +++ b/google/transport/config.go @@ -215,6 +215,8 @@ type Config struct { DefaultLabels map[string]string AddTerraformAttributionLabel bool TerraformAttributionLabelAdditionStrategy string + DeletionPolicy string + // PollInterval is passed to retry.StateChangeConf in common_operation.go // It controls the interval at which we poll for successful operations PollInterval time.Duration diff --git a/website/docs/r/access_context_manager_access_level.html.markdown b/website/docs/r/access_context_manager_access_level.html.markdown index 15d51b7cf09..a13473b63f0 100644 --- a/website/docs/r/access_context_manager_access_level.html.markdown +++ b/website/docs/r/access_context_manager_access_level.html.markdown @@ -105,6 +105,12 @@ The following arguments are supported: See CEL spec at: https://github.com/google/cel-spec. Structure is [documented below](#nested_custom). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `basic` block supports: diff --git a/website/docs/r/access_context_manager_access_level_condition.html.markdown b/website/docs/r/access_context_manager_access_level_condition.html.markdown index 06fb2ff31cd..b9d76cbf131 100644 --- a/website/docs/r/access_context_manager_access_level_condition.html.markdown +++ b/website/docs/r/access_context_manager_access_level_condition.html.markdown @@ -166,6 +166,12 @@ The following arguments are supported: The request must originate from one of the provided VPC networks in Google Cloud. Cannot specify this field together with `ip_subnetworks`. Structure is [documented below](#nested_vpc_network_sources). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `device_policy` block supports: diff --git a/website/docs/r/access_context_manager_access_levels.html.markdown b/website/docs/r/access_context_manager_access_levels.html.markdown index a665f6f4e82..71a9e97a084 100644 --- a/website/docs/r/access_context_manager_access_levels.html.markdown +++ b/website/docs/r/access_context_manager_access_levels.html.markdown @@ -107,6 +107,12 @@ The following arguments are supported: The desired Access Levels that should replace all existing Access Levels in the Access Policy. Structure is [documented below](#nested_access_levels). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `access_levels` block supports: diff --git a/website/docs/r/access_context_manager_access_policy.html.markdown b/website/docs/r/access_context_manager_access_policy.html.markdown index 5eb3fc77824..2a6e5f1bcf2 100644 --- a/website/docs/r/access_context_manager_access_policy.html.markdown +++ b/website/docs/r/access_context_manager_access_policy.html.markdown @@ -89,6 +89,12 @@ The following arguments are supported: Folder or project on which this policy is applicable. Format: 'folders/{{folder_id}}' or 'projects/{{project_number}}' +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/access_context_manager_authorized_orgs_desc.html.markdown b/website/docs/r/access_context_manager_authorized_orgs_desc.html.markdown index 588638031ee..0bac36421b9 100644 --- a/website/docs/r/access_context_manager_authorized_orgs_desc.html.markdown +++ b/website/docs/r/access_context_manager_authorized_orgs_desc.html.markdown @@ -117,6 +117,12 @@ The following arguments are supported: A granular control type for authorization levels. Valid value is "AUTHORIZATION_TYPE_TRUST". Possible values are: `AUTHORIZATION_TYPE_TRUST`. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/access_context_manager_egress_policy.html.markdown b/website/docs/r/access_context_manager_egress_policy.html.markdown index aa1ea295fa1..b27b059e325 100644 --- a/website/docs/r/access_context_manager_egress_policy.html.markdown +++ b/website/docs/r/access_context_manager_egress_policy.html.markdown @@ -42,6 +42,12 @@ The following arguments are supported: The name of the Service Perimeter to add this resource to. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/access_context_manager_gcp_user_access_binding.html.markdown b/website/docs/r/access_context_manager_gcp_user_access_binding.html.markdown index 34df11586fa..f90dda016f8 100644 --- a/website/docs/r/access_context_manager_gcp_user_access_binding.html.markdown +++ b/website/docs/r/access_context_manager_gcp_user_access_binding.html.markdown @@ -109,6 +109,12 @@ The following arguments are supported: Optional. A list of scoped access settings that set this binding's restrictions on a subset of applications. Structure is [documented below](#nested_scoped_access_settings). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `session_settings` block supports: diff --git a/website/docs/r/access_context_manager_ingress_policy.html.markdown b/website/docs/r/access_context_manager_ingress_policy.html.markdown index ad6e16654f2..ced476f00a6 100644 --- a/website/docs/r/access_context_manager_ingress_policy.html.markdown +++ b/website/docs/r/access_context_manager_ingress_policy.html.markdown @@ -42,6 +42,12 @@ The following arguments are supported: The name of the Service Perimeter to add this resource to. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/access_context_manager_service_perimeter.html.markdown b/website/docs/r/access_context_manager_service_perimeter.html.markdown index 92e58f194f5..97926a0d9fc 100644 --- a/website/docs/r/access_context_manager_service_perimeter.html.markdown +++ b/website/docs/r/access_context_manager_service_perimeter.html.markdown @@ -350,6 +350,12 @@ The following arguments are supported: between currently enforced and suggested restrictions. useExplicitDryRunSpec must bet set to True if any of the fields in the spec are set to non-default values. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `status` block supports: diff --git a/website/docs/r/access_context_manager_service_perimeter_dry_run_egress_policy.html.markdown b/website/docs/r/access_context_manager_service_perimeter_dry_run_egress_policy.html.markdown index 87017dffdd9..80a11998eb5 100644 --- a/website/docs/r/access_context_manager_service_perimeter_dry_run_egress_policy.html.markdown +++ b/website/docs/r/access_context_manager_service_perimeter_dry_run_egress_policy.html.markdown @@ -151,6 +151,12 @@ The following arguments are supported: (Optional) Human readable title. Must be unique within the perimeter. Does not affect behavior. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `egress_from` block supports: diff --git a/website/docs/r/access_context_manager_service_perimeter_dry_run_ingress_policy.html.markdown b/website/docs/r/access_context_manager_service_perimeter_dry_run_ingress_policy.html.markdown index 4cd590ed027..89901166be3 100644 --- a/website/docs/r/access_context_manager_service_perimeter_dry_run_ingress_policy.html.markdown +++ b/website/docs/r/access_context_manager_service_perimeter_dry_run_ingress_policy.html.markdown @@ -159,6 +159,12 @@ The following arguments are supported: (Optional) Human readable title. Must be unique within the perimeter. Does not affect behavior. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `ingress_from` block supports: diff --git a/website/docs/r/access_context_manager_service_perimeter_dry_run_resource.html.markdown b/website/docs/r/access_context_manager_service_perimeter_dry_run_resource.html.markdown index 0532f09daf2..5a8b25d39cb 100644 --- a/website/docs/r/access_context_manager_service_perimeter_dry_run_resource.html.markdown +++ b/website/docs/r/access_context_manager_service_perimeter_dry_run_resource.html.markdown @@ -88,6 +88,12 @@ The following arguments are supported: The name of the Service Perimeter to add this resource to. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/access_context_manager_service_perimeter_egress_policy.html.markdown b/website/docs/r/access_context_manager_service_perimeter_egress_policy.html.markdown index 8efd418ae32..ee4379ed33d 100644 --- a/website/docs/r/access_context_manager_service_perimeter_egress_policy.html.markdown +++ b/website/docs/r/access_context_manager_service_perimeter_egress_policy.html.markdown @@ -151,6 +151,12 @@ The following arguments are supported: (Optional) Human readable title. Must be unique within the perimeter. Does not affect behavior. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `egress_from` block supports: diff --git a/website/docs/r/access_context_manager_service_perimeter_ingress_policy.html.markdown b/website/docs/r/access_context_manager_service_perimeter_ingress_policy.html.markdown index 74e38aa3972..913c7166595 100644 --- a/website/docs/r/access_context_manager_service_perimeter_ingress_policy.html.markdown +++ b/website/docs/r/access_context_manager_service_perimeter_ingress_policy.html.markdown @@ -159,6 +159,12 @@ The following arguments are supported: (Optional) Human readable title. Must be unique within the perimeter. Does not affect behavior. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `ingress_from` block supports: diff --git a/website/docs/r/access_context_manager_service_perimeter_resource.html.markdown b/website/docs/r/access_context_manager_service_perimeter_resource.html.markdown index 3a0575b86c5..64d8c6abbb3 100644 --- a/website/docs/r/access_context_manager_service_perimeter_resource.html.markdown +++ b/website/docs/r/access_context_manager_service_perimeter_resource.html.markdown @@ -88,6 +88,12 @@ The following arguments are supported: The name of the Service Perimeter to add this resource to. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/access_context_manager_service_perimeters.html.markdown b/website/docs/r/access_context_manager_service_perimeters.html.markdown index 4f21b7e2d81..3bce30bf8a3 100644 --- a/website/docs/r/access_context_manager_service_perimeters.html.markdown +++ b/website/docs/r/access_context_manager_service_perimeters.html.markdown @@ -100,6 +100,12 @@ The following arguments are supported: The desired Service Perimeters that should replace all existing Service Perimeters in the Access Policy. Structure is [documented below](#nested_service_perimeters). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `service_perimeters` block supports: diff --git a/website/docs/r/active_directory_domain.html.markdown b/website/docs/r/active_directory_domain.html.markdown index 117879d0071..31f1256ba2b 100644 --- a/website/docs/r/active_directory_domain.html.markdown +++ b/website/docs/r/active_directory_domain.html.markdown @@ -82,6 +82,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `deletion_protection` - (Optional) Whether Terraform will be prevented from destroying the domain. Defaults to true. When a`terraform destroy` or `terraform apply` would delete the domain, the command will fail if this field is not set to false in Terraform state. diff --git a/website/docs/r/active_directory_domain_trust.html.markdown b/website/docs/r/active_directory_domain_trust.html.markdown index fa0aa6c850e..3469c5bb337 100644 --- a/website/docs/r/active_directory_domain_trust.html.markdown +++ b/website/docs/r/active_directory_domain_trust.html.markdown @@ -90,6 +90,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/active_directory_peering.html.markdown b/website/docs/r/active_directory_peering.html.markdown index 718f421dc3d..f1fcd5e7b2b 100644 --- a/website/docs/r/active_directory_peering.html.markdown +++ b/website/docs/r/active_directory_peering.html.markdown @@ -117,6 +117,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/alloydb_backup.html.markdown b/website/docs/r/alloydb_backup.html.markdown index a8529d4aff6..7009ec84952 100644 --- a/website/docs/r/alloydb_backup.html.markdown +++ b/website/docs/r/alloydb_backup.html.markdown @@ -186,6 +186,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `encryption_config` block supports: diff --git a/website/docs/r/alloydb_cluster.html.markdown b/website/docs/r/alloydb_cluster.html.markdown index 41ff31ce415..3dc388e540e 100644 --- a/website/docs/r/alloydb_cluster.html.markdown +++ b/website/docs/r/alloydb_cluster.html.markdown @@ -490,7 +490,14 @@ The following arguments are supported: * `deletion_policy` - (Optional) Policy to determine if the cluster should be deleted forcefully. Deleting a cluster forcefully, deletes the cluster and all its associated instances within the cluster. Deleting a Secondary cluster with a secondary instance REQUIRES setting deletion_policy = "FORCE" otherwise an error is returned. This is needed as there is no support to delete just the secondary instance, and the only way to delete secondary instance is to delete the associated secondary cluster forcefully which also deletes the secondary instance. -Possible values: DEFAULT, FORCE + +When a 'terraform destroy' or 'terraform apply' would delete the resource, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", the command will behave as if set to "DEFAULT". + +Possible values: DEFAULT, FORCE, PREVENT, ABANDON, DELETE * `deletion_protection` - (Optional) Whether Terraform will be prevented from destroying the cluster. When the field is set to true or unset in Terraform state, a `terraform apply` diff --git a/website/docs/r/alloydb_instance.html.markdown b/website/docs/r/alloydb_instance.html.markdown index 084203b0af9..b38b78ff5a5 100644 --- a/website/docs/r/alloydb_instance.html.markdown +++ b/website/docs/r/alloydb_instance.html.markdown @@ -284,6 +284,12 @@ The following arguments are supported: Configuration for Managed Connection Pool. Structure is [documented below](#nested_connection_pool_config). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `query_insights_config` block supports: diff --git a/website/docs/r/alloydb_user.html.markdown b/website/docs/r/alloydb_user.html.markdown index 9aa69825cf3..dc5a34fcbb0 100644 --- a/website/docs/r/alloydb_user.html.markdown +++ b/website/docs/r/alloydb_user.html.markdown @@ -188,6 +188,12 @@ The following arguments are supported: (Optional) Triggers update of `password_wo` write-only. Increment this value when an update to `password_wo` is needed. For more info see [updating write-only arguments](/docs/providers/google/guides/using_write_only_arguments.html#updating-write-only-arguments) +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/api_gateway_api.html.markdown b/website/docs/r/api_gateway_api.html.markdown index 793a0425c95..b528a6f3d1f 100644 --- a/website/docs/r/api_gateway_api.html.markdown +++ b/website/docs/r/api_gateway_api.html.markdown @@ -76,6 +76,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/api_gateway_api_config.html.markdown b/website/docs/r/api_gateway_api_config.html.markdown index 77abf0183fa..7d453f63a51 100644 --- a/website/docs/r/api_gateway_api_config.html.markdown +++ b/website/docs/r/api_gateway_api_config.html.markdown @@ -165,6 +165,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `api_config_id_prefix` - (Optional) Creates a unique name beginning with the specified prefix. If this and api_config_id are unspecified, a random value is chosen for the name. diff --git a/website/docs/r/api_gateway_gateway.html.markdown b/website/docs/r/api_gateway_gateway.html.markdown index a3c72212151..804e0c12909 100644 --- a/website/docs/r/api_gateway_gateway.html.markdown +++ b/website/docs/r/api_gateway_gateway.html.markdown @@ -103,6 +103,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/apigee_addons_config.html.markdown b/website/docs/r/apigee_addons_config.html.markdown index 2028a32670c..a5883406c92 100644 --- a/website/docs/r/apigee_addons_config.html.markdown +++ b/website/docs/r/apigee_addons_config.html.markdown @@ -138,6 +138,12 @@ The following arguments are supported: Addon configurations of the Apigee organization. Structure is [documented below](#nested_addons_config). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `addons_config` block supports: diff --git a/website/docs/r/apigee_api.html.markdown b/website/docs/r/apigee_api.html.markdown index 2ff1e20cef0..3ab9bdd2a23 100644 --- a/website/docs/r/apigee_api.html.markdown +++ b/website/docs/r/apigee_api.html.markdown @@ -67,6 +67,14 @@ The following arguments are supported: (Required) Path to the config zip bundle. +* `deletion_policy` - + (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + - - - ## Attributes Reference diff --git a/website/docs/r/apigee_api_deployment.html.markdown b/website/docs/r/apigee_api_deployment.html.markdown index f982627ff31..e37940a1852 100644 --- a/website/docs/r/apigee_api_deployment.html.markdown +++ b/website/docs/r/apigee_api_deployment.html.markdown @@ -96,6 +96,12 @@ The following arguments are supported: The revision of the API proxy to be deployed. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/apigee_api_product.html.markdown b/website/docs/r/apigee_api_product.html.markdown index 791f3d1a660..22d56b85591 100644 --- a/website/docs/r/apigee_api_product.html.markdown +++ b/website/docs/r/apigee_api_product.html.markdown @@ -465,6 +465,12 @@ The following arguments are supported: (Optional) Optional. The resource ID of the parent Space. If not set, the parent resource will be the Organization. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `attributes` block supports: diff --git a/website/docs/r/apigee_app_group.html.markdown b/website/docs/r/apigee_app_group.html.markdown index 92dc880f0c0..6af0f050b8f 100644 --- a/website/docs/r/apigee_app_group.html.markdown +++ b/website/docs/r/apigee_app_group.html.markdown @@ -176,6 +176,12 @@ The following arguments are supported: A list of attributes Structure is [documented below](#nested_attributes). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `attributes` block supports: diff --git a/website/docs/r/apigee_control_plane_access.html.markdown b/website/docs/r/apigee_control_plane_access.html.markdown index ef17d21b591..312bf929949 100644 --- a/website/docs/r/apigee_control_plane_access.html.markdown +++ b/website/docs/r/apigee_control_plane_access.html.markdown @@ -100,6 +100,12 @@ The following arguments are supported: The `service-account-name` is formatted like an email address. For example: serviceAccount@my_project_id.iam.gserviceaccount.com You might specify multiple service accounts, for example, if you have multiple environments and wish to assign a unique service account to each one. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/apigee_developer.html.markdown b/website/docs/r/apigee_developer.html.markdown index a2f51d5aaba..b608d029716 100644 --- a/website/docs/r/apigee_developer.html.markdown +++ b/website/docs/r/apigee_developer.html.markdown @@ -169,6 +169,12 @@ The following arguments are supported: Developer attributes (name/value pairs). The custom attribute limit is 18. Structure is [documented below](#nested_attributes). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `attributes` block supports: diff --git a/website/docs/r/apigee_developer_app.html.markdown b/website/docs/r/apigee_developer_app.html.markdown index 2d2a9c48ab2..6be70e64712 100644 --- a/website/docs/r/apigee_developer_app.html.markdown +++ b/website/docs/r/apigee_developer_app.html.markdown @@ -245,6 +245,12 @@ The following arguments are supported: Developer attributes (name/value pairs). The custom attribute limit is 18. Structure is [documented below](#nested_attributes). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `attributes` block supports: diff --git a/website/docs/r/apigee_dns_zone.html.markdown b/website/docs/r/apigee_dns_zone.html.markdown index bb166211c7e..c5cc46a51f2 100644 --- a/website/docs/r/apigee_dns_zone.html.markdown +++ b/website/docs/r/apigee_dns_zone.html.markdown @@ -87,6 +87,12 @@ The following arguments are supported: ID of the dns zone. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `peering_config` block supports: diff --git a/website/docs/r/apigee_endpoint_attachment.html.markdown b/website/docs/r/apigee_endpoint_attachment.html.markdown index ed48001e2dd..70ef3228aab 100644 --- a/website/docs/r/apigee_endpoint_attachment.html.markdown +++ b/website/docs/r/apigee_endpoint_attachment.html.markdown @@ -53,6 +53,12 @@ The following arguments are supported: ID of the endpoint attachment. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/apigee_env_keystore.html.markdown b/website/docs/r/apigee_env_keystore.html.markdown index 70cf06e5fc6..ecfbaf80f69 100644 --- a/website/docs/r/apigee_env_keystore.html.markdown +++ b/website/docs/r/apigee_env_keystore.html.markdown @@ -46,6 +46,12 @@ The following arguments are supported: The name of the newly created keystore. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/apigee_env_references.html.markdown b/website/docs/r/apigee_env_references.html.markdown index 4e770233dde..67087eaee24 100644 --- a/website/docs/r/apigee_env_references.html.markdown +++ b/website/docs/r/apigee_env_references.html.markdown @@ -58,6 +58,12 @@ The following arguments are supported: (Optional) Optional. A human-readable description of this reference. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/apigee_envgroup.html.markdown b/website/docs/r/apigee_envgroup.html.markdown index a366af553c0..888acc1b85c 100644 --- a/website/docs/r/apigee_envgroup.html.markdown +++ b/website/docs/r/apigee_envgroup.html.markdown @@ -87,6 +87,12 @@ The following arguments are supported: (Optional) Hostnames of the environment group. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/apigee_envgroup_attachment.html.markdown b/website/docs/r/apigee_envgroup_attachment.html.markdown index 7aa2929d61c..df2da689f43 100644 --- a/website/docs/r/apigee_envgroup_attachment.html.markdown +++ b/website/docs/r/apigee_envgroup_attachment.html.markdown @@ -123,6 +123,12 @@ The following arguments are supported: in the format `organizations/{{org_name}}/envgroups/{{envgroup_name}}`. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/apigee_environment.html.markdown b/website/docs/r/apigee_environment.html.markdown index e2c7281ae81..149e19bb597 100644 --- a/website/docs/r/apigee_environment.html.markdown +++ b/website/docs/r/apigee_environment.html.markdown @@ -142,6 +142,12 @@ The following arguments are supported: The algorithm to resolve IP. This will affect Analytics, API Security, and other features that use the client ip. To remove a client ip resolution config, update the field to an empty value. Example: '{ "clientIpResolutionConfig" = {} }' For more information, see: https://cloud.google.com/apigee/docs/api-platform/system-administration/client-ip-resolution Structure is [documented below](#nested_client_ip_resolution_config). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `node_config` block supports: diff --git a/website/docs/r/apigee_environment_addons_config.html.markdown b/website/docs/r/apigee_environment_addons_config.html.markdown index d3bcb3b6f5a..2a51451ea12 100644 --- a/website/docs/r/apigee_environment_addons_config.html.markdown +++ b/website/docs/r/apigee_environment_addons_config.html.markdown @@ -70,6 +70,12 @@ The following arguments are supported: (Optional) Flag to enable/disable Analytics. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/apigee_environment_api_revision_deployment.html.markdown b/website/docs/r/apigee_environment_api_revision_deployment.html.markdown index c4121e09244..768573cc3ce 100644 --- a/website/docs/r/apigee_environment_api_revision_deployment.html.markdown +++ b/website/docs/r/apigee_environment_api_revision_deployment.html.markdown @@ -78,6 +78,12 @@ The following arguments are supported: (Optional) Optional service account the deployed proxy runs as. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/apigee_environment_keyvaluemaps.html.markdown b/website/docs/r/apigee_environment_keyvaluemaps.html.markdown index 83d782c6221..5cabe13f52c 100644 --- a/website/docs/r/apigee_environment_keyvaluemaps.html.markdown +++ b/website/docs/r/apigee_environment_keyvaluemaps.html.markdown @@ -106,6 +106,12 @@ The following arguments are supported: in the format `organizations/{{org_name}}/environments/{{env_name}}`. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/apigee_environment_keyvaluemaps_entries.html.markdown b/website/docs/r/apigee_environment_keyvaluemaps_entries.html.markdown index 52afa657e5f..97bd69a9c15 100644 --- a/website/docs/r/apigee_environment_keyvaluemaps_entries.html.markdown +++ b/website/docs/r/apigee_environment_keyvaluemaps_entries.html.markdown @@ -123,6 +123,12 @@ The following arguments are supported: in the format `organizations/{{org_name}}/environments/{{env_name}}/keyvaluemaps/{{keyvaluemap_name}}`. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/apigee_flowhook.html.markdown b/website/docs/r/apigee_flowhook.html.markdown index 839cb30ad55..ef1c82ddb81 100644 --- a/website/docs/r/apigee_flowhook.html.markdown +++ b/website/docs/r/apigee_flowhook.html.markdown @@ -58,6 +58,14 @@ The following arguments are supported: (Optional) Flag that specifies whether execution should continue if the flow hook throws an exception. Set to true to continue execution. Set to false to stop execution if the flow hook throws an exception. Defaults to true. +* `deletion_policy` - + (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + ## Attributes Reference diff --git a/website/docs/r/apigee_instance.html.markdown b/website/docs/r/apigee_instance.html.markdown index 4e1826fc0dd..1b9eaa87775 100644 --- a/website/docs/r/apigee_instance.html.markdown +++ b/website/docs/r/apigee_instance.html.markdown @@ -278,6 +278,12 @@ The following arguments are supported: Apigee customers can enable access logging to ship the access logs to their own project's cloud logging. Structure is [documented below](#nested_access_logging_config). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `access_logging_config` block supports: diff --git a/website/docs/r/apigee_instance_attachment.html.markdown b/website/docs/r/apigee_instance_attachment.html.markdown index cf1c8956c8f..edb90fc02c8 100644 --- a/website/docs/r/apigee_instance_attachment.html.markdown +++ b/website/docs/r/apigee_instance_attachment.html.markdown @@ -123,6 +123,12 @@ The following arguments are supported: in the format `organizations/{{org_name}}/instances/{{instance_name}}`. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/apigee_keystores_aliases_pkcs12.html.markdown b/website/docs/r/apigee_keystores_aliases_pkcs12.html.markdown index 9d47080f258..a12aab594bb 100644 --- a/website/docs/r/apigee_keystores_aliases_pkcs12.html.markdown +++ b/website/docs/r/apigee_keystores_aliases_pkcs12.html.markdown @@ -53,6 +53,14 @@ The following arguments are supported: (Required) PKCS12 file content +* `deletion_policy` - + (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + - - - * `password` - diff --git a/website/docs/r/apigee_keystores_aliases_self_signed_cert.html.markdown b/website/docs/r/apigee_keystores_aliases_self_signed_cert.html.markdown index b22f99a9312..96aa2afca9f 100644 --- a/website/docs/r/apigee_keystores_aliases_self_signed_cert.html.markdown +++ b/website/docs/r/apigee_keystores_aliases_self_signed_cert.html.markdown @@ -172,6 +172,12 @@ The following arguments are supported: (Optional) Validity duration of certificate, in days. Accepts positive non-zero value. Defaults to 365. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `subject` block supports: diff --git a/website/docs/r/apigee_nat_address.html.markdown b/website/docs/r/apigee_nat_address.html.markdown index 101f7c166c4..ba39f6bbf07 100644 --- a/website/docs/r/apigee_nat_address.html.markdown +++ b/website/docs/r/apigee_nat_address.html.markdown @@ -209,6 +209,12 @@ The following arguments are supported: (Optional) Flag that specifies whether the reserved NAT address should be activate. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/apigee_organization.html.markdown b/website/docs/r/apigee_organization.html.markdown index 5d9b71790fe..39ce84e4b59 100644 --- a/website/docs/r/apigee_organization.html.markdown +++ b/website/docs/r/apigee_organization.html.markdown @@ -287,6 +287,12 @@ The following arguments are supported: Default value is `DELETION_RETENTION_UNSPECIFIED`. Possible values are: `DELETION_RETENTION_UNSPECIFIED`, `MINIMUM`. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `properties` block supports: diff --git a/website/docs/r/apigee_security_action.html.markdown b/website/docs/r/apigee_security_action.html.markdown index 2a71e0955f7..a187a4e0032 100644 --- a/website/docs/r/apigee_security_action.html.markdown +++ b/website/docs/r/apigee_security_action.html.markdown @@ -176,6 +176,12 @@ The following arguments are supported: The TTL for this SecurityAction. A duration in seconds with up to nine fractional digits, ending with 's'. Example: "3.5s". +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `condition_config` block supports: diff --git a/website/docs/r/apigee_security_feedback.html.markdown b/website/docs/r/apigee_security_feedback.html.markdown index e8c6267aa50..c7d5a75ce5a 100644 --- a/website/docs/r/apigee_security_feedback.html.markdown +++ b/website/docs/r/apigee_security_feedback.html.markdown @@ -130,6 +130,12 @@ The following arguments are supported: (Optional) Optional text the user can provide for additional, unstructured context. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `feedback_contexts` block supports: diff --git a/website/docs/r/apigee_security_monitoring_condition.html.markdown b/website/docs/r/apigee_security_monitoring_condition.html.markdown index a06dd58ae43..b29e06f9fc6 100644 --- a/website/docs/r/apigee_security_monitoring_condition.html.markdown +++ b/website/docs/r/apigee_security_monitoring_condition.html.markdown @@ -116,6 +116,12 @@ The following arguments are supported: (Optional) A nested object resource. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/apigee_security_profile_v2.html.markdown b/website/docs/r/apigee_security_profile_v2.html.markdown index f7f9841d65c..4603d5f57f3 100644 --- a/website/docs/r/apigee_security_profile_v2.html.markdown +++ b/website/docs/r/apigee_security_profile_v2.html.markdown @@ -116,6 +116,12 @@ The following arguments are supported: (Optional) Description of the security profile. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `profile_assessment_configs` block supports: diff --git a/website/docs/r/apigee_sharedflow.html.markdown b/website/docs/r/apigee_sharedflow.html.markdown index 210d7dd3066..3eae3134925 100644 --- a/website/docs/r/apigee_sharedflow.html.markdown +++ b/website/docs/r/apigee_sharedflow.html.markdown @@ -140,6 +140,14 @@ The following arguments are supported: (Required) Path to the config zip bundle. +* `deletion_policy` - + (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + - - - diff --git a/website/docs/r/apigee_sharedflow_deployment.html.markdown b/website/docs/r/apigee_sharedflow_deployment.html.markdown index 4b9359c6682..606f3e10759 100644 --- a/website/docs/r/apigee_sharedflow_deployment.html.markdown +++ b/website/docs/r/apigee_sharedflow_deployment.html.markdown @@ -50,6 +50,13 @@ The following arguments are supported: (Required) Revision of the Sharedflow to be deployed. +* `deletion_policy` - + (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. - - - diff --git a/website/docs/r/apigee_space.html.markdown b/website/docs/r/apigee_space.html.markdown index 39377031143..cc8f3a582ed 100644 --- a/website/docs/r/apigee_space.html.markdown +++ b/website/docs/r/apigee_space.html.markdown @@ -86,6 +86,12 @@ The following arguments are supported: Space ID of the Apigee Space. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/apigee_sync_authorization.html.markdown b/website/docs/r/apigee_sync_authorization.html.markdown index 0c01d7c5940..8f06bde7069 100644 --- a/website/docs/r/apigee_sync_authorization.html.markdown +++ b/website/docs/r/apigee_sync_authorization.html.markdown @@ -92,6 +92,12 @@ The following arguments are supported: Name of the Apigee organization. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/apigee_target_server.html.markdown b/website/docs/r/apigee_target_server.html.markdown index f47f4c89103..44c8a042c8d 100644 --- a/website/docs/r/apigee_target_server.html.markdown +++ b/website/docs/r/apigee_target_server.html.markdown @@ -149,6 +149,12 @@ The following arguments are supported: Immutable. The protocol used by this TargetServer. Possible values are: `HTTP`, `HTTP2`, `GRPC_TARGET`, `GRPC`, `EXTERNAL_CALLOUT`. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `s_sl_info` block supports: diff --git a/website/docs/r/apihub_api_hub_instance.html.markdown b/website/docs/r/apihub_api_hub_instance.html.markdown index 1cf89844fc7..162979bb536 100644 --- a/website/docs/r/apihub_api_hub_instance.html.markdown +++ b/website/docs/r/apihub_api_hub_instance.html.markdown @@ -97,6 +97,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `config` block supports: diff --git a/website/docs/r/apihub_curation.html.markdown b/website/docs/r/apihub_curation.html.markdown index 8ce69c8aaea..adb52d40780 100644 --- a/website/docs/r/apihub_curation.html.markdown +++ b/website/docs/r/apihub_curation.html.markdown @@ -88,6 +88,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `endpoint` block supports: diff --git a/website/docs/r/apihub_host_project_registration.html.markdown b/website/docs/r/apihub_host_project_registration.html.markdown index 3b738eb215d..c5c6934b4ba 100644 --- a/website/docs/r/apihub_host_project_registration.html.markdown +++ b/website/docs/r/apihub_host_project_registration.html.markdown @@ -88,6 +88,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/apihub_plugin.html.markdown b/website/docs/r/apihub_plugin.html.markdown index 885dceaf074..03fcfce3332 100644 --- a/website/docs/r/apihub_plugin.html.markdown +++ b/website/docs/r/apihub_plugin.html.markdown @@ -161,6 +161,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `actions_config` block supports: diff --git a/website/docs/r/apihub_plugin_instance.html.markdown b/website/docs/r/apihub_plugin_instance.html.markdown index 18ca9010cd5..8c7e7e58ee7 100644 --- a/website/docs/r/apihub_plugin_instance.html.markdown +++ b/website/docs/r/apihub_plugin_instance.html.markdown @@ -87,6 +87,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `actions` block supports: diff --git a/website/docs/r/apikeys_key.html.markdown b/website/docs/r/apikeys_key.html.markdown index 48d1517cfd3..b23b5838442 100644 --- a/website/docs/r/apikeys_key.html.markdown +++ b/website/docs/r/apikeys_key.html.markdown @@ -169,6 +169,13 @@ The following arguments are supported: * `service_account_email` - (Optional) The email of the service account the key is bound to. If this field is specified, the key is a service account bound key and auth enabled. See [Documentation](https://cloud.google.com/docs/authentication/api-keys?#api-keys-bound-sa) for more details. + +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. diff --git a/website/docs/r/app_engine_application_url_dispatch_rules.html.markdown b/website/docs/r/app_engine_application_url_dispatch_rules.html.markdown index 671f3f9a0bc..0e6aae55a9a 100644 --- a/website/docs/r/app_engine_application_url_dispatch_rules.html.markdown +++ b/website/docs/r/app_engine_application_url_dispatch_rules.html.markdown @@ -99,6 +99,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `dispatch_rules` block supports: diff --git a/website/docs/r/app_engine_domain_mapping.html.markdown b/website/docs/r/app_engine_domain_mapping.html.markdown index 5e055395810..7ac3ecb27f5 100644 --- a/website/docs/r/app_engine_domain_mapping.html.markdown +++ b/website/docs/r/app_engine_domain_mapping.html.markdown @@ -73,6 +73,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `ssl_settings` block supports: diff --git a/website/docs/r/app_engine_firewall_rule.html.markdown b/website/docs/r/app_engine_firewall_rule.html.markdown index 76f910eadef..1e44edfb404 100644 --- a/website/docs/r/app_engine_firewall_rule.html.markdown +++ b/website/docs/r/app_engine_firewall_rule.html.markdown @@ -87,6 +87,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/app_engine_flexible_app_version.html.markdown b/website/docs/r/app_engine_flexible_app_version.html.markdown index d21450c7756..c74e6c0e660 100644 --- a/website/docs/r/app_engine_flexible_app_version.html.markdown +++ b/website/docs/r/app_engine_flexible_app_version.html.markdown @@ -294,6 +294,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `noop_on_destroy` - (Optional) If set to `true`, the application version will not be deleted. * `delete_service_on_destroy` - (Optional) If set to `true`, the service will be deleted if it is the last version. diff --git a/website/docs/r/app_engine_service_network_settings.html.markdown b/website/docs/r/app_engine_service_network_settings.html.markdown index 6a7715d545a..96290bc7ef6 100644 --- a/website/docs/r/app_engine_service_network_settings.html.markdown +++ b/website/docs/r/app_engine_service_network_settings.html.markdown @@ -93,6 +93,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `network_settings` block supports: diff --git a/website/docs/r/app_engine_service_split_traffic.html.markdown b/website/docs/r/app_engine_service_split_traffic.html.markdown index c84da8351b0..0030e60843e 100644 --- a/website/docs/r/app_engine_service_split_traffic.html.markdown +++ b/website/docs/r/app_engine_service_split_traffic.html.markdown @@ -117,6 +117,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `split` block supports: diff --git a/website/docs/r/app_engine_standard_app_version.html.markdown b/website/docs/r/app_engine_standard_app_version.html.markdown index 202a3164e65..40b76ccd2f1 100644 --- a/website/docs/r/app_engine_standard_app_version.html.markdown +++ b/website/docs/r/app_engine_standard_app_version.html.markdown @@ -227,6 +227,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `noop_on_destroy` - (Optional) If set to `true`, the application version will not be deleted. * `delete_service_on_destroy` - (Optional) If set to `true`, the service will be deleted if it is the last version. diff --git a/website/docs/r/apphub_application.html.markdown b/website/docs/r/apphub_application.html.markdown index 67a9b4a36b2..c606b112ced 100644 --- a/website/docs/r/apphub_application.html.markdown +++ b/website/docs/r/apphub_application.html.markdown @@ -134,6 +134,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `scope` block supports: diff --git a/website/docs/r/apphub_boundary.html.markdown b/website/docs/r/apphub_boundary.html.markdown index f9b4a6513eb..42779b373ff 100644 --- a/website/docs/r/apphub_boundary.html.markdown +++ b/website/docs/r/apphub_boundary.html.markdown @@ -59,6 +59,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/apphub_service.html.markdown b/website/docs/r/apphub_service.html.markdown index 2749af38e35..a8c15cbd37a 100644 --- a/website/docs/r/apphub_service.html.markdown +++ b/website/docs/r/apphub_service.html.markdown @@ -314,6 +314,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `attributes` block supports: diff --git a/website/docs/r/apphub_service_project_attachment.html.markdown b/website/docs/r/apphub_service_project_attachment.html.markdown index bcc14f7514f..2663feb7cf4 100644 --- a/website/docs/r/apphub_service_project_attachment.html.markdown +++ b/website/docs/r/apphub_service_project_attachment.html.markdown @@ -90,6 +90,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/apphub_workload.html.markdown b/website/docs/r/apphub_workload.html.markdown index b5dee498c06..5bffe22ba5e 100644 --- a/website/docs/r/apphub_workload.html.markdown +++ b/website/docs/r/apphub_workload.html.markdown @@ -349,6 +349,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `attributes` block supports: diff --git a/website/docs/r/artifact_registry_repository.html.markdown b/website/docs/r/artifact_registry_repository.html.markdown index 8c7f06e5a49..03b4062350f 100644 --- a/website/docs/r/artifact_registry_repository.html.markdown +++ b/website/docs/r/artifact_registry_repository.html.markdown @@ -776,6 +776,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `docker_config` block supports: diff --git a/website/docs/r/artifact_registry_rule.html.markdown b/website/docs/r/artifact_registry_rule.html.markdown index addd6b51047..5b838fda4c3 100644 --- a/website/docs/r/artifact_registry_rule.html.markdown +++ b/website/docs/r/artifact_registry_rule.html.markdown @@ -140,6 +140,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `condition` block supports: diff --git a/website/docs/r/artifact_registry_vpcsc_config.html.markdown b/website/docs/r/artifact_registry_vpcsc_config.html.markdown index 29904097cf0..3dc8a088e32 100644 --- a/website/docs/r/artifact_registry_vpcsc_config.html.markdown +++ b/website/docs/r/artifact_registry_vpcsc_config.html.markdown @@ -63,6 +63,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/assured_workloads_workload.html.markdown b/website/docs/r/assured_workloads_workload.html.markdown index 2ba69170c1c..cb3b123c356 100644 --- a/website/docs/r/assured_workloads_workload.html.markdown +++ b/website/docs/r/assured_workloads_workload.html.markdown @@ -214,6 +214,13 @@ Please refer to the field `effective_labels` for all of the labels present on th * `workload_options` - (Optional) Optional. Used to specify certain options for a workload during workload creation - currently only supporting KAT Optionality for Regional Controls workloads. + +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. diff --git a/website/docs/r/backup_dr_backup_plan.html.markdown b/website/docs/r/backup_dr_backup_plan.html.markdown index ea58fa14df0..52f4d81144e 100644 --- a/website/docs/r/backup_dr_backup_plan.html.markdown +++ b/website/docs/r/backup_dr_backup_plan.html.markdown @@ -217,6 +217,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `backup_rules` block supports: diff --git a/website/docs/r/backup_dr_backup_plan_association.html.markdown b/website/docs/r/backup_dr_backup_plan_association.html.markdown index 9437acfe860..62956085032 100644 --- a/website/docs/r/backup_dr_backup_plan_association.html.markdown +++ b/website/docs/r/backup_dr_backup_plan_association.html.markdown @@ -197,6 +197,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/backup_dr_backup_vault.html.markdown b/website/docs/r/backup_dr_backup_vault.html.markdown index ec158a16b69..91608bcd58c 100644 --- a/website/docs/r/backup_dr_backup_vault.html.markdown +++ b/website/docs/r/backup_dr_backup_vault.html.markdown @@ -170,6 +170,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `encryption_config` block supports: diff --git a/website/docs/r/backup_dr_management_server.html.markdown b/website/docs/r/backup_dr_management_server.html.markdown index 1aa457fe93a..0b040fcb974 100644 --- a/website/docs/r/backup_dr_management_server.html.markdown +++ b/website/docs/r/backup_dr_management_server.html.markdown @@ -88,6 +88,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `networks` block supports: diff --git a/website/docs/r/backup_dr_restore_workload.html.markdown b/website/docs/r/backup_dr_restore_workload.html.markdown index 75fba2d131c..dd99dc47053 100644 --- a/website/docs/r/backup_dr_restore_workload.html.markdown +++ b/website/docs/r/backup_dr_restore_workload.html.markdown @@ -298,6 +298,12 @@ The following arguments are supported: Optional. If true (default), running terraform destroy will delete the live resource in GCP. If false, only the restore record is removed from the state, leaving the resource active. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `compute_instance_target_environment` block supports: diff --git a/website/docs/r/backup_dr_service_config.html.markdown b/website/docs/r/backup_dr_service_config.html.markdown index a1314e84f37..09779cc775c 100644 --- a/website/docs/r/backup_dr_service_config.html.markdown +++ b/website/docs/r/backup_dr_service_config.html.markdown @@ -55,6 +55,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/beyondcorp_app_connection.html.markdown b/website/docs/r/beyondcorp_app_connection.html.markdown index 45fed5475f5..41d826eaed2 100644 --- a/website/docs/r/beyondcorp_app_connection.html.markdown +++ b/website/docs/r/beyondcorp_app_connection.html.markdown @@ -161,6 +161,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `application_endpoint` block supports: diff --git a/website/docs/r/beyondcorp_app_connector.html.markdown b/website/docs/r/beyondcorp_app_connector.html.markdown index 339de13871e..24a20bc425b 100644 --- a/website/docs/r/beyondcorp_app_connector.html.markdown +++ b/website/docs/r/beyondcorp_app_connector.html.markdown @@ -120,6 +120,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `principal_info` block supports: diff --git a/website/docs/r/beyondcorp_app_gateway.html.markdown b/website/docs/r/beyondcorp_app_gateway.html.markdown index 7619225d4f7..cb136dd6e07 100644 --- a/website/docs/r/beyondcorp_app_gateway.html.markdown +++ b/website/docs/r/beyondcorp_app_gateway.html.markdown @@ -110,6 +110,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/beyondcorp_security_gateway.html.markdown b/website/docs/r/beyondcorp_security_gateway.html.markdown index e2b2f7248d6..85ca90e0a54 100644 --- a/website/docs/r/beyondcorp_security_gateway.html.markdown +++ b/website/docs/r/beyondcorp_security_gateway.html.markdown @@ -146,6 +146,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `hubs` block supports: diff --git a/website/docs/r/beyondcorp_security_gateway_application.html.markdown b/website/docs/r/beyondcorp_security_gateway_application.html.markdown index 6a9fe6d0949..78b4be4c794 100644 --- a/website/docs/r/beyondcorp_security_gateway_application.html.markdown +++ b/website/docs/r/beyondcorp_security_gateway_application.html.markdown @@ -218,6 +218,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `endpoint_matchers` block supports: diff --git a/website/docs/r/biglake_catalog.html.markdown b/website/docs/r/biglake_catalog.html.markdown index 1c79eccb763..45c5fccd969 100644 --- a/website/docs/r/biglake_catalog.html.markdown +++ b/website/docs/r/biglake_catalog.html.markdown @@ -63,6 +63,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/biglake_database.html.markdown b/website/docs/r/biglake_database.html.markdown index 445dff4fbf0..ce2f17f536d 100644 --- a/website/docs/r/biglake_database.html.markdown +++ b/website/docs/r/biglake_database.html.markdown @@ -93,6 +93,12 @@ The following arguments are supported: The name of the database. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `hive_options` block supports: diff --git a/website/docs/r/biglake_iceberg_catalog.html.markdown b/website/docs/r/biglake_iceberg_catalog.html.markdown index cdb3054ae43..806c5876e7e 100644 --- a/website/docs/r/biglake_iceberg_catalog.html.markdown +++ b/website/docs/r/biglake_iceberg_catalog.html.markdown @@ -117,6 +117,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/biglake_iceberg_namespace.html.markdown b/website/docs/r/biglake_iceberg_namespace.html.markdown index 2afb4fa1589..7b43f3141ee 100644 --- a/website/docs/r/biglake_iceberg_namespace.html.markdown +++ b/website/docs/r/biglake_iceberg_namespace.html.markdown @@ -71,6 +71,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/biglake_iceberg_table.html.markdown b/website/docs/r/biglake_iceberg_table.html.markdown index 10ac44964d4..3738f672404 100644 --- a/website/docs/r/biglake_iceberg_table.html.markdown +++ b/website/docs/r/biglake_iceberg_table.html.markdown @@ -167,6 +167,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `schema` block supports: diff --git a/website/docs/r/biglake_table.html.markdown b/website/docs/r/biglake_table.html.markdown index 371f3a98214..919e3a70c3a 100644 --- a/website/docs/r/biglake_table.html.markdown +++ b/website/docs/r/biglake_table.html.markdown @@ -127,6 +127,12 @@ The following arguments are supported: (Optional) The id of the parent database. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `hive_options` block supports: diff --git a/website/docs/r/bigquery_analytics_hub_data_exchange.html.markdown b/website/docs/r/bigquery_analytics_hub_data_exchange.html.markdown index 8d370ac205f..5b748afda96 100644 --- a/website/docs/r/bigquery_analytics_hub_data_exchange.html.markdown +++ b/website/docs/r/bigquery_analytics_hub_data_exchange.html.markdown @@ -152,6 +152,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `sharing_environment_config` block supports: diff --git a/website/docs/r/bigquery_analytics_hub_data_exchange_subscription.html.markdown b/website/docs/r/bigquery_analytics_hub_data_exchange_subscription.html.markdown index 74cd9816ddc..0350de994ed 100644 --- a/website/docs/r/bigquery_analytics_hub_data_exchange_subscription.html.markdown +++ b/website/docs/r/bigquery_analytics_hub_data_exchange_subscription.html.markdown @@ -179,6 +179,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `refresh_policy` - (Optional) Controls when the subscription is automatically refreshed by the provider. * `ON_READ`: Default value if not specified. The subscription will be refreshed every time Terraform performs a read operation (e.g., `terraform plan`, `terraform apply`, `terraform refresh`). This ensures the state is always up-to-date. * `ON_STALE`: The subscription will only be refreshed when its reported `state` (an output-only field from the API) is `STATE_STALE` during a Terraform read operation. diff --git a/website/docs/r/bigquery_analytics_hub_listing.html.markdown b/website/docs/r/bigquery_analytics_hub_listing.html.markdown index 3192d9a51c2..4eaa50d95f3 100644 --- a/website/docs/r/bigquery_analytics_hub_listing.html.markdown +++ b/website/docs/r/bigquery_analytics_hub_listing.html.markdown @@ -496,6 +496,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `delete_commercial` - (Optional) If the listing is commercial then this field must be set to true, otherwise a failure is thrown. This acts as a safety guard to avoid deleting commercial listings accidentally. diff --git a/website/docs/r/bigquery_analytics_hub_listing_subscription.html.markdown b/website/docs/r/bigquery_analytics_hub_listing_subscription.html.markdown index b9fc2e6ba4a..6906f78b2cc 100644 --- a/website/docs/r/bigquery_analytics_hub_listing_subscription.html.markdown +++ b/website/docs/r/bigquery_analytics_hub_listing_subscription.html.markdown @@ -149,6 +149,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `destination_dataset` block supports: diff --git a/website/docs/r/bigquery_bi_reservation.html.markdown b/website/docs/r/bigquery_bi_reservation.html.markdown index 083e2d93597..364cd677c40 100644 --- a/website/docs/r/bigquery_bi_reservation.html.markdown +++ b/website/docs/r/bigquery_bi_reservation.html.markdown @@ -67,6 +67,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `preferred_tables` block supports: diff --git a/website/docs/r/bigquery_capacity_commitment.html.markdown b/website/docs/r/bigquery_capacity_commitment.html.markdown index cf13888e976..6814fc73363 100644 --- a/website/docs/r/bigquery_capacity_commitment.html.markdown +++ b/website/docs/r/bigquery_capacity_commitment.html.markdown @@ -87,6 +87,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/bigquery_connection.html.markdown b/website/docs/r/bigquery_connection.html.markdown index 88868b7210f..e465eaff861 100644 --- a/website/docs/r/bigquery_connection.html.markdown +++ b/website/docs/r/bigquery_connection.html.markdown @@ -486,6 +486,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `cloud_sql` block supports: diff --git a/website/docs/r/bigquery_data_transfer_config.html.markdown b/website/docs/r/bigquery_data_transfer_config.html.markdown index 7f0f9ddff90..0b61c0e843d 100644 --- a/website/docs/r/bigquery_data_transfer_config.html.markdown +++ b/website/docs/r/bigquery_data_transfer_config.html.markdown @@ -247,6 +247,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `schedule_options` block supports: diff --git a/website/docs/r/bigquery_datapolicy_data_policy.html.markdown b/website/docs/r/bigquery_datapolicy_data_policy.html.markdown index 4b5d939b21e..94fa340cbb6 100644 --- a/website/docs/r/bigquery_datapolicy_data_policy.html.markdown +++ b/website/docs/r/bigquery_datapolicy_data_policy.html.markdown @@ -143,6 +143,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `data_masking_policy` block supports: diff --git a/website/docs/r/bigquery_datapolicyv2_data_policy.html.markdown b/website/docs/r/bigquery_datapolicyv2_data_policy.html.markdown index 9a4c494630c..daa2d562e13 100644 --- a/website/docs/r/bigquery_datapolicyv2_data_policy.html.markdown +++ b/website/docs/r/bigquery_datapolicyv2_data_policy.html.markdown @@ -157,6 +157,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `data_masking_policy` block supports: diff --git a/website/docs/r/bigquery_dataset.html.markdown b/website/docs/r/bigquery_dataset.html.markdown index be67d6faa1d..34d7c146077 100644 --- a/website/docs/r/bigquery_dataset.html.markdown +++ b/website/docs/r/bigquery_dataset.html.markdown @@ -377,6 +377,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `delete_contents_on_destroy` - (Optional) If set to `true`, delete all the tables in the dataset when destroying the resource; otherwise, destroying the resource will fail if tables are present. diff --git a/website/docs/r/bigquery_dataset_access.html.markdown b/website/docs/r/bigquery_dataset_access.html.markdown index 64da837e2de..63067a82978 100644 --- a/website/docs/r/bigquery_dataset_access.html.markdown +++ b/website/docs/r/bigquery_dataset_access.html.markdown @@ -236,6 +236,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `view` block supports: diff --git a/website/docs/r/bigquery_job.html.markdown b/website/docs/r/bigquery_job.html.markdown index afcea27a518..2c0d0f9b0f7 100644 --- a/website/docs/r/bigquery_job.html.markdown +++ b/website/docs/r/bigquery_job.html.markdown @@ -546,6 +546,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `query` block supports: diff --git a/website/docs/r/bigquery_reservation.html.markdown b/website/docs/r/bigquery_reservation.html.markdown index 32bbac65ed6..73a5602537d 100644 --- a/website/docs/r/bigquery_reservation.html.markdown +++ b/website/docs/r/bigquery_reservation.html.markdown @@ -178,6 +178,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `autoscale` block supports: diff --git a/website/docs/r/bigquery_reservation_assignment.html.markdown b/website/docs/r/bigquery_reservation_assignment.html.markdown index c8241b644ec..b9cdbedae91 100644 --- a/website/docs/r/bigquery_reservation_assignment.html.markdown +++ b/website/docs/r/bigquery_reservation_assignment.html.markdown @@ -74,6 +74,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/bigquery_reservation_group.html.markdown b/website/docs/r/bigquery_reservation_group.html.markdown index 160c603a49b..bec62cffc21 100644 --- a/website/docs/r/bigquery_reservation_group.html.markdown +++ b/website/docs/r/bigquery_reservation_group.html.markdown @@ -61,6 +61,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/bigquery_routine.html.markdown b/website/docs/r/bigquery_routine.html.markdown index af909764962..522703622a8 100644 --- a/website/docs/r/bigquery_routine.html.markdown +++ b/website/docs/r/bigquery_routine.html.markdown @@ -444,6 +444,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `arguments` block supports: diff --git a/website/docs/r/bigquery_row_access_policy.html.markdown b/website/docs/r/bigquery_row_access_policy.html.markdown index f6da9a546ce..4a1bdb6757b 100644 --- a/website/docs/r/bigquery_row_access_policy.html.markdown +++ b/website/docs/r/bigquery_row_access_policy.html.markdown @@ -126,6 +126,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/bigquery_table.html.markdown b/website/docs/r/bigquery_table.html.markdown index da8f88a0728..4d6dfc2db29 100644 --- a/website/docs/r/bigquery_table.html.markdown +++ b/website/docs/r/bigquery_table.html.markdown @@ -142,6 +142,14 @@ The following arguments are supported: * `effective_labels` - All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Terraform, other clients and services. +* `deletion_policy` - + (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + * `schema` - (Optional) A JSON schema for the table. ~>**NOTE:** Because this field expects a JSON string, any changes to the diff --git a/website/docs/r/bigtable_app_profile.html.markdown b/website/docs/r/bigtable_app_profile.html.markdown index 54ba1786ec4..eb3c76a65fd 100644 --- a/website/docs/r/bigtable_app_profile.html.markdown +++ b/website/docs/r/bigtable_app_profile.html.markdown @@ -234,6 +234,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `single_cluster_routing` block supports: diff --git a/website/docs/r/bigtable_authorized_view.html.markdown b/website/docs/r/bigtable_authorized_view.html.markdown index 514d3e16d55..af859b2ce73 100644 --- a/website/docs/r/bigtable_authorized_view.html.markdown +++ b/website/docs/r/bigtable_authorized_view.html.markdown @@ -112,6 +112,13 @@ The following arguments are supported: If not provided, currently deletion protection will be set to UNPROTECTED as it is the API default value. Note this field configs the deletion protection provided by the API in the backend, and should not be confused with Terraform-side deletion protection. * `subset_view` - (Optional) An AuthorizedView permitting access to an explicit subset of a Table. Structure is documented below. + +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ----- diff --git a/website/docs/r/bigtable_gc_policy.html.markdown b/website/docs/r/bigtable_gc_policy.html.markdown index 0472de8aacc..acbb78e92fe 100644 --- a/website/docs/r/bigtable_gc_policy.html.markdown +++ b/website/docs/r/bigtable_gc_policy.html.markdown @@ -175,10 +175,15 @@ The following arguments are supported: * `gc_rules` - (Optional) Serialized JSON object to represent a more complex GC policy. Conflicts with `mode`, `max_age` and `max_version`. Conflicts with `mode`, `max_age` and `max_version`. -* `deletion_policy` - (Optional) The deletion policy for the GC policy. - Setting ABANDON allows the resource to be abandoned rather than deleted. This is useful for GC policy as it cannot be deleted in a replicated instance. - - Possible values are: `ABANDON`. +* `deletion_policy` - (Optional) The deletion policy for the GC policy. Setting ABANDON allows the resource + to be abandoned rather than deleted. This is useful for GC policy as it cannot be deleted + in a replicated instance. + + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "DELETE" or "", deleting the resource is allowed. + + Possible values: PREVENT, ABANDON, DELETE. * `ignore_warnings` - (Optional) Boolean for whether to allow ignoring warnings when updating the gc policy. Setting this to `true` allows relaxing the gc policy for replicated clusters by up to 90 days, but keep in mind this may increase how long clusters are inconsistent. Make sure diff --git a/website/docs/r/bigtable_instance.html.markdown b/website/docs/r/bigtable_instance.html.markdown index 1a2c2099d50..f0b34f785f1 100644 --- a/website/docs/r/bigtable_instance.html.markdown +++ b/website/docs/r/bigtable_instance.html.markdown @@ -128,6 +128,14 @@ to default to the backend value. See [structure below](#nested_cluster). * `effective_labels` - All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Terraform, other clients and services. +* `deletion_policy` - + (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + * `tags` - (Optional) A set of key/value label pairs to assign to the resource. Tags must follow the requirements at [create and manage tags](https://docs.cloud.google.com/resource-manager/docs/tags/tags-creating-and-managing). ----- diff --git a/website/docs/r/bigtable_logical_view.html.markdown b/website/docs/r/bigtable_logical_view.html.markdown index a70830a57d6..f0b7657d56d 100644 --- a/website/docs/r/bigtable_logical_view.html.markdown +++ b/website/docs/r/bigtable_logical_view.html.markdown @@ -98,6 +98,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/bigtable_materialized_view.html.markdown b/website/docs/r/bigtable_materialized_view.html.markdown index fed4e4e3763..37dff6fcc77 100644 --- a/website/docs/r/bigtable_materialized_view.html.markdown +++ b/website/docs/r/bigtable_materialized_view.html.markdown @@ -99,6 +99,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/bigtable_schema_bundle.html.markdown b/website/docs/r/bigtable_schema_bundle.html.markdown index 8ff59b6d9ca..f3c7b8d7766 100644 --- a/website/docs/r/bigtable_schema_bundle.html.markdown +++ b/website/docs/r/bigtable_schema_bundle.html.markdown @@ -101,6 +101,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `proto_schema` block supports: diff --git a/website/docs/r/bigtable_table.html.markdown b/website/docs/r/bigtable_table.html.markdown index eb93b2b75ca..c656ca33e2d 100644 --- a/website/docs/r/bigtable_table.html.markdown +++ b/website/docs/r/bigtable_table.html.markdown @@ -115,6 +115,13 @@ to delete/recreate the entire `google_bigtable_table` resource. * `change_stream_retention` - (Optional) Duration to retain change stream data for the table. Set to 0 to disable. Must be between 1 and 7 days. * `automated_backup_policy` - (Optional) Defines an automated backup policy for a table, specified by Retention Period and Frequency. To _create_ a table with automated backup disabled, either omit the automated_backup_policy argument, or set both Retention Period and Frequency properties to "0". To disable automated backup on an _existing_ table that has automated backup enabled, set _both_ Retention Period and Frequency properties to "0". When updating an existing table, to modify the Retention Period or Frequency properties of the resource's automated backup policy, set the respective property to a non-zero value. If the automated_backup_policy argument is not provided in the configuration on update, the resource's automated backup policy will _not_ be modified. + +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ----- diff --git a/website/docs/r/billing_budget.html.markdown b/website/docs/r/billing_budget.html.markdown index e24d4355c54..051f08590c8 100644 --- a/website/docs/r/billing_budget.html.markdown +++ b/website/docs/r/billing_budget.html.markdown @@ -306,6 +306,12 @@ The following arguments are supported: IAM permissions determine who has full access to the budget's data. Possible values are: `OWNERSHIP_SCOPE_UNSPECIFIED`, `ALL_USERS`, `BILLING_ACCOUNT`. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `amount` block supports: diff --git a/website/docs/r/billing_project_info.html.markdown b/website/docs/r/billing_project_info.html.markdown index d9bb87fa826..e60c91713d4 100644 --- a/website/docs/r/billing_project_info.html.markdown +++ b/website/docs/r/billing_project_info.html.markdown @@ -65,6 +65,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/binary_authorization_attestor.html.markdown b/website/docs/r/binary_authorization_attestor.html.markdown index fb620f84e98..5233167e533 100644 --- a/website/docs/r/binary_authorization_attestor.html.markdown +++ b/website/docs/r/binary_authorization_attestor.html.markdown @@ -149,6 +149,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `attestation_authority_note` block supports: diff --git a/website/docs/r/binary_authorization_policy.html.markdown b/website/docs/r/binary_authorization_policy.html.markdown index 7ea674866eb..8a98198039c 100644 --- a/website/docs/r/binary_authorization_policy.html.markdown +++ b/website/docs/r/binary_authorization_policy.html.markdown @@ -145,6 +145,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `default_admission_rule` block supports: diff --git a/website/docs/r/blockchain_node_engine_blockchain_nodes.html.markdown b/website/docs/r/blockchain_node_engine_blockchain_nodes.html.markdown index 9546c187c2f..3233e152766 100644 --- a/website/docs/r/blockchain_node_engine_blockchain_nodes.html.markdown +++ b/website/docs/r/blockchain_node_engine_blockchain_nodes.html.markdown @@ -158,6 +158,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `ethereum_details` block supports: diff --git a/website/docs/r/certificate_manager_certificate.html.markdown b/website/docs/r/certificate_manager_certificate.html.markdown index 82fe323034d..246774b2968 100644 --- a/website/docs/r/certificate_manager_certificate.html.markdown +++ b/website/docs/r/certificate_manager_certificate.html.markdown @@ -421,6 +421,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `self_managed` block supports: diff --git a/website/docs/r/certificate_manager_certificate_issuance_config.html.markdown b/website/docs/r/certificate_manager_certificate_issuance_config.html.markdown index 2a5c221fe9e..e7342d918c4 100644 --- a/website/docs/r/certificate_manager_certificate_issuance_config.html.markdown +++ b/website/docs/r/certificate_manager_certificate_issuance_config.html.markdown @@ -153,6 +153,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `certificate_authority_config` block supports: diff --git a/website/docs/r/certificate_manager_certificate_map.html.markdown b/website/docs/r/certificate_manager_certificate_map.html.markdown index 4a9c3c9fc59..b7d3938baac 100644 --- a/website/docs/r/certificate_manager_certificate_map.html.markdown +++ b/website/docs/r/certificate_manager_certificate_map.html.markdown @@ -71,6 +71,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/certificate_manager_certificate_map_entry.html.markdown b/website/docs/r/certificate_manager_certificate_map_entry.html.markdown index 62ca0eb01f7..a69b12ab9e2 100644 --- a/website/docs/r/certificate_manager_certificate_map_entry.html.markdown +++ b/website/docs/r/certificate_manager_certificate_map_entry.html.markdown @@ -135,6 +135,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/certificate_manager_dns_authorization.html.markdown b/website/docs/r/certificate_manager_dns_authorization.html.markdown index 2bee591ac81..55eba32b8d1 100644 --- a/website/docs/r/certificate_manager_dns_authorization.html.markdown +++ b/website/docs/r/certificate_manager_dns_authorization.html.markdown @@ -116,6 +116,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/certificate_manager_trust_config.html.markdown b/website/docs/r/certificate_manager_trust_config.html.markdown index 450c8d37307..8b668e9b391 100644 --- a/website/docs/r/certificate_manager_trust_config.html.markdown +++ b/website/docs/r/certificate_manager_trust_config.html.markdown @@ -128,6 +128,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `trust_stores` block supports: diff --git a/website/docs/r/ces_agent.html.markdown b/website/docs/r/ces_agent.html.markdown index 1f748aa91d6..ab335dbbaec 100644 --- a/website/docs/r/ces_agent.html.markdown +++ b/website/docs/r/ces_agent.html.markdown @@ -441,6 +441,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `after_agent_callbacks` block supports: diff --git a/website/docs/r/ces_app.html.markdown b/website/docs/r/ces_app.html.markdown index b81153f0c73..c5329ed7964 100644 --- a/website/docs/r/ces_app.html.markdown +++ b/website/docs/r/ces_app.html.markdown @@ -489,6 +489,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `audio_processing_config` block supports: diff --git a/website/docs/r/ces_app_root_agent_association.html.markdown b/website/docs/r/ces_app_root_agent_association.html.markdown index b4943d353c7..bbe99240a17 100644 --- a/website/docs/r/ces_app_root_agent_association.html.markdown +++ b/website/docs/r/ces_app_root_agent_association.html.markdown @@ -105,6 +105,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/ces_app_version.html.markdown b/website/docs/r/ces_app_version.html.markdown index 12a7dc45224..b8007f63b93 100644 --- a/website/docs/r/ces_app_version.html.markdown +++ b/website/docs/r/ces_app_version.html.markdown @@ -82,6 +82,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/ces_deployment.html.markdown b/website/docs/r/ces_deployment.html.markdown index 709de02e7fb..e46d016e8bf 100644 --- a/website/docs/r/ces_deployment.html.markdown +++ b/website/docs/r/ces_deployment.html.markdown @@ -97,6 +97,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `channel_profile` block supports: diff --git a/website/docs/r/ces_evaluation.html.markdown b/website/docs/r/ces_evaluation.html.markdown index 16748ef81d0..edca7059584 100644 --- a/website/docs/r/ces_evaluation.html.markdown +++ b/website/docs/r/ces_evaluation.html.markdown @@ -720,6 +720,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `golden` block supports: diff --git a/website/docs/r/ces_example.html.markdown b/website/docs/r/ces_example.html.markdown index 32134e59c72..82268b53457 100644 --- a/website/docs/r/ces_example.html.markdown +++ b/website/docs/r/ces_example.html.markdown @@ -241,6 +241,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `messages` block supports: diff --git a/website/docs/r/ces_guardrail.html.markdown b/website/docs/r/ces_guardrail.html.markdown index 42b498f03a6..76f1f05e27e 100644 --- a/website/docs/r/ces_guardrail.html.markdown +++ b/website/docs/r/ces_guardrail.html.markdown @@ -358,6 +358,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `action` block supports: diff --git a/website/docs/r/ces_tool.html.markdown b/website/docs/r/ces_tool.html.markdown index 7f2e255fd68..ab6546c322b 100644 --- a/website/docs/r/ces_tool.html.markdown +++ b/website/docs/r/ces_tool.html.markdown @@ -358,6 +358,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `client_function` block supports: diff --git a/website/docs/r/ces_toolset.html.markdown b/website/docs/r/ces_toolset.html.markdown index 6fb5ce7a49e..7d97ef66599 100644 --- a/website/docs/r/ces_toolset.html.markdown +++ b/website/docs/r/ces_toolset.html.markdown @@ -643,6 +643,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `open_api_toolset` block supports: diff --git a/website/docs/r/chronicle_dashboard_chart.html.markdown b/website/docs/r/chronicle_dashboard_chart.html.markdown index 0df0e81ecee..4954c6cdceb 100644 --- a/website/docs/r/chronicle_dashboard_chart.html.markdown +++ b/website/docs/r/chronicle_dashboard_chart.html.markdown @@ -346,6 +346,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `dashboard_chart` block supports: diff --git a/website/docs/r/chronicle_data_access_label.html.markdown b/website/docs/r/chronicle_data_access_label.html.markdown index 59bf0a61832..efe0e3147b6 100644 --- a/website/docs/r/chronicle_data_access_label.html.markdown +++ b/website/docs/r/chronicle_data_access_label.html.markdown @@ -75,6 +75,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/chronicle_data_access_scope.html.markdown b/website/docs/r/chronicle_data_access_scope.html.markdown index de8e5f680f0..1e7a38290ad 100644 --- a/website/docs/r/chronicle_data_access_scope.html.markdown +++ b/website/docs/r/chronicle_data_access_scope.html.markdown @@ -191,6 +191,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `allowed_data_access_labels` block supports: diff --git a/website/docs/r/chronicle_data_table.html.markdown b/website/docs/r/chronicle_data_table.html.markdown index f524e0b5b1b..66f9e46c565 100644 --- a/website/docs/r/chronicle_data_table.html.markdown +++ b/website/docs/r/chronicle_data_table.html.markdown @@ -165,7 +165,14 @@ The following arguments are supported: * `deletion_policy` - (Optional) The policy governing the deletion of the data table. If set to `FORCE`, allows the deletion of the data table even if it contains rows. If set to `DEFAULT`,or if the field is omitted, the data table must be empty before it can be deleted. -Possible values: DEFAULT, FORCE + +When a 'terraform destroy' or 'terraform apply' would delete the resource, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", the command will behave as if set to "DEFAULT". + +Possible values: DEFAULT, FORCE, PREVENT, ABANDON, DELETE diff --git a/website/docs/r/chronicle_data_table_row.html.markdown b/website/docs/r/chronicle_data_table_row.html.markdown index 2a6bd1fcbca..416e82bfe44 100644 --- a/website/docs/r/chronicle_data_table_row.html.markdown +++ b/website/docs/r/chronicle_data_table_row.html.markdown @@ -115,6 +115,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/chronicle_feed.html.markdown b/website/docs/r/chronicle_feed.html.markdown index 4ef4dc70d1c..aac73f1c5c9 100644 --- a/website/docs/r/chronicle_feed.html.markdown +++ b/website/docs/r/chronicle_feed.html.markdown @@ -215,6 +215,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `secret` - (Optional) Output only. The secret generated for the feed. This is only available when the feed source type is HTTPS_PUSH_AMAZON_KINESIS_FIREHOSE. * `feed_service_account` - (Optional) Output only. The service account used by Chronicle to ingest data from Cloud Storage. This is only available when the feed source type is GOOGLE_CLOUD_STORAGE_EVENT_DRIVEN or GOOGLE_CLOUD_STORAGE. diff --git a/website/docs/r/chronicle_native_dashboard.html.markdown b/website/docs/r/chronicle_native_dashboard.html.markdown index 225f8b92bc2..2b8fd184919 100644 --- a/website/docs/r/chronicle_native_dashboard.html.markdown +++ b/website/docs/r/chronicle_native_dashboard.html.markdown @@ -111,6 +111,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `charts` block supports: diff --git a/website/docs/r/chronicle_reference_list.html.markdown b/website/docs/r/chronicle_reference_list.html.markdown index 7152b350c2a..6951fed9a18 100644 --- a/website/docs/r/chronicle_reference_list.html.markdown +++ b/website/docs/r/chronicle_reference_list.html.markdown @@ -114,6 +114,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `entries` block supports: diff --git a/website/docs/r/chronicle_retrohunt.html.markdown b/website/docs/r/chronicle_retrohunt.html.markdown index 4fdf957a718..3e05241e23f 100644 --- a/website/docs/r/chronicle_retrohunt.html.markdown +++ b/website/docs/r/chronicle_retrohunt.html.markdown @@ -88,6 +88,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `process_interval` block supports: diff --git a/website/docs/r/chronicle_rule.html.markdown b/website/docs/r/chronicle_rule.html.markdown index ea5a4c60143..ef961e2cacc 100644 --- a/website/docs/r/chronicle_rule.html.markdown +++ b/website/docs/r/chronicle_rule.html.markdown @@ -124,9 +124,16 @@ The following arguments are supported: If deletion_policy = "FORCE", any retrohunts and any detections associated with the rule will also be deleted. If deletion_policy = "DEFAULT", the call will only succeed if the rule has no associated retrohunts, including completed retrohunts, and no -associated detections. Regardless of this field's value, the rule -deployment associated with this rule will also be deleted. -Possible values: DEFAULT, FORCE +associated detections. Regardless of being set to "FORCE" the rule +deployment associated with this rule will also be deleted if deletion is successful. + +When a 'terraform destroy' or 'terraform apply' would delete the resource, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", the command will behave as if set to "DEFAULT". + +Possible values: DEFAULT, FORCE, PREVENT, ABANDON, DELETE diff --git a/website/docs/r/chronicle_rule_deployment.html.markdown b/website/docs/r/chronicle_rule_deployment.html.markdown index c7d19c28059..eeccf173fa0 100644 --- a/website/docs/r/chronicle_rule_deployment.html.markdown +++ b/website/docs/r/chronicle_rule_deployment.html.markdown @@ -142,6 +142,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/chronicle_watchlist.html.markdown b/website/docs/r/chronicle_watchlist.html.markdown index c12e2bdc936..97b3f59cb47 100644 --- a/website/docs/r/chronicle_watchlist.html.markdown +++ b/website/docs/r/chronicle_watchlist.html.markdown @@ -122,6 +122,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `entity_population_mechanism` block supports: diff --git a/website/docs/r/cloud_asset_folder_feed.html.markdown b/website/docs/r/cloud_asset_folder_feed.html.markdown index 82bf356f916..2e735437f7c 100644 --- a/website/docs/r/cloud_asset_folder_feed.html.markdown +++ b/website/docs/r/cloud_asset_folder_feed.html.markdown @@ -137,6 +137,12 @@ The following arguments are supported: condition are optional. Structure is [documented below](#nested_condition). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `feed_output_config` block supports: diff --git a/website/docs/r/cloud_asset_organization_feed.html.markdown b/website/docs/r/cloud_asset_organization_feed.html.markdown index 953698347a7..bdc84019bf4 100644 --- a/website/docs/r/cloud_asset_organization_feed.html.markdown +++ b/website/docs/r/cloud_asset_organization_feed.html.markdown @@ -130,6 +130,12 @@ The following arguments are supported: condition are optional. Structure is [documented below](#nested_condition). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `feed_output_config` block supports: diff --git a/website/docs/r/cloud_asset_project_feed.html.markdown b/website/docs/r/cloud_asset_project_feed.html.markdown index eb21972b76c..239e022a537 100644 --- a/website/docs/r/cloud_asset_project_feed.html.markdown +++ b/website/docs/r/cloud_asset_project_feed.html.markdown @@ -128,6 +128,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `feed_output_config` block supports: diff --git a/website/docs/r/cloud_identity_group.html.markdown b/website/docs/r/cloud_identity_group.html.markdown index 48c0e1d9139..67343b6df21 100644 --- a/website/docs/r/cloud_identity_group.html.markdown +++ b/website/docs/r/cloud_identity_group.html.markdown @@ -100,6 +100,12 @@ The following arguments are supported: Default value is `EMPTY`. Possible values are: `INITIAL_GROUP_CONFIG_UNSPECIFIED`, `WITH_INITIAL_OWNER`, `EMPTY`. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `group_key` block supports: diff --git a/website/docs/r/cloud_identity_group_membership.html.markdown b/website/docs/r/cloud_identity_group_membership.html.markdown index 323923e2959..8f3fc73a829 100644 --- a/website/docs/r/cloud_identity_group_membership.html.markdown +++ b/website/docs/r/cloud_identity_group_membership.html.markdown @@ -141,6 +141,12 @@ The following arguments are supported: EntityKey of the member. Structure is [documented below](#nested_preferred_member_key). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `create_ignore_already_exists` - (Optional) If set to true, skip group member creation if a membership with the same name already exists. Defaults to false. diff --git a/website/docs/r/cloud_identity_policy.html.markdown b/website/docs/r/cloud_identity_policy.html.markdown index fe69a1c8f89..25bd1eae59e 100644 --- a/website/docs/r/cloud_identity_policy.html.markdown +++ b/website/docs/r/cloud_identity_policy.html.markdown @@ -75,6 +75,12 @@ The following arguments are supported: Structure is [documented below](#nested_setting). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `policy_query` block supports: diff --git a/website/docs/r/cloud_ids_endpoint.html.markdown b/website/docs/r/cloud_ids_endpoint.html.markdown index b48ea0d1d28..fea535ab7de 100644 --- a/website/docs/r/cloud_ids_endpoint.html.markdown +++ b/website/docs/r/cloud_ids_endpoint.html.markdown @@ -91,6 +91,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/cloud_quotas_quota_adjuster_settings.html.markdown b/website/docs/r/cloud_quotas_quota_adjuster_settings.html.markdown index ed27c6b6e4b..bff0ff7ddd2 100644 --- a/website/docs/r/cloud_quotas_quota_adjuster_settings.html.markdown +++ b/website/docs/r/cloud_quotas_quota_adjuster_settings.html.markdown @@ -58,6 +58,12 @@ The following arguments are supported: The parent of the quota preference. Allowed parent format is "projects/[project-id / number]". +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/cloud_quotas_quota_preference.html.markdown b/website/docs/r/cloud_quotas_quota_preference.html.markdown index 6ddcba12084..57103c5bf73 100644 --- a/website/docs/r/cloud_quotas_quota_preference.html.markdown +++ b/website/docs/r/cloud_quotas_quota_preference.html.markdown @@ -96,6 +96,12 @@ The following arguments are supported: Default value is `QUOTA_SAFETY_CHECK_UNSPECIFIED`. Possible values are: `QUOTA_SAFETY_CHECK_UNSPECIFIED`, `QUOTA_DECREASE_BELOW_USAGE`, `QUOTA_DECREASE_PERCENTAGE_TOO_HIGH`. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `quota_config` block supports: diff --git a/website/docs/r/cloud_run_domain_mapping.html.markdown b/website/docs/r/cloud_run_domain_mapping.html.markdown index 0174d12a48d..d962b5d860f 100644 --- a/website/docs/r/cloud_run_domain_mapping.html.markdown +++ b/website/docs/r/cloud_run_domain_mapping.html.markdown @@ -93,6 +93,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `spec` block supports: diff --git a/website/docs/r/cloud_run_service.html.markdown b/website/docs/r/cloud_run_service.html.markdown index e4c44c5c104..249a4f5dd8d 100644 --- a/website/docs/r/cloud_run_service.html.markdown +++ b/website/docs/r/cloud_run_service.html.markdown @@ -391,6 +391,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `autogenerate_revision_name` - (Optional) If set to `true`, the revision name (template.metadata.name) will be omitted and autogenerated by Cloud Run. This cannot be set to `true` while `template.metadata.name` is also set. diff --git a/website/docs/r/cloud_run_v2_job.html.markdown b/website/docs/r/cloud_run_v2_job.html.markdown index 110627c6657..fac33accdc5 100644 --- a/website/docs/r/cloud_run_v2_job.html.markdown +++ b/website/docs/r/cloud_run_v2_job.html.markdown @@ -534,6 +534,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `deletion_protection` - (Optional) Whether Terraform will be prevented from destroying the job. Defaults to true. When a`terraform destroy` or `terraform apply` would delete the job, the command will fail if this field is not set to false in Terraform state. diff --git a/website/docs/r/cloud_run_v2_service.html.markdown b/website/docs/r/cloud_run_v2_service.html.markdown index 927a3558747..82b21caf573 100644 --- a/website/docs/r/cloud_run_v2_service.html.markdown +++ b/website/docs/r/cloud_run_v2_service.html.markdown @@ -847,6 +847,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `deletion_protection` - (Optional) Whether Terraform will be prevented from destroying the service. Defaults to true. When a`terraform destroy` or `terraform apply` would delete the service, the command will fail if this field is not set to false in Terraform state. diff --git a/website/docs/r/cloud_run_v2_worker_pool.html.markdown b/website/docs/r/cloud_run_v2_worker_pool.html.markdown index a342c6295d4..c3dcde55e3a 100644 --- a/website/docs/r/cloud_run_v2_worker_pool.html.markdown +++ b/website/docs/r/cloud_run_v2_worker_pool.html.markdown @@ -644,6 +644,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `deletion_protection` - (Optional) Whether Terraform will be prevented from destroying the service. Defaults to true. When a`terraform destroy` or `terraform apply` would delete the service, the command will fail if this field is not set to false in Terraform state. diff --git a/website/docs/r/cloud_scheduler_job.html.markdown b/website/docs/r/cloud_scheduler_job.html.markdown index 42870118621..9afc4e3d47d 100644 --- a/website/docs/r/cloud_scheduler_job.html.markdown +++ b/website/docs/r/cloud_scheduler_job.html.markdown @@ -282,6 +282,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `retry_config` block supports: diff --git a/website/docs/r/cloud_security_compliance_cloud_control.html.markdown b/website/docs/r/cloud_security_compliance_cloud_control.html.markdown index 0835486c829..a28a58e8305 100644 --- a/website/docs/r/cloud_security_compliance_cloud_control.html.markdown +++ b/website/docs/r/cloud_security_compliance_cloud_control.html.markdown @@ -249,6 +249,12 @@ The following arguments are supported: (Optional) cloud providers supported +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `parameter_spec` block supports: diff --git a/website/docs/r/cloud_security_compliance_framework.html.markdown b/website/docs/r/cloud_security_compliance_framework.html.markdown index 566bd1a6f0c..d69a69fc0df 100644 --- a/website/docs/r/cloud_security_compliance_framework.html.markdown +++ b/website/docs/r/cloud_security_compliance_framework.html.markdown @@ -128,6 +128,12 @@ The following arguments are supported: (Optional) Display name of the framework. The maximum length is 200 characters. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `cloud_control_details` block supports: diff --git a/website/docs/r/cloud_security_compliance_framework_deployment.html.markdown b/website/docs/r/cloud_security_compliance_framework_deployment.html.markdown index 16de07ee4ba..da7cc600cb3 100644 --- a/website/docs/r/cloud_security_compliance_framework_deployment.html.markdown +++ b/website/docs/r/cloud_security_compliance_framework_deployment.html.markdown @@ -362,6 +362,12 @@ The following arguments are supported: (Optional) User provided description of the Framework deployment +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `cloud_control_metadata` block supports: diff --git a/website/docs/r/cloud_tasks_queue.html.markdown b/website/docs/r/cloud_tasks_queue.html.markdown index 8fb4b290afa..4219ca989fa 100644 --- a/website/docs/r/cloud_tasks_queue.html.markdown +++ b/website/docs/r/cloud_tasks_queue.html.markdown @@ -228,6 +228,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `desired_state` - (Optional) The desired state of the queue. Use this to pause and resume the queue. * RUNNING: The queue is running. Tasks can be dispatched. diff --git a/website/docs/r/cloudbuild_bitbucket_server_config.html.markdown b/website/docs/r/cloudbuild_bitbucket_server_config.html.markdown index f660548b931..d27531cd0da 100644 --- a/website/docs/r/cloudbuild_bitbucket_server_config.html.markdown +++ b/website/docs/r/cloudbuild_bitbucket_server_config.html.markdown @@ -182,6 +182,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `secrets` block supports: diff --git a/website/docs/r/cloudbuild_trigger.html.markdown b/website/docs/r/cloudbuild_trigger.html.markdown index 4ead392aa67..f632b8c6b99 100644 --- a/website/docs/r/cloudbuild_trigger.html.markdown +++ b/website/docs/r/cloudbuild_trigger.html.markdown @@ -939,6 +939,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `git_file_source` block supports: diff --git a/website/docs/r/cloudbuild_worker_pool.html.markdown b/website/docs/r/cloudbuild_worker_pool.html.markdown index 8cb61a4c548..82d904e0202 100644 --- a/website/docs/r/cloudbuild_worker_pool.html.markdown +++ b/website/docs/r/cloudbuild_worker_pool.html.markdown @@ -106,7 +106,13 @@ The following arguments are supported: * `worker_config` - (Optional) Configuration to be used for a creating workers in the `WorkerPool`. Structure is [documented below](#nested_worker_config). - + +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `network_config` block supports: diff --git a/website/docs/r/cloudbuildv2_connection.html.markdown b/website/docs/r/cloudbuildv2_connection.html.markdown index 4fb56a9c9d2..a64abe0c6bf 100644 --- a/website/docs/r/cloudbuildv2_connection.html.markdown +++ b/website/docs/r/cloudbuildv2_connection.html.markdown @@ -214,6 +214,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `github_config` block supports: diff --git a/website/docs/r/cloudbuildv2_repository.html.markdown b/website/docs/r/cloudbuildv2_repository.html.markdown index 780566e7555..ce99e7f689f 100644 --- a/website/docs/r/cloudbuildv2_repository.html.markdown +++ b/website/docs/r/cloudbuildv2_repository.html.markdown @@ -185,6 +185,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/clouddeploy_automation.html.markdown b/website/docs/r/clouddeploy_automation.html.markdown index 2e88d95d022..e6ebc3e9e9b 100644 --- a/website/docs/r/clouddeploy_automation.html.markdown +++ b/website/docs/r/clouddeploy_automation.html.markdown @@ -228,6 +228,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `selector` block supports: diff --git a/website/docs/r/clouddeploy_custom_target_type.html.markdown b/website/docs/r/clouddeploy_custom_target_type.html.markdown index 9c0fd3e7227..977b80511e7 100644 --- a/website/docs/r/clouddeploy_custom_target_type.html.markdown +++ b/website/docs/r/clouddeploy_custom_target_type.html.markdown @@ -211,6 +211,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `custom_actions` block supports: diff --git a/website/docs/r/clouddeploy_delivery_pipeline.html.markdown b/website/docs/r/clouddeploy_delivery_pipeline.html.markdown index c80eaec6823..601370ba4ba 100644 --- a/website/docs/r/clouddeploy_delivery_pipeline.html.markdown +++ b/website/docs/r/clouddeploy_delivery_pipeline.html.markdown @@ -288,7 +288,13 @@ Please refer to the field `effective_labels` for all of the labels present on th * `suspended` - (Optional) When suspended, no new releases or rollouts can be created, but in-progress ones will complete. - + +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `serial_pipeline` block supports: diff --git a/website/docs/r/clouddeploy_deploy_policy.html.markdown b/website/docs/r/clouddeploy_deploy_policy.html.markdown index 44a76199dab..bda614a4194 100644 --- a/website/docs/r/clouddeploy_deploy_policy.html.markdown +++ b/website/docs/r/clouddeploy_deploy_policy.html.markdown @@ -217,6 +217,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `selectors` block supports: diff --git a/website/docs/r/clouddeploy_target.html.markdown b/website/docs/r/clouddeploy_target.html.markdown index 0798fd52614..7e4c2da2067 100644 --- a/website/docs/r/clouddeploy_target.html.markdown +++ b/website/docs/r/clouddeploy_target.html.markdown @@ -203,7 +203,13 @@ Please refer to the field `effective_labels` for all of the labels present on th * `run` - (Optional) Information specifying a Cloud Run deployment target. - + +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `anthos_cluster` block supports: diff --git a/website/docs/r/clouddomains_registration.html.markdown b/website/docs/r/clouddomains_registration.html.markdown index cc35f6cb52e..0f7df203e53 100644 --- a/website/docs/r/clouddomains_registration.html.markdown +++ b/website/docs/r/clouddomains_registration.html.markdown @@ -152,6 +152,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `yearly_price` block supports: diff --git a/website/docs/r/cloudfunctions2_function.html.markdown b/website/docs/r/cloudfunctions2_function.html.markdown index 05447db123f..babee0c0f47 100644 --- a/website/docs/r/cloudfunctions2_function.html.markdown +++ b/website/docs/r/cloudfunctions2_function.html.markdown @@ -1091,6 +1091,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `build_config` block supports: diff --git a/website/docs/r/cloudfunctions_function.html.markdown b/website/docs/r/cloudfunctions_function.html.markdown index cb26ea0e9f6..ed4898dd8fa 100644 --- a/website/docs/r/cloudfunctions_function.html.markdown +++ b/website/docs/r/cloudfunctions_function.html.markdown @@ -197,6 +197,13 @@ Please refer to the field 'effective_labels' for all of the labels present on th * `on_deploy_update_policy` - (Optional) Security patches are only applied when a function is redeployed. This should be specified as an empty block and cannot be set alongside `automatic_update_policy`. Structure is [documented below](#nested_on_deploy_update_policy). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + The `event_trigger` block supports: * `event_type` - (Required) The type of event to observe. For example: `"google.storage.object.finalize"`. diff --git a/website/docs/r/colab_notebook_execution.html.markdown b/website/docs/r/colab_notebook_execution.html.markdown index 5c85d90aa26..bae8c7475d5 100644 --- a/website/docs/r/colab_notebook_execution.html.markdown +++ b/website/docs/r/colab_notebook_execution.html.markdown @@ -458,6 +458,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `dataform_repository_source` block supports: diff --git a/website/docs/r/colab_runtime.html.markdown b/website/docs/r/colab_runtime.html.markdown index 3d877c78fe1..43cf4468ed9 100644 --- a/website/docs/r/colab_runtime.html.markdown +++ b/website/docs/r/colab_runtime.html.markdown @@ -218,6 +218,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `desired_state` - (Optional) Desired state of the Colab Runtime. Set this field to `RUNNING` to start the runtime, and `STOPPED` to stop it. * `auto_upgrade` - (Optional) Triggers an upgrade anytime the runtime is started if it is upgradable. diff --git a/website/docs/r/colab_runtime_template.html.markdown b/website/docs/r/colab_runtime_template.html.markdown index 7f25223354b..302a3ac0e31 100644 --- a/website/docs/r/colab_runtime_template.html.markdown +++ b/website/docs/r/colab_runtime_template.html.markdown @@ -240,6 +240,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `machine_spec` block supports: diff --git a/website/docs/r/colab_schedule.html.markdown b/website/docs/r/colab_schedule.html.markdown index 2583c44f466..042c3d7ef47 100644 --- a/website/docs/r/colab_schedule.html.markdown +++ b/website/docs/r/colab_schedule.html.markdown @@ -367,6 +367,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `desired_state` - (Optional) Desired state of the Colab Schedule. Set this field to `ACTIVE` to start/resume the schedule, and `PAUSED` to pause the schedule. diff --git a/website/docs/r/composer_environment.html.markdown b/website/docs/r/composer_environment.html.markdown index 4140bf296da..ded4daaba96 100644 --- a/website/docs/r/composer_environment.html.markdown +++ b/website/docs/r/composer_environment.html.markdown @@ -472,6 +472,14 @@ The following arguments are supported: (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - + (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + * `storage_config` - (Optional) Configuration options for storage used by the environment. Structure is diff --git a/website/docs/r/composer_user_workloads_config_map.html.markdown b/website/docs/r/composer_user_workloads_config_map.html.markdown index cd405452925..66e6ef9fd78 100644 --- a/website/docs/r/composer_user_workloads_config_map.html.markdown +++ b/website/docs/r/composer_user_workloads_config_map.html.markdown @@ -101,6 +101,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/composer_user_workloads_secret.html.markdown b/website/docs/r/composer_user_workloads_secret.html.markdown index 0710fa534af..b957fac937d 100644 --- a/website/docs/r/composer_user_workloads_secret.html.markdown +++ b/website/docs/r/composer_user_workloads_secret.html.markdown @@ -80,6 +80,13 @@ The following arguments are supported: The values for all keys have to be base64-encoded strings. For details see: https://kubernetes.io/docs/concepts/configuration/secret/ +* `deletion_policy` - + (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/compute_address.html.markdown b/website/docs/r/compute_address.html.markdown index 7d4e8065ebb..ea578b4fe8c 100644 --- a/website/docs/r/compute_address.html.markdown +++ b/website/docs/r/compute_address.html.markdown @@ -292,6 +292,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/compute_attached_disk.html.markdown b/website/docs/r/compute_attached_disk.html.markdown index 47be7baa3be..a202d3fbf71 100644 --- a/website/docs/r/compute_attached_disk.html.markdown +++ b/website/docs/r/compute_attached_disk.html.markdown @@ -127,6 +127,13 @@ The following arguments are supported: "SCSI" "NVME" +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + ## Attributes Reference In addition to the arguments listed above, the following computed attributes are exported: diff --git a/website/docs/r/compute_autoscaler.html.markdown b/website/docs/r/compute_autoscaler.html.markdown index 05495e5be06..79962c1f5cb 100644 --- a/website/docs/r/compute_autoscaler.html.markdown +++ b/website/docs/r/compute_autoscaler.html.markdown @@ -233,6 +233,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `autoscaling_policy` block supports: diff --git a/website/docs/r/compute_backend_bucket.html.markdown b/website/docs/r/compute_backend_bucket.html.markdown index 2aa14410095..1bd0a836477 100644 --- a/website/docs/r/compute_backend_bucket.html.markdown +++ b/website/docs/r/compute_backend_bucket.html.markdown @@ -202,6 +202,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `cdn_policy` block supports: diff --git a/website/docs/r/compute_backend_bucket_signed_url_key.html.markdown b/website/docs/r/compute_backend_bucket_signed_url_key.html.markdown index 66133674133..ac53db25873 100644 --- a/website/docs/r/compute_backend_bucket_signed_url_key.html.markdown +++ b/website/docs/r/compute_backend_bucket_signed_url_key.html.markdown @@ -84,6 +84,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/compute_backend_service.html.markdown b/website/docs/r/compute_backend_service.html.markdown index d8a82d464e9..10c96b581b2 100644 --- a/website/docs/r/compute_backend_service.html.markdown +++ b/website/docs/r/compute_backend_service.html.markdown @@ -1047,6 +1047,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `backend` block supports: diff --git a/website/docs/r/compute_backend_service_signed_url_key.html.markdown b/website/docs/r/compute_backend_service_signed_url_key.html.markdown index 5f936730157..eb7d8feb221 100644 --- a/website/docs/r/compute_backend_service_signed_url_key.html.markdown +++ b/website/docs/r/compute_backend_service_signed_url_key.html.markdown @@ -122,6 +122,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/compute_cross_site_network.html.markdown b/website/docs/r/compute_cross_site_network.html.markdown index 4235d02b546..8abd02d61bc 100644 --- a/website/docs/r/compute_cross_site_network.html.markdown +++ b/website/docs/r/compute_cross_site_network.html.markdown @@ -64,6 +64,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/compute_disk.html.markdown b/website/docs/r/compute_disk.html.markdown index 3d3c06e1c99..0a3f3e7bfaa 100644 --- a/website/docs/r/compute_disk.html.markdown +++ b/website/docs/r/compute_disk.html.markdown @@ -353,6 +353,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `create_snapshot_before_destroy` - (Optional) If set to true, a snapshot of the disk will be created before it is destroyed. If your disk is encrypted with customer managed encryption keys these will be reused for the snapshot creation. The name of the snapshot by default will be `{{disk-name}}-YYYYMMDD-HHmm` diff --git a/website/docs/r/compute_disk_async_replication.html.markdown b/website/docs/r/compute_disk_async_replication.html.markdown index 0224aa365f9..b0e16b2c966 100644 --- a/website/docs/r/compute_disk_async_replication.html.markdown +++ b/website/docs/r/compute_disk_async_replication.html.markdown @@ -63,6 +63,13 @@ The following arguments are supported: * `secondary_disk` - (Required) The secondary disk (target of replication). You can specify only one value. Structure is documented below. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + The `secondary_disk` block includes: * `disk` - (Required) The secondary disk. diff --git a/website/docs/r/compute_disk_resource_policy_attachment.html.markdown b/website/docs/r/compute_disk_resource_policy_attachment.html.markdown index ce3ada00577..a2429f90668 100644 --- a/website/docs/r/compute_disk_resource_policy_attachment.html.markdown +++ b/website/docs/r/compute_disk_resource_policy_attachment.html.markdown @@ -92,6 +92,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/compute_external_vpn_gateway.html.markdown b/website/docs/r/compute_external_vpn_gateway.html.markdown index f9880e82d03..dfad0996a19 100644 --- a/website/docs/r/compute_external_vpn_gateway.html.markdown +++ b/website/docs/r/compute_external_vpn_gateway.html.markdown @@ -184,6 +184,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `interface` block supports: diff --git a/website/docs/r/compute_firewall.html.markdown b/website/docs/r/compute_firewall.html.markdown index 4ec42ada824..640e362d3ac 100644 --- a/website/docs/r/compute_firewall.html.markdown +++ b/website/docs/r/compute_firewall.html.markdown @@ -228,6 +228,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `enable_logging` - (Optional, Deprecated) This field denotes whether to enable logging for a particular firewall rule. If logging is enabled, logs will be exported to Stackdriver. Deprecated in favor of `log_config` diff --git a/website/docs/r/compute_firewall_policy.html.markdown b/website/docs/r/compute_firewall_policy.html.markdown index 3a2356a1132..4f47a3133fe 100644 --- a/website/docs/r/compute_firewall_policy.html.markdown +++ b/website/docs/r/compute_firewall_policy.html.markdown @@ -63,6 +63,12 @@ The following arguments are supported: (Optional) An optional description of this resource. Provide this property when you create the resource. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/compute_firewall_policy_association.html.markdown b/website/docs/r/compute_firewall_policy_association.html.markdown index 21bf85fe748..1f37646c80a 100644 --- a/website/docs/r/compute_firewall_policy_association.html.markdown +++ b/website/docs/r/compute_firewall_policy_association.html.markdown @@ -99,6 +99,12 @@ The following arguments are supported: on your exisiting firewall policy so as to prevent a situation where your attachment target has no associated policy. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/compute_firewall_policy_rule.html.markdown b/website/docs/r/compute_firewall_policy_rule.html.markdown index 51e1f13991b..abd5e96f46d 100644 --- a/website/docs/r/compute_firewall_policy_rule.html.markdown +++ b/website/docs/r/compute_firewall_policy_rule.html.markdown @@ -369,6 +369,12 @@ The following arguments are supported: When set to true, the firewall policy rule is not enforced and traffic behaves as if it did not exist. If this is unspecified, the firewall policy rule will be enabled. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `match` block supports: diff --git a/website/docs/r/compute_firewall_policy_with_rules.html.markdown b/website/docs/r/compute_firewall_policy_with_rules.html.markdown index 7c4d25b3648..8fef803ebd7 100644 --- a/website/docs/r/compute_firewall_policy_with_rules.html.markdown +++ b/website/docs/r/compute_firewall_policy_with_rules.html.markdown @@ -199,6 +199,12 @@ The following arguments are supported: (Optional) An optional description of this resource. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `rule` block supports: diff --git a/website/docs/r/compute_forwarding_rule.html.markdown b/website/docs/r/compute_forwarding_rule.html.markdown index 3f70c818d42..936eb9d406f 100644 --- a/website/docs/r/compute_forwarding_rule.html.markdown +++ b/website/docs/r/compute_forwarding_rule.html.markdown @@ -1626,6 +1626,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `recreate_closed_psc` - (Optional) This is used in PSC consumer ForwardingRule to make terraform recreate the ForwardingRule when the status is closed diff --git a/website/docs/r/compute_future_reservation.html.markdown b/website/docs/r/compute_future_reservation.html.markdown index e90e0fc9c86..5c3de29af6a 100644 --- a/website/docs/r/compute_future_reservation.html.markdown +++ b/website/docs/r/compute_future_reservation.html.markdown @@ -191,6 +191,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `time_window` block supports: diff --git a/website/docs/r/compute_global_address.html.markdown b/website/docs/r/compute_global_address.html.markdown index 5b3ac788a89..32fb44ce488 100644 --- a/website/docs/r/compute_global_address.html.markdown +++ b/website/docs/r/compute_global_address.html.markdown @@ -138,6 +138,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/compute_global_forwarding_rule.html.markdown b/website/docs/r/compute_global_forwarding_rule.html.markdown index 4c138f13da9..b7b6f650a7a 100644 --- a/website/docs/r/compute_global_forwarding_rule.html.markdown +++ b/website/docs/r/compute_global_forwarding_rule.html.markdown @@ -1405,6 +1405,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `metadata_filters` block supports: diff --git a/website/docs/r/compute_global_network_endpoint.html.markdown b/website/docs/r/compute_global_network_endpoint.html.markdown index a4ad040685d..ffb9991841a 100644 --- a/website/docs/r/compute_global_network_endpoint.html.markdown +++ b/website/docs/r/compute_global_network_endpoint.html.markdown @@ -75,6 +75,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/compute_global_network_endpoint_group.html.markdown b/website/docs/r/compute_global_network_endpoint_group.html.markdown index 859d0b55d77..35d8fecf916 100644 --- a/website/docs/r/compute_global_network_endpoint_group.html.markdown +++ b/website/docs/r/compute_global_network_endpoint_group.html.markdown @@ -100,6 +100,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/compute_ha_vpn_gateway.html.markdown b/website/docs/r/compute_ha_vpn_gateway.html.markdown index 52dfa74ff8b..1cc95d97f81 100644 --- a/website/docs/r/compute_ha_vpn_gateway.html.markdown +++ b/website/docs/r/compute_ha_vpn_gateway.html.markdown @@ -211,6 +211,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `vpn_interfaces` block supports: diff --git a/website/docs/r/compute_health_check.html.markdown b/website/docs/r/compute_health_check.html.markdown index 2a930d81190..6a576e193e6 100644 --- a/website/docs/r/compute_health_check.html.markdown +++ b/website/docs/r/compute_health_check.html.markdown @@ -559,6 +559,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `http_health_check` block supports: diff --git a/website/docs/r/compute_http_health_check.html.markdown b/website/docs/r/compute_http_health_check.html.markdown index 62919859bd9..b314708ec4b 100644 --- a/website/docs/r/compute_http_health_check.html.markdown +++ b/website/docs/r/compute_http_health_check.html.markdown @@ -116,6 +116,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/compute_https_health_check.html.markdown b/website/docs/r/compute_https_health_check.html.markdown index 34f015597c6..8508e982189 100644 --- a/website/docs/r/compute_https_health_check.html.markdown +++ b/website/docs/r/compute_https_health_check.html.markdown @@ -116,6 +116,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/compute_image.html.markdown b/website/docs/r/compute_image.html.markdown index f9485a59e92..21970a8feac 100644 --- a/website/docs/r/compute_image.html.markdown +++ b/website/docs/r/compute_image.html.markdown @@ -279,6 +279,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `guest_os_features` block supports: diff --git a/website/docs/r/compute_instance.html.markdown b/website/docs/r/compute_instance.html.markdown index 4914384e8e3..11ab51f9e0a 100644 --- a/website/docs/r/compute_instance.html.markdown +++ b/website/docs/r/compute_instance.html.markdown @@ -270,6 +270,13 @@ is desired, you will need to modify your state file manually using * `erase_windows_vss_signature` - (optional) [Beta](../guides/provider_versions.html.markdown) Specifies whether the disks restored from source snapshots or source machine image should erase Windows specific VSS signature. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + --- The `boot_disk` block supports: diff --git a/website/docs/r/compute_instance_group.html.markdown b/website/docs/r/compute_instance_group.html.markdown index d331034d387..4206f6af025 100644 --- a/website/docs/r/compute_instance_group.html.markdown +++ b/website/docs/r/compute_instance_group.html.markdown @@ -160,6 +160,13 @@ The following arguments are supported: fails. Defaults to the network where the instances are in (if neither `network` nor `instances` is specified, this field will be blank). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + The `named_port` block supports: * `name` - (Required) The name which the port will be mapped to. diff --git a/website/docs/r/compute_instance_group_manager.html.markdown b/website/docs/r/compute_instance_group_manager.html.markdown index 493b3e47faf..55b3353a25b 100644 --- a/website/docs/r/compute_instance_group_manager.html.markdown +++ b/website/docs/r/compute_instance_group_manager.html.markdown @@ -272,6 +272,13 @@ group. You can specify only one value. Structure is [documented below](#nested_a * `target_size_policy` - (Optional) The policy that specifies how the MIG creates its VMs to achieve the target size. Structure is [documented below](#nested_target_size_policy). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + - - - The `standby_policy` block supports: diff --git a/website/docs/r/compute_instance_group_membership.html.markdown b/website/docs/r/compute_instance_group_membership.html.markdown index d9ae2504a1b..59c433b173c 100644 --- a/website/docs/r/compute_instance_group_membership.html.markdown +++ b/website/docs/r/compute_instance_group_membership.html.markdown @@ -95,6 +95,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/compute_instance_group_named_port.html.markdown b/website/docs/r/compute_instance_group_named_port.html.markdown index 66373c34b71..3afcae4de55 100644 --- a/website/docs/r/compute_instance_group_named_port.html.markdown +++ b/website/docs/r/compute_instance_group_named_port.html.markdown @@ -113,6 +113,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/compute_instance_settings.html.markdown b/website/docs/r/compute_instance_settings.html.markdown index ebe7764e370..508bc97d246 100644 --- a/website/docs/r/compute_instance_settings.html.markdown +++ b/website/docs/r/compute_instance_settings.html.markdown @@ -68,6 +68,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `metadata` block supports: diff --git a/website/docs/r/compute_instant_snapshot.html.markdown b/website/docs/r/compute_instant_snapshot.html.markdown index 9b72e5ea032..5b9b859ff2d 100644 --- a/website/docs/r/compute_instant_snapshot.html.markdown +++ b/website/docs/r/compute_instant_snapshot.html.markdown @@ -100,6 +100,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `params` block supports: diff --git a/website/docs/r/compute_interconnect.html.markdown b/website/docs/r/compute_interconnect.html.markdown index bda62c1e6af..6b5b1b7b078 100644 --- a/website/docs/r/compute_interconnect.html.markdown +++ b/website/docs/r/compute_interconnect.html.markdown @@ -163,6 +163,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `params` block supports: diff --git a/website/docs/r/compute_interconnect_attachment.html.markdown b/website/docs/r/compute_interconnect_attachment.html.markdown index 4e1ff853439..61cc572ce35 100644 --- a/website/docs/r/compute_interconnect_attachment.html.markdown +++ b/website/docs/r/compute_interconnect_attachment.html.markdown @@ -319,6 +319,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `params` block supports: diff --git a/website/docs/r/compute_interconnect_attachment_group.html.markdown b/website/docs/r/compute_interconnect_attachment_group.html.markdown index ba541a2438d..7c5afeea38e 100644 --- a/website/docs/r/compute_interconnect_attachment_group.html.markdown +++ b/website/docs/r/compute_interconnect_attachment_group.html.markdown @@ -91,6 +91,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `intent` block supports: diff --git a/website/docs/r/compute_interconnect_group.html.markdown b/website/docs/r/compute_interconnect_group.html.markdown index c0726b7b36b..06df384fc3f 100644 --- a/website/docs/r/compute_interconnect_group.html.markdown +++ b/website/docs/r/compute_interconnect_group.html.markdown @@ -85,6 +85,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `intent` block supports: diff --git a/website/docs/r/compute_machine_image.html.markdown b/website/docs/r/compute_machine_image.html.markdown index c59118fd816..d2f45d5b59c 100644 --- a/website/docs/r/compute_machine_image.html.markdown +++ b/website/docs/r/compute_machine_image.html.markdown @@ -203,6 +203,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `machine_image_encryption_key` block supports: diff --git a/website/docs/r/compute_managed_ssl_certificate.html.markdown b/website/docs/r/compute_managed_ssl_certificate.html.markdown index 531543d39f6..4c829b24a6f 100644 --- a/website/docs/r/compute_managed_ssl_certificate.html.markdown +++ b/website/docs/r/compute_managed_ssl_certificate.html.markdown @@ -229,6 +229,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `managed` block supports: diff --git a/website/docs/r/compute_network.html.markdown b/website/docs/r/compute_network.html.markdown index 58051482e0e..7caa661832c 100644 --- a/website/docs/r/compute_network.html.markdown +++ b/website/docs/r/compute_network.html.markdown @@ -217,6 +217,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `delete_default_routes_on_create` - (Optional) If set to `true`, default routes (`0.0.0.0/0`) will be deleted immediately after network creation. Defaults to `false`. diff --git a/website/docs/r/compute_network_attachment.html.markdown b/website/docs/r/compute_network_attachment.html.markdown index 3d40bfb2f18..6bbbffd4b84 100644 --- a/website/docs/r/compute_network_attachment.html.markdown +++ b/website/docs/r/compute_network_attachment.html.markdown @@ -176,6 +176,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/compute_network_edge_security_service.html.markdown b/website/docs/r/compute_network_edge_security_service.html.markdown index 208b3192ca4..bf932dba1a0 100644 --- a/website/docs/r/compute_network_edge_security_service.html.markdown +++ b/website/docs/r/compute_network_edge_security_service.html.markdown @@ -70,6 +70,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/compute_network_endpoint.html.markdown b/website/docs/r/compute_network_endpoint.html.markdown index 564abda67e9..0e14e213198 100644 --- a/website/docs/r/compute_network_endpoint.html.markdown +++ b/website/docs/r/compute_network_endpoint.html.markdown @@ -129,6 +129,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/compute_network_endpoint_group.html.markdown b/website/docs/r/compute_network_endpoint_group.html.markdown index a9d9192d8d3..9ae94a7ae4a 100644 --- a/website/docs/r/compute_network_endpoint_group.html.markdown +++ b/website/docs/r/compute_network_endpoint_group.html.markdown @@ -157,6 +157,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/compute_network_endpoints.html.markdown b/website/docs/r/compute_network_endpoints.html.markdown index fad79df4394..668ff430193 100644 --- a/website/docs/r/compute_network_endpoints.html.markdown +++ b/website/docs/r/compute_network_endpoints.html.markdown @@ -144,6 +144,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `network_endpoints` block supports: diff --git a/website/docs/r/compute_network_firewall_policy.html.markdown b/website/docs/r/compute_network_firewall_policy.html.markdown index d5239fb7c2a..710fd32ffe7 100644 --- a/website/docs/r/compute_network_firewall_policy.html.markdown +++ b/website/docs/r/compute_network_firewall_policy.html.markdown @@ -64,6 +64,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/compute_network_firewall_policy_association.html.markdown b/website/docs/r/compute_network_firewall_policy_association.html.markdown index fba1a0c2369..d2fc18ca403 100644 --- a/website/docs/r/compute_network_firewall_policy_association.html.markdown +++ b/website/docs/r/compute_network_firewall_policy_association.html.markdown @@ -72,6 +72,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/compute_network_firewall_policy_packet_mirroring_rule.html.markdown b/website/docs/r/compute_network_firewall_policy_packet_mirroring_rule.html.markdown index 788f0a754de..450b0704d55 100644 --- a/website/docs/r/compute_network_firewall_policy_packet_mirroring_rule.html.markdown +++ b/website/docs/r/compute_network_firewall_policy_packet_mirroring_rule.html.markdown @@ -192,6 +192,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `match` block supports: diff --git a/website/docs/r/compute_network_firewall_policy_rule.html.markdown b/website/docs/r/compute_network_firewall_policy_rule.html.markdown index 0ec2b0c9f89..30d28470d09 100644 --- a/website/docs/r/compute_network_firewall_policy_rule.html.markdown +++ b/website/docs/r/compute_network_firewall_policy_rule.html.markdown @@ -309,6 +309,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `match` block supports: diff --git a/website/docs/r/compute_network_firewall_policy_with_rules.html.markdown b/website/docs/r/compute_network_firewall_policy_with_rules.html.markdown index d91ebe40c47..710863a4eae 100644 --- a/website/docs/r/compute_network_firewall_policy_with_rules.html.markdown +++ b/website/docs/r/compute_network_firewall_policy_with_rules.html.markdown @@ -183,6 +183,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `rule` block supports: diff --git a/website/docs/r/compute_network_peering.html.markdown b/website/docs/r/compute_network_peering.html.markdown index 176cd839d51..504e037c609 100644 --- a/website/docs/r/compute_network_peering.html.markdown +++ b/website/docs/r/compute_network_peering.html.markdown @@ -85,6 +85,14 @@ Which IP version(s) of traffic and routes are allowed to be imported or exported * `update_strategy` - (Optional) The update strategy determines the semantics for updates and deletes to the peering connection configuration. The default value is INDEPENDENT. Possible values: ["INDEPENDENT", "CONSENSUS"] +* `deletion_policy` - + (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + ## Attributes Reference In addition to the arguments listed above, the following computed attributes are diff --git a/website/docs/r/compute_network_peering_routes_config.html.markdown b/website/docs/r/compute_network_peering_routes_config.html.markdown index c44b9428735..9c0fcea92d2 100644 --- a/website/docs/r/compute_network_peering_routes_config.html.markdown +++ b/website/docs/r/compute_network_peering_routes_config.html.markdown @@ -118,6 +118,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/compute_node_group.html.markdown b/website/docs/r/compute_node_group.html.markdown index 93b7a0a80be..65a9a30a9c9 100644 --- a/website/docs/r/compute_node_group.html.markdown +++ b/website/docs/r/compute_node_group.html.markdown @@ -206,6 +206,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `maintenance_window` block supports: diff --git a/website/docs/r/compute_node_template.html.markdown b/website/docs/r/compute_node_template.html.markdown index fdd568e5331..41b66f26173 100644 --- a/website/docs/r/compute_node_template.html.markdown +++ b/website/docs/r/compute_node_template.html.markdown @@ -188,6 +188,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `node_type_flexibility` block supports: diff --git a/website/docs/r/compute_organization_security_policy.html.markdown b/website/docs/r/compute_organization_security_policy.html.markdown index 3a642625559..cc84634c86b 100644 --- a/website/docs/r/compute_organization_security_policy.html.markdown +++ b/website/docs/r/compute_organization_security_policy.html.markdown @@ -97,6 +97,12 @@ The following arguments are supported: Additional options for this security policy. Structure is [documented below](#nested_advanced_options_config). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `advanced_options_config` block supports: diff --git a/website/docs/r/compute_organization_security_policy_association.html.markdown b/website/docs/r/compute_organization_security_policy_association.html.markdown index c0677f54f91..7576643dd64 100644 --- a/website/docs/r/compute_organization_security_policy_association.html.markdown +++ b/website/docs/r/compute_organization_security_policy_association.html.markdown @@ -79,6 +79,12 @@ The following arguments are supported: (Optional) A list of folders to exclude from the security policy. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/compute_organization_security_policy_rule.html.markdown b/website/docs/r/compute_organization_security_policy_rule.html.markdown index 664e855c867..9b185631a3a 100644 --- a/website/docs/r/compute_organization_security_policy_rule.html.markdown +++ b/website/docs/r/compute_organization_security_policy_rule.html.markdown @@ -299,6 +299,12 @@ The following arguments are supported: A list of service accounts indicating the sets of instances that are applied with this rule. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `match` block supports: diff --git a/website/docs/r/compute_packet_mirroring.html.markdown b/website/docs/r/compute_packet_mirroring.html.markdown index 013cd0bb4ba..c943fe24122 100644 --- a/website/docs/r/compute_packet_mirroring.html.markdown +++ b/website/docs/r/compute_packet_mirroring.html.markdown @@ -183,6 +183,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `network` block supports: diff --git a/website/docs/r/compute_per_instance_config.html.markdown b/website/docs/r/compute_per_instance_config.html.markdown index b5acf44062b..4128bf3dc14 100644 --- a/website/docs/r/compute_per_instance_config.html.markdown +++ b/website/docs/r/compute_per_instance_config.html.markdown @@ -131,6 +131,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `minimal_action` - (Optional) The minimal action to perform on the instance during an update. Default is `NONE`. Possible values are: * REPLACE diff --git a/website/docs/r/compute_preview_feature.html.markdown b/website/docs/r/compute_preview_feature.html.markdown index 2bd577d2146..26c0a1f5b76 100644 --- a/website/docs/r/compute_preview_feature.html.markdown +++ b/website/docs/r/compute_preview_feature.html.markdown @@ -73,6 +73,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `rollout_operation` block supports: diff --git a/website/docs/r/compute_project_cloud_armor_tier.html.markdown b/website/docs/r/compute_project_cloud_armor_tier.html.markdown index 15653dc1f3d..fa1c9239642 100644 --- a/website/docs/r/compute_project_cloud_armor_tier.html.markdown +++ b/website/docs/r/compute_project_cloud_armor_tier.html.markdown @@ -76,6 +76,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/compute_project_metadata.html.markdown b/website/docs/r/compute_project_metadata.html.markdown index 03f62a60657..2c8451ea304 100644 --- a/website/docs/r/compute_project_metadata.html.markdown +++ b/website/docs/r/compute_project_metadata.html.markdown @@ -71,6 +71,13 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + ## Attributes Reference In addition to the arguments listed above, the following computed attributes are exported: diff --git a/website/docs/r/compute_project_metadata_item.html.markdown b/website/docs/r/compute_project_metadata_item.html.markdown index fd50d7adacf..666e7392bbc 100644 --- a/website/docs/r/compute_project_metadata_item.html.markdown +++ b/website/docs/r/compute_project_metadata_item.html.markdown @@ -47,6 +47,13 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + ## Attributes Reference In addition to the arguments listed above, the following computed attributes are exported: diff --git a/website/docs/r/compute_public_advertised_prefix.html.markdown b/website/docs/r/compute_public_advertised_prefix.html.markdown index 3c7225e4826..7e613e65eb1 100644 --- a/website/docs/r/compute_public_advertised_prefix.html.markdown +++ b/website/docs/r/compute_public_advertised_prefix.html.markdown @@ -117,6 +117,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/compute_public_delegated_prefix.html.markdown b/website/docs/r/compute_public_delegated_prefix.html.markdown index daec54c88f4..9e6a48e386b 100644 --- a/website/docs/r/compute_public_delegated_prefix.html.markdown +++ b/website/docs/r/compute_public_delegated_prefix.html.markdown @@ -192,6 +192,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/compute_region_autoscaler.html.markdown b/website/docs/r/compute_region_autoscaler.html.markdown index 022215cdb15..d50df2a047f 100644 --- a/website/docs/r/compute_region_autoscaler.html.markdown +++ b/website/docs/r/compute_region_autoscaler.html.markdown @@ -152,6 +152,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `autoscaling_policy` block supports: diff --git a/website/docs/r/compute_region_backend_bucket.html.markdown b/website/docs/r/compute_region_backend_bucket.html.markdown index bc7dca2d377..937e5892e41 100644 --- a/website/docs/r/compute_region_backend_bucket.html.markdown +++ b/website/docs/r/compute_region_backend_bucket.html.markdown @@ -211,6 +211,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/compute_region_backend_service.html.markdown b/website/docs/r/compute_region_backend_service.html.markdown index 7486f632fc9..4fc3085f481 100644 --- a/website/docs/r/compute_region_backend_service.html.markdown +++ b/website/docs/r/compute_region_backend_service.html.markdown @@ -1023,6 +1023,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `backend` block supports: diff --git a/website/docs/r/compute_region_commitment.html.markdown b/website/docs/r/compute_region_commitment.html.markdown index ae3db3c4ac0..28f01c9cd1a 100644 --- a/website/docs/r/compute_region_commitment.html.markdown +++ b/website/docs/r/compute_region_commitment.html.markdown @@ -162,6 +162,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `resources` block supports: diff --git a/website/docs/r/compute_region_composite_health_check.html.markdown b/website/docs/r/compute_region_composite_health_check.html.markdown index 4fbd69f5d02..480f83e901a 100644 --- a/website/docs/r/compute_region_composite_health_check.html.markdown +++ b/website/docs/r/compute_region_composite_health_check.html.markdown @@ -143,6 +143,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/compute_region_disk.html.markdown b/website/docs/r/compute_region_disk.html.markdown index b901bba27c9..917d057ce6e 100644 --- a/website/docs/r/compute_region_disk.html.markdown +++ b/website/docs/r/compute_region_disk.html.markdown @@ -329,6 +329,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `create_snapshot_before_destroy` - (Optional) If set to true, a snapshot of the disk will be created before it is destroyed. If your disk is encrypted with customer managed encryption keys these will be reused for the snapshot creation. The name of the snapshot by default will be `{{disk-name}}-YYYYMMDD-HHmm` diff --git a/website/docs/r/compute_region_disk_resource_policy_attachment.html.markdown b/website/docs/r/compute_region_disk_resource_policy_attachment.html.markdown index 355532d3cff..b7d59961316 100644 --- a/website/docs/r/compute_region_disk_resource_policy_attachment.html.markdown +++ b/website/docs/r/compute_region_disk_resource_policy_attachment.html.markdown @@ -107,6 +107,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/compute_region_health_aggregation_policy.html.markdown b/website/docs/r/compute_region_health_aggregation_policy.html.markdown index 000e59b4e8b..8cca97f6f11 100644 --- a/website/docs/r/compute_region_health_aggregation_policy.html.markdown +++ b/website/docs/r/compute_region_health_aggregation_policy.html.markdown @@ -110,6 +110,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/compute_region_health_check.html.markdown b/website/docs/r/compute_region_health_check.html.markdown index c7dfacf172f..fdc1c816dcb 100644 --- a/website/docs/r/compute_region_health_check.html.markdown +++ b/website/docs/r/compute_region_health_check.html.markdown @@ -482,6 +482,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `http_health_check` block supports: diff --git a/website/docs/r/compute_region_health_source.html.markdown b/website/docs/r/compute_region_health_source.html.markdown index 9cc13cb7137..4ff63f3bde0 100644 --- a/website/docs/r/compute_region_health_source.html.markdown +++ b/website/docs/r/compute_region_health_source.html.markdown @@ -122,6 +122,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/compute_region_instance_group_manager.html.markdown b/website/docs/r/compute_region_instance_group_manager.html.markdown index e7fa5014131..4785bb0c205 100644 --- a/website/docs/r/compute_region_instance_group_manager.html.markdown +++ b/website/docs/r/compute_region_instance_group_manager.html.markdown @@ -151,6 +151,13 @@ The following arguments are supported: * `region` - (Optional) The region where the managed instance group resides. If not provided, the provider region is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + - - - * `description` - (Optional) An optional textual description of the instance diff --git a/website/docs/r/compute_region_instance_template.html.markdown b/website/docs/r/compute_region_instance_template.html.markdown index f966c78b20a..6887b690394 100644 --- a/website/docs/r/compute_region_instance_template.html.markdown +++ b/website/docs/r/compute_region_instance_template.html.markdown @@ -409,6 +409,13 @@ The following arguments are supported: * `key_revocation_action_type` - (optional) Action to be taken when a customer's encryption key is revoked. Supports `STOP` and `NONE`, with `NONE` being the default. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + The `disk` block supports: * `auto_delete` - (Optional) Whether or not the disk should be auto-deleted. diff --git a/website/docs/r/compute_region_instant_snapshot.html.markdown b/website/docs/r/compute_region_instant_snapshot.html.markdown index 37423e5d702..dd9e48ad98b 100644 --- a/website/docs/r/compute_region_instant_snapshot.html.markdown +++ b/website/docs/r/compute_region_instant_snapshot.html.markdown @@ -102,6 +102,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `params` block supports: diff --git a/website/docs/r/compute_region_network_endpoint.html.markdown b/website/docs/r/compute_region_network_endpoint.html.markdown index 12c8514df7f..9819a4a17c4 100644 --- a/website/docs/r/compute_region_network_endpoint.html.markdown +++ b/website/docs/r/compute_region_network_endpoint.html.markdown @@ -201,6 +201,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/compute_region_network_endpoint_group.html.markdown b/website/docs/r/compute_region_network_endpoint_group.html.markdown index 6578b851a1a..68d579d93ed 100644 --- a/website/docs/r/compute_region_network_endpoint_group.html.markdown +++ b/website/docs/r/compute_region_network_endpoint_group.html.markdown @@ -474,6 +474,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `psc_data` block supports: diff --git a/website/docs/r/compute_region_network_firewall_policy.html.markdown b/website/docs/r/compute_region_network_firewall_policy.html.markdown index 171be6d6363..968e28122c6 100644 --- a/website/docs/r/compute_region_network_firewall_policy.html.markdown +++ b/website/docs/r/compute_region_network_firewall_policy.html.markdown @@ -83,6 +83,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/compute_region_network_firewall_policy_association.html.markdown b/website/docs/r/compute_region_network_firewall_policy_association.html.markdown index cf2c6cccb05..ba59e6009a4 100644 --- a/website/docs/r/compute_region_network_firewall_policy_association.html.markdown +++ b/website/docs/r/compute_region_network_firewall_policy_association.html.markdown @@ -110,6 +110,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/compute_region_network_firewall_policy_rule.html.markdown b/website/docs/r/compute_region_network_firewall_policy_rule.html.markdown index 158261c1a35..4e9065e4c2a 100644 --- a/website/docs/r/compute_region_network_firewall_policy_rule.html.markdown +++ b/website/docs/r/compute_region_network_firewall_policy_rule.html.markdown @@ -379,6 +379,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `match` block supports: diff --git a/website/docs/r/compute_region_network_firewall_policy_with_rules.html.markdown b/website/docs/r/compute_region_network_firewall_policy_with_rules.html.markdown index d17a1fde19e..0c5e9e1c753 100644 --- a/website/docs/r/compute_region_network_firewall_policy_with_rules.html.markdown +++ b/website/docs/r/compute_region_network_firewall_policy_with_rules.html.markdown @@ -185,6 +185,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `rule` block supports: diff --git a/website/docs/r/compute_region_per_instance_config.html.markdown b/website/docs/r/compute_region_per_instance_config.html.markdown index b5988a79300..9688b5d0403 100644 --- a/website/docs/r/compute_region_per_instance_config.html.markdown +++ b/website/docs/r/compute_region_per_instance_config.html.markdown @@ -138,6 +138,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `minimal_action` - (Optional) The minimal action to perform on the instance during an update. Default is `NONE`. Possible values are: * REPLACE diff --git a/website/docs/r/compute_region_resize_request.html.markdown b/website/docs/r/compute_region_resize_request.html.markdown index 5beb32f95a1..6f078b1985b 100644 --- a/website/docs/r/compute_region_resize_request.html.markdown +++ b/website/docs/r/compute_region_resize_request.html.markdown @@ -159,6 +159,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `requested_run_duration` block supports: diff --git a/website/docs/r/compute_region_security_policy.html.markdown b/website/docs/r/compute_region_security_policy.html.markdown index cf1f27a8240..e644d31aa35 100644 --- a/website/docs/r/compute_region_security_policy.html.markdown +++ b/website/docs/r/compute_region_security_policy.html.markdown @@ -185,6 +185,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `ddos_protection_config` block supports: diff --git a/website/docs/r/compute_region_security_policy_rule.html.markdown b/website/docs/r/compute_region_security_policy_rule.html.markdown index 318482f2b56..e788fa0d86c 100644 --- a/website/docs/r/compute_region_security_policy_rule.html.markdown +++ b/website/docs/r/compute_region_security_policy_rule.html.markdown @@ -335,6 +335,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `match` block supports: diff --git a/website/docs/r/compute_region_ssl_certificate.html.markdown b/website/docs/r/compute_region_ssl_certificate.html.markdown index 5e9be8f108a..1275d70725e 100644 --- a/website/docs/r/compute_region_ssl_certificate.html.markdown +++ b/website/docs/r/compute_region_ssl_certificate.html.markdown @@ -248,6 +248,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `name_prefix` - (Optional) Creates a unique name beginning with the specified prefix. Conflicts with `name`. Max length is 54 characters. Prefixes with lengths longer than 37 characters will use a shortened diff --git a/website/docs/r/compute_region_ssl_policy.html.markdown b/website/docs/r/compute_region_ssl_policy.html.markdown index a28d5564ce1..04ec6d792f0 100644 --- a/website/docs/r/compute_region_ssl_policy.html.markdown +++ b/website/docs/r/compute_region_ssl_policy.html.markdown @@ -90,6 +90,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/compute_region_target_http_proxy.html.markdown b/website/docs/r/compute_region_target_http_proxy.html.markdown index 0825e8c834f..8ca2fc56390 100644 --- a/website/docs/r/compute_region_target_http_proxy.html.markdown +++ b/website/docs/r/compute_region_target_http_proxy.html.markdown @@ -209,6 +209,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/compute_region_target_https_proxy.html.markdown b/website/docs/r/compute_region_target_https_proxy.html.markdown index 5bbfce5b19e..ad722e0136f 100644 --- a/website/docs/r/compute_region_target_https_proxy.html.markdown +++ b/website/docs/r/compute_region_target_https_proxy.html.markdown @@ -388,6 +388,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/compute_region_target_tcp_proxy.html.markdown b/website/docs/r/compute_region_target_tcp_proxy.html.markdown index 74203a629ab..c0bc4e62d05 100644 --- a/website/docs/r/compute_region_target_tcp_proxy.html.markdown +++ b/website/docs/r/compute_region_target_tcp_proxy.html.markdown @@ -236,6 +236,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/compute_region_url_map.html.markdown b/website/docs/r/compute_region_url_map.html.markdown index 4b75933c64a..308491c19f4 100644 --- a/website/docs/r/compute_region_url_map.html.markdown +++ b/website/docs/r/compute_region_url_map.html.markdown @@ -1562,6 +1562,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `host_rule` block supports: diff --git a/website/docs/r/compute_reservation.html.markdown b/website/docs/r/compute_reservation.html.markdown index 1214bc56d40..e961ae6bb5d 100644 --- a/website/docs/r/compute_reservation.html.markdown +++ b/website/docs/r/compute_reservation.html.markdown @@ -266,6 +266,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `block_names` - (Optional) List of all reservation block names in the parent reservation. diff --git a/website/docs/r/compute_resize_request.html.markdown b/website/docs/r/compute_resize_request.html.markdown index f025c71fd5c..d16611bbd0b 100644 --- a/website/docs/r/compute_resize_request.html.markdown +++ b/website/docs/r/compute_resize_request.html.markdown @@ -149,6 +149,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `requested_run_duration` block supports: diff --git a/website/docs/r/compute_resource_policy.html.markdown b/website/docs/r/compute_resource_policy.html.markdown index bf2c70ebd71..2f2ac73f868 100644 --- a/website/docs/r/compute_resource_policy.html.markdown +++ b/website/docs/r/compute_resource_policy.html.markdown @@ -361,6 +361,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `snapshot_schedule_policy` block supports: diff --git a/website/docs/r/compute_resource_policy_attachment.html.markdown b/website/docs/r/compute_resource_policy_attachment.html.markdown index 895dde2a75d..baa3e26a2f8 100644 --- a/website/docs/r/compute_resource_policy_attachment.html.markdown +++ b/website/docs/r/compute_resource_policy_attachment.html.markdown @@ -106,6 +106,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/compute_rollout_plan.html.markdown b/website/docs/r/compute_rollout_plan.html.markdown index 4d927a2c673..574d843dbdf 100644 --- a/website/docs/r/compute_rollout_plan.html.markdown +++ b/website/docs/r/compute_rollout_plan.html.markdown @@ -91,6 +91,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `waves` block supports: diff --git a/website/docs/r/compute_route.html.markdown b/website/docs/r/compute_route.html.markdown index d4863f92fe2..1e3feb7217a 100644 --- a/website/docs/r/compute_route.html.markdown +++ b/website/docs/r/compute_route.html.markdown @@ -318,6 +318,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `next_hop_instance_zone` - (Optional when `next_hop_instance` is specified) The zone of the instance specified in `next_hop_instance`. Omit if `next_hop_instance` is specified as diff --git a/website/docs/r/compute_router.html.markdown b/website/docs/r/compute_router.html.markdown index 9744c54ef13..1afc971087c 100644 --- a/website/docs/r/compute_router.html.markdown +++ b/website/docs/r/compute_router.html.markdown @@ -207,6 +207,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `bgp` block supports: diff --git a/website/docs/r/compute_router_interface.html.markdown b/website/docs/r/compute_router_interface.html.markdown index d3b5aec7db4..3266831d2ee 100644 --- a/website/docs/r/compute_router_interface.html.markdown +++ b/website/docs/r/compute_router_interface.html.markdown @@ -83,6 +83,13 @@ In addition to the above required fields, a router interface must have specified * `region` - (Optional) The region this interface's router sits in. If not specified, the project region will be used. Changing this forces a new interface to be created. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + ## Attributes Reference In addition to the arguments listed above, the following computed attributes are exported: diff --git a/website/docs/r/compute_router_named_set.html.markdown b/website/docs/r/compute_router_named_set.html.markdown index 706cf685a55..b6359c09de2 100644 --- a/website/docs/r/compute_router_named_set.html.markdown +++ b/website/docs/r/compute_router_named_set.html.markdown @@ -218,6 +218,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `elements` block supports: diff --git a/website/docs/r/compute_router_nat.html.markdown b/website/docs/r/compute_router_nat.html.markdown index d9a99693e08..16cadfa490b 100644 --- a/website/docs/r/compute_router_nat.html.markdown +++ b/website/docs/r/compute_router_nat.html.markdown @@ -408,6 +408,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `subnetwork` block supports: diff --git a/website/docs/r/compute_router_nat_address.html.markdown b/website/docs/r/compute_router_nat_address.html.markdown index 91740bcede3..8127b204a5e 100644 --- a/website/docs/r/compute_router_nat_address.html.markdown +++ b/website/docs/r/compute_router_nat_address.html.markdown @@ -119,6 +119,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/compute_router_peer.html.markdown b/website/docs/r/compute_router_peer.html.markdown index cdd818f80b1..c607b5744f9 100644 --- a/website/docs/r/compute_router_peer.html.markdown +++ b/website/docs/r/compute_router_peer.html.markdown @@ -549,6 +549,13 @@ The following arguments are supported: * `md5_authentication_key` - (Optional) Configuration for MD5 authentication on the BGP session. Structure is [documented below](#nested_md5_authentication_key). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + The `advertised_ip_ranges` block supports: * `range` - diff --git a/website/docs/r/compute_router_route_policy.html.markdown b/website/docs/r/compute_router_route_policy.html.markdown index 33b251ad541..d42d82b2b11 100644 --- a/website/docs/r/compute_router_route_policy.html.markdown +++ b/website/docs/r/compute_router_route_policy.html.markdown @@ -148,6 +148,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `terms` block supports: diff --git a/website/docs/r/compute_security_policy.html.markdown b/website/docs/r/compute_security_policy.html.markdown index fa827ec904b..36f81aeaf24 100644 --- a/website/docs/r/compute_security_policy.html.markdown +++ b/website/docs/r/compute_security_policy.html.markdown @@ -240,6 +240,13 @@ The following arguments are supported: * `label_fingerprint` - The unique fingerprint of the labels. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + The `advanced_options_config` block supports: * `json_parsing` - Whether or not to JSON parse the payload body. Defaults to `DISABLED`. diff --git a/website/docs/r/compute_security_policy_rule.html.markdown b/website/docs/r/compute_security_policy_rule.html.markdown index d96bed54bb8..b9396467a78 100644 --- a/website/docs/r/compute_security_policy_rule.html.markdown +++ b/website/docs/r/compute_security_policy_rule.html.markdown @@ -375,6 +375,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `match` block supports: diff --git a/website/docs/r/compute_service_attachment.html.markdown b/website/docs/r/compute_service_attachment.html.markdown index d0ff1de6c1e..4c00ae20ea4 100644 --- a/website/docs/r/compute_service_attachment.html.markdown +++ b/website/docs/r/compute_service_attachment.html.markdown @@ -670,6 +670,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `send_propagated_connection_limit_if_zero` - (Optional) Controls the behavior of propagated_connection_limit. When false, setting propagated_connection_limit to zero causes the provider to use to the API's default value. When true, the provider will set propagated_connection_limit to zero. diff --git a/website/docs/r/compute_shared_vpc_host_project.html.markdown b/website/docs/r/compute_shared_vpc_host_project.html.markdown index e2898dd4512..c59f4c1acca 100644 --- a/website/docs/r/compute_shared_vpc_host_project.html.markdown +++ b/website/docs/r/compute_shared_vpc_host_project.html.markdown @@ -55,6 +55,13 @@ The following arguments are expected: * `project` - (Required) The ID of the project that will serve as a Shared VPC host project +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + ## Attributes Reference In addition to the arguments listed above, the following computed attributes are exported: diff --git a/website/docs/r/compute_snapshot.html.markdown b/website/docs/r/compute_snapshot.html.markdown index 416393f2a76..554827806ce 100644 --- a/website/docs/r/compute_snapshot.html.markdown +++ b/website/docs/r/compute_snapshot.html.markdown @@ -270,6 +270,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `snapshot_encryption_key` block supports: diff --git a/website/docs/r/compute_snapshot_settings.html.markdown b/website/docs/r/compute_snapshot_settings.html.markdown index 9304ff121ab..ffff53a28a4 100644 --- a/website/docs/r/compute_snapshot_settings.html.markdown +++ b/website/docs/r/compute_snapshot_settings.html.markdown @@ -60,6 +60,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `storage_location` block supports: diff --git a/website/docs/r/compute_ssl_certificate.html.markdown b/website/docs/r/compute_ssl_certificate.html.markdown index f4a3fd85410..cc57de28a0f 100644 --- a/website/docs/r/compute_ssl_certificate.html.markdown +++ b/website/docs/r/compute_ssl_certificate.html.markdown @@ -234,6 +234,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `name_prefix` - (Optional) Creates a unique name beginning with the specified prefix. Conflicts with `name`. Max length is 54 characters. Prefixes with lengths longer than 37 characters will use a shortened diff --git a/website/docs/r/compute_ssl_policy.html.markdown b/website/docs/r/compute_ssl_policy.html.markdown index d0bdb9a1a5c..186d78cf67e 100644 --- a/website/docs/r/compute_ssl_policy.html.markdown +++ b/website/docs/r/compute_ssl_policy.html.markdown @@ -116,6 +116,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/compute_storage_pool.html.markdown b/website/docs/r/compute_storage_pool.html.markdown index ef67cc8164a..71052fc00d1 100644 --- a/website/docs/r/compute_storage_pool.html.markdown +++ b/website/docs/r/compute_storage_pool.html.markdown @@ -169,6 +169,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `deletion_protection` - (Optional) Whether Terraform will be prevented from destroying the StoragePool. When the field is set to true or unset in Terraform state, a `terraform apply` or `terraform destroy` that would delete the StoragePool will fail. diff --git a/website/docs/r/compute_subnetwork.html.markdown b/website/docs/r/compute_subnetwork.html.markdown index 389c1436733..26b1ae73de3 100644 --- a/website/docs/r/compute_subnetwork.html.markdown +++ b/website/docs/r/compute_subnetwork.html.markdown @@ -493,6 +493,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `send_secondary_ip_range_if_empty` - (Optional) Controls the removal behavior of secondary_ip_range. When false, removing secondary_ip_range from config will not produce a diff as the provider will default to the API's value. diff --git a/website/docs/r/compute_target_grpc_proxy.html.markdown b/website/docs/r/compute_target_grpc_proxy.html.markdown index 4f7db5fb583..dc7018979bf 100644 --- a/website/docs/r/compute_target_grpc_proxy.html.markdown +++ b/website/docs/r/compute_target_grpc_proxy.html.markdown @@ -173,6 +173,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/compute_target_http_proxy.html.markdown b/website/docs/r/compute_target_http_proxy.html.markdown index 7309351f52f..a8d3bbfec4f 100644 --- a/website/docs/r/compute_target_http_proxy.html.markdown +++ b/website/docs/r/compute_target_http_proxy.html.markdown @@ -257,6 +257,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/compute_target_https_proxy.html.markdown b/website/docs/r/compute_target_https_proxy.html.markdown index abc2833b928..6d23edc37c2 100644 --- a/website/docs/r/compute_target_https_proxy.html.markdown +++ b/website/docs/r/compute_target_https_proxy.html.markdown @@ -478,6 +478,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/compute_target_instance.html.markdown b/website/docs/r/compute_target_instance.html.markdown index 31d9d6e7408..4e67c28a13e 100644 --- a/website/docs/r/compute_target_instance.html.markdown +++ b/website/docs/r/compute_target_instance.html.markdown @@ -255,6 +255,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/compute_target_pool.html.markdown b/website/docs/r/compute_target_pool.html.markdown index 19e798c1225..3067b8f0f51 100644 --- a/website/docs/r/compute_target_pool.html.markdown +++ b/website/docs/r/compute_target_pool.html.markdown @@ -89,6 +89,13 @@ The following arguments are supported: * `security_policy` - (Optional, [Beta](../guides/provider_versions.html.markdown)) The resource URL for the security policy associated with this target pool. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + ## Attributes Reference In addition to the arguments listed above, the following computed attributes are diff --git a/website/docs/r/compute_target_ssl_proxy.html.markdown b/website/docs/r/compute_target_ssl_proxy.html.markdown index 20e047abeb1..8de103158b9 100644 --- a/website/docs/r/compute_target_ssl_proxy.html.markdown +++ b/website/docs/r/compute_target_ssl_proxy.html.markdown @@ -129,6 +129,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/compute_target_tcp_proxy.html.markdown b/website/docs/r/compute_target_tcp_proxy.html.markdown index 10f10eb6f38..2744dcc7afc 100644 --- a/website/docs/r/compute_target_tcp_proxy.html.markdown +++ b/website/docs/r/compute_target_tcp_proxy.html.markdown @@ -218,6 +218,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/compute_url_map.html.markdown b/website/docs/r/compute_url_map.html.markdown index 71f15b4acfd..d69b74bbc76 100644 --- a/website/docs/r/compute_url_map.html.markdown +++ b/website/docs/r/compute_url_map.html.markdown @@ -1785,6 +1785,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `header_action` block supports: diff --git a/website/docs/r/compute_vpn_gateway.html.markdown b/website/docs/r/compute_vpn_gateway.html.markdown index 56522de6722..1ec46b60c49 100644 --- a/website/docs/r/compute_vpn_gateway.html.markdown +++ b/website/docs/r/compute_vpn_gateway.html.markdown @@ -223,6 +223,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `params` block supports: diff --git a/website/docs/r/compute_vpn_tunnel.html.markdown b/website/docs/r/compute_vpn_tunnel.html.markdown index 24fd2d090f7..61f477d56bd 100644 --- a/website/docs/r/compute_vpn_tunnel.html.markdown +++ b/website/docs/r/compute_vpn_tunnel.html.markdown @@ -316,6 +316,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `params` block supports: diff --git a/website/docs/r/compute_wire_group.html.markdown b/website/docs/r/compute_wire_group.html.markdown index a3bf5d1bb77..ce39bf8f19b 100644 --- a/website/docs/r/compute_wire_group.html.markdown +++ b/website/docs/r/compute_wire_group.html.markdown @@ -135,6 +135,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `endpoints` block supports: diff --git a/website/docs/r/contact_center_insights_analysis_rule.html.markdown b/website/docs/r/contact_center_insights_analysis_rule.html.markdown index 9adfa2510ff..4e8674a65de 100644 --- a/website/docs/r/contact_center_insights_analysis_rule.html.markdown +++ b/website/docs/r/contact_center_insights_analysis_rule.html.markdown @@ -157,6 +157,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `annotator_selector` block supports: diff --git a/website/docs/r/contact_center_insights_assessment_rule.html.markdown b/website/docs/r/contact_center_insights_assessment_rule.html.markdown index 5f172600f84..e14d8bfb038 100644 --- a/website/docs/r/contact_center_insights_assessment_rule.html.markdown +++ b/website/docs/r/contact_center_insights_assessment_rule.html.markdown @@ -120,6 +120,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `sample_rule` block supports: diff --git a/website/docs/r/contact_center_insights_auto_labeling_rule.html.markdown b/website/docs/r/contact_center_insights_auto_labeling_rule.html.markdown index 6ffe217487c..5a6ef51abb7 100644 --- a/website/docs/r/contact_center_insights_auto_labeling_rule.html.markdown +++ b/website/docs/r/contact_center_insights_auto_labeling_rule.html.markdown @@ -102,6 +102,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `conditions` block supports: diff --git a/website/docs/r/contact_center_insights_qa_question.html.markdown b/website/docs/r/contact_center_insights_qa_question.html.markdown index fc4a1d676e4..8c065b65fd4 100644 --- a/website/docs/r/contact_center_insights_qa_question.html.markdown +++ b/website/docs/r/contact_center_insights_qa_question.html.markdown @@ -149,6 +149,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `answer_choices` block supports: diff --git a/website/docs/r/contact_center_insights_qa_scorecard.html.markdown b/website/docs/r/contact_center_insights_qa_scorecard.html.markdown index b2e959b7e83..d1edfaec380 100644 --- a/website/docs/r/contact_center_insights_qa_scorecard.html.markdown +++ b/website/docs/r/contact_center_insights_qa_scorecard.html.markdown @@ -85,6 +85,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/contact_center_insights_qa_scorecard_revision.html.markdown b/website/docs/r/contact_center_insights_qa_scorecard_revision.html.markdown index 822c1f0b3e5..f5cde992d9b 100644 --- a/website/docs/r/contact_center_insights_qa_scorecard_revision.html.markdown +++ b/website/docs/r/contact_center_insights_qa_scorecard_revision.html.markdown @@ -70,6 +70,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/contact_center_insights_view.html.markdown b/website/docs/r/contact_center_insights_view.html.markdown index 03e7440fa25..86d35e04097 100644 --- a/website/docs/r/contact_center_insights_view.html.markdown +++ b/website/docs/r/contact_center_insights_view.html.markdown @@ -82,6 +82,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/container_analysis_note.html.markdown b/website/docs/r/container_analysis_note.html.markdown index dd59411577c..4af1a30526a 100644 --- a/website/docs/r/container_analysis_note.html.markdown +++ b/website/docs/r/container_analysis_note.html.markdown @@ -131,6 +131,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `attestation_authority` block supports: diff --git a/website/docs/r/container_analysis_occurrence.html.markdown b/website/docs/r/container_analysis_occurrence.html.markdown index 3de3a9ef007..91c1d4d8d0f 100644 --- a/website/docs/r/container_analysis_occurrence.html.markdown +++ b/website/docs/r/container_analysis_occurrence.html.markdown @@ -126,6 +126,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `attestation` block supports: diff --git a/website/docs/r/container_attached_cluster.html.markdown b/website/docs/r/container_attached_cluster.html.markdown index 2c85806edd8..27c209ac225 100644 --- a/website/docs/r/container_attached_cluster.html.markdown +++ b/website/docs/r/container_attached_cluster.html.markdown @@ -251,7 +251,15 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. -* `deletion_policy` - (Optional) Policy to determine what flags to send on delete. Possible values: DELETE, DELETE_IGNORE_ERRORS +* `deletion_policy` - (Optional) Policy to determine what flags to send on delete. + +When a 'terraform destroy' or 'terraform apply' would delete the resource, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. + +Possible values: DELETE, DELETE_IGNORE_ERRORS, PREVENT, ABANDON'. Defaults to 'DELETE'. + The `oidc_config` block supports: diff --git a/website/docs/r/container_aws_cluster.html.markdown b/website/docs/r/container_aws_cluster.html.markdown index a06a6c2f697..82dc06ebea2 100644 --- a/website/docs/r/container_aws_cluster.html.markdown +++ b/website/docs/r/container_aws_cluster.html.markdown @@ -338,7 +338,13 @@ The following arguments are supported: * `networking` - (Required) Cluster-wide networking configuration. - + +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `authorization` block supports: diff --git a/website/docs/r/container_aws_node_pool.html.markdown b/website/docs/r/container_aws_node_pool.html.markdown index d135b085a35..defd317fad2 100644 --- a/website/docs/r/container_aws_node_pool.html.markdown +++ b/website/docs/r/container_aws_node_pool.html.markdown @@ -547,7 +547,13 @@ The following arguments are supported: * `version` - (Required) The Kubernetes version to run on this node pool (e.g. `1.19.10-gke.1000`). You can list all supported versions on a given Google Cloud region by calling GetAwsServerConfig. - + +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `autoscaling` block supports: diff --git a/website/docs/r/container_azure_client.html.markdown b/website/docs/r/container_azure_client.html.markdown index 5bc5261248b..4b28f038338 100644 --- a/website/docs/r/container_azure_client.html.markdown +++ b/website/docs/r/container_azure_client.html.markdown @@ -64,6 +64,13 @@ The following arguments are supported: * `project` - (Optional) The project for the resource + +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. diff --git a/website/docs/r/container_azure_cluster.html.markdown b/website/docs/r/container_azure_cluster.html.markdown index e2a0a61f285..822eabeac95 100644 --- a/website/docs/r/container_azure_cluster.html.markdown +++ b/website/docs/r/container_azure_cluster.html.markdown @@ -181,7 +181,13 @@ The following arguments are supported: * `resource_group_id` - (Required) The ARM ID of the resource group where the cluster resources are deployed. For example: `/subscriptions/*/resourceGroups/*` - + +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `authorization` block supports: diff --git a/website/docs/r/container_azure_node_pool.html.markdown b/website/docs/r/container_azure_node_pool.html.markdown index cfd5c4c34fb..8dc3053119e 100644 --- a/website/docs/r/container_azure_node_pool.html.markdown +++ b/website/docs/r/container_azure_node_pool.html.markdown @@ -168,7 +168,13 @@ The following arguments are supported: * `version` - (Required) The Kubernetes version (e.g. `1.19.10-gke.1000`) running on this node pool. - + +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `autoscaling` block supports: diff --git a/website/docs/r/container_cluster.html.markdown b/website/docs/r/container_cluster.html.markdown index 8e2c9ab3314..d8c2cb5fef8 100644 --- a/website/docs/r/container_cluster.html.markdown +++ b/website/docs/r/container_cluster.html.markdown @@ -461,6 +461,14 @@ Fleet configuration for the cluster. Structure is [documented below](#nested_fle * `rbac_binding_config` - (Optional) RBACBindingConfig allows user to restrict ClusterRoleBindings an RoleBindings that can be created. Structure is [documented below](#nested_rbac_binding_config). +* `deletion_policy` - + (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + The `default_snat_status` block supports * `disabled` - (Required) Whether the cluster disables default in-node sNAT rules. In-node sNAT rules will be disabled when defaultSnatStatus is disabled.When disabled is set to false, default IP masquerade rules will be applied to the nodes to prevent sNAT on cluster internal traffic diff --git a/website/docs/r/container_node_pool.html.markdown b/website/docs/r/container_node_pool.html.markdown index 55923f9efcb..d214d931091 100644 --- a/website/docs/r/container_node_pool.html.markdown +++ b/website/docs/r/container_node_pool.html.markdown @@ -189,6 +189,13 @@ cluster. * `queued_provisioning` - (Optional) Specifies node pool-level settings of queued provisioning. Structure is [documented below](#nested_queued_provisioning). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + The `autoscaling` block supports (either total or per zone limits are required): * `min_node_count` - (Optional) Minimum number of nodes per zone in the NodePool. diff --git a/website/docs/r/data_catalog_entry.html.markdown b/website/docs/r/data_catalog_entry.html.markdown index 65491400720..0c612810106 100644 --- a/website/docs/r/data_catalog_entry.html.markdown +++ b/website/docs/r/data_catalog_entry.html.markdown @@ -210,6 +210,12 @@ The following arguments are supported: Specification that applies to a Cloud Storage fileset. This is only valid on entries of type FILESET. Structure is [documented below](#nested_gcs_fileset_spec). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `gcs_fileset_spec` block supports: diff --git a/website/docs/r/data_catalog_entry_group.html.markdown b/website/docs/r/data_catalog_entry_group.html.markdown index fc160da5574..6d12854d44f 100644 --- a/website/docs/r/data_catalog_entry_group.html.markdown +++ b/website/docs/r/data_catalog_entry_group.html.markdown @@ -87,6 +87,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/data_catalog_policy_tag.html.markdown b/website/docs/r/data_catalog_policy_tag.html.markdown index 59cf6ae9b6d..9e31b3657e7 100644 --- a/website/docs/r/data_catalog_policy_tag.html.markdown +++ b/website/docs/r/data_catalog_policy_tag.html.markdown @@ -118,6 +118,12 @@ The following arguments are supported: If empty, it means this policy tag is a top level policy tag. If not set, defaults to an empty string. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/data_catalog_tag.html.markdown b/website/docs/r/data_catalog_tag.html.markdown index 0dc788b662d..5b29c8d8ee6 100644 --- a/website/docs/r/data_catalog_tag.html.markdown +++ b/website/docs/r/data_catalog_tag.html.markdown @@ -362,6 +362,12 @@ The following arguments are supported: The name of the parent this tag is attached to. This can be the name of an entry or an entry group. If an entry group, the tag will be attached to all entries in that group. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `fields` block supports: diff --git a/website/docs/r/data_catalog_tag_template.html.markdown b/website/docs/r/data_catalog_tag_template.html.markdown index a59d0369089..1b901e8ff59 100644 --- a/website/docs/r/data_catalog_tag_template.html.markdown +++ b/website/docs/r/data_catalog_tag_template.html.markdown @@ -115,6 +115,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `fields` block supports: diff --git a/website/docs/r/data_catalog_taxonomy.html.markdown b/website/docs/r/data_catalog_taxonomy.html.markdown index 0efd5613286..ca0bea1db08 100644 --- a/website/docs/r/data_catalog_taxonomy.html.markdown +++ b/website/docs/r/data_catalog_taxonomy.html.markdown @@ -79,6 +79,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/data_fusion_instance.html.markdown b/website/docs/r/data_fusion_instance.html.markdown index 813ad645934..70dba4dab92 100644 --- a/website/docs/r/data_fusion_instance.html.markdown +++ b/website/docs/r/data_fusion_instance.html.markdown @@ -384,6 +384,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `network_config` block supports: diff --git a/website/docs/r/data_lineage_config.html.markdown b/website/docs/r/data_lineage_config.html.markdown index 0dbec537f06..dec84d9b046 100644 --- a/website/docs/r/data_lineage_config.html.markdown +++ b/website/docs/r/data_lineage_config.html.markdown @@ -151,6 +151,12 @@ The following arguments are supported: The region of the data lineage configuration for integration. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `ingestion` block supports: diff --git a/website/docs/r/data_loss_prevention_deidentify_template.html.markdown b/website/docs/r/data_loss_prevention_deidentify_template.html.markdown index 34890bbe6e3..34866bfb036 100644 --- a/website/docs/r/data_loss_prevention_deidentify_template.html.markdown +++ b/website/docs/r/data_loss_prevention_deidentify_template.html.markdown @@ -205,6 +205,12 @@ The following arguments are supported: that is, it must match the regular expression: [a-zA-Z\d-_]+. The maximum length is 100 characters. Can be empty to allow the system to generate one. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `deidentify_config` block supports: diff --git a/website/docs/r/data_loss_prevention_discovery_config.html.markdown b/website/docs/r/data_loss_prevention_discovery_config.html.markdown index e346e2a7173..019c0a7b8df 100644 --- a/website/docs/r/data_loss_prevention_discovery_config.html.markdown +++ b/website/docs/r/data_loss_prevention_discovery_config.html.markdown @@ -561,6 +561,12 @@ The following arguments are supported: Required. A status for this configuration Possible values are: `RUNNING`, `PAUSED`. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `org_config` block supports: diff --git a/website/docs/r/data_loss_prevention_inspect_template.html.markdown b/website/docs/r/data_loss_prevention_inspect_template.html.markdown index 553bdcbed21..aac76a623db 100644 --- a/website/docs/r/data_loss_prevention_inspect_template.html.markdown +++ b/website/docs/r/data_loss_prevention_inspect_template.html.markdown @@ -332,6 +332,12 @@ The following arguments are supported: The core content of the template. Structure is [documented below](#nested_inspect_config). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `inspect_config` block supports: diff --git a/website/docs/r/data_loss_prevention_job_trigger.html.markdown b/website/docs/r/data_loss_prevention_job_trigger.html.markdown index 8abec5e56cd..f0e18fe1c20 100644 --- a/website/docs/r/data_loss_prevention_job_trigger.html.markdown +++ b/website/docs/r/data_loss_prevention_job_trigger.html.markdown @@ -648,6 +648,12 @@ The following arguments are supported: Controls what and how to inspect for findings. Structure is [documented below](#nested_inspect_job). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `triggers` block supports: diff --git a/website/docs/r/data_loss_prevention_stored_info_type.html.markdown b/website/docs/r/data_loss_prevention_stored_info_type.html.markdown index a4024858c19..b5a26f4514e 100644 --- a/website/docs/r/data_loss_prevention_stored_info_type.html.markdown +++ b/website/docs/r/data_loss_prevention_stored_info_type.html.markdown @@ -152,6 +152,12 @@ The following arguments are supported: Dictionary which defines the rule. Structure is [documented below](#nested_large_custom_dictionary). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `regex` block supports: diff --git a/website/docs/r/data_pipeline_pipeline.html.markdown b/website/docs/r/data_pipeline_pipeline.html.markdown index 6bf1c92ff41..8b3b1944322 100644 --- a/website/docs/r/data_pipeline_pipeline.html.markdown +++ b/website/docs/r/data_pipeline_pipeline.html.markdown @@ -146,6 +146,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `workload` block supports: diff --git a/website/docs/r/database_migration_service_connection_profile.html.markdown b/website/docs/r/database_migration_service_connection_profile.html.markdown index bca0d0a9b5f..46674d4e2c4 100644 --- a/website/docs/r/database_migration_service_connection_profile.html.markdown +++ b/website/docs/r/database_migration_service_connection_profile.html.markdown @@ -568,6 +568,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `mysql` block supports: diff --git a/website/docs/r/database_migration_service_migration_job.html.markdown b/website/docs/r/database_migration_service_migration_job.html.markdown index 01b44658666..26bbff7c62e 100644 --- a/website/docs/r/database_migration_service_migration_job.html.markdown +++ b/website/docs/r/database_migration_service_migration_job.html.markdown @@ -582,6 +582,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `dump_flags` block supports: diff --git a/website/docs/r/database_migration_service_private_connection.html.markdown b/website/docs/r/database_migration_service_private_connection.html.markdown index 043262b5fef..3df4c1cd16f 100644 --- a/website/docs/r/database_migration_service_private_connection.html.markdown +++ b/website/docs/r/database_migration_service_private_connection.html.markdown @@ -99,6 +99,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `vpc_peering_config` block supports: diff --git a/website/docs/r/dataflow_flex_template_job.html.markdown b/website/docs/r/dataflow_flex_template_job.html.markdown index 5aad523da59..fa747fb31e2 100644 --- a/website/docs/r/dataflow_flex_template_job.html.markdown +++ b/website/docs/r/dataflow_flex_template_job.html.markdown @@ -166,6 +166,13 @@ and will remove the resource from terraform state and move on. See above note. * `transform_name_mapping` - (Optional) Only applicable when updating a pipeline. Map of transform name prefixes of the job to be replaced with the corresponding name prefixes of the new job.Only applicable when updating a pipeline. Map of transform name prefixes of the job to be replaced with the corresponding name prefixes of the new job. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + ## Attributes Reference In addition to the arguments listed above, the following computed attributes are exported: diff --git a/website/docs/r/dataflow_job.html.markdown b/website/docs/r/dataflow_job.html.markdown index ad0cde9bf5d..26d44701eda 100644 --- a/website/docs/r/dataflow_job.html.markdown +++ b/website/docs/r/dataflow_job.html.markdown @@ -138,6 +138,12 @@ The following arguments are supported: * `ip_configuration` - (Optional) The configuration for VM IPs. Options are `"WORKER_IP_PUBLIC"` or `"WORKER_IP_PRIVATE"`. * `additional_experiments` - (Optional) List of experiments that should be used by the job. An example value is `["enable_stackdriver_agent_metrics"]`. * `enable_streaming_engine` - (Optional) Enable/disable the use of [Streaming Engine](https://cloud.google.com/dataflow/docs/guides/deploying-a-pipeline#streaming-engine) for the job. Note that Streaming Engine is enabled by default for pipelines developed against the Beam SDK for Python v2.21.0 or later when using Python 3. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/dataform_config.html.markdown b/website/docs/r/dataform_config.html.markdown index 7981ab34d03..10ed2b31373 100644 --- a/website/docs/r/dataform_config.html.markdown +++ b/website/docs/r/dataform_config.html.markdown @@ -178,6 +178,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/dataform_folder.html.markdown b/website/docs/r/dataform_folder.html.markdown index 62512b125f0..d6f32d4635c 100644 --- a/website/docs/r/dataform_folder.html.markdown +++ b/website/docs/r/dataform_folder.html.markdown @@ -87,6 +87,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/dataform_repository.html.markdown b/website/docs/r/dataform_repository.html.markdown index ce6fb26475f..c829a8b704c 100644 --- a/website/docs/r/dataform_repository.html.markdown +++ b/website/docs/r/dataform_repository.html.markdown @@ -159,7 +159,15 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. -* `deletion_policy` - (Optional) Policy to control how the repository and its child resources are deleted. When set to `FORCE`, any child resources of this repository will also be deleted. Possible values: `DELETE`, `FORCE`. Defaults to `DELETE`. +* `deletion_policy` - (Optional) Policy to control how the repository and its child resources are deleted. +When set to `FORCE`, any child resources of this repository will also be deleted. + +When a 'terraform destroy' or 'terraform apply' would delete the resource, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. + +Possible values: `DELETE`, `FORCE`, 'PREVENT', 'ABANDON'. Defaults to `DELETE`. diff --git a/website/docs/r/dataform_repository_release_config.html.markdown b/website/docs/r/dataform_repository_release_config.html.markdown index cbf4eba9726..2242c8983aa 100644 --- a/website/docs/r/dataform_repository_release_config.html.markdown +++ b/website/docs/r/dataform_repository_release_config.html.markdown @@ -211,6 +211,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `code_compilation_config` block supports: diff --git a/website/docs/r/dataform_repository_workflow_config.html.markdown b/website/docs/r/dataform_repository_workflow_config.html.markdown index fc8263b106f..fc6ba4f6448 100644 --- a/website/docs/r/dataform_repository_workflow_config.html.markdown +++ b/website/docs/r/dataform_repository_workflow_config.html.markdown @@ -182,6 +182,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `invocation_config` block supports: diff --git a/website/docs/r/dataform_team_folder.html.markdown b/website/docs/r/dataform_team_folder.html.markdown index b1793f731c9..ad91620f137 100644 --- a/website/docs/r/dataform_team_folder.html.markdown +++ b/website/docs/r/dataform_team_folder.html.markdown @@ -62,6 +62,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/dataplex_aspect_type.html.markdown b/website/docs/r/dataplex_aspect_type.html.markdown index 6c4bc488cc2..59bf4de352f 100644 --- a/website/docs/r/dataplex_aspect_type.html.markdown +++ b/website/docs/r/dataplex_aspect_type.html.markdown @@ -253,6 +253,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/dataplex_asset.html.markdown b/website/docs/r/dataplex_asset.html.markdown index f0719970a8e..16134c5e6ab 100644 --- a/website/docs/r/dataplex_asset.html.markdown +++ b/website/docs/r/dataplex_asset.html.markdown @@ -119,7 +119,13 @@ The following arguments are supported: * `resource_spec` - (Required) Required. Immutable. Specification of the resource that is referenced by this asset. - + +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `discovery_spec` block supports: diff --git a/website/docs/r/dataplex_data_asset.html.markdown b/website/docs/r/dataplex_data_asset.html.markdown index a13f519c4c4..d3c3d50af74 100644 --- a/website/docs/r/dataplex_data_asset.html.markdown +++ b/website/docs/r/dataplex_data_asset.html.markdown @@ -174,6 +174,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `access_group_configs` block supports: diff --git a/website/docs/r/dataplex_data_product.html.markdown b/website/docs/r/dataplex_data_product.html.markdown index 645b23eb60b..0d3187c8585 100644 --- a/website/docs/r/dataplex_data_product.html.markdown +++ b/website/docs/r/dataplex_data_product.html.markdown @@ -140,6 +140,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `access_groups` block supports: diff --git a/website/docs/r/dataplex_data_product_data_asset.html.markdown b/website/docs/r/dataplex_data_product_data_asset.html.markdown index c2ccae0e960..bbc066b941a 100644 --- a/website/docs/r/dataplex_data_product_data_asset.html.markdown +++ b/website/docs/r/dataplex_data_product_data_asset.html.markdown @@ -173,6 +173,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `access_group_configs` block supports: diff --git a/website/docs/r/dataplex_datascan.html.markdown b/website/docs/r/dataplex_datascan.html.markdown index f038e8379b0..e0059bc1ec2 100644 --- a/website/docs/r/dataplex_datascan.html.markdown +++ b/website/docs/r/dataplex_datascan.html.markdown @@ -1192,6 +1192,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `data` block supports: diff --git a/website/docs/r/dataplex_entry.html.markdown b/website/docs/r/dataplex_entry.html.markdown index ec7973b7580..4710cd7281e 100644 --- a/website/docs/r/dataplex_entry.html.markdown +++ b/website/docs/r/dataplex_entry.html.markdown @@ -418,6 +418,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `aspects` block supports: diff --git a/website/docs/r/dataplex_entry_group.html.markdown b/website/docs/r/dataplex_entry_group.html.markdown index edfdc4b818a..7c8aa8b4962 100644 --- a/website/docs/r/dataplex_entry_group.html.markdown +++ b/website/docs/r/dataplex_entry_group.html.markdown @@ -82,6 +82,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/dataplex_entry_link.html.markdown b/website/docs/r/dataplex_entry_link.html.markdown index a3259d19908..816abcf3eb2 100644 --- a/website/docs/r/dataplex_entry_link.html.markdown +++ b/website/docs/r/dataplex_entry_link.html.markdown @@ -240,6 +240,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `entry_references` block supports: diff --git a/website/docs/r/dataplex_entry_type.html.markdown b/website/docs/r/dataplex_entry_type.html.markdown index bd4a0dada2d..4bc06c577fa 100644 --- a/website/docs/r/dataplex_entry_type.html.markdown +++ b/website/docs/r/dataplex_entry_type.html.markdown @@ -140,6 +140,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `required_aspects` block supports: diff --git a/website/docs/r/dataplex_glossary.html.markdown b/website/docs/r/dataplex_glossary.html.markdown index 84ac353ec03..6406545b020 100644 --- a/website/docs/r/dataplex_glossary.html.markdown +++ b/website/docs/r/dataplex_glossary.html.markdown @@ -90,6 +90,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/dataplex_glossary_category.html.markdown b/website/docs/r/dataplex_glossary_category.html.markdown index 8363504e5ea..59cea1c5409 100644 --- a/website/docs/r/dataplex_glossary_category.html.markdown +++ b/website/docs/r/dataplex_glossary_category.html.markdown @@ -112,6 +112,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/dataplex_glossary_term.html.markdown b/website/docs/r/dataplex_glossary_term.html.markdown index 5639814028c..eb0bc20ea22 100644 --- a/website/docs/r/dataplex_glossary_term.html.markdown +++ b/website/docs/r/dataplex_glossary_term.html.markdown @@ -112,6 +112,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/dataplex_lake.html.markdown b/website/docs/r/dataplex_lake.html.markdown index 1189a630acf..d5c9d3f68d3 100644 --- a/website/docs/r/dataplex_lake.html.markdown +++ b/website/docs/r/dataplex_lake.html.markdown @@ -78,6 +78,13 @@ Please refer to the field `effective_labels` for all of the labels present on th * `project` - (Optional) The project for the resource + +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. diff --git a/website/docs/r/dataplex_task.html.markdown b/website/docs/r/dataplex_task.html.markdown index 9cd3f63bac0..3f2bbeb75aa 100644 --- a/website/docs/r/dataplex_task.html.markdown +++ b/website/docs/r/dataplex_task.html.markdown @@ -269,6 +269,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `trigger_spec` block supports: diff --git a/website/docs/r/dataplex_zone.html.markdown b/website/docs/r/dataplex_zone.html.markdown index c63e852c1b6..26db1fbbc2e 100644 --- a/website/docs/r/dataplex_zone.html.markdown +++ b/website/docs/r/dataplex_zone.html.markdown @@ -87,7 +87,13 @@ The following arguments are supported: * `type` - (Required) Required. Immutable. The type of the zone. Possible values: TYPE_UNSPECIFIED, RAW, CURATED - + +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `discovery_spec` block supports: diff --git a/website/docs/r/dataproc_autoscaling_policy.html.markdown b/website/docs/r/dataproc_autoscaling_policy.html.markdown index b6fe7ab1481..e922381f444 100644 --- a/website/docs/r/dataproc_autoscaling_policy.html.markdown +++ b/website/docs/r/dataproc_autoscaling_policy.html.markdown @@ -99,6 +99,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `worker_config` block supports: diff --git a/website/docs/r/dataproc_batch.html.markdown b/website/docs/r/dataproc_batch.html.markdown index 46893f2fbac..096f2c12fd9 100644 --- a/website/docs/r/dataproc_batch.html.markdown +++ b/website/docs/r/dataproc_batch.html.markdown @@ -349,6 +349,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `runtime_config` block supports: diff --git a/website/docs/r/dataproc_cluster.html.markdown b/website/docs/r/dataproc_cluster.html.markdown index cd6829e2fa8..766811ea6ee 100644 --- a/website/docs/r/dataproc_cluster.html.markdown +++ b/website/docs/r/dataproc_cluster.html.markdown @@ -170,6 +170,14 @@ resource "google_dataproc_cluster" "accelerated_cluster" { [Duration](https://developers.google.com/protocol-buffers/docs/proto3#json)). Only supported on Dataproc image versions 1.2 and higher. For more context see the [docs](https://cloud.google.com/dataproc/docs/reference/rest/v1/projects.regions.clusters/patch#query-parameters) + +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + - - - The `virtual_cluster_config` block supports: diff --git a/website/docs/r/dataproc_gdc_application_environment.html.markdown b/website/docs/r/dataproc_gdc_application_environment.html.markdown index b1472dca23b..6bf20ed0da5 100644 --- a/website/docs/r/dataproc_gdc_application_environment.html.markdown +++ b/website/docs/r/dataproc_gdc_application_environment.html.markdown @@ -124,6 +124,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `spark_application_environment_config` block supports: diff --git a/website/docs/r/dataproc_gdc_service_instance.html.markdown b/website/docs/r/dataproc_gdc_service_instance.html.markdown index cb20808458a..a56a13a64e5 100644 --- a/website/docs/r/dataproc_gdc_service_instance.html.markdown +++ b/website/docs/r/dataproc_gdc_service_instance.html.markdown @@ -94,6 +94,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `gdce_cluster` block supports: diff --git a/website/docs/r/dataproc_gdc_spark_application.html.markdown b/website/docs/r/dataproc_gdc_spark_application.html.markdown index cd921e93e22..b5d87af69d3 100644 --- a/website/docs/r/dataproc_gdc_spark_application.html.markdown +++ b/website/docs/r/dataproc_gdc_spark_application.html.markdown @@ -275,6 +275,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `pyspark_application_config` block supports: diff --git a/website/docs/r/dataproc_job.html.markdown b/website/docs/r/dataproc_job.html.markdown index 6136e572599..0ad838af9e5 100644 --- a/website/docs/r/dataproc_job.html.markdown +++ b/website/docs/r/dataproc_job.html.markdown @@ -131,6 +131,13 @@ output "pyspark_status" { * `wait_for_completion` - (Optional) If set to true, Terraform will wait for the job to reach a terminal state (`DONE`, `ERROR`, `CANCELLED`, `ATTEMPT_FAILURE`). Otherwise, Terraform will consider the job 'created' once it is in the `RUNNING` state. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + The `pyspark_config` block supports: Submitting a pyspark job to the cluster. Below is an example configuration: diff --git a/website/docs/r/dataproc_metastore_federation.html.markdown b/website/docs/r/dataproc_metastore_federation.html.markdown index c6d3aa5bfee..65a546ba651 100644 --- a/website/docs/r/dataproc_metastore_federation.html.markdown +++ b/website/docs/r/dataproc_metastore_federation.html.markdown @@ -141,6 +141,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `deletion_protection` - (Optional) Whether Terraform will be prevented from destroying the federation. Defaults to false. When the field is set to true in Terraform state, a `terraform apply` or `terraform destroy` that would delete the federation will fail. diff --git a/website/docs/r/dataproc_metastore_service.html.markdown b/website/docs/r/dataproc_metastore_service.html.markdown index 46523cfccb5..ad3755779e7 100644 --- a/website/docs/r/dataproc_metastore_service.html.markdown +++ b/website/docs/r/dataproc_metastore_service.html.markdown @@ -515,6 +515,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `scaling_config` block supports: diff --git a/website/docs/r/dataproc_session_template.html.markdown b/website/docs/r/dataproc_session_template.html.markdown index 8e5548163cb..cb441cd1798 100644 --- a/website/docs/r/dataproc_session_template.html.markdown +++ b/website/docs/r/dataproc_session_template.html.markdown @@ -250,6 +250,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `runtime_config` block supports: diff --git a/website/docs/r/dataproc_workflow_template.html.markdown b/website/docs/r/dataproc_workflow_template.html.markdown index ad94c14b5d7..d48310d8f03 100644 --- a/website/docs/r/dataproc_workflow_template.html.markdown +++ b/website/docs/r/dataproc_workflow_template.html.markdown @@ -169,6 +169,13 @@ The following arguments are supported: * `encryption_config` - (Optional) Encryption settings for encrypting workflow template job arguments. Structure is [documented below](#nested_encryption_config) +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + The `encryption_config` block supports: * `kms_key` - (Optional) The Cloud KMS key name to use for encrypting workflow template [job arguments](https://docs.docs.cloud.google.com/dataproc/docs/concepts/workflows/use-workflows). diff --git a/website/docs/r/datastream_connection_profile.html.markdown b/website/docs/r/datastream_connection_profile.html.markdown index 674ae1ca6ec..4cc86962147 100644 --- a/website/docs/r/datastream_connection_profile.html.markdown +++ b/website/docs/r/datastream_connection_profile.html.markdown @@ -611,6 +611,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `oracle_profile` block supports: diff --git a/website/docs/r/datastream_private_connection.html.markdown b/website/docs/r/datastream_private_connection.html.markdown index 3298f16c2bf..a51fa9b52ba 100644 --- a/website/docs/r/datastream_private_connection.html.markdown +++ b/website/docs/r/datastream_private_connection.html.markdown @@ -176,7 +176,12 @@ The following arguments are supported: * `deletion_policy` - (Optional) The deletion policy for the private connection. Setting `FORCE` will also delete any child routes that belong to this private connection. Setting `DEFAULT` will fail the delete if child routes exist. Defaults to `FORCE` for backwards compatibility. -Possible values: `DEFAULT`, `FORCE`. + +When a 'terraform destroy' or 'terraform apply' would delete the resource, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", the command will behave as if set to "DEFAULT". diff --git a/website/docs/r/datastream_stream.html.markdown b/website/docs/r/datastream_stream.html.markdown index 6113abf59c8..765db0a12f8 100644 --- a/website/docs/r/datastream_stream.html.markdown +++ b/website/docs/r/datastream_stream.html.markdown @@ -1655,6 +1655,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `desired_state` - (Optional) Desired state of the Stream. Set this field to `RUNNING` to start the stream, `NOT_STARTED` to create the stream without starting and `PAUSED` to pause the stream from a `RUNNING` state. diff --git a/website/docs/r/deployment_manager_deployment.html.markdown b/website/docs/r/deployment_manager_deployment.html.markdown index 7136f58a2b5..265c995cf1c 100644 --- a/website/docs/r/deployment_manager_deployment.html.markdown +++ b/website/docs/r/deployment_manager_deployment.html.markdown @@ -154,6 +154,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `target` block supports: diff --git a/website/docs/r/developer_connect_account_connector.html.markdown b/website/docs/r/developer_connect_account_connector.html.markdown index ddb54a1dc88..e9e5a03ee88 100644 --- a/website/docs/r/developer_connect_account_connector.html.markdown +++ b/website/docs/r/developer_connect_account_connector.html.markdown @@ -285,6 +285,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `custom_oauth_config` block supports: diff --git a/website/docs/r/developer_connect_connection.html.markdown b/website/docs/r/developer_connect_connection.html.markdown index 4958047d015..fd42a0c8a41 100644 --- a/website/docs/r/developer_connect_connection.html.markdown +++ b/website/docs/r/developer_connect_connection.html.markdown @@ -882,6 +882,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `github_config` block supports: diff --git a/website/docs/r/developer_connect_git_repository_link.html.markdown b/website/docs/r/developer_connect_git_repository_link.html.markdown index 6aab464c38b..134e50f4f29 100644 --- a/website/docs/r/developer_connect_git_repository_link.html.markdown +++ b/website/docs/r/developer_connect_git_repository_link.html.markdown @@ -126,6 +126,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/developer_connect_insights_config.html.markdown b/website/docs/r/developer_connect_insights_config.html.markdown index 4b65d9b395b..59af7318288 100644 --- a/website/docs/r/developer_connect_insights_config.html.markdown +++ b/website/docs/r/developer_connect_insights_config.html.markdown @@ -341,6 +341,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `target_projects` block supports: diff --git a/website/docs/r/dialogflow_agent.html.markdown b/website/docs/r/dialogflow_agent.html.markdown index 5a68c8823cd..aa42c6ae4dd 100644 --- a/website/docs/r/dialogflow_agent.html.markdown +++ b/website/docs/r/dialogflow_agent.html.markdown @@ -154,6 +154,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/dialogflow_conversation_profile.html.markdown b/website/docs/r/dialogflow_conversation_profile.html.markdown index 63e826defbe..f1e6ac4d38d 100644 --- a/website/docs/r/dialogflow_conversation_profile.html.markdown +++ b/website/docs/r/dialogflow_conversation_profile.html.markdown @@ -191,6 +191,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `automated_agent_config` block supports: diff --git a/website/docs/r/dialogflow_cx_agent.html.markdown b/website/docs/r/dialogflow_cx_agent.html.markdown index cd5eadfa86c..d671a011d6f 100644 --- a/website/docs/r/dialogflow_cx_agent.html.markdown +++ b/website/docs/r/dialogflow_cx_agent.html.markdown @@ -259,6 +259,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `delete_chat_engine_on_destroy` - (Optional) If set to `true`, Terraform will delete the chat engine associated with the agent when the agent is destroyed. Otherwise, the chat engine will persist. diff --git a/website/docs/r/dialogflow_cx_entity_type.html.markdown b/website/docs/r/dialogflow_cx_entity_type.html.markdown index af4c657e8b5..f74c68d8681 100644 --- a/website/docs/r/dialogflow_cx_entity_type.html.markdown +++ b/website/docs/r/dialogflow_cx_entity_type.html.markdown @@ -129,6 +129,12 @@ The following arguments are supported: EntityType.excluded_phrases.value If not specified, the agent's default language is used. Many languages are supported. Note: languages must be enabled in the agent before they can be used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `entities` block supports: diff --git a/website/docs/r/dialogflow_cx_environment.html.markdown b/website/docs/r/dialogflow_cx_environment.html.markdown index 70fb727f909..054176ca63b 100644 --- a/website/docs/r/dialogflow_cx_environment.html.markdown +++ b/website/docs/r/dialogflow_cx_environment.html.markdown @@ -96,6 +96,12 @@ The following arguments are supported: The Agent to create an Environment for. Format: projects//locations//agents/. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `version_configs` block supports: diff --git a/website/docs/r/dialogflow_cx_flow.html.markdown b/website/docs/r/dialogflow_cx_flow.html.markdown index 1fd5280de8c..b5308d18998 100644 --- a/website/docs/r/dialogflow_cx_flow.html.markdown +++ b/website/docs/r/dialogflow_cx_flow.html.markdown @@ -612,6 +612,12 @@ The following arguments are supported: Flow.transition_routes.trigger_fulfillment.conditional_cases If not specified, the agent's default language is used. Many languages are supported. Note: languages must be enabled in the agent before they can be used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `is_default_start_flow` - (Optional) Marks this as the [Default Start Flow](https://cloud.google.com/dialogflow/cx/docs/concept/flow#start) for an agent. When you create an agent, the Default Start Flow is created automatically. The Default Start Flow cannot be deleted; deleting the `google_dialogflow_cx_flow` resource does nothing to the underlying GCP resources. diff --git a/website/docs/r/dialogflow_cx_generative_settings.html.markdown b/website/docs/r/dialogflow_cx_generative_settings.html.markdown index 23c61a8824d..25c093c987c 100644 --- a/website/docs/r/dialogflow_cx_generative_settings.html.markdown +++ b/website/docs/r/dialogflow_cx_generative_settings.html.markdown @@ -120,6 +120,12 @@ The following arguments are supported: The agent to create a flow for. Format: projects//locations//agents/. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `fallback_settings` block supports: diff --git a/website/docs/r/dialogflow_cx_generator.html.markdown b/website/docs/r/dialogflow_cx_generator.html.markdown index a74dc41f75a..28d0520419a 100644 --- a/website/docs/r/dialogflow_cx_generator.html.markdown +++ b/website/docs/r/dialogflow_cx_generator.html.markdown @@ -106,6 +106,12 @@ The following arguments are supported: * Generator.prompt_text.text If not specified, the agent's default language is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `prompt_text` block supports: diff --git a/website/docs/r/dialogflow_cx_intent.html.markdown b/website/docs/r/dialogflow_cx_intent.html.markdown index 73100a1a5f7..16721ab8474 100644 --- a/website/docs/r/dialogflow_cx_intent.html.markdown +++ b/website/docs/r/dialogflow_cx_intent.html.markdown @@ -144,6 +144,12 @@ The following arguments are supported: Intent.training_phrases.parts.text If not specified, the agent's default language is used. Many languages are supported. Note: languages must be enabled in the agent before they can be used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `is_default_welcome_intent` - (Optional) Marks this as the [Default Welcome Intent](https://cloud.google.com/dialogflow/cx/docs/concept/intent#welcome) for an agent. When you create an agent, a Default Welcome Intent is created automatically. The Default Welcome Intent cannot be deleted; deleting the `google_dialogflow_cx_intent` resource does nothing to the underlying GCP resources. diff --git a/website/docs/r/dialogflow_cx_page.html.markdown b/website/docs/r/dialogflow_cx_page.html.markdown index 17e68b91ae7..a16f273becf 100644 --- a/website/docs/r/dialogflow_cx_page.html.markdown +++ b/website/docs/r/dialogflow_cx_page.html.markdown @@ -806,6 +806,12 @@ The following arguments are supported: Page.transition_routes.trigger_fulfillment.conditional_cases If not specified, the agent's default language is used. Many languages are supported. Note: languages must be enabled in the agent before they can be used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `entry_fulfillment` block supports: diff --git a/website/docs/r/dialogflow_cx_playbook.html.markdown b/website/docs/r/dialogflow_cx_playbook.html.markdown index c8250946db7..d9f00ab40f1 100644 --- a/website/docs/r/dialogflow_cx_playbook.html.markdown +++ b/website/docs/r/dialogflow_cx_playbook.html.markdown @@ -219,6 +219,12 @@ The following arguments are supported: The agent to create a Playbook for. Format: projects//locations//agents/. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `instruction` block supports: diff --git a/website/docs/r/dialogflow_cx_security_settings.html.markdown b/website/docs/r/dialogflow_cx_security_settings.html.markdown index c864bc89754..8d30ce8d7c1 100644 --- a/website/docs/r/dialogflow_cx_security_settings.html.markdown +++ b/website/docs/r/dialogflow_cx_security_settings.html.markdown @@ -178,6 +178,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `audio_export_settings` block supports: diff --git a/website/docs/r/dialogflow_cx_test_case.html.markdown b/website/docs/r/dialogflow_cx_test_case.html.markdown index e76d37f6b02..aeb081ddfee 100644 --- a/website/docs/r/dialogflow_cx_test_case.html.markdown +++ b/website/docs/r/dialogflow_cx_test_case.html.markdown @@ -200,6 +200,12 @@ The following arguments are supported: The agent to create the test case for. Format: projects//locations//agents/. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `test_config` block supports: diff --git a/website/docs/r/dialogflow_cx_tool.html.markdown b/website/docs/r/dialogflow_cx_tool.html.markdown index 8ed49332f9f..d554ce1f9a0 100644 --- a/website/docs/r/dialogflow_cx_tool.html.markdown +++ b/website/docs/r/dialogflow_cx_tool.html.markdown @@ -374,6 +374,12 @@ The following arguments are supported: The agent to create a Tool for. Format: projects//locations//agents/. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `open_api_spec` block supports: diff --git a/website/docs/r/dialogflow_cx_tool_version.html.markdown b/website/docs/r/dialogflow_cx_tool_version.html.markdown index bac10aac0a1..d113387e4f0 100644 --- a/website/docs/r/dialogflow_cx_tool_version.html.markdown +++ b/website/docs/r/dialogflow_cx_tool_version.html.markdown @@ -505,6 +505,12 @@ The following arguments are supported: Format: projects//locations//agents//tools/. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `tool` block supports: diff --git a/website/docs/r/dialogflow_cx_version.html.markdown b/website/docs/r/dialogflow_cx_version.html.markdown index 95e455c9198..73e1d266996 100644 --- a/website/docs/r/dialogflow_cx_version.html.markdown +++ b/website/docs/r/dialogflow_cx_version.html.markdown @@ -82,6 +82,12 @@ The following arguments are supported: The Flow to create an Version for. Format: projects//locations//agents//flows/. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/dialogflow_cx_webhook.html.markdown b/website/docs/r/dialogflow_cx_webhook.html.markdown index 79ae87b61ba..afbf61fe4e9 100644 --- a/website/docs/r/dialogflow_cx_webhook.html.markdown +++ b/website/docs/r/dialogflow_cx_webhook.html.markdown @@ -341,6 +341,12 @@ The following arguments are supported: The agent to create a webhook for. Format: projects//locations//agents/. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `generic_web_service` block supports: diff --git a/website/docs/r/dialogflow_encryption_spec.html.markdown b/website/docs/r/dialogflow_encryption_spec.html.markdown index 3ce5fa0b833..771ae4109d4 100644 --- a/website/docs/r/dialogflow_encryption_spec.html.markdown +++ b/website/docs/r/dialogflow_encryption_spec.html.markdown @@ -128,6 +128,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `encryption_spec` block supports: diff --git a/website/docs/r/dialogflow_entity_type.html.markdown b/website/docs/r/dialogflow_entity_type.html.markdown index adb1b2287ee..a165120ef88 100644 --- a/website/docs/r/dialogflow_entity_type.html.markdown +++ b/website/docs/r/dialogflow_entity_type.html.markdown @@ -86,6 +86,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `entities` block supports: diff --git a/website/docs/r/dialogflow_environment.html.markdown b/website/docs/r/dialogflow_environment.html.markdown index a33660a8fa0..a9eaa18305b 100644 --- a/website/docs/r/dialogflow_environment.html.markdown +++ b/website/docs/r/dialogflow_environment.html.markdown @@ -107,6 +107,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `text_to_speech_settings` block supports: diff --git a/website/docs/r/dialogflow_fulfillment.html.markdown b/website/docs/r/dialogflow_fulfillment.html.markdown index 5902f55ce51..83a3a0a362b 100644 --- a/website/docs/r/dialogflow_fulfillment.html.markdown +++ b/website/docs/r/dialogflow_fulfillment.html.markdown @@ -82,6 +82,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `features` block supports: diff --git a/website/docs/r/dialogflow_generator.html.markdown b/website/docs/r/dialogflow_generator.html.markdown index 32df52242da..2ccfae44472 100644 --- a/website/docs/r/dialogflow_generator.html.markdown +++ b/website/docs/r/dialogflow_generator.html.markdown @@ -96,6 +96,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `summarization_context` block supports: diff --git a/website/docs/r/dialogflow_intent.html.markdown b/website/docs/r/dialogflow_intent.html.markdown index 6951d17996f..84ebb44f92c 100644 --- a/website/docs/r/dialogflow_intent.html.markdown +++ b/website/docs/r/dialogflow_intent.html.markdown @@ -165,6 +165,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/dialogflow_version.html.markdown b/website/docs/r/dialogflow_version.html.markdown index 4fbe22d2495..7f6db77eb2c 100644 --- a/website/docs/r/dialogflow_version.html.markdown +++ b/website/docs/r/dialogflow_version.html.markdown @@ -80,6 +80,12 @@ The following arguments are supported: (Optional) The developer-provided description of this version. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/discovery_engine_acl_config.html.markdown b/website/docs/r/discovery_engine_acl_config.html.markdown index fb8873f68bd..d001eed6fa2 100644 --- a/website/docs/r/discovery_engine_acl_config.html.markdown +++ b/website/docs/r/discovery_engine_acl_config.html.markdown @@ -67,6 +67,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `idp_config` block supports: diff --git a/website/docs/r/discovery_engine_assistant.html.markdown b/website/docs/r/discovery_engine_assistant.html.markdown index ffc9c4bee46..32c48e0cf78 100644 --- a/website/docs/r/discovery_engine_assistant.html.markdown +++ b/website/docs/r/discovery_engine_assistant.html.markdown @@ -130,6 +130,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `generation_config` block supports: diff --git a/website/docs/r/discovery_engine_chat_engine.html.markdown b/website/docs/r/discovery_engine_chat_engine.html.markdown index c6336133eb6..19c13992d87 100644 --- a/website/docs/r/discovery_engine_chat_engine.html.markdown +++ b/website/docs/r/discovery_engine_chat_engine.html.markdown @@ -163,6 +163,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `chat_engine_config` block supports: diff --git a/website/docs/r/discovery_engine_cmek_config.html.markdown b/website/docs/r/discovery_engine_cmek_config.html.markdown index e8294f01682..afed1406673 100644 --- a/website/docs/r/discovery_engine_cmek_config.html.markdown +++ b/website/docs/r/discovery_engine_cmek_config.html.markdown @@ -83,6 +83,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `single_region_keys` block supports: diff --git a/website/docs/r/discovery_engine_control.html.markdown b/website/docs/r/discovery_engine_control.html.markdown index 8ec73901ff5..8f4ea4912c3 100644 --- a/website/docs/r/discovery_engine_control.html.markdown +++ b/website/docs/r/discovery_engine_control.html.markdown @@ -145,6 +145,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `conditions` block supports: diff --git a/website/docs/r/discovery_engine_data_connector.html.markdown b/website/docs/r/discovery_engine_data_connector.html.markdown index 22087784048..f78633901b1 100644 --- a/website/docs/r/discovery_engine_data_connector.html.markdown +++ b/website/docs/r/discovery_engine_data_connector.html.markdown @@ -333,6 +333,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `entities` block supports: diff --git a/website/docs/r/discovery_engine_data_store.html.markdown b/website/docs/r/discovery_engine_data_store.html.markdown index bf769c425a4..692b4da3287 100644 --- a/website/docs/r/discovery_engine_data_store.html.markdown +++ b/website/docs/r/discovery_engine_data_store.html.markdown @@ -203,6 +203,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `advanced_site_search_config` block supports: diff --git a/website/docs/r/discovery_engine_license_config.html.markdown b/website/docs/r/discovery_engine_license_config.html.markdown index 068fa0ab6e9..728521a8bd4 100644 --- a/website/docs/r/discovery_engine_license_config.html.markdown +++ b/website/docs/r/discovery_engine_license_config.html.markdown @@ -101,6 +101,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `start_date` block supports: diff --git a/website/docs/r/discovery_engine_recommendation_engine.html.markdown b/website/docs/r/discovery_engine_recommendation_engine.html.markdown index 50601c0e084..a23cc18a61a 100644 --- a/website/docs/r/discovery_engine_recommendation_engine.html.markdown +++ b/website/docs/r/discovery_engine_recommendation_engine.html.markdown @@ -144,6 +144,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `media_recommendation_engine_config` block supports: diff --git a/website/docs/r/discovery_engine_schema.html.markdown b/website/docs/r/discovery_engine_schema.html.markdown index 2e2fc98afeb..190efe86048 100644 --- a/website/docs/r/discovery_engine_schema.html.markdown +++ b/website/docs/r/discovery_engine_schema.html.markdown @@ -84,6 +84,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/discovery_engine_search_engine.html.markdown b/website/docs/r/discovery_engine_search_engine.html.markdown index 685546158d9..0c95ce4ddec 100644 --- a/website/docs/r/discovery_engine_search_engine.html.markdown +++ b/website/docs/r/discovery_engine_search_engine.html.markdown @@ -169,6 +169,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `search_engine_config` block supports: diff --git a/website/docs/r/discovery_engine_serving_config.html.markdown b/website/docs/r/discovery_engine_serving_config.html.markdown index f709c392b3a..7b3c93ae5a4 100644 --- a/website/docs/r/discovery_engine_serving_config.html.markdown +++ b/website/docs/r/discovery_engine_serving_config.html.markdown @@ -75,6 +75,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/discovery_engine_sitemap.html.markdown b/website/docs/r/discovery_engine_sitemap.html.markdown index 9b41d2d3baa..ea9ccc73a60 100644 --- a/website/docs/r/discovery_engine_sitemap.html.markdown +++ b/website/docs/r/discovery_engine_sitemap.html.markdown @@ -79,6 +79,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/discovery_engine_target_site.html.markdown b/website/docs/r/discovery_engine_target_site.html.markdown index 60052fcc7bd..5eb9a1e4ec7 100644 --- a/website/docs/r/discovery_engine_target_site.html.markdown +++ b/website/docs/r/discovery_engine_target_site.html.markdown @@ -124,6 +124,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/discovery_engine_user_store.html.markdown b/website/docs/r/discovery_engine_user_store.html.markdown index 6d618377e8d..a8c3abd3928 100644 --- a/website/docs/r/discovery_engine_user_store.html.markdown +++ b/website/docs/r/discovery_engine_user_store.html.markdown @@ -100,6 +100,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/discovery_engine_widget_config.html.markdown b/website/docs/r/discovery_engine_widget_config.html.markdown index e98303f579b..6fbe2a1fa3b 100644 --- a/website/docs/r/discovery_engine_widget_config.html.markdown +++ b/website/docs/r/discovery_engine_widget_config.html.markdown @@ -129,6 +129,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `access_settings` block supports: diff --git a/website/docs/r/dns_managed_zone.html.markdown b/website/docs/r/dns_managed_zone.html.markdown index 0bfbe508af6..a02bb2aef00 100644 --- a/website/docs/r/dns_managed_zone.html.markdown +++ b/website/docs/r/dns_managed_zone.html.markdown @@ -454,6 +454,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `force_destroy` - (Optional) Set this true to delete all records in the zone. diff --git a/website/docs/r/dns_policy.html.markdown b/website/docs/r/dns_policy.html.markdown index 52a96f45e39..d06041463eb 100644 --- a/website/docs/r/dns_policy.html.markdown +++ b/website/docs/r/dns_policy.html.markdown @@ -122,6 +122,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `alternative_name_server_config` block supports: diff --git a/website/docs/r/dns_record_set.html.markdown b/website/docs/r/dns_record_set.html.markdown index 80f745890f8..7f6128294ed 100644 --- a/website/docs/r/dns_record_set.html.markdown +++ b/website/docs/r/dns_record_set.html.markdown @@ -329,6 +329,13 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + The `routing_policy` block supports: * `wrr` - (Optional) The configuration for Weighted Round Robin based routing policy. diff --git a/website/docs/r/dns_response_policy.html.markdown b/website/docs/r/dns_response_policy.html.markdown index afedd4e47b9..72201fa7174 100644 --- a/website/docs/r/dns_response_policy.html.markdown +++ b/website/docs/r/dns_response_policy.html.markdown @@ -135,6 +135,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `networks` block supports: diff --git a/website/docs/r/dns_response_policy_rule.html.markdown b/website/docs/r/dns_response_policy_rule.html.markdown index b11c265071d..5f56fce428e 100644 --- a/website/docs/r/dns_response_policy_rule.html.markdown +++ b/website/docs/r/dns_response_policy_rule.html.markdown @@ -106,6 +106,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `local_data` block supports: diff --git a/website/docs/r/document_ai_processor.html.markdown b/website/docs/r/document_ai_processor.html.markdown index f277f2dda20..c510f25c841 100644 --- a/website/docs/r/document_ai_processor.html.markdown +++ b/website/docs/r/document_ai_processor.html.markdown @@ -71,6 +71,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/document_ai_processor_default_version.html.markdown b/website/docs/r/document_ai_processor_default_version.html.markdown index 86c02621c69..db37571fe0d 100644 --- a/website/docs/r/document_ai_processor_default_version.html.markdown +++ b/website/docs/r/document_ai_processor_default_version.html.markdown @@ -68,6 +68,12 @@ The following arguments are supported: The processor to set the version on. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/document_ai_schema.html.markdown b/website/docs/r/document_ai_schema.html.markdown index 689e643516d..d74da0c4eaf 100644 --- a/website/docs/r/document_ai_schema.html.markdown +++ b/website/docs/r/document_ai_schema.html.markdown @@ -70,6 +70,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/document_ai_warehouse_document_schema.html.markdown b/website/docs/r/document_ai_warehouse_document_schema.html.markdown index 0f10f360c33..085f2526010 100644 --- a/website/docs/r/document_ai_warehouse_document_schema.html.markdown +++ b/website/docs/r/document_ai_warehouse_document_schema.html.markdown @@ -88,6 +88,12 @@ The following arguments are supported: (Optional) Tells whether the document is a folder or a typical document. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `property_definitions` block supports: diff --git a/website/docs/r/document_ai_warehouse_location.html.markdown b/website/docs/r/document_ai_warehouse_location.html.markdown index a052b50c98a..76f444b8d37 100644 --- a/website/docs/r/document_ai_warehouse_location.html.markdown +++ b/website/docs/r/document_ai_warehouse_location.html.markdown @@ -84,6 +84,12 @@ The following arguments are supported: The default role for the person who create a document. Possible values are: `DOCUMENT_ADMIN`, `DOCUMENT_EDITOR`, `DOCUMENT_VIEWER`. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/edgecontainer_cluster.html.markdown b/website/docs/r/edgecontainer_cluster.html.markdown index f012113f73b..2843edb99ba 100644 --- a/website/docs/r/edgecontainer_cluster.html.markdown +++ b/website/docs/r/edgecontainer_cluster.html.markdown @@ -156,6 +156,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `fleet` block supports: diff --git a/website/docs/r/edgecontainer_node_pool.html.markdown b/website/docs/r/edgecontainer_node_pool.html.markdown index 5b8b0b16d61..b568f6ec54f 100644 --- a/website/docs/r/edgecontainer_node_pool.html.markdown +++ b/website/docs/r/edgecontainer_node_pool.html.markdown @@ -127,6 +127,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `local_disk_encryption` block supports: diff --git a/website/docs/r/edgecontainer_vpn_connection.html.markdown b/website/docs/r/edgecontainer_vpn_connection.html.markdown index 938d600bf7b..b704d8ddfcd 100644 --- a/website/docs/r/edgecontainer_vpn_connection.html.markdown +++ b/website/docs/r/edgecontainer_vpn_connection.html.markdown @@ -132,6 +132,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `vpc_project` block supports: diff --git a/website/docs/r/edgenetwork_interconnect_attachment.html.markdown b/website/docs/r/edgenetwork_interconnect_attachment.html.markdown index bd50f9899b1..abdfd5cd272 100644 --- a/website/docs/r/edgenetwork_interconnect_attachment.html.markdown +++ b/website/docs/r/edgenetwork_interconnect_attachment.html.markdown @@ -107,6 +107,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/edgenetwork_network.html.markdown b/website/docs/r/edgenetwork_network.html.markdown index 8837975150f..2dbdddabb45 100644 --- a/website/docs/r/edgenetwork_network.html.markdown +++ b/website/docs/r/edgenetwork_network.html.markdown @@ -83,6 +83,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/edgenetwork_subnet.html.markdown b/website/docs/r/edgenetwork_subnet.html.markdown index a6993275fe3..f92acadb49c 100644 --- a/website/docs/r/edgenetwork_subnet.html.markdown +++ b/website/docs/r/edgenetwork_subnet.html.markdown @@ -131,6 +131,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/essential_contacts_contact.html.markdown b/website/docs/r/essential_contacts_contact.html.markdown index d50f7838a9b..20ad70a30e2 100644 --- a/website/docs/r/essential_contacts_contact.html.markdown +++ b/website/docs/r/essential_contacts_contact.html.markdown @@ -78,6 +78,12 @@ The following arguments are supported: The resource to save this contact for. Format: organizations/{organization_id}, folders/{folder_id} or projects/{project_id} +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/eventarc_channel.html.markdown b/website/docs/r/eventarc_channel.html.markdown index 6cbb8887003..82efbd8bcea 100644 --- a/website/docs/r/eventarc_channel.html.markdown +++ b/website/docs/r/eventarc_channel.html.markdown @@ -73,6 +73,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/eventarc_enrollment.html.markdown b/website/docs/r/eventarc_enrollment.html.markdown index 19932674db7..523de5b0bf9 100644 --- a/website/docs/r/eventarc_enrollment.html.markdown +++ b/website/docs/r/eventarc_enrollment.html.markdown @@ -111,6 +111,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/eventarc_google_api_source.html.markdown b/website/docs/r/eventarc_google_api_source.html.markdown index 6e14881a63d..7956371122e 100644 --- a/website/docs/r/eventarc_google_api_source.html.markdown +++ b/website/docs/r/eventarc_google_api_source.html.markdown @@ -121,6 +121,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `logging_config` block supports: diff --git a/website/docs/r/eventarc_google_channel_config.html.markdown b/website/docs/r/eventarc_google_channel_config.html.markdown index 779fae752f5..8746845419c 100644 --- a/website/docs/r/eventarc_google_channel_config.html.markdown +++ b/website/docs/r/eventarc_google_channel_config.html.markdown @@ -83,6 +83,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/eventarc_message_bus.html.markdown b/website/docs/r/eventarc_message_bus.html.markdown index 962b6a8d7b7..72e0ef72982 100644 --- a/website/docs/r/eventarc_message_bus.html.markdown +++ b/website/docs/r/eventarc_message_bus.html.markdown @@ -109,6 +109,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `logging_config` block supports: diff --git a/website/docs/r/eventarc_pipeline.html.markdown b/website/docs/r/eventarc_pipeline.html.markdown index 84f6caad263..2ac3171f28e 100644 --- a/website/docs/r/eventarc_pipeline.html.markdown +++ b/website/docs/r/eventarc_pipeline.html.markdown @@ -356,6 +356,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `destinations` block supports: diff --git a/website/docs/r/eventarc_trigger.html.markdown b/website/docs/r/eventarc_trigger.html.markdown index 8cd29f0872e..9d5ac1a61a1 100644 --- a/website/docs/r/eventarc_trigger.html.markdown +++ b/website/docs/r/eventarc_trigger.html.markdown @@ -149,6 +149,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `matching_criteria` block supports: diff --git a/website/docs/r/filestore_backup.html.markdown b/website/docs/r/filestore_backup.html.markdown index fb9dcca888e..ac3b0946415 100644 --- a/website/docs/r/filestore_backup.html.markdown +++ b/website/docs/r/filestore_backup.html.markdown @@ -120,6 +120,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/filestore_instance.html.markdown b/website/docs/r/filestore_instance.html.markdown index 1c1f1414659..8549154ec40 100644 --- a/website/docs/r/filestore_instance.html.markdown +++ b/website/docs/r/filestore_instance.html.markdown @@ -259,6 +259,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `desired_replica_state` - (Optional) The desired_replica_state field controls the state of a replica. Terraform will attempt to make the actual state of the replica match the desired state. diff --git a/website/docs/r/filestore_snapshot.html.markdown b/website/docs/r/filestore_snapshot.html.markdown index 40f849fa7ff..1abab1c7957 100644 --- a/website/docs/r/filestore_snapshot.html.markdown +++ b/website/docs/r/filestore_snapshot.html.markdown @@ -138,6 +138,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/firebase_ai_logic_config.html.markdown b/website/docs/r/firebase_ai_logic_config.html.markdown index 9cacbf71b1a..e18ebf1f74d 100644 --- a/website/docs/r/firebase_ai_logic_config.html.markdown +++ b/website/docs/r/firebase_ai_logic_config.html.markdown @@ -206,6 +206,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `generative_language_config` block supports: diff --git a/website/docs/r/firebase_ai_logic_prompt_template.html.markdown b/website/docs/r/firebase_ai_logic_prompt_template.html.markdown index db1ebb5f653..572b6e4db33 100644 --- a/website/docs/r/firebase_ai_logic_prompt_template.html.markdown +++ b/website/docs/r/firebase_ai_logic_prompt_template.html.markdown @@ -98,6 +98,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/firebase_ai_logic_prompt_template_lock.html.markdown b/website/docs/r/firebase_ai_logic_prompt_template_lock.html.markdown index 02630fd5713..e4d28b22d05 100644 --- a/website/docs/r/firebase_ai_logic_prompt_template_lock.html.markdown +++ b/website/docs/r/firebase_ai_logic_prompt_template_lock.html.markdown @@ -69,6 +69,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/firebase_android_app.html.markdown b/website/docs/r/firebase_android_app.html.markdown index 1a0c7a44148..8eeb0adb27b 100644 --- a/website/docs/r/firebase_android_app.html.markdown +++ b/website/docs/r/firebase_android_app.html.markdown @@ -109,10 +109,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. -* `deletion_policy` - (Optional) (Optional) Set to `ABANDON` to allow the AndroidApp to be untracked from terraform state -rather than deleted upon `terraform destroy`. This is useful because the AndroidApp may be -serving traffic. Set to `DELETE` to delete the AndroidApp. Defaults to `DELETE`. - +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/firebase_app_check_app_attest_config.html.markdown b/website/docs/r/firebase_app_check_app_attest_config.html.markdown index cefa2ab39ad..d2505e76062 100644 --- a/website/docs/r/firebase_app_check_app_attest_config.html.markdown +++ b/website/docs/r/firebase_app_check_app_attest_config.html.markdown @@ -125,6 +125,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/firebase_app_check_debug_token.html.markdown b/website/docs/r/firebase_app_check_debug_token.html.markdown index 78de4c02de8..90acb4b8957 100644 --- a/website/docs/r/firebase_app_check_debug_token.html.markdown +++ b/website/docs/r/firebase_app_check_debug_token.html.markdown @@ -98,6 +98,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/firebase_app_check_device_check_config.html.markdown b/website/docs/r/firebase_app_check_device_check_config.html.markdown index 2853c4dcc6b..ce3f3a953ac 100644 --- a/website/docs/r/firebase_app_check_device_check_config.html.markdown +++ b/website/docs/r/firebase_app_check_device_check_config.html.markdown @@ -104,6 +104,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/firebase_app_check_play_integrity_config.html.markdown b/website/docs/r/firebase_app_check_play_integrity_config.html.markdown index 998ec05fb30..7ed3f532744 100644 --- a/website/docs/r/firebase_app_check_play_integrity_config.html.markdown +++ b/website/docs/r/firebase_app_check_play_integrity_config.html.markdown @@ -145,6 +145,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/firebase_app_check_recaptcha_enterprise_config.html.markdown b/website/docs/r/firebase_app_check_recaptcha_enterprise_config.html.markdown index 2e83abd57e4..6ad0f959521 100644 --- a/website/docs/r/firebase_app_check_recaptcha_enterprise_config.html.markdown +++ b/website/docs/r/firebase_app_check_recaptcha_enterprise_config.html.markdown @@ -93,6 +93,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/firebase_app_check_recaptcha_v3_config.html.markdown b/website/docs/r/firebase_app_check_recaptcha_v3_config.html.markdown index 9edd659126c..28788a8f716 100644 --- a/website/docs/r/firebase_app_check_recaptcha_v3_config.html.markdown +++ b/website/docs/r/firebase_app_check_recaptcha_v3_config.html.markdown @@ -90,6 +90,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/firebase_app_check_resource_policy.html.markdown b/website/docs/r/firebase_app_check_resource_policy.html.markdown index 1bf3fec2a66..2e1c229faa0 100644 --- a/website/docs/r/firebase_app_check_resource_policy.html.markdown +++ b/website/docs/r/firebase_app_check_resource_policy.html.markdown @@ -100,6 +100,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/firebase_app_check_service_config.html.markdown b/website/docs/r/firebase_app_check_service_config.html.markdown index d58f32fa3bc..344f6c8254d 100644 --- a/website/docs/r/firebase_app_check_service_config.html.markdown +++ b/website/docs/r/firebase_app_check_service_config.html.markdown @@ -127,6 +127,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/firebase_app_hosting_backend.html.markdown b/website/docs/r/firebase_app_hosting_backend.html.markdown index 7d53cc50324..e919a7de720 100644 --- a/website/docs/r/firebase_app_hosting_backend.html.markdown +++ b/website/docs/r/firebase_app_hosting_backend.html.markdown @@ -276,6 +276,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `codebase` block supports: diff --git a/website/docs/r/firebase_app_hosting_build.html.markdown b/website/docs/r/firebase_app_hosting_build.html.markdown index 0e46c048ce1..d6b8ce5e5b4 100644 --- a/website/docs/r/firebase_app_hosting_build.html.markdown +++ b/website/docs/r/firebase_app_hosting_build.html.markdown @@ -273,6 +273,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `source` block supports: diff --git a/website/docs/r/firebase_app_hosting_default_domain.html.markdown b/website/docs/r/firebase_app_hosting_default_domain.html.markdown index 9b08ab35f62..b9633adff68 100644 --- a/website/docs/r/firebase_app_hosting_default_domain.html.markdown +++ b/website/docs/r/firebase_app_hosting_default_domain.html.markdown @@ -154,6 +154,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/firebase_app_hosting_domain.html.markdown b/website/docs/r/firebase_app_hosting_domain.html.markdown index 509e402e6f2..d798bd000b3 100644 --- a/website/docs/r/firebase_app_hosting_domain.html.markdown +++ b/website/docs/r/firebase_app_hosting_domain.html.markdown @@ -127,6 +127,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `serve` block supports: diff --git a/website/docs/r/firebase_app_hosting_traffic.html.markdown b/website/docs/r/firebase_app_hosting_traffic.html.markdown index da794297076..83354399fe9 100644 --- a/website/docs/r/firebase_app_hosting_traffic.html.markdown +++ b/website/docs/r/firebase_app_hosting_traffic.html.markdown @@ -231,6 +231,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `target` block supports: diff --git a/website/docs/r/firebase_apple_app.html.markdown b/website/docs/r/firebase_apple_app.html.markdown index c602f0f7c5c..c35ca540435 100644 --- a/website/docs/r/firebase_apple_app.html.markdown +++ b/website/docs/r/firebase_apple_app.html.markdown @@ -103,10 +103,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. -* `deletion_policy` - (Optional) (Optional) Set to `ABANDON` to allow the Apple to be untracked from terraform state -rather than deleted upon `terraform destroy`. This is useful because the Apple may be -serving traffic. Set to `DELETE` to delete the Apple. Defaults to `DELETE`. - +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/firebase_data_connect_service.html.markdown b/website/docs/r/firebase_data_connect_service.html.markdown index 289362e52b0..8e13574f8b4 100644 --- a/website/docs/r/firebase_data_connect_service.html.markdown +++ b/website/docs/r/firebase_data_connect_service.html.markdown @@ -118,7 +118,14 @@ The following arguments are supported: Service to be deleted even if a Schema or Connector is present. By default, the Service deletion will only succeed when no Schema or Connectors are present. -Possible values: DEFAULT, FORCE + +When a 'terraform destroy' or 'terraform apply' would delete the resource, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", the command will behave as if set to "DEFAULT". + +Possible values: DEFAULT, FORCE, PREVENT, ABANDON, DELETE ## Attributes Reference diff --git a/website/docs/r/firebase_database_instance.html.markdown b/website/docs/r/firebase_database_instance.html.markdown index e33459ea908..d0eefabc9e8 100644 --- a/website/docs/r/firebase_database_instance.html.markdown +++ b/website/docs/r/firebase_database_instance.html.markdown @@ -133,6 +133,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `desired_state` - (Optional) The intended database state. Possible values: ACTIVE, DISABLED. diff --git a/website/docs/r/firebase_extensions_instance.html.markdown b/website/docs/r/firebase_extensions_instance.html.markdown index 2a9fc518b66..ca14c1592eb 100644 --- a/website/docs/r/firebase_extensions_instance.html.markdown +++ b/website/docs/r/firebase_extensions_instance.html.markdown @@ -104,6 +104,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `config` block supports: diff --git a/website/docs/r/firebase_hosting_channel.html.markdown b/website/docs/r/firebase_hosting_channel.html.markdown index 904d9c70261..2e0242b3d73 100644 --- a/website/docs/r/firebase_hosting_channel.html.markdown +++ b/website/docs/r/firebase_hosting_channel.html.markdown @@ -109,6 +109,12 @@ The following arguments are supported: duration past the time of the request. A duration in seconds with up to nine fractional digits, terminated by 's'. Example: "86400s" (one day). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/firebase_hosting_custom_domain.html.markdown b/website/docs/r/firebase_hosting_custom_domain.html.markdown index 6869221c923..953149f119e 100644 --- a/website/docs/r/firebase_hosting_custom_domain.html.markdown +++ b/website/docs/r/firebase_hosting_custom_domain.html.markdown @@ -160,6 +160,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `wait_dns_verification` - (Optional) If true, Terraform will wait for DNS records to be fully resolved on the `CustomDomain`. If false, Terraform will not wait for DNS records on the `CustomDomain`. Any issues in the `CustomDomain` will be returned and stored in the Terraform state. diff --git a/website/docs/r/firebase_hosting_release.html.markdown b/website/docs/r/firebase_hosting_release.html.markdown index a1c5d9b6600..6e545b00fba 100644 --- a/website/docs/r/firebase_hosting_release.html.markdown +++ b/website/docs/r/firebase_hosting_release.html.markdown @@ -150,6 +150,12 @@ The following arguments are supported: The Version must belong to the same site as in the `site_id`. This parameter must be empty if the `type` of the release is `SITE_DISABLE`. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/firebase_hosting_site.html.markdown b/website/docs/r/firebase_hosting_site.html.markdown index c54c80ee18a..8b0f0f8eec2 100644 --- a/website/docs/r/firebase_hosting_site.html.markdown +++ b/website/docs/r/firebase_hosting_site.html.markdown @@ -90,6 +90,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/firebase_hosting_version.html.markdown b/website/docs/r/firebase_hosting_version.html.markdown index 61167b1fd8c..71184b5a965 100644 --- a/website/docs/r/firebase_hosting_version.html.markdown +++ b/website/docs/r/firebase_hosting_version.html.markdown @@ -285,6 +285,12 @@ The following arguments are supported: The configuration for the behavior of the site. This configuration exists in the `firebase.json` file. Structure is [documented below](#nested_config). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `config` block supports: diff --git a/website/docs/r/firebase_project.html.markdown b/website/docs/r/firebase_project.html.markdown index 795933a65a6..53205fbf353 100644 --- a/website/docs/r/firebase_project.html.markdown +++ b/website/docs/r/firebase_project.html.markdown @@ -71,6 +71,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/firebase_remote_config_remote_config.html.markdown b/website/docs/r/firebase_remote_config_remote_config.html.markdown index 832b9ff997a..77f837bfbdf 100644 --- a/website/docs/r/firebase_remote_config_remote_config.html.markdown +++ b/website/docs/r/firebase_remote_config_remote_config.html.markdown @@ -108,6 +108,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `conditions` block supports: diff --git a/website/docs/r/firebase_storage_bucket.html.markdown b/website/docs/r/firebase_storage_bucket.html.markdown index 53ba8f5bdf5..8eb7878cfb5 100644 --- a/website/docs/r/firebase_storage_bucket.html.markdown +++ b/website/docs/r/firebase_storage_bucket.html.markdown @@ -64,6 +64,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/firebase_storage_default_bucket.html.markdown b/website/docs/r/firebase_storage_default_bucket.html.markdown index 3767b7b50f5..8e1b5509a07 100644 --- a/website/docs/r/firebase_storage_default_bucket.html.markdown +++ b/website/docs/r/firebase_storage_default_bucket.html.markdown @@ -58,6 +58,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/firebase_web_app.html.markdown b/website/docs/r/firebase_web_app.html.markdown index e604876b531..1e58edadf63 100644 --- a/website/docs/r/firebase_web_app.html.markdown +++ b/website/docs/r/firebase_web_app.html.markdown @@ -114,10 +114,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. -* `deletion_policy` - (Optional) Set to `ABANDON` to allow the WebApp to be untracked from terraform state -rather than deleted upon `terraform destroy`. This is useful becaue the WebApp may be -serving traffic. Set to `DELETE` to delete the WebApp. Default to `DELETE` - +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/firebaserules_release.html.markdown b/website/docs/r/firebaserules_release.html.markdown index e8211d39406..6a9765bf6db 100644 --- a/website/docs/r/firebaserules_release.html.markdown +++ b/website/docs/r/firebaserules_release.html.markdown @@ -134,7 +134,13 @@ The following arguments are supported: * `project` - (Optional) The project for the resource - + +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/firebaserules_ruleset.html.markdown b/website/docs/r/firebaserules_ruleset.html.markdown index 82cc3ba8f0c..db399955908 100644 --- a/website/docs/r/firebaserules_ruleset.html.markdown +++ b/website/docs/r/firebaserules_ruleset.html.markdown @@ -85,7 +85,13 @@ The `source` block supports: * `project` - (Optional) The project for the resource - + +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `files` block supports: diff --git a/website/docs/r/firestore_backup_schedule.html.markdown b/website/docs/r/firestore_backup_schedule.html.markdown index 86e4cf9d558..4d7a5c67085 100644 --- a/website/docs/r/firestore_backup_schedule.html.markdown +++ b/website/docs/r/firestore_backup_schedule.html.markdown @@ -114,6 +114,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `weekly_recurrence` block supports: diff --git a/website/docs/r/firestore_database.html.markdown b/website/docs/r/firestore_database.html.markdown index 5742aec78d4..5b54e563665 100644 --- a/website/docs/r/firestore_database.html.markdown +++ b/website/docs/r/firestore_database.html.markdown @@ -325,12 +325,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. -* `deletion_policy` - (Optional) Deletion behavior for this database. -If the deletion policy is `ABANDON`, the database will be removed from Terraform state but not deleted from Google Cloud upon destruction. -If the deletion policy is `DELETE`, the database will both be removed from Terraform state and deleted from Google Cloud upon destruction. -The default value is `ABANDON`. -See also `delete_protection`. - +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to ABANDON. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `cmek_config` block supports: diff --git a/website/docs/r/firestore_document.html.markdown b/website/docs/r/firestore_document.html.markdown index fa66508eef5..4471de7e287 100644 --- a/website/docs/r/firestore_document.html.markdown +++ b/website/docs/r/firestore_document.html.markdown @@ -166,6 +166,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/firestore_field.html.markdown b/website/docs/r/firestore_field.html.markdown index 88d4113c9ec..1cc808809ef 100644 --- a/website/docs/r/firestore_field.html.markdown +++ b/website/docs/r/firestore_field.html.markdown @@ -194,6 +194,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `index_config` block supports: diff --git a/website/docs/r/firestore_index.html.markdown b/website/docs/r/firestore_index.html.markdown index 3c396813d82..2141851d55c 100644 --- a/website/docs/r/firestore_index.html.markdown +++ b/website/docs/r/firestore_index.html.markdown @@ -498,12 +498,13 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `skip_wait` - (Optional) Whether to skip waiting for the index to be created. -* `deletion_policy` - (Optional) Deletion behavior for this index. -If the deletion policy is `PREVENT`, the index cannot be deleted and a terraform destroy will fail. -If the deletion policy is `DELETE`, the index will both be removed from Terraform state and deleted from Google Cloud upon destruction. -The default value is `DELETE`. - The `fields` block supports: diff --git a/website/docs/r/firestore_user_creds.html.markdown b/website/docs/r/firestore_user_creds.html.markdown index eda5dce257b..a7b6c643995 100644 --- a/website/docs/r/firestore_user_creds.html.markdown +++ b/website/docs/r/firestore_user_creds.html.markdown @@ -113,6 +113,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/folder_access_approval_settings.html.markdown b/website/docs/r/folder_access_approval_settings.html.markdown index 772e7ac2239..ab4f46b7728 100644 --- a/website/docs/r/folder_access_approval_settings.html.markdown +++ b/website/docs/r/folder_access_approval_settings.html.markdown @@ -136,6 +136,12 @@ The following arguments are supported: Empty active_key_version indicates that a Google-managed key should be used for signing. This property will be ignored if set by an ancestor of the resource, and new non-empty values may not be set. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `enrolled_services` block supports: diff --git a/website/docs/r/gemini_code_repository_index.html.markdown b/website/docs/r/gemini_code_repository_index.html.markdown index d75ce496a60..9626e2d7563 100644 --- a/website/docs/r/gemini_code_repository_index.html.markdown +++ b/website/docs/r/gemini_code_repository_index.html.markdown @@ -69,6 +69,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `force_destroy` - (Optional) If set to true, will allow deletion of the CodeRepositoryIndex even if there are existing RepositoryGroups for the resource. These RepositoryGroups will also be deleted. diff --git a/website/docs/r/gemini_code_tools_setting.html.markdown b/website/docs/r/gemini_code_tools_setting.html.markdown index cce67e625f7..9f328b41bc9 100644 --- a/website/docs/r/gemini_code_tools_setting.html.markdown +++ b/website/docs/r/gemini_code_tools_setting.html.markdown @@ -74,6 +74,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `enabled_tool` block supports: diff --git a/website/docs/r/gemini_code_tools_setting_binding.html.markdown b/website/docs/r/gemini_code_tools_setting_binding.html.markdown index c1b0afdfbe6..b64a533bc54 100644 --- a/website/docs/r/gemini_code_tools_setting_binding.html.markdown +++ b/website/docs/r/gemini_code_tools_setting_binding.html.markdown @@ -92,6 +92,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/gemini_data_sharing_with_google_setting.html.markdown b/website/docs/r/gemini_data_sharing_with_google_setting.html.markdown index a911fc800e3..8895fa04c5b 100644 --- a/website/docs/r/gemini_data_sharing_with_google_setting.html.markdown +++ b/website/docs/r/gemini_data_sharing_with_google_setting.html.markdown @@ -69,6 +69,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/gemini_data_sharing_with_google_setting_binding.html.markdown b/website/docs/r/gemini_data_sharing_with_google_setting_binding.html.markdown index 9637fe4f569..c6f0713910c 100644 --- a/website/docs/r/gemini_data_sharing_with_google_setting_binding.html.markdown +++ b/website/docs/r/gemini_data_sharing_with_google_setting_binding.html.markdown @@ -83,6 +83,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/gemini_gemini_gcp_enablement_setting.html.markdown b/website/docs/r/gemini_gemini_gcp_enablement_setting.html.markdown index bd6883d1f15..231c1150e2b 100644 --- a/website/docs/r/gemini_gemini_gcp_enablement_setting.html.markdown +++ b/website/docs/r/gemini_gemini_gcp_enablement_setting.html.markdown @@ -83,6 +83,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/gemini_gemini_gcp_enablement_setting_binding.html.markdown b/website/docs/r/gemini_gemini_gcp_enablement_setting_binding.html.markdown index 768126abd9b..7d29c7a0724 100644 --- a/website/docs/r/gemini_gemini_gcp_enablement_setting_binding.html.markdown +++ b/website/docs/r/gemini_gemini_gcp_enablement_setting_binding.html.markdown @@ -83,6 +83,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/gemini_logging_setting.html.markdown b/website/docs/r/gemini_logging_setting.html.markdown index b8ff6e06a5f..014cc40a52b 100644 --- a/website/docs/r/gemini_logging_setting.html.markdown +++ b/website/docs/r/gemini_logging_setting.html.markdown @@ -74,6 +74,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/gemini_logging_setting_binding.html.markdown b/website/docs/r/gemini_logging_setting_binding.html.markdown index 25ba6ad3de5..2ddbbb1d157 100644 --- a/website/docs/r/gemini_logging_setting_binding.html.markdown +++ b/website/docs/r/gemini_logging_setting_binding.html.markdown @@ -83,6 +83,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/gemini_release_channel_setting.html.markdown b/website/docs/r/gemini_release_channel_setting.html.markdown index 5c71523a0e9..9e60bdb8539 100644 --- a/website/docs/r/gemini_release_channel_setting.html.markdown +++ b/website/docs/r/gemini_release_channel_setting.html.markdown @@ -72,6 +72,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/gemini_release_channel_setting_binding.html.markdown b/website/docs/r/gemini_release_channel_setting_binding.html.markdown index 8f7b991da60..aab36656777 100644 --- a/website/docs/r/gemini_release_channel_setting_binding.html.markdown +++ b/website/docs/r/gemini_release_channel_setting_binding.html.markdown @@ -83,6 +83,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/gemini_repository_group.html.markdown b/website/docs/r/gemini_repository_group.html.markdown index d4c9675d2ef..b01cb2a6a9b 100644 --- a/website/docs/r/gemini_repository_group.html.markdown +++ b/website/docs/r/gemini_repository_group.html.markdown @@ -76,6 +76,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `repositories` block supports: diff --git a/website/docs/r/gke_backup_backup_channel.html.markdown b/website/docs/r/gke_backup_backup_channel.html.markdown index fc54aa7620f..2f5ffc63fcf 100644 --- a/website/docs/r/gke_backup_backup_channel.html.markdown +++ b/website/docs/r/gke_backup_backup_channel.html.markdown @@ -82,6 +82,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/gke_backup_backup_plan.html.markdown b/website/docs/r/gke_backup_backup_plan.html.markdown index 993ea3b9973..c741d0810c8 100644 --- a/website/docs/r/gke_backup_backup_plan.html.markdown +++ b/website/docs/r/gke_backup_backup_plan.html.markdown @@ -477,6 +477,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `retention_policy` block supports: diff --git a/website/docs/r/gke_backup_restore_channel.html.markdown b/website/docs/r/gke_backup_restore_channel.html.markdown index f4ec0dd0dab..7770da34def 100644 --- a/website/docs/r/gke_backup_restore_channel.html.markdown +++ b/website/docs/r/gke_backup_restore_channel.html.markdown @@ -82,6 +82,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/gke_backup_restore_plan.html.markdown b/website/docs/r/gke_backup_restore_plan.html.markdown index a9166d9fa5f..373867a25b9 100644 --- a/website/docs/r/gke_backup_restore_plan.html.markdown +++ b/website/docs/r/gke_backup_restore_plan.html.markdown @@ -595,6 +595,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `restore_config` block supports: diff --git a/website/docs/r/gke_hub_feature.html.markdown b/website/docs/r/gke_hub_feature.html.markdown index 30f0edff520..b446a14a60d 100644 --- a/website/docs/r/gke_hub_feature.html.markdown +++ b/website/docs/r/gke_hub_feature.html.markdown @@ -370,6 +370,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `spec` block supports: diff --git a/website/docs/r/gke_hub_feature_membership.html.markdown b/website/docs/r/gke_hub_feature_membership.html.markdown index fd0df46bbb7..a2b0a308d60 100644 --- a/website/docs/r/gke_hub_feature_membership.html.markdown +++ b/website/docs/r/gke_hub_feature_membership.html.markdown @@ -372,6 +372,13 @@ The following arguments are supported: * `project` - (Optional) The project of the feature + +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. diff --git a/website/docs/r/gke_hub_fleet.html.markdown b/website/docs/r/gke_hub_fleet.html.markdown index 28fe2ed97a7..22f21d4af0a 100644 --- a/website/docs/r/gke_hub_fleet.html.markdown +++ b/website/docs/r/gke_hub_fleet.html.markdown @@ -64,6 +64,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `default_cluster_config` block supports: diff --git a/website/docs/r/gke_hub_membership.html.markdown b/website/docs/r/gke_hub_membership.html.markdown index 483aa88b5cc..3bfcd71cb72 100644 --- a/website/docs/r/gke_hub_membership.html.markdown +++ b/website/docs/r/gke_hub_membership.html.markdown @@ -150,6 +150,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `endpoint` block supports: diff --git a/website/docs/r/gke_hub_membership_binding.html.markdown b/website/docs/r/gke_hub_membership_binding.html.markdown index 239ae196cc1..cd97bbd1191 100644 --- a/website/docs/r/gke_hub_membership_binding.html.markdown +++ b/website/docs/r/gke_hub_membership_binding.html.markdown @@ -108,6 +108,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/gke_hub_membership_rbac_role_binding.html.markdown b/website/docs/r/gke_hub_membership_rbac_role_binding.html.markdown index c3c85dbe92c..1977f146395 100644 --- a/website/docs/r/gke_hub_membership_rbac_role_binding.html.markdown +++ b/website/docs/r/gke_hub_membership_rbac_role_binding.html.markdown @@ -108,6 +108,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `role` block supports: diff --git a/website/docs/r/gke_hub_namespace.html.markdown b/website/docs/r/gke_hub_namespace.html.markdown index e1b45121a8c..1b9f4b530d4 100644 --- a/website/docs/r/gke_hub_namespace.html.markdown +++ b/website/docs/r/gke_hub_namespace.html.markdown @@ -93,6 +93,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/gke_hub_rollout_sequence.html.markdown b/website/docs/r/gke_hub_rollout_sequence.html.markdown index 8b5b311aabd..33e54b05379 100644 --- a/website/docs/r/gke_hub_rollout_sequence.html.markdown +++ b/website/docs/r/gke_hub_rollout_sequence.html.markdown @@ -72,6 +72,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `stages` block supports: diff --git a/website/docs/r/gke_hub_scope.html.markdown b/website/docs/r/gke_hub_scope.html.markdown index c3df95996c9..36116371118 100644 --- a/website/docs/r/gke_hub_scope.html.markdown +++ b/website/docs/r/gke_hub_scope.html.markdown @@ -77,6 +77,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/gke_hub_scope_rbac_role_binding.html.markdown b/website/docs/r/gke_hub_scope_rbac_role_binding.html.markdown index 80df4a3321b..ab5f80b1347 100644 --- a/website/docs/r/gke_hub_scope_rbac_role_binding.html.markdown +++ b/website/docs/r/gke_hub_scope_rbac_role_binding.html.markdown @@ -124,6 +124,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `role` block supports: diff --git a/website/docs/r/gkeonprem_bare_metal_admin_cluster.html.markdown b/website/docs/r/gkeonprem_bare_metal_admin_cluster.html.markdown index f42cb07a892..918589c2bbd 100644 --- a/website/docs/r/gkeonprem_bare_metal_admin_cluster.html.markdown +++ b/website/docs/r/gkeonprem_bare_metal_admin_cluster.html.markdown @@ -322,6 +322,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `network_config` block supports: diff --git a/website/docs/r/gkeonprem_bare_metal_cluster.html.markdown b/website/docs/r/gkeonprem_bare_metal_cluster.html.markdown index 8d3cc24d523..959ba5e1b31 100644 --- a/website/docs/r/gkeonprem_bare_metal_cluster.html.markdown +++ b/website/docs/r/gkeonprem_bare_metal_cluster.html.markdown @@ -417,6 +417,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `network_config` block supports: diff --git a/website/docs/r/gkeonprem_bare_metal_node_pool.html.markdown b/website/docs/r/gkeonprem_bare_metal_node_pool.html.markdown index fa7e845059f..16c22f76f7a 100644 --- a/website/docs/r/gkeonprem_bare_metal_node_pool.html.markdown +++ b/website/docs/r/gkeonprem_bare_metal_node_pool.html.markdown @@ -254,6 +254,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `node_pool_config` block supports: diff --git a/website/docs/r/gkeonprem_vmware_admin_cluster.html.markdown b/website/docs/r/gkeonprem_vmware_admin_cluster.html.markdown index 6f6958dd1b4..db801a7a3fa 100644 --- a/website/docs/r/gkeonprem_vmware_admin_cluster.html.markdown +++ b/website/docs/r/gkeonprem_vmware_admin_cluster.html.markdown @@ -337,6 +337,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `network_config` block supports: diff --git a/website/docs/r/gkeonprem_vmware_cluster.html.markdown b/website/docs/r/gkeonprem_vmware_cluster.html.markdown index 7af53441f5f..9da0bb904a8 100644 --- a/website/docs/r/gkeonprem_vmware_cluster.html.markdown +++ b/website/docs/r/gkeonprem_vmware_cluster.html.markdown @@ -362,6 +362,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `control_plane_node` block supports: diff --git a/website/docs/r/gkeonprem_vmware_node_pool.html.markdown b/website/docs/r/gkeonprem_vmware_node_pool.html.markdown index 50d58adfe63..a151e2544bf 100644 --- a/website/docs/r/gkeonprem_vmware_node_pool.html.markdown +++ b/website/docs/r/gkeonprem_vmware_node_pool.html.markdown @@ -220,6 +220,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `config` block supports: diff --git a/website/docs/r/google_billing_subaccount.html.markdown b/website/docs/r/google_billing_subaccount.html.markdown index a9a1871e62e..e6625e02256 100644 --- a/website/docs/r/google_billing_subaccount.html.markdown +++ b/website/docs/r/google_billing_subaccount.html.markdown @@ -40,7 +40,13 @@ resource "google_billing_subaccount" "subaccount" { * `deletion_policy` (Optional) - If set to "RENAME_ON_DESTROY" the billing account display_name will be changed to "Terraform Destroyed" along with a timestamp. If set to "" this will not occur. - Default is "". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", the command will behave as if set to "". + + Possible values: RENAME_ON_DESTROY, PREVENT, ABANDON, DELETE. ## Attributes Reference diff --git a/website/docs/r/google_folder.html.markdown b/website/docs/r/google_folder.html.markdown index 56961f9af7f..f570a1a7785 100644 --- a/website/docs/r/google_folder.html.markdown +++ b/website/docs/r/google_folder.html.markdown @@ -73,6 +73,13 @@ The following arguments are supported: * `tags` - (Optional) A map of resource manager tags. Resource manager tag keys and values have the same definition as resource manager tags. Keys must be in the format tagKeys/{tag_key_id}, and values are in the format tagValues/456. The field is ignored when empty. The field is immutable and causes resource replacement when mutated. This field is only set at create time and modifying this field after creation will trigger recreation. To apply tags to an existing resource, see the `google_tags_tag_value` resource. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + ## Attributes Reference In addition to the arguments listed above, the following computed attributes are diff --git a/website/docs/r/google_folder_organization_policy.html.markdown b/website/docs/r/google_folder_organization_policy.html.markdown index ed78516ad78..1d7eda2922a 100644 --- a/website/docs/r/google_folder_organization_policy.html.markdown +++ b/website/docs/r/google_folder_organization_policy.html.markdown @@ -114,6 +114,13 @@ can also be used to allow or deny all values. Structure is [documented below](#n ~> **Note:** If none of [`boolean_policy`, `list_policy`, `restore_policy`] are defined the policy for a given constraint will effectively be unset. This is represented in the UI as the constraint being 'Inherited'. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + - - - The `boolean_policy` block supports: diff --git a/website/docs/r/google_organization_iam_custom_role.html.markdown b/website/docs/r/google_organization_iam_custom_role.html.markdown index 24eafc97161..9350706d7fa 100644 --- a/website/docs/r/google_organization_iam_custom_role.html.markdown +++ b/website/docs/r/google_organization_iam_custom_role.html.markdown @@ -64,6 +64,13 @@ The following arguments are supported: * `description` - (Optional) A human-readable description for the role. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + ## Attributes Reference In addition to the arguments listed above, the following computed attributes are diff --git a/website/docs/r/google_organization_policy.html.markdown b/website/docs/r/google_organization_policy.html.markdown index 1e1672980c8..5864d8ff2f0 100644 --- a/website/docs/r/google_organization_policy.html.markdown +++ b/website/docs/r/google_organization_policy.html.markdown @@ -113,6 +113,13 @@ below](#nested_boolean_policy). ~> **Note:** If none of [`boolean_policy`, `list_policy`, `restore_policy`] are defined the policy for a given constraint will effectively be unset. This is represented in the UI as the constraint being 'Inherited'. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + - - - The `boolean_policy` block supports: diff --git a/website/docs/r/google_project_iam_custom_role.html.markdown b/website/docs/r/google_project_iam_custom_role.html.markdown index 602e15c69f2..822312ea108 100644 --- a/website/docs/r/google_project_iam_custom_role.html.markdown +++ b/website/docs/r/google_project_iam_custom_role.html.markdown @@ -64,6 +64,13 @@ The following arguments are supported: * `description` - (Optional) A human-readable description for the role. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + ## Attributes Reference In addition to the arguments listed above, the following computed attributes are diff --git a/website/docs/r/google_project_iam_member_remove.html.markdown b/website/docs/r/google_project_iam_member_remove.html.markdown index ce820a091ae..c4de9845e90 100644 --- a/website/docs/r/google_project_iam_member_remove.html.markdown +++ b/website/docs/r/google_project_iam_member_remove.html.markdown @@ -67,3 +67,10 @@ The following arguments are supported: * **group:{emailid}**: An email address that represents a Google group. For example, admins@example.com. * **domain:{domain}**: A G Suite domain (primary, instead of alias) name that represents all the users of that domain. For example, google.com or example.com. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + diff --git a/website/docs/r/google_project_organization_policy.html.markdown b/website/docs/r/google_project_organization_policy.html.markdown index dd2719316eb..ecfa5d8715b 100644 --- a/website/docs/r/google_project_organization_policy.html.markdown +++ b/website/docs/r/google_project_organization_policy.html.markdown @@ -113,6 +113,13 @@ The following arguments are supported: ~> **Note:** If none of [`boolean_policy`, `list_policy`, `restore_policy`] are defined the policy for a given constraint will effectively be unset. This is represented in the UI as the constraint being 'Inherited'. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + - - - The `boolean_policy` block supports: diff --git a/website/docs/r/google_project_service.html.markdown b/website/docs/r/google_project_service.html.markdown index 79f96126c7d..e86d8677098 100644 --- a/website/docs/r/google_project_service.html.markdown +++ b/website/docs/r/google_project_service.html.markdown @@ -74,6 +74,13 @@ services depend on this service when attempting to destroy it. If `true`, the usage of the service to be disabled will be checked and an error will be returned if the service to be disabled has usage in last 30 days. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + ## Attributes Reference In addition to the arguments listed above, the following computed attributes are diff --git a/website/docs/r/google_service_account.html.markdown b/website/docs/r/google_service_account.html.markdown index 96767f8b9ab..c40cde5c428 100644 --- a/website/docs/r/google_service_account.html.markdown +++ b/website/docs/r/google_service_account.html.markdown @@ -67,6 +67,13 @@ The following arguments are supported: * `create_ignore_already_exists` - (Optional) If set to true, skip service account creation if a service account with the same email already exists. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + ## Attributes Reference In addition to the arguments listed above, the following computed attributes are diff --git a/website/docs/r/google_service_account_key.html.markdown b/website/docs/r/google_service_account_key.html.markdown index ef6a07b6200..db04476ddb1 100644 --- a/website/docs/r/google_service_account_key.html.markdown +++ b/website/docs/r/google_service_account_key.html.markdown @@ -115,6 +115,13 @@ Valid values are listed at * `keepers` (Optional) Arbitrary map of values that, when changed, will trigger a new key to be generated. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + ## Attributes Reference The following attributes are exported in addition to the arguments listed above: diff --git a/website/docs/r/google_service_networking_peered_dns_domain.html.markdown b/website/docs/r/google_service_networking_peered_dns_domain.html.markdown index c7b9ccb6e62..fa0f5f1ddb8 100644 --- a/website/docs/r/google_service_networking_peered_dns_domain.html.markdown +++ b/website/docs/r/google_service_networking_peered_dns_domain.html.markdown @@ -52,6 +52,13 @@ The following arguments are supported: * `service` - (Optional) Private service connection between service and consumer network, defaults to `servicenetworking.googleapis.com` +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + ## Attributes Reference In addition to the arguments listed above, the following computed attributes are exported: diff --git a/website/docs/r/google_tags_location_tag_binding.html.markdown b/website/docs/r/google_tags_location_tag_binding.html.markdown index 315ab4463c9..12164ab3c1f 100644 --- a/website/docs/r/google_tags_location_tag_binding.html.markdown +++ b/website/docs/r/google_tags_location_tag_binding.html.markdown @@ -126,6 +126,13 @@ The following arguments are supported: (Required) Location of the target resource. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + - - - diff --git a/website/docs/r/healthcare_consent_store.html.markdown b/website/docs/r/healthcare_consent_store.html.markdown index 785d28c58a0..93f2b0355bf 100644 --- a/website/docs/r/healthcare_consent_store.html.markdown +++ b/website/docs/r/healthcare_consent_store.html.markdown @@ -147,6 +147,12 @@ The following arguments are supported: **Note**: This field is non-authoritative, and will only manage the labels present in your configuration. Please refer to the field `effective_labels` for all of the labels present on the resource. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/healthcare_dataset.html.markdown b/website/docs/r/healthcare_dataset.html.markdown index dd9b4771900..69aff29e2b6 100644 --- a/website/docs/r/healthcare_dataset.html.markdown +++ b/website/docs/r/healthcare_dataset.html.markdown @@ -114,6 +114,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `encryption_spec` block supports: diff --git a/website/docs/r/healthcare_dicom_store.html.markdown b/website/docs/r/healthcare_dicom_store.html.markdown index 3b106c7769a..5058fb9da29 100644 --- a/website/docs/r/healthcare_dicom_store.html.markdown +++ b/website/docs/r/healthcare_dicom_store.html.markdown @@ -167,6 +167,12 @@ The following arguments are supported: streamConfigs is an array, so you can specify multiple BigQuery destinations. You can stream metadata from a single DICOM store to up to five BigQuery tables in a BigQuery dataset. Structure is [documented below](#nested_stream_configs). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `notification_config` block supports: diff --git a/website/docs/r/healthcare_fhir_store.html.markdown b/website/docs/r/healthcare_fhir_store.html.markdown index 272ae6ad710..8e66d1a3f55 100644 --- a/website/docs/r/healthcare_fhir_store.html.markdown +++ b/website/docs/r/healthcare_fhir_store.html.markdown @@ -388,6 +388,12 @@ The following arguments are supported: A list of notifcation configs that configure the notification for every resource mutation in this FHIR store. Structure is [documented below](#nested_notification_configs). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `consent_config` block supports: diff --git a/website/docs/r/healthcare_hl7_v2_store.html.markdown b/website/docs/r/healthcare_hl7_v2_store.html.markdown index 497daa02eeb..0f01e18c974 100644 --- a/website/docs/r/healthcare_hl7_v2_store.html.markdown +++ b/website/docs/r/healthcare_hl7_v2_store.html.markdown @@ -250,6 +250,12 @@ The following arguments are supported: ~> **Warning:** `notification_config` is deprecated and will be removed in a future major release. Use `notification_configs` instead. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `parser_config` block supports: diff --git a/website/docs/r/healthcare_pipeline_job.html.markdown b/website/docs/r/healthcare_pipeline_job.html.markdown index 12ee6615957..12cdd978d09 100644 --- a/website/docs/r/healthcare_pipeline_job.html.markdown +++ b/website/docs/r/healthcare_pipeline_job.html.markdown @@ -345,6 +345,12 @@ The following arguments are supported: Specifies the backfill configuration. Structure is [documented below](#nested_backfill_pipeline_job). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `mapping_pipeline_job` block supports: diff --git a/website/docs/r/healthcare_workspace.html.markdown b/website/docs/r/healthcare_workspace.html.markdown index 8b2ad936e97..526ec61b667 100644 --- a/website/docs/r/healthcare_workspace.html.markdown +++ b/website/docs/r/healthcare_workspace.html.markdown @@ -86,6 +86,12 @@ The following arguments are supported: **Note**: This field is non-authoritative, and will only manage the labels present in your configuration. Please refer to the field `effective_labels` for all of the labels present on the resource. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `settings` block supports: diff --git a/website/docs/r/hypercomputecluster_cluster.html.markdown b/website/docs/r/hypercomputecluster_cluster.html.markdown index ae2ac26ae7b..565b27d96ed 100644 --- a/website/docs/r/hypercomputecluster_cluster.html.markdown +++ b/website/docs/r/hypercomputecluster_cluster.html.markdown @@ -157,6 +157,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `compute_resources` block supports: diff --git a/website/docs/r/iam_access_boundary_policy.html.markdown b/website/docs/r/iam_access_boundary_policy.html.markdown index 4d5e26192f4..269bface4a0 100644 --- a/website/docs/r/iam_access_boundary_policy.html.markdown +++ b/website/docs/r/iam_access_boundary_policy.html.markdown @@ -106,6 +106,12 @@ The following arguments are supported: (Optional) The display name of the rule. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `rules` block supports: diff --git a/website/docs/r/iam_deny_policy.html.markdown b/website/docs/r/iam_deny_policy.html.markdown index 2ad339558da..922a729e320 100644 --- a/website/docs/r/iam_deny_policy.html.markdown +++ b/website/docs/r/iam_deny_policy.html.markdown @@ -101,6 +101,12 @@ The following arguments are supported: (Optional) The display name of the rule. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `rules` block supports: diff --git a/website/docs/r/iam_folders_policy_binding.html.markdown b/website/docs/r/iam_folders_policy_binding.html.markdown index 8b425773dee..687fd02326f 100644 --- a/website/docs/r/iam_folders_policy_binding.html.markdown +++ b/website/docs/r/iam_folders_policy_binding.html.markdown @@ -137,6 +137,12 @@ The following arguments are supported: additional information. Structure is [documented below](#nested_condition). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `target` block supports: diff --git a/website/docs/r/iam_oauth_client.html.markdown b/website/docs/r/iam_oauth_client.html.markdown index 6d40075b62f..38a0cedc253 100644 --- a/website/docs/r/iam_oauth_client.html.markdown +++ b/website/docs/r/iam_oauth_client.html.markdown @@ -122,6 +122,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/iam_oauth_client_credential.html.markdown b/website/docs/r/iam_oauth_client_credential.html.markdown index 88f613deb9b..0ea476b3897 100644 --- a/website/docs/r/iam_oauth_client_credential.html.markdown +++ b/website/docs/r/iam_oauth_client_credential.html.markdown @@ -97,6 +97,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/iam_organizations_policy_binding.html.markdown b/website/docs/r/iam_organizations_policy_binding.html.markdown index 2e4ff34d7d4..890353cb0cc 100644 --- a/website/docs/r/iam_organizations_policy_binding.html.markdown +++ b/website/docs/r/iam_organizations_policy_binding.html.markdown @@ -131,6 +131,12 @@ The following arguments are supported: additional information. Structure is [documented below](#nested_condition). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `target` block supports: diff --git a/website/docs/r/iam_principal_access_boundary_policy.html.markdown b/website/docs/r/iam_principal_access_boundary_policy.html.markdown index 521cedd14b5..c0cb3292a0d 100644 --- a/website/docs/r/iam_principal_access_boundary_policy.html.markdown +++ b/website/docs/r/iam_principal_access_boundary_policy.html.markdown @@ -111,6 +111,12 @@ The following arguments are supported: Principal access boundary policy details Structure is [documented below](#nested_details). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `details` block supports: diff --git a/website/docs/r/iam_projects_policy_binding.html.markdown b/website/docs/r/iam_projects_policy_binding.html.markdown index a90dcdf195e..6497ef06c5b 100644 --- a/website/docs/r/iam_projects_policy_binding.html.markdown +++ b/website/docs/r/iam_projects_policy_binding.html.markdown @@ -134,6 +134,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `target` block supports: diff --git a/website/docs/r/iam_workforce_pool.html.markdown b/website/docs/r/iam_workforce_pool.html.markdown index 292381ce0e1..7b9b91f1244 100644 --- a/website/docs/r/iam_workforce_pool.html.markdown +++ b/website/docs/r/iam_workforce_pool.html.markdown @@ -112,6 +112,12 @@ The following arguments are supported: sign-in can be restricted to given set of services or programmatic sign-in can be disabled for pool users. Structure is [documented below](#nested_access_restrictions). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `access_restrictions` block supports: diff --git a/website/docs/r/iam_workforce_pool_provider.html.markdown b/website/docs/r/iam_workforce_pool_provider.html.markdown index 291eabfd50c..a0648903169 100644 --- a/website/docs/r/iam_workforce_pool_provider.html.markdown +++ b/website/docs/r/iam_workforce_pool_provider.html.markdown @@ -625,6 +625,12 @@ The following arguments are supported: (Optional) If true, populates additional debug information in Cloud Audit Logs for this provider. Logged attribute mappings and values can be found in `sts.googleapis.com` data access logs. Default value is false. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `saml` block supports: diff --git a/website/docs/r/iam_workforce_pool_provider_key.html.markdown b/website/docs/r/iam_workforce_pool_provider_key.html.markdown index 7cfecc4add8..77bf98ed89b 100644 --- a/website/docs/r/iam_workforce_pool_provider_key.html.markdown +++ b/website/docs/r/iam_workforce_pool_provider_key.html.markdown @@ -99,6 +99,12 @@ The following arguments are supported: The ID to use for the key, which becomes the final component of the resource name. This value must be 4-32 characters, and may contain the characters [a-z0-9-]. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `key_data` block supports: diff --git a/website/docs/r/iam_workforce_pool_provider_scim_tenant.html.markdown b/website/docs/r/iam_workforce_pool_provider_scim_tenant.html.markdown index c4bfbfc14c3..c9206dab11b 100644 --- a/website/docs/r/iam_workforce_pool_provider_scim_tenant.html.markdown +++ b/website/docs/r/iam_workforce_pool_provider_scim_tenant.html.markdown @@ -124,6 +124,12 @@ The following arguments are supported: (Optional) Deletes the SCIM tenant immediately. This operation cannot be undone. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/iam_workforce_pool_provider_scim_token.html.markdown b/website/docs/r/iam_workforce_pool_provider_scim_token.html.markdown index 74f6dc8b97a..3af4e61a8ab 100644 --- a/website/docs/r/iam_workforce_pool_provider_scim_token.html.markdown +++ b/website/docs/r/iam_workforce_pool_provider_scim_token.html.markdown @@ -125,6 +125,12 @@ The following arguments are supported: (Optional) A user-specified display name for the scim token. Cannot exceed 32 characters. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/iam_workload_identity_pool.html.markdown b/website/docs/r/iam_workload_identity_pool.html.markdown index e95e340a725..4031cfa434e 100644 --- a/website/docs/r/iam_workload_identity_pool.html.markdown +++ b/website/docs/r/iam_workload_identity_pool.html.markdown @@ -229,6 +229,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `inline_certificate_issuance_config` block supports: diff --git a/website/docs/r/iam_workload_identity_pool_managed_identity.html.markdown b/website/docs/r/iam_workload_identity_pool_managed_identity.html.markdown index c33c9c6c991..cef0c58233d 100644 --- a/website/docs/r/iam_workload_identity_pool_managed_identity.html.markdown +++ b/website/docs/r/iam_workload_identity_pool_managed_identity.html.markdown @@ -136,6 +136,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `attestation_rules` block supports: diff --git a/website/docs/r/iam_workload_identity_pool_namespace.html.markdown b/website/docs/r/iam_workload_identity_pool_namespace.html.markdown index 5c50b28da0a..e2d1358e079 100644 --- a/website/docs/r/iam_workload_identity_pool_namespace.html.markdown +++ b/website/docs/r/iam_workload_identity_pool_namespace.html.markdown @@ -108,6 +108,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/iam_workload_identity_pool_provider.html.markdown b/website/docs/r/iam_workload_identity_pool_provider.html.markdown index cd9d139b38d..6ebcaf42fa0 100644 --- a/website/docs/r/iam_workload_identity_pool_provider.html.markdown +++ b/website/docs/r/iam_workload_identity_pool_provider.html.markdown @@ -459,6 +459,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `aws` block supports: diff --git a/website/docs/r/iap_brand.html.markdown b/website/docs/r/iap_brand.html.markdown index 22c2eae0efe..53b50e89094 100644 --- a/website/docs/r/iap_brand.html.markdown +++ b/website/docs/r/iap_brand.html.markdown @@ -83,6 +83,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/iap_client.html.markdown b/website/docs/r/iap_client.html.markdown index 6441d877085..b14b4719d3e 100644 --- a/website/docs/r/iap_client.html.markdown +++ b/website/docs/r/iap_client.html.markdown @@ -83,6 +83,12 @@ The following arguments are supported: `projects/{project_number}/brands/{brand_id}`. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/iap_settings.html.markdown b/website/docs/r/iap_settings.html.markdown index 6a99cfcd957..15e71a383ba 100644 --- a/website/docs/r/iap_settings.html.markdown +++ b/website/docs/r/iap_settings.html.markdown @@ -184,6 +184,12 @@ The following arguments are supported: Top level wrapper for all application related settings in IAP. Structure is [documented below](#nested_application_settings). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `access_settings` block supports: diff --git a/website/docs/r/iap_tunnel_dest_group.html.markdown b/website/docs/r/iap_tunnel_dest_group.html.markdown index ae6b3072d0f..29c3982de6d 100644 --- a/website/docs/r/iap_tunnel_dest_group.html.markdown +++ b/website/docs/r/iap_tunnel_dest_group.html.markdown @@ -74,6 +74,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/identity_platform_config.html.markdown b/website/docs/r/identity_platform_config.html.markdown index 4090beaf0fe..29de15d4048 100644 --- a/website/docs/r/identity_platform_config.html.markdown +++ b/website/docs/r/identity_platform_config.html.markdown @@ -171,6 +171,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `sign_in` block supports: diff --git a/website/docs/r/identity_platform_default_supported_idp_config.html.markdown b/website/docs/r/identity_platform_default_supported_idp_config.html.markdown index 3599bb1f157..cd40c85ca31 100644 --- a/website/docs/r/identity_platform_default_supported_idp_config.html.markdown +++ b/website/docs/r/identity_platform_default_supported_idp_config.html.markdown @@ -76,6 +76,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/identity_platform_inbound_saml_config.html.markdown b/website/docs/r/identity_platform_inbound_saml_config.html.markdown index 0b2cbc55a73..d186bac5a70 100644 --- a/website/docs/r/identity_platform_inbound_saml_config.html.markdown +++ b/website/docs/r/identity_platform_inbound_saml_config.html.markdown @@ -91,6 +91,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `idp_config` block supports: diff --git a/website/docs/r/identity_platform_oauth_idp_config.html.markdown b/website/docs/r/identity_platform_oauth_idp_config.html.markdown index 9f5154bfe83..c7f7ffb80fa 100644 --- a/website/docs/r/identity_platform_oauth_idp_config.html.markdown +++ b/website/docs/r/identity_platform_oauth_idp_config.html.markdown @@ -92,6 +92,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `response_type` block supports: diff --git a/website/docs/r/identity_platform_tenant.html.markdown b/website/docs/r/identity_platform_tenant.html.markdown index b55fd45ea48..739234bde6c 100644 --- a/website/docs/r/identity_platform_tenant.html.markdown +++ b/website/docs/r/identity_platform_tenant.html.markdown @@ -79,6 +79,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `client` block supports: diff --git a/website/docs/r/identity_platform_tenant_default_supported_idp_config.html.markdown b/website/docs/r/identity_platform_tenant_default_supported_idp_config.html.markdown index d55bec86606..765058cc611 100644 --- a/website/docs/r/identity_platform_tenant_default_supported_idp_config.html.markdown +++ b/website/docs/r/identity_platform_tenant_default_supported_idp_config.html.markdown @@ -90,6 +90,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/identity_platform_tenant_inbound_saml_config.html.markdown b/website/docs/r/identity_platform_tenant_inbound_saml_config.html.markdown index 0eced074c11..61c0b08cc77 100644 --- a/website/docs/r/identity_platform_tenant_inbound_saml_config.html.markdown +++ b/website/docs/r/identity_platform_tenant_inbound_saml_config.html.markdown @@ -100,6 +100,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `idp_config` block supports: diff --git a/website/docs/r/identity_platform_tenant_oauth_idp_config.html.markdown b/website/docs/r/identity_platform_tenant_oauth_idp_config.html.markdown index efabb3381a2..55cbe9fb86d 100644 --- a/website/docs/r/identity_platform_tenant_oauth_idp_config.html.markdown +++ b/website/docs/r/identity_platform_tenant_oauth_idp_config.html.markdown @@ -90,6 +90,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/integration_connectors_connection.html.markdown b/website/docs/r/integration_connectors_connection.html.markdown index 06942e57dae..c23b43c0411 100644 --- a/website/docs/r/integration_connectors_connection.html.markdown +++ b/website/docs/r/integration_connectors_connection.html.markdown @@ -375,6 +375,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `config_variable` block supports: diff --git a/website/docs/r/integration_connectors_endpoint_attachment.html.markdown b/website/docs/r/integration_connectors_endpoint_attachment.html.markdown index 5ecb7d58b74..9f7f4502cc0 100644 --- a/website/docs/r/integration_connectors_endpoint_attachment.html.markdown +++ b/website/docs/r/integration_connectors_endpoint_attachment.html.markdown @@ -86,6 +86,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/integration_connectors_managed_zone.html.markdown b/website/docs/r/integration_connectors_managed_zone.html.markdown index 50beabd47f0..45d42e0e28d 100644 --- a/website/docs/r/integration_connectors_managed_zone.html.markdown +++ b/website/docs/r/integration_connectors_managed_zone.html.markdown @@ -130,6 +130,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/integrations_auth_config.html.markdown b/website/docs/r/integrations_auth_config.html.markdown index 9734ae106ae..682e0b0fdf6 100644 --- a/website/docs/r/integrations_auth_config.html.markdown +++ b/website/docs/r/integrations_auth_config.html.markdown @@ -100,6 +100,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `decrypted_credential` block supports: diff --git a/website/docs/r/integrations_client.html.markdown b/website/docs/r/integrations_client.html.markdown index 0b25373ed56..b5e73c2f0a8 100644 --- a/website/docs/r/integrations_client.html.markdown +++ b/website/docs/r/integrations_client.html.markdown @@ -111,6 +111,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `cloud_kms_config` block supports: diff --git a/website/docs/r/kms_autokey_config.html.markdown b/website/docs/r/kms_autokey_config.html.markdown index ed174858f30..cbff554dba2 100644 --- a/website/docs/r/kms_autokey_config.html.markdown +++ b/website/docs/r/kms_autokey_config.html.markdown @@ -141,6 +141,12 @@ The following arguments are supported: How Autokey determines which project to use when provisioning CMEK keys. Possible values are: `DEDICATED_KEY_PROJECT`, `RESOURCE_PROJECT`, `DISABLED`. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/kms_crypto_key.html.markdown b/website/docs/r/kms_crypto_key.html.markdown index 68ea0b34639..0c827edaf11 100644 --- a/website/docs/r/kms_crypto_key.html.markdown +++ b/website/docs/r/kms_crypto_key.html.markdown @@ -157,6 +157,12 @@ The following arguments are supported: or `google_kms_key_ring_import_job` resource to import the CryptoKeyVersion. This field is only applicable during initial CryptoKey creation. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `version_template` block supports: diff --git a/website/docs/r/kms_crypto_key_version.html.markdown b/website/docs/r/kms_crypto_key_version.html.markdown index a7f7016435a..73e276056d0 100644 --- a/website/docs/r/kms_crypto_key_version.html.markdown +++ b/website/docs/r/kms_crypto_key_version.html.markdown @@ -75,6 +75,12 @@ The following arguments are supported: ExternalProtectionLevelOptions stores a group of additional fields for configuring a CryptoKeyVersion that are specific to the EXTERNAL protection level and EXTERNAL_VPC protection levels. Structure is [documented below](#nested_external_protection_level_options). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `external_protection_level_options` block supports: diff --git a/website/docs/r/kms_ekm_connection.html.markdown b/website/docs/r/kms_ekm_connection.html.markdown index a57a6779f1f..da77f3ae07c 100644 --- a/website/docs/r/kms_ekm_connection.html.markdown +++ b/website/docs/r/kms_ekm_connection.html.markdown @@ -89,6 +89,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `service_resolvers` block supports: diff --git a/website/docs/r/kms_folder_kaj_policy_config.html.markdown b/website/docs/r/kms_folder_kaj_policy_config.html.markdown index 31e576ac68b..b68348293e8 100644 --- a/website/docs/r/kms_folder_kaj_policy_config.html.markdown +++ b/website/docs/r/kms_folder_kaj_policy_config.html.markdown @@ -109,6 +109,12 @@ The following arguments are supported: policy is not provided in the CreateCryptoKeyRequest. Structure is [documented below](#nested_default_key_access_justification_policy). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `default_key_access_justification_policy` block supports: diff --git a/website/docs/r/kms_key_handle.html.markdown b/website/docs/r/kms_key_handle.html.markdown index 3cfc77c0170..b79be0fa32c 100644 --- a/website/docs/r/kms_key_handle.html.markdown +++ b/website/docs/r/kms_key_handle.html.markdown @@ -159,6 +159,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/kms_key_ring.html.markdown b/website/docs/r/kms_key_ring.html.markdown index 7acc6bb625a..737d2a58aff 100644 --- a/website/docs/r/kms_key_ring.html.markdown +++ b/website/docs/r/kms_key_ring.html.markdown @@ -63,6 +63,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/kms_key_ring_import_job.html.markdown b/website/docs/r/kms_key_ring_import_job.html.markdown index ec2d0bba04a..c1a3327b3d1 100644 --- a/website/docs/r/kms_key_ring_import_job.html.markdown +++ b/website/docs/r/kms_key_ring_import_job.html.markdown @@ -89,6 +89,12 @@ The following arguments are supported: It must be unique within a KeyRing and match the regular expression [a-zA-Z0-9_-]{1,63} +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/kms_organization_kaj_policy_config.html.markdown b/website/docs/r/kms_organization_kaj_policy_config.html.markdown index 2c2fcd2f4e8..4d22aa518e9 100644 --- a/website/docs/r/kms_organization_kaj_policy_config.html.markdown +++ b/website/docs/r/kms_organization_kaj_policy_config.html.markdown @@ -71,6 +71,12 @@ The following arguments are supported: policy is not provided in the CreateCryptoKeyRequest. Structure is [documented below](#nested_default_key_access_justification_policy). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `default_key_access_justification_policy` block supports: diff --git a/website/docs/r/kms_project_autokey_config.html.markdown b/website/docs/r/kms_project_autokey_config.html.markdown index 80d96c11690..e43e65fb78b 100644 --- a/website/docs/r/kms_project_autokey_config.html.markdown +++ b/website/docs/r/kms_project_autokey_config.html.markdown @@ -117,6 +117,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/kms_project_kaj_policy_config.html.markdown b/website/docs/r/kms_project_kaj_policy_config.html.markdown index b8d85a624a0..8a2d9f92854 100644 --- a/website/docs/r/kms_project_kaj_policy_config.html.markdown +++ b/website/docs/r/kms_project_kaj_policy_config.html.markdown @@ -95,6 +95,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `default_key_access_justification_policy` block supports: diff --git a/website/docs/r/kms_secret_ciphertext.html.markdown b/website/docs/r/kms_secret_ciphertext.html.markdown index 29be79fcd53..02204959d3c 100644 --- a/website/docs/r/kms_secret_ciphertext.html.markdown +++ b/website/docs/r/kms_secret_ciphertext.html.markdown @@ -109,6 +109,12 @@ The following arguments are supported: The additional authenticated data used for integrity checks during encryption and decryption. **Note**: This property is sensitive and will not be displayed in the plan. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/logging_billing_account_bucket_config.html.markdown b/website/docs/r/logging_billing_account_bucket_config.html.markdown index edf9f986d84..eab74ffb217 100644 --- a/website/docs/r/logging_billing_account_bucket_config.html.markdown +++ b/website/docs/r/logging_billing_account_bucket_config.html.markdown @@ -73,6 +73,13 @@ The following arguments are supported: * `index_configs` - (Optional) A list of indexed fields and related configuration data. Structure is [documented below](#nested_index_configs). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + The `index_configs` block supports: * `field_path` - The LogEntry field path to index. diff --git a/website/docs/r/logging_billing_account_sink.html.markdown b/website/docs/r/logging_billing_account_sink.html.markdown index 990d4d43590..22e59ab5369 100644 --- a/website/docs/r/logging_billing_account_sink.html.markdown +++ b/website/docs/r/logging_billing_account_sink.html.markdown @@ -86,6 +86,13 @@ The following arguments are supported: * `exclusions` - (Optional) Log entries that match any of the exclusion filters will not be exported. If a log entry is matched by both `filter` and one of `exclusions.filter`, it will not be exported. Can be repeated multiple times for multiple exclusions. Structure is [documented below](#nested_exclusions). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + The `bigquery_options` block supports: * `use_partitioned_tables` - (Required) Whether to use [BigQuery's partition tables](https://cloud.google.com/bigquery/docs/partitioned-tables). diff --git a/website/docs/r/logging_folder_bucket_config.html.markdown b/website/docs/r/logging_folder_bucket_config.html.markdown index e0a5e82ee08..c5df798d215 100644 --- a/website/docs/r/logging_folder_bucket_config.html.markdown +++ b/website/docs/r/logging_folder_bucket_config.html.markdown @@ -63,6 +63,13 @@ The following arguments are supported: * `index_configs` - (Optional) A list of indexed fields and related configuration data. Structure is [documented below](#nested_index_configs). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + The `index_configs` block supports: * `field_path` - The LogEntry field path to index. diff --git a/website/docs/r/logging_folder_settings.html.markdown b/website/docs/r/logging_folder_settings.html.markdown index 05f0a4698ee..2eef11737c4 100644 --- a/website/docs/r/logging_folder_settings.html.markdown +++ b/website/docs/r/logging_folder_settings.html.markdown @@ -81,6 +81,12 @@ The following arguments are supported: (Optional) If set to true, the _Default sink in newly created projects and folders will created in a disabled state. This can be used to automatically disable log storage if there is already an aggregated sink configured in the hierarchy. The _Default sink can be re-enabled manually if needed. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/logging_folder_sink.html.markdown b/website/docs/r/logging_folder_sink.html.markdown index 5727e6051a4..141330de708 100644 --- a/website/docs/r/logging_folder_sink.html.markdown +++ b/website/docs/r/logging_folder_sink.html.markdown @@ -98,6 +98,13 @@ The following arguments are supported: * `exclusions` - (Optional) Log entries that match any of the exclusion filters will not be exported. If a log entry is matched by both `filter` and one of `exclusions.filter`, it will not be exported. Can be repeated multiple times for multiple exclusions. Structure is [documented below](#nested_exclusions). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + The `bigquery_options` block supports: * `use_partitioned_tables` - (Required) Whether to use [BigQuery's partition tables](https://cloud.google.com/bigquery/docs/partitioned-tables). diff --git a/website/docs/r/logging_linked_dataset.html.markdown b/website/docs/r/logging_linked_dataset.html.markdown index 00439615d02..aa0721edf3e 100644 --- a/website/docs/r/logging_linked_dataset.html.markdown +++ b/website/docs/r/logging_linked_dataset.html.markdown @@ -95,6 +95,12 @@ The following arguments are supported: (Optional) The location of the linked dataset. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/logging_log_scope.html.markdown b/website/docs/r/logging_log_scope.html.markdown index 6bf240a8447..ab279cbcf88 100644 --- a/website/docs/r/logging_log_scope.html.markdown +++ b/website/docs/r/logging_log_scope.html.markdown @@ -73,6 +73,12 @@ The following arguments are supported: (Optional) The location of the resource. The only supported location is global so far. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/logging_log_view.html.markdown b/website/docs/r/logging_log_view.html.markdown index e7853bd5bef..940be42faf4 100644 --- a/website/docs/r/logging_log_view.html.markdown +++ b/website/docs/r/logging_log_view.html.markdown @@ -79,6 +79,12 @@ The following arguments are supported: (Optional) The location of the resource. The supported locations are: global, us-central1, us-east1, us-west1, asia-east1, europe-west1. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/logging_metric.html.markdown b/website/docs/r/logging_metric.html.markdown index 010c334f361..3fa4d0042ed 100644 --- a/website/docs/r/logging_metric.html.markdown +++ b/website/docs/r/logging_metric.html.markdown @@ -222,6 +222,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `metric_descriptor` block supports: diff --git a/website/docs/r/logging_organization_bucket_config.html.markdown b/website/docs/r/logging_organization_bucket_config.html.markdown index 0e7005e2499..5ac94685e5e 100644 --- a/website/docs/r/logging_organization_bucket_config.html.markdown +++ b/website/docs/r/logging_organization_bucket_config.html.markdown @@ -62,6 +62,13 @@ The following arguments are supported: * `index_configs` - (Optional) A list of indexed fields and related configuration data. Structure is [documented below](#nested_index_configs). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + The `index_configs` block supports: * `field_path` - The LogEntry field path to index. diff --git a/website/docs/r/logging_organization_settings.html.markdown b/website/docs/r/logging_organization_settings.html.markdown index 0dd0b00034e..630ed217e3d 100644 --- a/website/docs/r/logging_organization_settings.html.markdown +++ b/website/docs/r/logging_organization_settings.html.markdown @@ -75,6 +75,12 @@ The following arguments are supported: (Optional) If set to true, the _Default sink in newly created projects and folders will created in a disabled state. This can be used to automatically disable log storage if there is already an aggregated sink configured in the hierarchy. The _Default sink can be re-enabled manually if needed. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/logging_organization_sink.html.markdown b/website/docs/r/logging_organization_sink.html.markdown index 4cdbef9ca65..661fbffece1 100644 --- a/website/docs/r/logging_organization_sink.html.markdown +++ b/website/docs/r/logging_organization_sink.html.markdown @@ -88,6 +88,13 @@ The following arguments are supported: * `exclusions` - (Optional) Log entries that match any of the exclusion filters will not be exported. If a log entry is matched by both `filter` and one of `exclusions.filter`, it will not be exported. Can be repeated multiple times for multiple exclusions. Structure is [documented below](#nested_exclusions). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + The `bigquery_options` block supports: * `use_partitioned_tables` - (Required) Whether to use [BigQuery's partition tables](https://cloud.google.com/bigquery/docs/partitioned-tables). diff --git a/website/docs/r/logging_project_bucket_config.html.markdown b/website/docs/r/logging_project_bucket_config.html.markdown index fe967a869e0..d6ef39087f0 100644 --- a/website/docs/r/logging_project_bucket_config.html.markdown +++ b/website/docs/r/logging_project_bucket_config.html.markdown @@ -145,6 +145,13 @@ The following arguments are supported: * `index_configs` - (Optional) A list of indexed fields and related configuration data. Structure is [documented below](#nested_index_configs). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + The `cmek_settings` block supports: * `name` - The resource name of the CMEK settings. diff --git a/website/docs/r/logging_project_sink.html.markdown b/website/docs/r/logging_project_sink.html.markdown index c2ce72023bc..8234aea9b76 100644 --- a/website/docs/r/logging_project_sink.html.markdown +++ b/website/docs/r/logging_project_sink.html.markdown @@ -217,6 +217,13 @@ The following arguments are supported: * `exclusions` - (Optional) Log entries that match any of the exclusion filters will not be exported. If a log entry is matched by both `filter` and one of `exclusions.filter`, it will not be exported. Can be repeated multiple times for multiple exclusions. Structure is [documented below](#nested_exclusions). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + The `bigquery_options` block supports: * `use_partitioned_tables` - (Required) Whether to use [BigQuery's partition tables](https://cloud.google.com/bigquery/docs/partitioned-tables). diff --git a/website/docs/r/logging_saved_query.html.markdown b/website/docs/r/logging_saved_query.html.markdown index d1a42a254af..493f49be1bb 100644 --- a/website/docs/r/logging_saved_query.html.markdown +++ b/website/docs/r/logging_saved_query.html.markdown @@ -155,6 +155,12 @@ The following arguments are supported: The contents of the saved query. Structure is [documented below](#nested_ops_analytics_query). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `logging_query` block supports: diff --git a/website/docs/r/looker_instance.html.markdown b/website/docs/r/looker_instance.html.markdown index 04fe46ab66f..c0d21dcd548 100644 --- a/website/docs/r/looker_instance.html.markdown +++ b/website/docs/r/looker_instance.html.markdown @@ -425,7 +425,15 @@ The following arguments are supported: * `deletion_policy` - (Optional) Policy to determine if the cluster should be deleted forcefully. If setting deletion_policy = "FORCE", the Looker instance will be deleted regardless of its nested resources. If set to "DEFAULT", Looker instances that still have -nested resources will return an error. Possible values: DEFAULT, FORCE +nested resources will return an error. + +When a 'terraform destroy' or 'terraform apply' would delete the resource, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", the command will behave as if set to "DEFAULT". + +Possible values: DEFAULT, FORCE, PREVENT, ABANDON, DELETE diff --git a/website/docs/r/lustre_instance.html.markdown b/website/docs/r/lustre_instance.html.markdown index 81dd1ef19bb..99cb1296d4f 100644 --- a/website/docs/r/lustre_instance.html.markdown +++ b/website/docs/r/lustre_instance.html.markdown @@ -164,6 +164,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `access_rules_options` block supports: diff --git a/website/docs/r/managed_kafka_acl.html.markdown b/website/docs/r/managed_kafka_acl.html.markdown index 18b1576ffd2..0233e3f53f3 100644 --- a/website/docs/r/managed_kafka_acl.html.markdown +++ b/website/docs/r/managed_kafka_acl.html.markdown @@ -102,6 +102,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `acl_entries` block supports: diff --git a/website/docs/r/managed_kafka_cluster.html.markdown b/website/docs/r/managed_kafka_cluster.html.markdown index 7a6b6c4e652..d85291bf70d 100644 --- a/website/docs/r/managed_kafka_cluster.html.markdown +++ b/website/docs/r/managed_kafka_cluster.html.markdown @@ -193,6 +193,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `gcp_config` block supports: diff --git a/website/docs/r/managed_kafka_connect_cluster.html.markdown b/website/docs/r/managed_kafka_connect_cluster.html.markdown index edb208793d0..b16472b916a 100644 --- a/website/docs/r/managed_kafka_connect_cluster.html.markdown +++ b/website/docs/r/managed_kafka_connect_cluster.html.markdown @@ -117,6 +117,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `capacity_config` block supports: diff --git a/website/docs/r/managed_kafka_connector.html.markdown b/website/docs/r/managed_kafka_connector.html.markdown index 7b6df918a04..460e8517ab5 100644 --- a/website/docs/r/managed_kafka_connector.html.markdown +++ b/website/docs/r/managed_kafka_connector.html.markdown @@ -147,6 +147,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `task_restart_policy` block supports: diff --git a/website/docs/r/managed_kafka_topic.html.markdown b/website/docs/r/managed_kafka_topic.html.markdown index 0ea0ecab638..3a1264bd37f 100644 --- a/website/docs/r/managed_kafka_topic.html.markdown +++ b/website/docs/r/managed_kafka_topic.html.markdown @@ -98,6 +98,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/memcache_instance.html.markdown b/website/docs/r/memcache_instance.html.markdown index b7b003cec98..9d92ec64c08 100644 --- a/website/docs/r/memcache_instance.html.markdown +++ b/website/docs/r/memcache_instance.html.markdown @@ -162,6 +162,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `deletion_protection` - (Optional) Whether Terraform will be prevented from destroying the instance. When a `terraform destroy` or `terraform apply` would delete the instance, the command will fail if this field is not set to false in Terraform state. diff --git a/website/docs/r/memorystore_instance.html.markdown b/website/docs/r/memorystore_instance.html.markdown index 765978de80f..f9585165e88 100644 --- a/website/docs/r/memorystore_instance.html.markdown +++ b/website/docs/r/memorystore_instance.html.markdown @@ -628,6 +628,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `desired_psc_auto_connections` - (Optional) `desired_psc_auto_connections` is deprecated Use `desired_auto_created_endpoints` instead `terraform import` will only work with desired_auto_created_endpoints`. * `desired_auto_created_endpoints` - (Optional) Immutable. User inputs for the auto-created endpoints connections. diff --git a/website/docs/r/memorystore_instance_desired_user_created_endpoints.html.markdown b/website/docs/r/memorystore_instance_desired_user_created_endpoints.html.markdown index 07f8fd76c35..8193e82f21a 100644 --- a/website/docs/r/memorystore_instance_desired_user_created_endpoints.html.markdown +++ b/website/docs/r/memorystore_instance_desired_user_created_endpoints.html.markdown @@ -335,6 +335,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `desired_user_created_endpoints` block supports: diff --git a/website/docs/r/migration_center_group.html.markdown b/website/docs/r/migration_center_group.html.markdown index 1bcda2ecbb1..c3a19f8d5a4 100644 --- a/website/docs/r/migration_center_group.html.markdown +++ b/website/docs/r/migration_center_group.html.markdown @@ -76,6 +76,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/migration_center_preference_set.html.markdown b/website/docs/r/migration_center_preference_set.html.markdown index 43acb3e46d4..26ed50c661a 100644 --- a/website/docs/r/migration_center_preference_set.html.markdown +++ b/website/docs/r/migration_center_preference_set.html.markdown @@ -158,6 +158,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `virtual_machine_preferences` block supports: diff --git a/website/docs/r/ml_engine_model.html.markdown b/website/docs/r/ml_engine_model.html.markdown index 65fe049c199..aba72a44596 100644 --- a/website/docs/r/ml_engine_model.html.markdown +++ b/website/docs/r/ml_engine_model.html.markdown @@ -102,6 +102,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `default_version` block supports: diff --git a/website/docs/r/model_armor_floorsetting.html.markdown b/website/docs/r/model_armor_floorsetting.html.markdown index d984189be38..f28183bef59 100644 --- a/website/docs/r/model_armor_floorsetting.html.markdown +++ b/website/docs/r/model_armor_floorsetting.html.markdown @@ -144,6 +144,12 @@ The following arguments are supported: Metadata to enable multi language detection via floor setting. Structure is [documented below](#nested_floor_setting_metadata). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `filter_config` block supports: diff --git a/website/docs/r/model_armor_template.html.markdown b/website/docs/r/model_armor_template.html.markdown index 5a288bd23d9..800eaccd5c6 100644 --- a/website/docs/r/model_armor_template.html.markdown +++ b/website/docs/r/model_armor_template.html.markdown @@ -198,6 +198,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `filter_config` block supports: diff --git a/website/docs/r/monitoring_alert_policy.html.markdown b/website/docs/r/monitoring_alert_policy.html.markdown index 52de003fd53..3755887fcc9 100644 --- a/website/docs/r/monitoring_alert_policy.html.markdown +++ b/website/docs/r/monitoring_alert_policy.html.markdown @@ -232,6 +232,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `conditions` block supports: diff --git a/website/docs/r/monitoring_custom_service.html.markdown b/website/docs/r/monitoring_custom_service.html.markdown index e430ba9a252..c36fb1ebec3 100644 --- a/website/docs/r/monitoring_custom_service.html.markdown +++ b/website/docs/r/monitoring_custom_service.html.markdown @@ -92,6 +92,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `telemetry` block supports: diff --git a/website/docs/r/monitoring_dashboard.html.markdown b/website/docs/r/monitoring_dashboard.html.markdown index c5489419518..d887623fd20 100644 --- a/website/docs/r/monitoring_dashboard.html.markdown +++ b/website/docs/r/monitoring_dashboard.html.markdown @@ -140,6 +140,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/monitoring_group.html.markdown b/website/docs/r/monitoring_group.html.markdown index 58602f063f5..d304a90a84d 100644 --- a/website/docs/r/monitoring_group.html.markdown +++ b/website/docs/r/monitoring_group.html.markdown @@ -100,6 +100,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/monitoring_metric_descriptor.html.markdown b/website/docs/r/monitoring_metric_descriptor.html.markdown index faa268bc9bf..dce72c9973d 100644 --- a/website/docs/r/monitoring_metric_descriptor.html.markdown +++ b/website/docs/r/monitoring_metric_descriptor.html.markdown @@ -156,6 +156,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `labels` block supports: diff --git a/website/docs/r/monitoring_monitored_project.html.markdown b/website/docs/r/monitoring_monitored_project.html.markdown index c1aa2dd644a..fb113df572d 100644 --- a/website/docs/r/monitoring_monitored_project.html.markdown +++ b/website/docs/r/monitoring_monitored_project.html.markdown @@ -61,6 +61,12 @@ The following arguments are supported: Required. The resource name of the existing Metrics Scope that will monitor this project. Example: locations/global/metricsScopes/{SCOPING_PROJECT_ID_OR_NUMBER} +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/monitoring_notification_channel.html.markdown b/website/docs/r/monitoring_notification_channel.html.markdown index c6b7c0adafd..105da56ea7d 100644 --- a/website/docs/r/monitoring_notification_channel.html.markdown +++ b/website/docs/r/monitoring_notification_channel.html.markdown @@ -136,6 +136,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `force_delete` - (Optional) If true, the notification channel will be deleted regardless of its use in alert policies (the policies will be updated to remove the channel). If false, channels that are still diff --git a/website/docs/r/monitoring_service.html.markdown b/website/docs/r/monitoring_service.html.markdown index 18c3ae2ccc0..963773b8c9e 100644 --- a/website/docs/r/monitoring_service.html.markdown +++ b/website/docs/r/monitoring_service.html.markdown @@ -97,6 +97,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `basic_service` block supports: diff --git a/website/docs/r/monitoring_slo.html.markdown b/website/docs/r/monitoring_slo.html.markdown index 59281e2d124..59180a873e2 100644 --- a/website/docs/r/monitoring_slo.html.markdown +++ b/website/docs/r/monitoring_slo.html.markdown @@ -323,6 +323,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `basic_sli` block supports: diff --git a/website/docs/r/monitoring_uptime_check_config.html.markdown b/website/docs/r/monitoring_uptime_check_config.html.markdown index 1d387c03fbd..6be0197103e 100644 --- a/website/docs/r/monitoring_uptime_check_config.html.markdown +++ b/website/docs/r/monitoring_uptime_check_config.html.markdown @@ -367,6 +367,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `content_matchers` block supports: diff --git a/website/docs/r/netapp_active_directory.html.markdown b/website/docs/r/netapp_active_directory.html.markdown index 24d93e1af18..0e3644bc107 100644 --- a/website/docs/r/netapp_active_directory.html.markdown +++ b/website/docs/r/netapp_active_directory.html.markdown @@ -167,6 +167,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/netapp_backup.html.markdown b/website/docs/r/netapp_backup.html.markdown index 0e54e002906..9ab8e4bf09a 100644 --- a/website/docs/r/netapp_backup.html.markdown +++ b/website/docs/r/netapp_backup.html.markdown @@ -133,6 +133,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/netapp_backup_policy.html.markdown b/website/docs/r/netapp_backup_policy.html.markdown index d80dc899104..8af832a9c53 100644 --- a/website/docs/r/netapp_backup_policy.html.markdown +++ b/website/docs/r/netapp_backup_policy.html.markdown @@ -100,6 +100,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/netapp_backup_vault.html.markdown b/website/docs/r/netapp_backup_vault.html.markdown index ba62050a950..97c3d964f2c 100644 --- a/website/docs/r/netapp_backup_vault.html.markdown +++ b/website/docs/r/netapp_backup_vault.html.markdown @@ -93,6 +93,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `backup_retention_policy` block supports: diff --git a/website/docs/r/netapp_host_group.html.markdown b/website/docs/r/netapp_host_group.html.markdown index 86f0e8532a8..37fbd63ef8b 100644 --- a/website/docs/r/netapp_host_group.html.markdown +++ b/website/docs/r/netapp_host_group.html.markdown @@ -93,6 +93,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/netapp_kmsconfig.html.markdown b/website/docs/r/netapp_kmsconfig.html.markdown index da7fe4f32b3..97d49c8dcdc 100644 --- a/website/docs/r/netapp_kmsconfig.html.markdown +++ b/website/docs/r/netapp_kmsconfig.html.markdown @@ -81,6 +81,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/netapp_storage_pool.html.markdown b/website/docs/r/netapp_storage_pool.html.markdown index 41082f5fc8d..7605ee78844 100644 --- a/website/docs/r/netapp_storage_pool.html.markdown +++ b/website/docs/r/netapp_storage_pool.html.markdown @@ -228,6 +228,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/netapp_volume.html.markdown b/website/docs/r/netapp_volume.html.markdown index 1cc4f9d836b..644375f7e90 100644 --- a/website/docs/r/netapp_volume.html.markdown +++ b/website/docs/r/netapp_volume.html.markdown @@ -207,7 +207,14 @@ The following arguments are supported: * `deletion_policy` - (Optional) Policy to determine if the volume should be deleted forcefully. Volumes may have nested snapshot resources. Deleting such a volume will fail. Setting this parameter to FORCE will delete volumes including nested snapshots. -Possible values: DEFAULT, FORCE. + +When a 'terraform destroy' or 'terraform apply' would delete the resource, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", the command will behave as if set to "DEFAULT". + +Possible values: DEFAULT, FORCE, PREVENT, ABANDON, DELETE. diff --git a/website/docs/r/netapp_volume_quota_rule.html.markdown b/website/docs/r/netapp_volume_quota_rule.html.markdown index 31096ad372f..c938b050d32 100644 --- a/website/docs/r/netapp_volume_quota_rule.html.markdown +++ b/website/docs/r/netapp_volume_quota_rule.html.markdown @@ -121,6 +121,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/netapp_volume_replication.html.markdown b/website/docs/r/netapp_volume_replication.html.markdown index cc295d10403..102644d8ce2 100644 --- a/website/docs/r/netapp_volume_replication.html.markdown +++ b/website/docs/r/netapp_volume_replication.html.markdown @@ -154,6 +154,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `delete_destination_volume` - (Optional) A destination volume is created as part of replication creation. The destination volume will not became under Terraform management unless you import it manually. If you delete the replication, this volume will remain. diff --git a/website/docs/r/netapp_volume_snapshot.html.markdown b/website/docs/r/netapp_volume_snapshot.html.markdown index 21337d503e4..0c6bad0a62e 100644 --- a/website/docs/r/netapp_volume_snapshot.html.markdown +++ b/website/docs/r/netapp_volume_snapshot.html.markdown @@ -105,6 +105,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/network_connectivity_destination.html.markdown b/website/docs/r/network_connectivity_destination.html.markdown index bfa2b1b57f6..0ba0fec122c 100644 --- a/website/docs/r/network_connectivity_destination.html.markdown +++ b/website/docs/r/network_connectivity_destination.html.markdown @@ -102,6 +102,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `endpoints` block supports: diff --git a/website/docs/r/network_connectivity_gateway_advertised_route.html.markdown b/website/docs/r/network_connectivity_gateway_advertised_route.html.markdown index fe2a0bef4d7..f81bb33fec9 100644 --- a/website/docs/r/network_connectivity_gateway_advertised_route.html.markdown +++ b/website/docs/r/network_connectivity_gateway_advertised_route.html.markdown @@ -144,6 +144,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/network_connectivity_group.html.markdown b/website/docs/r/network_connectivity_group.html.markdown index 10a407c0ba6..13aa42dde72 100644 --- a/website/docs/r/network_connectivity_group.html.markdown +++ b/website/docs/r/network_connectivity_group.html.markdown @@ -96,6 +96,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `auto_accept` block supports: diff --git a/website/docs/r/network_connectivity_hub.html.markdown b/website/docs/r/network_connectivity_hub.html.markdown index 10c93f13c8c..89c8d4fbe1a 100644 --- a/website/docs/r/network_connectivity_hub.html.markdown +++ b/website/docs/r/network_connectivity_hub.html.markdown @@ -156,6 +156,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/network_connectivity_internal_range.html.markdown b/website/docs/r/network_connectivity_internal_range.html.markdown index a5c224adf27..b2bc857ebb0 100644 --- a/website/docs/r/network_connectivity_internal_range.html.markdown +++ b/website/docs/r/network_connectivity_internal_range.html.markdown @@ -321,6 +321,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `allocation_options` block supports: diff --git a/website/docs/r/network_connectivity_multicloud_data_transfer_config.html.markdown b/website/docs/r/network_connectivity_multicloud_data_transfer_config.html.markdown index f3f7732ba39..6071479224f 100644 --- a/website/docs/r/network_connectivity_multicloud_data_transfer_config.html.markdown +++ b/website/docs/r/network_connectivity_multicloud_data_transfer_config.html.markdown @@ -89,6 +89,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `services` block supports: diff --git a/website/docs/r/network_connectivity_policy_based_route.html.markdown b/website/docs/r/network_connectivity_policy_based_route.html.markdown index 4ac879a2cd0..3cf48f575ee 100644 --- a/website/docs/r/network_connectivity_policy_based_route.html.markdown +++ b/website/docs/r/network_connectivity_policy_based_route.html.markdown @@ -154,6 +154,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `filter` block supports: diff --git a/website/docs/r/network_connectivity_regional_endpoint.html.markdown b/website/docs/r/network_connectivity_regional_endpoint.html.markdown index 531f838a51b..04a644b8fcd 100644 --- a/website/docs/r/network_connectivity_regional_endpoint.html.markdown +++ b/website/docs/r/network_connectivity_regional_endpoint.html.markdown @@ -145,6 +145,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/network_connectivity_service_connection_policy.html.markdown b/website/docs/r/network_connectivity_service_connection_policy.html.markdown index 6077c9d3a51..e27ad07251f 100644 --- a/website/docs/r/network_connectivity_service_connection_policy.html.markdown +++ b/website/docs/r/network_connectivity_service_connection_policy.html.markdown @@ -108,6 +108,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `psc_config` block supports: diff --git a/website/docs/r/network_connectivity_spoke.html.markdown b/website/docs/r/network_connectivity_spoke.html.markdown index 8cdd77c3cdf..810f42b194c 100644 --- a/website/docs/r/network_connectivity_spoke.html.markdown +++ b/website/docs/r/network_connectivity_spoke.html.markdown @@ -648,6 +648,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `linked_vpn_tunnels` block supports: diff --git a/website/docs/r/network_connectivity_transport.html.markdown b/website/docs/r/network_connectivity_transport.html.markdown index 1ed155f6f86..1429ea092f4 100644 --- a/website/docs/r/network_connectivity_transport.html.markdown +++ b/website/docs/r/network_connectivity_transport.html.markdown @@ -143,6 +143,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/network_management_connectivity_test.html.markdown b/website/docs/r/network_management_connectivity_test.html.markdown index e580084f923..03c22b8c7cc 100644 --- a/website/docs/r/network_management_connectivity_test.html.markdown +++ b/website/docs/r/network_management_connectivity_test.html.markdown @@ -259,6 +259,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `source` block supports: diff --git a/website/docs/r/network_management_organization_vpc_flow_logs_config.html.markdown b/website/docs/r/network_management_organization_vpc_flow_logs_config.html.markdown index 5bda6712ce2..9f90d87b411 100644 --- a/website/docs/r/network_management_organization_vpc_flow_logs_config.html.markdown +++ b/website/docs/r/network_management_organization_vpc_flow_logs_config.html.markdown @@ -111,6 +111,12 @@ The following arguments are supported: CROSS_PROJECT_METADATA_DISABLED Possible values are: `CROSS_PROJECT_METADATA_ENABLED`, `CROSS_PROJECT_METADATA_DISABLED`. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/network_management_vpc_flow_logs_config.html.markdown b/website/docs/r/network_management_vpc_flow_logs_config.html.markdown index 8d38799a24a..2df602764a3 100644 --- a/website/docs/r/network_management_vpc_flow_logs_config.html.markdown +++ b/website/docs/r/network_management_vpc_flow_logs_config.html.markdown @@ -272,6 +272,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/network_security_address_group.html.markdown b/website/docs/r/network_security_address_group.html.markdown index ad7586674d5..0622632abf0 100644 --- a/website/docs/r/network_security_address_group.html.markdown +++ b/website/docs/r/network_security_address_group.html.markdown @@ -135,6 +135,12 @@ The following arguments are supported: (Optional) The name of the parent this address group belongs to. Format: organizations/{organization_id} or projects/{project_id}. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/network_security_authorization_policy.html.markdown b/website/docs/r/network_security_authorization_policy.html.markdown index ea8969a464e..3e6bfccd572 100644 --- a/website/docs/r/network_security_authorization_policy.html.markdown +++ b/website/docs/r/network_security_authorization_policy.html.markdown @@ -129,6 +129,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `rules` block supports: diff --git a/website/docs/r/network_security_authz_policy.html.markdown b/website/docs/r/network_security_authz_policy.html.markdown index b678ce6eb94..712600da961 100644 --- a/website/docs/r/network_security_authz_policy.html.markdown +++ b/website/docs/r/network_security_authz_policy.html.markdown @@ -376,6 +376,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `target` block supports: diff --git a/website/docs/r/network_security_backend_authentication_config.html.markdown b/website/docs/r/network_security_backend_authentication_config.html.markdown index 93c6c04c9d9..8390fb49e52 100644 --- a/website/docs/r/network_security_backend_authentication_config.html.markdown +++ b/website/docs/r/network_security_backend_authentication_config.html.markdown @@ -183,6 +183,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/network_security_client_tls_policy.html.markdown b/website/docs/r/network_security_client_tls_policy.html.markdown index 565f4e23644..ab07587f2fb 100644 --- a/website/docs/r/network_security_client_tls_policy.html.markdown +++ b/website/docs/r/network_security_client_tls_policy.html.markdown @@ -118,6 +118,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `client_certificate` block supports: diff --git a/website/docs/r/network_security_dns_threat_detector.html.markdown b/website/docs/r/network_security_dns_threat_detector.html.markdown index de4253a04d8..30bd5bac4af 100644 --- a/website/docs/r/network_security_dns_threat_detector.html.markdown +++ b/website/docs/r/network_security_dns_threat_detector.html.markdown @@ -83,6 +83,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/network_security_firewall_endpoint.html.markdown b/website/docs/r/network_security_firewall_endpoint.html.markdown index 43a96843d80..2cdc5187526 100644 --- a/website/docs/r/network_security_firewall_endpoint.html.markdown +++ b/website/docs/r/network_security_firewall_endpoint.html.markdown @@ -109,6 +109,12 @@ The following arguments are supported: Settings for the endpoint. Structure is [documented below](#nested_endpoint_settings). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `endpoint_settings` block supports: diff --git a/website/docs/r/network_security_firewall_endpoint_association.html.markdown b/website/docs/r/network_security_firewall_endpoint_association.html.markdown index 12a5cf31af3..411f3c0c0db 100644 --- a/website/docs/r/network_security_firewall_endpoint_association.html.markdown +++ b/website/docs/r/network_security_firewall_endpoint_association.html.markdown @@ -119,6 +119,12 @@ The following arguments are supported: The name of the parent this firewall endpoint association belongs to. Format: projects/{project_id}. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/network_security_gateway_security_policy.html.markdown b/website/docs/r/network_security_gateway_security_policy.html.markdown index 0ac01d71948..82cf9fe5a2f 100644 --- a/website/docs/r/network_security_gateway_security_policy.html.markdown +++ b/website/docs/r/network_security_gateway_security_policy.html.markdown @@ -164,6 +164,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/network_security_gateway_security_policy_rule.html.markdown b/website/docs/r/network_security_gateway_security_policy_rule.html.markdown index af37d415504..35f6fb210cb 100644 --- a/website/docs/r/network_security_gateway_security_policy_rule.html.markdown +++ b/website/docs/r/network_security_gateway_security_policy_rule.html.markdown @@ -137,6 +137,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/network_security_intercept_deployment.html.markdown b/website/docs/r/network_security_intercept_deployment.html.markdown index 6fcd8fde2c4..9feeda4e2f6 100644 --- a/website/docs/r/network_security_intercept_deployment.html.markdown +++ b/website/docs/r/network_security_intercept_deployment.html.markdown @@ -136,6 +136,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/network_security_intercept_deployment_group.html.markdown b/website/docs/r/network_security_intercept_deployment_group.html.markdown index e00b64ba212..e5ca3fa562f 100644 --- a/website/docs/r/network_security_intercept_deployment_group.html.markdown +++ b/website/docs/r/network_security_intercept_deployment_group.html.markdown @@ -88,6 +88,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/network_security_intercept_endpoint_group.html.markdown b/website/docs/r/network_security_intercept_endpoint_group.html.markdown index 35f0870f549..7fcfa0662d0 100644 --- a/website/docs/r/network_security_intercept_endpoint_group.html.markdown +++ b/website/docs/r/network_security_intercept_endpoint_group.html.markdown @@ -95,6 +95,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/network_security_intercept_endpoint_group_association.html.markdown b/website/docs/r/network_security_intercept_endpoint_group_association.html.markdown index 909b44f305b..71e98231155 100644 --- a/website/docs/r/network_security_intercept_endpoint_group_association.html.markdown +++ b/website/docs/r/network_security_intercept_endpoint_group_association.html.markdown @@ -111,6 +111,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/network_security_mirroring_deployment.html.markdown b/website/docs/r/network_security_mirroring_deployment.html.markdown index 2ebdaa2ceaa..4c6c8cf3f14 100644 --- a/website/docs/r/network_security_mirroring_deployment.html.markdown +++ b/website/docs/r/network_security_mirroring_deployment.html.markdown @@ -142,6 +142,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/network_security_mirroring_deployment_group.html.markdown b/website/docs/r/network_security_mirroring_deployment_group.html.markdown index e2e9081f3be..a619e6b1487 100644 --- a/website/docs/r/network_security_mirroring_deployment_group.html.markdown +++ b/website/docs/r/network_security_mirroring_deployment_group.html.markdown @@ -93,6 +93,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/network_security_mirroring_endpoint.html.markdown b/website/docs/r/network_security_mirroring_endpoint.html.markdown index 124372f2999..4bc2eb03c3e 100644 --- a/website/docs/r/network_security_mirroring_endpoint.html.markdown +++ b/website/docs/r/network_security_mirroring_endpoint.html.markdown @@ -102,6 +102,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/network_security_mirroring_endpoint_group.html.markdown b/website/docs/r/network_security_mirroring_endpoint_group.html.markdown index d68b51516a1..f9198a74f99 100644 --- a/website/docs/r/network_security_mirroring_endpoint_group.html.markdown +++ b/website/docs/r/network_security_mirroring_endpoint_group.html.markdown @@ -146,6 +146,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/network_security_mirroring_endpoint_group_association.html.markdown b/website/docs/r/network_security_mirroring_endpoint_group_association.html.markdown index 73368c4a85f..d09fedce60c 100644 --- a/website/docs/r/network_security_mirroring_endpoint_group_association.html.markdown +++ b/website/docs/r/network_security_mirroring_endpoint_group_association.html.markdown @@ -116,6 +116,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/network_security_sac_attachment.html.markdown b/website/docs/r/network_security_sac_attachment.html.markdown index c8ab2677ec8..292727129da 100644 --- a/website/docs/r/network_security_sac_attachment.html.markdown +++ b/website/docs/r/network_security_sac_attachment.html.markdown @@ -93,6 +93,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `symantec_options` block supports: diff --git a/website/docs/r/network_security_sac_realm.html.markdown b/website/docs/r/network_security_sac_realm.html.markdown index e0978e6ea61..9ad8a22ee95 100644 --- a/website/docs/r/network_security_sac_realm.html.markdown +++ b/website/docs/r/network_security_sac_realm.html.markdown @@ -97,6 +97,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `symantec_options` block supports: diff --git a/website/docs/r/network_security_security_profile.html.markdown b/website/docs/r/network_security_security_profile.html.markdown index 965501b179d..6d6d5420c6b 100644 --- a/website/docs/r/network_security_security_profile.html.markdown +++ b/website/docs/r/network_security_security_profile.html.markdown @@ -267,6 +267,12 @@ The following arguments are supported: The name of the parent this security profile belongs to. Format: `organizations/{organization_id}` or `projects/{project_id}`. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `threat_prevention_profile` block supports: diff --git a/website/docs/r/network_security_security_profile_group.html.markdown b/website/docs/r/network_security_security_profile_group.html.markdown index 57b47797c7a..ae5b2f10b50 100644 --- a/website/docs/r/network_security_security_profile_group.html.markdown +++ b/website/docs/r/network_security_security_profile_group.html.markdown @@ -219,6 +219,12 @@ The following arguments are supported: The name of the parent this security profile group belongs to. Format: `organizations/{organization_id}` or `projects/{project_id}`. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/network_security_server_tls_policy.html.markdown b/website/docs/r/network_security_server_tls_policy.html.markdown index 12eee48e849..cf932915ccb 100644 --- a/website/docs/r/network_security_server_tls_policy.html.markdown +++ b/website/docs/r/network_security_server_tls_policy.html.markdown @@ -200,6 +200,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `server_certificate` block supports: diff --git a/website/docs/r/network_security_tls_inspection_policy.html.markdown b/website/docs/r/network_security_tls_inspection_policy.html.markdown index 43a9b800027..95eba9bd4a4 100644 --- a/website/docs/r/network_security_tls_inspection_policy.html.markdown +++ b/website/docs/r/network_security_tls_inspection_policy.html.markdown @@ -306,6 +306,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/network_security_ull_mirroring_collector.html.markdown b/website/docs/r/network_security_ull_mirroring_collector.html.markdown index 89b664b510a..43444a92811 100644 --- a/website/docs/r/network_security_ull_mirroring_collector.html.markdown +++ b/website/docs/r/network_security_ull_mirroring_collector.html.markdown @@ -131,6 +131,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/network_security_ull_mirroring_collector_rule.html.markdown b/website/docs/r/network_security_ull_mirroring_collector_rule.html.markdown index 6f9bfbbe778..756cc1bc44a 100644 --- a/website/docs/r/network_security_ull_mirroring_collector_rule.html.markdown +++ b/website/docs/r/network_security_ull_mirroring_collector_rule.html.markdown @@ -140,6 +140,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `match` block supports: diff --git a/website/docs/r/network_security_ull_mirroring_engine.html.markdown b/website/docs/r/network_security_ull_mirroring_engine.html.markdown index 5efa045d336..3246381dbc2 100644 --- a/website/docs/r/network_security_ull_mirroring_engine.html.markdown +++ b/website/docs/r/network_security_ull_mirroring_engine.html.markdown @@ -67,6 +67,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/network_security_url_lists.html.markdown b/website/docs/r/network_security_url_lists.html.markdown index 62f5dff3c7f..eef14a37212 100644 --- a/website/docs/r/network_security_url_lists.html.markdown +++ b/website/docs/r/network_security_url_lists.html.markdown @@ -88,6 +88,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/network_services_agent_gateway.html.markdown b/website/docs/r/network_services_agent_gateway.html.markdown index 985d656c2a8..d4b830ad47d 100644 --- a/website/docs/r/network_services_agent_gateway.html.markdown +++ b/website/docs/r/network_services_agent_gateway.html.markdown @@ -154,6 +154,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `google_managed` block supports: diff --git a/website/docs/r/network_services_authz_extension.html.markdown b/website/docs/r/network_services_authz_extension.html.markdown index dbc5e764c5b..95ef8ac6c22 100644 --- a/website/docs/r/network_services_authz_extension.html.markdown +++ b/website/docs/r/network_services_authz_extension.html.markdown @@ -193,6 +193,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/network_services_edge_cache_keyset.html.markdown b/website/docs/r/network_services_edge_cache_keyset.html.markdown index 0640505b873..5cfa5389d53 100644 --- a/website/docs/r/network_services_edge_cache_keyset.html.markdown +++ b/website/docs/r/network_services_edge_cache_keyset.html.markdown @@ -136,6 +136,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `public_key` block supports: diff --git a/website/docs/r/network_services_edge_cache_origin.html.markdown b/website/docs/r/network_services_edge_cache_origin.html.markdown index db9f21ce2c5..59b59f4d0e2 100644 --- a/website/docs/r/network_services_edge_cache_origin.html.markdown +++ b/website/docs/r/network_services_edge_cache_origin.html.markdown @@ -250,6 +250,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `timeout` block supports: diff --git a/website/docs/r/network_services_edge_cache_service.html.markdown b/website/docs/r/network_services_edge_cache_service.html.markdown index 9e528ed0bc5..e8ec4f9cc23 100644 --- a/website/docs/r/network_services_edge_cache_service.html.markdown +++ b/website/docs/r/network_services_edge_cache_service.html.markdown @@ -472,6 +472,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `routing` block supports: diff --git a/website/docs/r/network_services_endpoint_policy.html.markdown b/website/docs/r/network_services_endpoint_policy.html.markdown index 6c9d9ff830c..e05dc10ea2e 100644 --- a/website/docs/r/network_services_endpoint_policy.html.markdown +++ b/website/docs/r/network_services_endpoint_policy.html.markdown @@ -137,6 +137,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `endpoint_matcher` block supports: diff --git a/website/docs/r/network_services_gateway.html.markdown b/website/docs/r/network_services_gateway.html.markdown index 6dcc0b8ee19..7ea6553b2c8 100644 --- a/website/docs/r/network_services_gateway.html.markdown +++ b/website/docs/r/network_services_gateway.html.markdown @@ -331,6 +331,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `delete_swg_autogen_router_on_destroy` - (Optional) When deleting a gateway of type 'SECURE_WEB_GATEWAY', this boolean option will also delete auto generated router by the gateway creation. If there is no other gateway of type 'SECURE_WEB_GATEWAY' remaining for that region and network it will be deleted. diff --git a/website/docs/r/network_services_grpc_route.html.markdown b/website/docs/r/network_services_grpc_route.html.markdown index 56fdd097b14..a9c4ed9383d 100644 --- a/website/docs/r/network_services_grpc_route.html.markdown +++ b/website/docs/r/network_services_grpc_route.html.markdown @@ -224,6 +224,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `rules` block supports: diff --git a/website/docs/r/network_services_http_route.html.markdown b/website/docs/r/network_services_http_route.html.markdown index 92c40bfdccd..f54faf22149 100644 --- a/website/docs/r/network_services_http_route.html.markdown +++ b/website/docs/r/network_services_http_route.html.markdown @@ -298,6 +298,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `rules` block supports: diff --git a/website/docs/r/network_services_lb_edge_extension.html.markdown b/website/docs/r/network_services_lb_edge_extension.html.markdown index 4627a884b80..23323030664 100644 --- a/website/docs/r/network_services_lb_edge_extension.html.markdown +++ b/website/docs/r/network_services_lb_edge_extension.html.markdown @@ -179,6 +179,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `extension_chains` block supports: diff --git a/website/docs/r/network_services_lb_route_extension.html.markdown b/website/docs/r/network_services_lb_route_extension.html.markdown index 0dcf368197d..a9bc0693cbc 100644 --- a/website/docs/r/network_services_lb_route_extension.html.markdown +++ b/website/docs/r/network_services_lb_route_extension.html.markdown @@ -802,6 +802,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `extension_chains` block supports: diff --git a/website/docs/r/network_services_lb_traffic_extension.html.markdown b/website/docs/r/network_services_lb_traffic_extension.html.markdown index 8045f2ae88f..f24e1d617e8 100644 --- a/website/docs/r/network_services_lb_traffic_extension.html.markdown +++ b/website/docs/r/network_services_lb_traffic_extension.html.markdown @@ -427,6 +427,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `extension_chains` block supports: diff --git a/website/docs/r/network_services_mesh.html.markdown b/website/docs/r/network_services_mesh.html.markdown index 532a49471d9..e2557e088cb 100644 --- a/website/docs/r/network_services_mesh.html.markdown +++ b/website/docs/r/network_services_mesh.html.markdown @@ -116,6 +116,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/network_services_multicast_consumer_association.html.markdown b/website/docs/r/network_services_multicast_consumer_association.html.markdown index ecd6a5de4e2..937b74b6202 100644 --- a/website/docs/r/network_services_multicast_consumer_association.html.markdown +++ b/website/docs/r/network_services_multicast_consumer_association.html.markdown @@ -110,6 +110,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/network_services_multicast_domain.html.markdown b/website/docs/r/network_services_multicast_domain.html.markdown index 6eb49511f52..a167e6c01e8 100644 --- a/website/docs/r/network_services_multicast_domain.html.markdown +++ b/website/docs/r/network_services_multicast_domain.html.markdown @@ -113,6 +113,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `connection_config` block supports: diff --git a/website/docs/r/network_services_multicast_domain_activation.html.markdown b/website/docs/r/network_services_multicast_domain_activation.html.markdown index c0675b50425..27316600e82 100644 --- a/website/docs/r/network_services_multicast_domain_activation.html.markdown +++ b/website/docs/r/network_services_multicast_domain_activation.html.markdown @@ -107,6 +107,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `traffic_spec` block supports: diff --git a/website/docs/r/network_services_multicast_domain_group.html.markdown b/website/docs/r/network_services_multicast_domain_group.html.markdown index c93b7800670..d437a124bdf 100644 --- a/website/docs/r/network_services_multicast_domain_group.html.markdown +++ b/website/docs/r/network_services_multicast_domain_group.html.markdown @@ -102,6 +102,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/network_services_multicast_group_consumer_activation.html.markdown b/website/docs/r/network_services_multicast_group_consumer_activation.html.markdown index c6890a89fa9..3bbb079e42c 100644 --- a/website/docs/r/network_services_multicast_group_consumer_activation.html.markdown +++ b/website/docs/r/network_services_multicast_group_consumer_activation.html.markdown @@ -146,6 +146,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `log_config` block supports: diff --git a/website/docs/r/network_services_multicast_group_producer_activation.html.markdown b/website/docs/r/network_services_multicast_group_producer_activation.html.markdown index 3ebe47923b2..c6e286e7b01 100644 --- a/website/docs/r/network_services_multicast_group_producer_activation.html.markdown +++ b/website/docs/r/network_services_multicast_group_producer_activation.html.markdown @@ -141,6 +141,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/network_services_multicast_group_range.html.markdown b/website/docs/r/network_services_multicast_group_range.html.markdown index c0558c2bdeb..23559ea1eb2 100644 --- a/website/docs/r/network_services_multicast_group_range.html.markdown +++ b/website/docs/r/network_services_multicast_group_range.html.markdown @@ -143,6 +143,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `log_config` block supports: diff --git a/website/docs/r/network_services_multicast_group_range_activation.html.markdown b/website/docs/r/network_services_multicast_group_range_activation.html.markdown index ed1a8e38ed7..63f0472f90a 100644 --- a/website/docs/r/network_services_multicast_group_range_activation.html.markdown +++ b/website/docs/r/network_services_multicast_group_range_activation.html.markdown @@ -133,6 +133,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `log_config` block supports: diff --git a/website/docs/r/network_services_multicast_producer_association.html.markdown b/website/docs/r/network_services_multicast_producer_association.html.markdown index 4e6f09f358c..c0bd69ea2a9 100644 --- a/website/docs/r/network_services_multicast_producer_association.html.markdown +++ b/website/docs/r/network_services_multicast_producer_association.html.markdown @@ -110,6 +110,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/network_services_service_binding.html.markdown b/website/docs/r/network_services_service_binding.html.markdown index 4eaeb90e231..ddb39b59fa8 100644 --- a/website/docs/r/network_services_service_binding.html.markdown +++ b/website/docs/r/network_services_service_binding.html.markdown @@ -88,6 +88,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/network_services_service_lb_policies.html.markdown b/website/docs/r/network_services_service_lb_policies.html.markdown index 40fa77d3ada..08ac64531ec 100644 --- a/website/docs/r/network_services_service_lb_policies.html.markdown +++ b/website/docs/r/network_services_service_lb_policies.html.markdown @@ -179,6 +179,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `auto_capacity_drain` block supports: diff --git a/website/docs/r/network_services_tcp_route.html.markdown b/website/docs/r/network_services_tcp_route.html.markdown index cb25b7bbba0..8d7a89a7cd6 100644 --- a/website/docs/r/network_services_tcp_route.html.markdown +++ b/website/docs/r/network_services_tcp_route.html.markdown @@ -271,6 +271,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `rules` block supports: diff --git a/website/docs/r/network_services_tls_route.html.markdown b/website/docs/r/network_services_tls_route.html.markdown index 98d440d2caa..f342d01688a 100644 --- a/website/docs/r/network_services_tls_route.html.markdown +++ b/website/docs/r/network_services_tls_route.html.markdown @@ -372,6 +372,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `rules` block supports: diff --git a/website/docs/r/network_services_wasm_plugin.html.markdown b/website/docs/r/network_services_wasm_plugin.html.markdown index 34a93ce747c..6f9917429f0 100644 --- a/website/docs/r/network_services_wasm_plugin.html.markdown +++ b/website/docs/r/network_services_wasm_plugin.html.markdown @@ -137,6 +137,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `versions` block supports: diff --git a/website/docs/r/notebooks_environment.html.markdown b/website/docs/r/notebooks_environment.html.markdown index e95fb8ddfaf..6c32b42d682 100644 --- a/website/docs/r/notebooks_environment.html.markdown +++ b/website/docs/r/notebooks_environment.html.markdown @@ -90,6 +90,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `vm_image` block supports: diff --git a/website/docs/r/notebooks_instance.html.markdown b/website/docs/r/notebooks_instance.html.markdown index d52b74128f9..c6655edf334 100644 --- a/website/docs/r/notebooks_instance.html.markdown +++ b/website/docs/r/notebooks_instance.html.markdown @@ -347,6 +347,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `desired_state` - (Optional) Desired state of the Notebook Instance. Set this field to `ACTIVE` to start the Instance, and `STOPPED` to stop the Instance. diff --git a/website/docs/r/notebooks_runtime.html.markdown b/website/docs/r/notebooks_runtime.html.markdown index 517493b709f..38b78647114 100644 --- a/website/docs/r/notebooks_runtime.html.markdown +++ b/website/docs/r/notebooks_runtime.html.markdown @@ -256,6 +256,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `virtual_machine` block supports: diff --git a/website/docs/r/observability_folder_settings.html.markdown b/website/docs/r/observability_folder_settings.html.markdown index 6b642edb620..2a3859686e7 100644 --- a/website/docs/r/observability_folder_settings.html.markdown +++ b/website/docs/r/observability_folder_settings.html.markdown @@ -128,6 +128,12 @@ The following arguments are supported: (Optional) The default Cloud KMS key to use for new resources. Only valid for regional locations. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/observability_organization_settings.html.markdown b/website/docs/r/observability_organization_settings.html.markdown index a66555fff1f..08d5f3d3ee9 100644 --- a/website/docs/r/observability_organization_settings.html.markdown +++ b/website/docs/r/observability_organization_settings.html.markdown @@ -99,6 +99,12 @@ The following arguments are supported: (Optional) The default Cloud KMS key to use for new resources. Only valid for regional locations. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/observability_project_settings.html.markdown b/website/docs/r/observability_project_settings.html.markdown index 7741e3e9cca..d4d082282a1 100644 --- a/website/docs/r/observability_project_settings.html.markdown +++ b/website/docs/r/observability_project_settings.html.markdown @@ -142,6 +142,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/observability_trace_scope.html.markdown b/website/docs/r/observability_trace_scope.html.markdown index 38ee982693e..38c81c86c40 100644 --- a/website/docs/r/observability_trace_scope.html.markdown +++ b/website/docs/r/observability_trace_scope.html.markdown @@ -79,6 +79,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/oracle_database_autonomous_database.html.markdown b/website/docs/r/oracle_database_autonomous_database.html.markdown index 0c572ecec9c..80757a8fbe8 100644 --- a/website/docs/r/oracle_database_autonomous_database.html.markdown +++ b/website/docs/r/oracle_database_autonomous_database.html.markdown @@ -278,6 +278,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `deletion_protection` - (Optional) Whether or not to allow Terraform to destroy the instance. Unless this field is set to false in Terraform state, a terraform destroy or terraform apply that would delete the instance will fail. diff --git a/website/docs/r/oracle_database_cloud_exadata_infrastructure.html.markdown b/website/docs/r/oracle_database_cloud_exadata_infrastructure.html.markdown index 1ab50f2ed71..417d14f14d2 100644 --- a/website/docs/r/oracle_database_cloud_exadata_infrastructure.html.markdown +++ b/website/docs/r/oracle_database_cloud_exadata_infrastructure.html.markdown @@ -135,6 +135,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `deletion_protection` - (Optional) Whether or not to allow Terraform to destroy the instance. Unless this field is set to false in Terraform state, a terraform destroy or terraform apply that would delete the instance will fail. diff --git a/website/docs/r/oracle_database_cloud_vm_cluster.html.markdown b/website/docs/r/oracle_database_cloud_vm_cluster.html.markdown index 1d9cb7e2b2f..d6201fb7039 100644 --- a/website/docs/r/oracle_database_cloud_vm_cluster.html.markdown +++ b/website/docs/r/oracle_database_cloud_vm_cluster.html.markdown @@ -271,6 +271,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `deletion_protection` - (Optional) Whether Terraform will be prevented from destroying the cluster. Deleting this cluster via terraform destroy or terraform apply will only succeed if this field is false in the Terraform state. diff --git a/website/docs/r/oracle_database_db_system.html.markdown b/website/docs/r/oracle_database_db_system.html.markdown index 6699117b674..6338f2e8c6f 100644 --- a/website/docs/r/oracle_database_db_system.html.markdown +++ b/website/docs/r/oracle_database_db_system.html.markdown @@ -167,6 +167,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `deletion_protection` - (Optional) Whether or not to allow Terraform to destroy the instance. Unless this field is set to false in Terraform state, a terraform destroy or terraform apply that would delete the instance will fail. diff --git a/website/docs/r/oracle_database_exadb_vm_cluster.html.markdown b/website/docs/r/oracle_database_exadb_vm_cluster.html.markdown index deb76a9df49..b2dcebd90c6 100644 --- a/website/docs/r/oracle_database_exadb_vm_cluster.html.markdown +++ b/website/docs/r/oracle_database_exadb_vm_cluster.html.markdown @@ -198,6 +198,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `deletion_protection` - (Optional) Whether or not to allow Terraform to destroy the instance. Unless this field is set to false in Terraform state, a terraform destroy or terraform apply that would delete the instance will fail. diff --git a/website/docs/r/oracle_database_exascale_db_storage_vault.html.markdown b/website/docs/r/oracle_database_exascale_db_storage_vault.html.markdown index b28ffd44bb3..479e49edb09 100644 --- a/website/docs/r/oracle_database_exascale_db_storage_vault.html.markdown +++ b/website/docs/r/oracle_database_exascale_db_storage_vault.html.markdown @@ -124,6 +124,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `deletion_protection` - (Optional) Whether or not to allow Terraform to destroy the instance. Unless this field is set to false in Terraform state, a terraform destroy or terraform apply that would delete the instance will fail. diff --git a/website/docs/r/oracle_database_odb_network.html.markdown b/website/docs/r/oracle_database_odb_network.html.markdown index 7e47709c35a..e952fac7ec0 100644 --- a/website/docs/r/oracle_database_odb_network.html.markdown +++ b/website/docs/r/oracle_database_odb_network.html.markdown @@ -117,6 +117,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `deletion_protection` - (Optional) Whether or not to allow Terraform to destroy the instance. Unless this field is set to false in Terraform state, a terraform destroy or terraform apply that would delete the instance will fail. diff --git a/website/docs/r/oracle_database_odb_subnet.html.markdown b/website/docs/r/oracle_database_odb_subnet.html.markdown index 01f2ac3876f..a8422134f0e 100644 --- a/website/docs/r/oracle_database_odb_subnet.html.markdown +++ b/website/docs/r/oracle_database_odb_subnet.html.markdown @@ -92,6 +92,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `deletion_protection` - (Optional) Whether or not to allow Terraform to destroy the instance. Unless this field is set to false in Terraform state, a terraform destroy or terraform apply that would delete the instance will fail. diff --git a/website/docs/r/org_policy_custom_constraint.html.markdown b/website/docs/r/org_policy_custom_constraint.html.markdown index 6ce0034be42..8fbdd9246ef 100644 --- a/website/docs/r/org_policy_custom_constraint.html.markdown +++ b/website/docs/r/org_policy_custom_constraint.html.markdown @@ -115,6 +115,12 @@ The following arguments are supported: (Optional) A human-friendly description of the constraint to display as an error message when the policy is violated. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/org_policy_policy.html.markdown b/website/docs/r/org_policy_policy.html.markdown index d59bdc7d0d2..04ccc06b187 100644 --- a/website/docs/r/org_policy_policy.html.markdown +++ b/website/docs/r/org_policy_policy.html.markdown @@ -207,6 +207,12 @@ The following arguments are supported: Dry-run policy. Audit-only policy, can be used to monitor how the policy would have impacted the existing and future resources if it's enforced. Structure is [documented below](#nested_dry_run_spec). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `spec` block supports: diff --git a/website/docs/r/organization_access_approval_settings.html.markdown b/website/docs/r/organization_access_approval_settings.html.markdown index c3945c184c5..c1fa403beb8 100644 --- a/website/docs/r/organization_access_approval_settings.html.markdown +++ b/website/docs/r/organization_access_approval_settings.html.markdown @@ -128,6 +128,12 @@ The following arguments are supported: The asymmetric crypto key version to use for signing approval requests. Empty active_key_version indicates that a Google-managed key should be used for signing. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `enrolled_services` block supports: diff --git a/website/docs/r/os_config_guest_policies.html.markdown b/website/docs/r/os_config_guest_policies.html.markdown index a7d9353fc14..38495c12707 100644 --- a/website/docs/r/os_config_guest_policies.html.markdown +++ b/website/docs/r/os_config_guest_policies.html.markdown @@ -244,6 +244,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `assignment` block supports: diff --git a/website/docs/r/os_config_os_policy_assignment.html.markdown b/website/docs/r/os_config_os_policy_assignment.html.markdown index cd76300e6b9..6398b24f6a4 100644 --- a/website/docs/r/os_config_os_policy_assignment.html.markdown +++ b/website/docs/r/os_config_os_policy_assignment.html.markdown @@ -144,6 +144,13 @@ The following arguments are supported: * `location` - (Required) The location for the resource +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + The `os_policies` block supports: * `id` - (Required) The id of the OS policy with the following restrictions: diff --git a/website/docs/r/os_config_patch_deployment.html.markdown b/website/docs/r/os_config_patch_deployment.html.markdown index 2d58ef01a38..77632bc54a2 100644 --- a/website/docs/r/os_config_patch_deployment.html.markdown +++ b/website/docs/r/os_config_patch_deployment.html.markdown @@ -354,6 +354,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `instance_filter` block supports: diff --git a/website/docs/r/os_config_v2_policy_orchestrator.html.markdown b/website/docs/r/os_config_v2_policy_orchestrator.html.markdown index 209031a3172..54f0600ad77 100644 --- a/website/docs/r/os_config_v2_policy_orchestrator.html.markdown +++ b/website/docs/r/os_config_v2_policy_orchestrator.html.markdown @@ -131,6 +131,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `orchestrated_resource` block supports: diff --git a/website/docs/r/os_config_v2_policy_orchestrator_for_folder.html.markdown b/website/docs/r/os_config_v2_policy_orchestrator_for_folder.html.markdown index 54e34abbb46..8f917eec6f1 100644 --- a/website/docs/r/os_config_v2_policy_orchestrator_for_folder.html.markdown +++ b/website/docs/r/os_config_v2_policy_orchestrator_for_folder.html.markdown @@ -199,6 +199,12 @@ The following arguments are supported: **Note**: This field is non-authoritative, and will only manage the labels present in your configuration. Please refer to the field `effective_labels` for all of the labels present on the resource. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `orchestrated_resource` block supports: diff --git a/website/docs/r/os_config_v2_policy_orchestrator_for_organization.html.markdown b/website/docs/r/os_config_v2_policy_orchestrator_for_organization.html.markdown index 1325d1ebd55..25e29d5f2df 100644 --- a/website/docs/r/os_config_v2_policy_orchestrator_for_organization.html.markdown +++ b/website/docs/r/os_config_v2_policy_orchestrator_for_organization.html.markdown @@ -143,6 +143,12 @@ The following arguments are supported: (Optional) Optional. Freeform text describing the purpose of the resource. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `orchestrated_resource` block supports: diff --git a/website/docs/r/os_login_ssh_public_key.html.markdown b/website/docs/r/os_login_ssh_public_key.html.markdown index b0d209ebb8b..25fcad2f88c 100644 --- a/website/docs/r/os_login_ssh_public_key.html.markdown +++ b/website/docs/r/os_login_ssh_public_key.html.markdown @@ -70,6 +70,12 @@ The following arguments are supported: (Optional) The project ID of the Google Cloud Platform project. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/parallelstore_instance.html.markdown b/website/docs/r/parallelstore_instance.html.markdown index 934233e382b..5642c392a51 100644 --- a/website/docs/r/parallelstore_instance.html.markdown +++ b/website/docs/r/parallelstore_instance.html.markdown @@ -218,6 +218,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/parameter_manager_parameter.html.markdown b/website/docs/r/parameter_manager_parameter.html.markdown index 6056ff994cc..9d3f9b5288f 100644 --- a/website/docs/r/parameter_manager_parameter.html.markdown +++ b/website/docs/r/parameter_manager_parameter.html.markdown @@ -131,6 +131,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/parameter_manager_parameter_version.html.markdown b/website/docs/r/parameter_manager_parameter_version.html.markdown index 0f9794bcdbc..3c3a91b02cb 100644 --- a/website/docs/r/parameter_manager_parameter_version.html.markdown +++ b/website/docs/r/parameter_manager_parameter_version.html.markdown @@ -183,6 +183,12 @@ The following arguments are supported: (Optional) The current state of Parameter Version. This field is only applicable for updating Parameter Version. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/parameter_manager_regional_parameter.html.markdown b/website/docs/r/parameter_manager_regional_parameter.html.markdown index 6eb50e9eb2a..12f2c725086 100644 --- a/website/docs/r/parameter_manager_regional_parameter.html.markdown +++ b/website/docs/r/parameter_manager_regional_parameter.html.markdown @@ -140,6 +140,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/parameter_manager_regional_parameter_version.html.markdown b/website/docs/r/parameter_manager_regional_parameter_version.html.markdown index 369aa730f8f..269f73d48da 100644 --- a/website/docs/r/parameter_manager_regional_parameter_version.html.markdown +++ b/website/docs/r/parameter_manager_regional_parameter_version.html.markdown @@ -190,6 +190,12 @@ The following arguments are supported: (Optional) The current state of Regional Parameter Version. This field is only applicable for updating Regional Parameter Version. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/privateca_ca_pool.html.markdown b/website/docs/r/privateca_ca_pool.html.markdown index b53812c9661..6aecb94d781 100644 --- a/website/docs/r/privateca_ca_pool.html.markdown +++ b/website/docs/r/privateca_ca_pool.html.markdown @@ -224,6 +224,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `issuance_policy` block supports: diff --git a/website/docs/r/privateca_certificate.html.markdown b/website/docs/r/privateca_certificate.html.markdown index a42af78cd00..e0e9a8bb75b 100644 --- a/website/docs/r/privateca_certificate.html.markdown +++ b/website/docs/r/privateca_certificate.html.markdown @@ -584,6 +584,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `config` block supports: diff --git a/website/docs/r/privateca_certificate_authority.html.markdown b/website/docs/r/privateca_certificate_authority.html.markdown index 264b8ddaa60..34607a995ec 100644 --- a/website/docs/r/privateca_certificate_authority.html.markdown +++ b/website/docs/r/privateca_certificate_authority.html.markdown @@ -475,6 +475,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `deletion_protection` - (Optional) Whether Terraform will be prevented from destroying the CertificateAuthority. When the field is set to true or unset in Terraform state, a `terraform apply` or `terraform destroy` that would delete the CertificateAuthority will fail. diff --git a/website/docs/r/privateca_certificate_template.html.markdown b/website/docs/r/privateca_certificate_template.html.markdown index 05d74d3b9e8..ccb9dbcf527 100644 --- a/website/docs/r/privateca_certificate_template.html.markdown +++ b/website/docs/r/privateca_certificate_template.html.markdown @@ -256,6 +256,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `predefined_values` block supports: diff --git a/website/docs/r/privileged_access_manager_entitlement.html.markdown b/website/docs/r/privileged_access_manager_entitlement.html.markdown index 984af5aa126..343f83633a6 100644 --- a/website/docs/r/privileged_access_manager_entitlement.html.markdown +++ b/website/docs/r/privileged_access_manager_entitlement.html.markdown @@ -137,6 +137,12 @@ The following arguments are supported: AdditionalNotificationTargets includes email addresses to be notified. Structure is [documented below](#nested_additional_notification_targets). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `eligible_users` block supports: diff --git a/website/docs/r/privileged_access_manager_settings.html.markdown b/website/docs/r/privileged_access_manager_settings.html.markdown index 2996739dad1..cc3d5c8c878 100644 --- a/website/docs/r/privileged_access_manager_settings.html.markdown +++ b/website/docs/r/privileged_access_manager_settings.html.markdown @@ -93,6 +93,12 @@ The following arguments are supported: EmailNotificationSettings defines node-wide email notification preferences for various PAM events. Structure is [documented below](#nested_email_notification_settings). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `service_account_approver_settings` block supports: diff --git a/website/docs/r/project_access_approval_settings.html.markdown b/website/docs/r/project_access_approval_settings.html.markdown index dc6123e61ef..c3ff69cb320 100644 --- a/website/docs/r/project_access_approval_settings.html.markdown +++ b/website/docs/r/project_access_approval_settings.html.markdown @@ -124,6 +124,12 @@ The following arguments are supported: ~> **Warning:** `project` is deprecated and will be removed in a future major release. Use `project_id` instead. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `enrolled_services` block supports: diff --git a/website/docs/r/project_usage_export_bucket.html.markdown b/website/docs/r/project_usage_export_bucket.html.markdown index fb9cd3b51cf..5171431794c 100644 --- a/website/docs/r/project_usage_export_bucket.html.markdown +++ b/website/docs/r/project_usage_export_bucket.html.markdown @@ -50,6 +50,14 @@ resource "google_project_usage_export_bucket" "usage_export" { * `project`: (Optional) The project to set the export bucket on. If it is not provided, the provider project is used. + +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + ## Timeouts This resource provides the following diff --git a/website/docs/r/public_ca_external_account_key.html.markdown b/website/docs/r/public_ca_external_account_key.html.markdown index 95718b32a45..e59d656c8a5 100644 --- a/website/docs/r/public_ca_external_account_key.html.markdown +++ b/website/docs/r/public_ca_external_account_key.html.markdown @@ -64,6 +64,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/pubsub_lite_reservation.html.markdown b/website/docs/r/pubsub_lite_reservation.html.markdown index dfb82ff90d5..d3cbda3b2f4 100644 --- a/website/docs/r/pubsub_lite_reservation.html.markdown +++ b/website/docs/r/pubsub_lite_reservation.html.markdown @@ -73,6 +73,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/pubsub_lite_subscription.html.markdown b/website/docs/r/pubsub_lite_subscription.html.markdown index 4976feda5c5..212678f9e3e 100644 --- a/website/docs/r/pubsub_lite_subscription.html.markdown +++ b/website/docs/r/pubsub_lite_subscription.html.markdown @@ -100,6 +100,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `delivery_config` block supports: diff --git a/website/docs/r/pubsub_lite_topic.html.markdown b/website/docs/r/pubsub_lite_topic.html.markdown index 634d28e8d57..e726e18636f 100644 --- a/website/docs/r/pubsub_lite_topic.html.markdown +++ b/website/docs/r/pubsub_lite_topic.html.markdown @@ -107,6 +107,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `partition_config` block supports: diff --git a/website/docs/r/pubsub_schema.html.markdown b/website/docs/r/pubsub_schema.html.markdown index cc6705704c0..f07c2f623c5 100644 --- a/website/docs/r/pubsub_schema.html.markdown +++ b/website/docs/r/pubsub_schema.html.markdown @@ -97,6 +97,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/pubsub_subscription.html.markdown b/website/docs/r/pubsub_subscription.html.markdown index 362680fd78f..77674883c8a 100644 --- a/website/docs/r/pubsub_subscription.html.markdown +++ b/website/docs/r/pubsub_subscription.html.markdown @@ -841,6 +841,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `bigquery_config` block supports: diff --git a/website/docs/r/pubsub_topic.html.markdown b/website/docs/r/pubsub_topic.html.markdown index 5b5d80c65cc..288b4aca086 100644 --- a/website/docs/r/pubsub_topic.html.markdown +++ b/website/docs/r/pubsub_topic.html.markdown @@ -448,6 +448,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `message_storage_policy` block supports: diff --git a/website/docs/r/recaptcha_enterprise_key.html.markdown b/website/docs/r/recaptcha_enterprise_key.html.markdown index f0543b01c79..d24280effbd 100644 --- a/website/docs/r/recaptcha_enterprise_key.html.markdown +++ b/website/docs/r/recaptcha_enterprise_key.html.markdown @@ -212,7 +212,13 @@ Please refer to the field `effective_labels` for all of the labels present on th * `web_settings` - (Optional) Settings for keys that can be used by websites. - + +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `android_settings` block supports: diff --git a/website/docs/r/redis_cluster.html.markdown b/website/docs/r/redis_cluster.html.markdown index b9d2021a827..e370605c533 100644 --- a/website/docs/r/redis_cluster.html.markdown +++ b/website/docs/r/redis_cluster.html.markdown @@ -885,6 +885,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `gcs_source` block supports: diff --git a/website/docs/r/redis_cluster_user_created_connections.html.markdown b/website/docs/r/redis_cluster_user_created_connections.html.markdown index d7f2ff87aaa..66b8714465a 100644 --- a/website/docs/r/redis_cluster_user_created_connections.html.markdown +++ b/website/docs/r/redis_cluster_user_created_connections.html.markdown @@ -334,6 +334,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `cluster_endpoints` block supports: diff --git a/website/docs/r/redis_instance.html.markdown b/website/docs/r/redis_instance.html.markdown index 95b85b9fd28..ce5a80602a1 100644 --- a/website/docs/r/redis_instance.html.markdown +++ b/website/docs/r/redis_instance.html.markdown @@ -422,6 +422,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `deletion_protection` - (Optional) Whether Terraform will be prevented from destroying the instance. When a`terraform destroy` or `terraform apply` would delete the instance, the command will fail if this field is not set to false in Terraform state. diff --git a/website/docs/r/resource_manager_capability.html.markdown b/website/docs/r/resource_manager_capability.html.markdown index 84092e2627d..784e5d59a5d 100644 --- a/website/docs/r/resource_manager_capability.html.markdown +++ b/website/docs/r/resource_manager_capability.html.markdown @@ -69,6 +69,12 @@ The following arguments are supported: Capability Value. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/resource_manager_lien.html.markdown b/website/docs/r/resource_manager_lien.html.markdown index 13b3003ed56..19ae64dbfd2 100644 --- a/website/docs/r/resource_manager_lien.html.markdown +++ b/website/docs/r/resource_manager_lien.html.markdown @@ -80,6 +80,12 @@ The following arguments are supported: e.g. ['resourcemanager.projects.delete'] +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/runtimeconfig_config.html.markdown b/website/docs/r/runtimeconfig_config.html.markdown index 5f073ae7fb7..5edbd4e74ef 100644 --- a/website/docs/r/runtimeconfig_config.html.markdown +++ b/website/docs/r/runtimeconfig_config.html.markdown @@ -56,6 +56,13 @@ is not provided, the provider project is used. * `description` - (Optional) The description to associate with the runtime config. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + ## Attributes Reference In addition to the arguments listed above, the following computed attributes are exported: diff --git a/website/docs/r/runtimeconfig_variable.html.markdown b/website/docs/r/runtimeconfig_variable.html.markdown index 1db28ae14ef..f0458a19fdd 100644 --- a/website/docs/r/runtimeconfig_variable.html.markdown +++ b/website/docs/r/runtimeconfig_variable.html.markdown @@ -83,6 +83,13 @@ is specified, it must be base64 encoded and less than 4096 bytes in length. * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + ## Attributes Reference In addition to the arguments listed above, the following computed attributes are diff --git a/website/docs/r/saas_runtime_release.html.markdown b/website/docs/r/saas_runtime_release.html.markdown index 61cb1ff0bf5..f07e8e8cc95 100644 --- a/website/docs/r/saas_runtime_release.html.markdown +++ b/website/docs/r/saas_runtime_release.html.markdown @@ -131,6 +131,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `blueprint` block supports: diff --git a/website/docs/r/saas_runtime_rollout_kind.html.markdown b/website/docs/r/saas_runtime_rollout_kind.html.markdown index e6c745237b0..436253ef78b 100644 --- a/website/docs/r/saas_runtime_rollout_kind.html.markdown +++ b/website/docs/r/saas_runtime_rollout_kind.html.markdown @@ -136,6 +136,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `error_budget` block supports: diff --git a/website/docs/r/saas_runtime_saas.html.markdown b/website/docs/r/saas_runtime_saas.html.markdown index 30d687d9395..9e5e989134c 100644 --- a/website/docs/r/saas_runtime_saas.html.markdown +++ b/website/docs/r/saas_runtime_saas.html.markdown @@ -89,6 +89,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `locations` block supports: diff --git a/website/docs/r/saas_runtime_tenant.html.markdown b/website/docs/r/saas_runtime_tenant.html.markdown index 46b8eada240..79c2504df30 100644 --- a/website/docs/r/saas_runtime_tenant.html.markdown +++ b/website/docs/r/saas_runtime_tenant.html.markdown @@ -96,6 +96,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/saas_runtime_unit.html.markdown b/website/docs/r/saas_runtime_unit.html.markdown index 42c4d08101c..9d2532b8bb5 100644 --- a/website/docs/r/saas_runtime_unit.html.markdown +++ b/website/docs/r/saas_runtime_unit.html.markdown @@ -115,6 +115,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `maintenance` block supports: diff --git a/website/docs/r/saas_runtime_unit_kind.html.markdown b/website/docs/r/saas_runtime_unit_kind.html.markdown index 714eb900c49..d97c93dd1b8 100644 --- a/website/docs/r/saas_runtime_unit_kind.html.markdown +++ b/website/docs/r/saas_runtime_unit_kind.html.markdown @@ -137,6 +137,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `dependencies` block supports: diff --git a/website/docs/r/saas_runtime_unit_operation.html.markdown b/website/docs/r/saas_runtime_unit_operation.html.markdown index edcaf61e39b..e9635e3d3d8 100644 --- a/website/docs/r/saas_runtime_unit_operation.html.markdown +++ b/website/docs/r/saas_runtime_unit_operation.html.markdown @@ -269,6 +269,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `wait_for_completion` - (Optional) If true, wait for the UnitOperation to reach a terminal state (SUCCEEDED, FAILED, CANCELLED) before completing the apply. diff --git a/website/docs/r/scc_event_threat_detection_custom_module.html.markdown b/website/docs/r/scc_event_threat_detection_custom_module.html.markdown index 58522cf7d30..f46c81de73b 100644 --- a/website/docs/r/scc_event_threat_detection_custom_module.html.markdown +++ b/website/docs/r/scc_event_threat_detection_custom_module.html.markdown @@ -85,6 +85,12 @@ The following arguments are supported: (Optional) The human readable name to be displayed for the module. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/scc_folder_custom_module.html.markdown b/website/docs/r/scc_folder_custom_module.html.markdown index ab4c27e15c6..ed8e28236b3 100644 --- a/website/docs/r/scc_folder_custom_module.html.markdown +++ b/website/docs/r/scc_folder_custom_module.html.markdown @@ -136,6 +136,12 @@ The following arguments are supported: Numerical ID of the parent folder. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `custom_config` block supports: diff --git a/website/docs/r/scc_folder_notification_config.html.markdown b/website/docs/r/scc_folder_notification_config.html.markdown index 5381ffef1a1..89393bf521d 100644 --- a/website/docs/r/scc_folder_notification_config.html.markdown +++ b/website/docs/r/scc_folder_notification_config.html.markdown @@ -90,6 +90,12 @@ The following arguments are supported: (Optional) The description of the notification config (max of 1024 characters). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `streaming_config` block supports: diff --git a/website/docs/r/scc_folder_scc_big_query_export.html.markdown b/website/docs/r/scc_folder_scc_big_query_export.html.markdown index adbf8b95f18..6ce83fc9263 100644 --- a/website/docs/r/scc_folder_scc_big_query_export.html.markdown +++ b/website/docs/r/scc_folder_scc_big_query_export.html.markdown @@ -120,6 +120,12 @@ The following arguments are supported: This must be unique within the organization. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/scc_management_folder_security_health_analytics_custom_module.html.markdown b/website/docs/r/scc_management_folder_security_health_analytics_custom_module.html.markdown index a218223829f..2573edcbd05 100644 --- a/website/docs/r/scc_management_folder_security_health_analytics_custom_module.html.markdown +++ b/website/docs/r/scc_management_folder_security_health_analytics_custom_module.html.markdown @@ -142,6 +142,12 @@ The following arguments are supported: (Optional) Location ID of the parent organization. If not provided, 'global' will be used as the default location. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `custom_config` block supports: diff --git a/website/docs/r/scc_management_organization_event_threat_detection_custom_module.html.markdown b/website/docs/r/scc_management_organization_event_threat_detection_custom_module.html.markdown index ac2b3bac59e..ad530e6ab60 100644 --- a/website/docs/r/scc_management_organization_event_threat_detection_custom_module.html.markdown +++ b/website/docs/r/scc_management_organization_event_threat_detection_custom_module.html.markdown @@ -90,6 +90,12 @@ The following arguments are supported: (Optional) Location ID of the parent organization. Only global is supported at the moment. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/scc_management_organization_security_health_analytics_custom_module.html.markdown b/website/docs/r/scc_management_organization_security_health_analytics_custom_module.html.markdown index 9bfd5c7195c..5eee3997151 100644 --- a/website/docs/r/scc_management_organization_security_health_analytics_custom_module.html.markdown +++ b/website/docs/r/scc_management_organization_security_health_analytics_custom_module.html.markdown @@ -130,6 +130,12 @@ The following arguments are supported: (Optional) Location ID of the parent organization. If not provided, 'global' will be used as the default location. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `custom_config` block supports: diff --git a/website/docs/r/scc_management_project_security_health_analytics_custom_module.html.markdown b/website/docs/r/scc_management_project_security_health_analytics_custom_module.html.markdown index dfdfa4a829f..6a2c78d92e5 100644 --- a/website/docs/r/scc_management_project_security_health_analytics_custom_module.html.markdown +++ b/website/docs/r/scc_management_project_security_health_analytics_custom_module.html.markdown @@ -127,6 +127,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `custom_config` block supports: diff --git a/website/docs/r/scc_mute_config.html.markdown b/website/docs/r/scc_mute_config.html.markdown index e432a9272a0..24eb6a1fc4b 100644 --- a/website/docs/r/scc_mute_config.html.markdown +++ b/website/docs/r/scc_mute_config.html.markdown @@ -89,6 +89,12 @@ The following arguments are supported: A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z". +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/scc_notification_config.html.markdown b/website/docs/r/scc_notification_config.html.markdown index 949e0deefc9..b4f547d257b 100644 --- a/website/docs/r/scc_notification_config.html.markdown +++ b/website/docs/r/scc_notification_config.html.markdown @@ -85,6 +85,12 @@ The following arguments are supported: (Optional) The description of the notification config (max of 1024 characters). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `streaming_config` block supports: diff --git a/website/docs/r/scc_organization_custom_module.html.markdown b/website/docs/r/scc_organization_custom_module.html.markdown index 0164bfa7360..b9d7792e997 100644 --- a/website/docs/r/scc_organization_custom_module.html.markdown +++ b/website/docs/r/scc_organization_custom_module.html.markdown @@ -124,6 +124,12 @@ The following arguments are supported: Numerical ID of the parent organization. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `custom_config` block supports: diff --git a/website/docs/r/scc_organization_scc_big_query_export.html.markdown b/website/docs/r/scc_organization_scc_big_query_export.html.markdown index 6220fbc6b7a..5f06d4807c7 100644 --- a/website/docs/r/scc_organization_scc_big_query_export.html.markdown +++ b/website/docs/r/scc_organization_scc_big_query_export.html.markdown @@ -113,6 +113,12 @@ The following arguments are supported: [Filtering notifications](https://cloud.google.com/security-command-center/docs/how-to-api-filter-notifications) for information on how to write a filter. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/scc_project_custom_module.html.markdown b/website/docs/r/scc_project_custom_module.html.markdown index 100ad9aa345..552899a2629 100644 --- a/website/docs/r/scc_project_custom_module.html.markdown +++ b/website/docs/r/scc_project_custom_module.html.markdown @@ -121,6 +121,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `custom_config` block supports: diff --git a/website/docs/r/scc_project_notification_config.html.markdown b/website/docs/r/scc_project_notification_config.html.markdown index df15773239a..f780b46371b 100644 --- a/website/docs/r/scc_project_notification_config.html.markdown +++ b/website/docs/r/scc_project_notification_config.html.markdown @@ -83,6 +83,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `streaming_config` block supports: diff --git a/website/docs/r/scc_project_scc_big_query_export.html.markdown b/website/docs/r/scc_project_scc_big_query_export.html.markdown index bb92270d286..46b8a153420 100644 --- a/website/docs/r/scc_project_scc_big_query_export.html.markdown +++ b/website/docs/r/scc_project_scc_big_query_export.html.markdown @@ -111,6 +111,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/scc_source.html.markdown b/website/docs/r/scc_source.html.markdown index 4bf5c9f9544..f788ac36cad 100644 --- a/website/docs/r/scc_source.html.markdown +++ b/website/docs/r/scc_source.html.markdown @@ -67,6 +67,12 @@ The following arguments are supported: (Optional) The description of the source (max of 1024 characters). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/scc_v2_folder_mute_config.html.markdown b/website/docs/r/scc_v2_folder_mute_config.html.markdown index 2ab7ad0f100..f3fb21a8a78 100644 --- a/website/docs/r/scc_v2_folder_mute_config.html.markdown +++ b/website/docs/r/scc_v2_folder_mute_config.html.markdown @@ -88,6 +88,12 @@ The following arguments are supported: (Optional) location Id is provided by folder. If not provided, Use global as default. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/scc_v2_folder_notification_config.html.markdown b/website/docs/r/scc_v2_folder_notification_config.html.markdown index 22947124aee..7ab9a2da708 100644 --- a/website/docs/r/scc_v2_folder_notification_config.html.markdown +++ b/website/docs/r/scc_v2_folder_notification_config.html.markdown @@ -88,6 +88,12 @@ The following arguments are supported: (Optional) Location ID of the parent organization. If not provided, 'global' will be used as the default location. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `streaming_config` block supports: diff --git a/website/docs/r/scc_v2_folder_scc_big_query_export.html.markdown b/website/docs/r/scc_v2_folder_scc_big_query_export.html.markdown index 378c462bd7e..340dba971f6 100644 --- a/website/docs/r/scc_v2_folder_scc_big_query_export.html.markdown +++ b/website/docs/r/scc_v2_folder_scc_big_query_export.html.markdown @@ -126,6 +126,12 @@ The following arguments are supported: (Optional) The BigQuery export configuration is stored in this location. If not provided, Use global as default. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/scc_v2_organization_mute_config.html.markdown b/website/docs/r/scc_v2_organization_mute_config.html.markdown index 59d596fdcbc..2a2d0acaea7 100644 --- a/website/docs/r/scc_v2_organization_mute_config.html.markdown +++ b/website/docs/r/scc_v2_organization_mute_config.html.markdown @@ -83,6 +83,12 @@ The following arguments are supported: (Optional) location Id is provided by organization. If not provided, Use global as default. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/scc_v2_organization_notification_config.html.markdown b/website/docs/r/scc_v2_organization_notification_config.html.markdown index 3eaa2d82329..564bc87a23f 100644 --- a/website/docs/r/scc_v2_organization_notification_config.html.markdown +++ b/website/docs/r/scc_v2_organization_notification_config.html.markdown @@ -84,6 +84,12 @@ The following arguments are supported: (Optional) location Id is provided by organization. If not provided, Use global as default. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `streaming_config` block supports: diff --git a/website/docs/r/scc_v2_organization_scc_big_query_export.html.markdown b/website/docs/r/scc_v2_organization_scc_big_query_export.html.markdown index 2d3418d98a3..7d057f53f56 100644 --- a/website/docs/r/scc_v2_organization_scc_big_query_export.html.markdown +++ b/website/docs/r/scc_v2_organization_scc_big_query_export.html.markdown @@ -124,6 +124,12 @@ The following arguments are supported: (Optional) location Id is provided by organization. If not provided, Use global as default. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/scc_v2_organization_scc_big_query_exports.html.markdown b/website/docs/r/scc_v2_organization_scc_big_query_exports.html.markdown index bb144841a5b..80eadcb3f29 100644 --- a/website/docs/r/scc_v2_organization_scc_big_query_exports.html.markdown +++ b/website/docs/r/scc_v2_organization_scc_big_query_exports.html.markdown @@ -125,6 +125,12 @@ The following arguments are supported: (Optional) location Id is provided by organization. If not provided, Use global as default. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/scc_v2_organization_source.html.markdown b/website/docs/r/scc_v2_organization_source.html.markdown index 8fd27fbaf8e..8faf6d6e9cc 100644 --- a/website/docs/r/scc_v2_organization_source.html.markdown +++ b/website/docs/r/scc_v2_organization_source.html.markdown @@ -67,6 +67,12 @@ The following arguments are supported: (Optional) The description of the source (max of 1024 characters). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/scc_v2_project_mute_config.html.markdown b/website/docs/r/scc_v2_project_mute_config.html.markdown index bf853d81429..62a01bad79b 100644 --- a/website/docs/r/scc_v2_project_mute_config.html.markdown +++ b/website/docs/r/scc_v2_project_mute_config.html.markdown @@ -81,6 +81,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/scc_v2_project_notification_config.html.markdown b/website/docs/r/scc_v2_project_notification_config.html.markdown index 01c71dbd996..0483ed39514 100644 --- a/website/docs/r/scc_v2_project_notification_config.html.markdown +++ b/website/docs/r/scc_v2_project_notification_config.html.markdown @@ -81,6 +81,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `streaming_config` block supports: diff --git a/website/docs/r/scc_v2_project_scc_big_query_export.html.markdown b/website/docs/r/scc_v2_project_scc_big_query_export.html.markdown index 436f682b6eb..a7ad8d047ed 100644 --- a/website/docs/r/scc_v2_project_scc_big_query_export.html.markdown +++ b/website/docs/r/scc_v2_project_scc_big_query_export.html.markdown @@ -116,6 +116,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/secret_manager_regional_secret.html.markdown b/website/docs/r/secret_manager_regional_secret.html.markdown index b7831b2a1d0..767f21a073d 100644 --- a/website/docs/r/secret_manager_regional_secret.html.markdown +++ b/website/docs/r/secret_manager_regional_secret.html.markdown @@ -302,6 +302,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `deletion_protection` - (Optional) Whether Terraform will be prevented from destroying the regional secret. Defaults to false. When the field is set to true in Terraform state, a `terraform apply` or `terraform destroy` that would delete the federation will fail. diff --git a/website/docs/r/secret_manager_regional_secret_version.html.markdown b/website/docs/r/secret_manager_regional_secret_version.html.markdown index f8498410559..dfdbb8ddae0 100644 --- a/website/docs/r/secret_manager_regional_secret_version.html.markdown +++ b/website/docs/r/secret_manager_regional_secret_version.html.markdown @@ -159,12 +159,18 @@ The following arguments are supported: (Optional) The current state of the regional secret version. -* `deletion_policy` - (Optional) The deletion policy for the regional secret version. Setting `ABANDON` allows the resource +* `deletion_policy` - (Optional) The deletion policy for the secret version. Setting `ABANDON` allows the resource to be abandoned rather than deleted. Setting `DISABLE` allows the resource to be -disabled rather than deleted. Default is `DELETE`. Possible values are: +disabled rather than deleted. + +When a 'terraform destroy' or 'terraform apply' would delete the resource, +the command will fail if this field is set to "PREVENT" in Terraform state. + +Default is `DELETE`. Possible values are: * DELETE * DISABLE * ABANDON + * PREVENT * `is_secret_data_base64` - (Optional) If set to 'true', the secret data is expected to be base64-encoded string and would be sent as is. diff --git a/website/docs/r/secret_manager_secret.html.markdown b/website/docs/r/secret_manager_secret.html.markdown index 936eff49086..61eb695b6d0 100644 --- a/website/docs/r/secret_manager_secret.html.markdown +++ b/website/docs/r/secret_manager_secret.html.markdown @@ -234,6 +234,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `deletion_protection` - (Optional) Whether Terraform will be prevented from destroying the secret. Defaults to false. When the field is set to true in Terraform state, a `terraform apply` or `terraform destroy` that would delete the secret will fail. diff --git a/website/docs/r/secret_manager_secret_version.html.markdown b/website/docs/r/secret_manager_secret_version.html.markdown index 42bb1bed85c..f76a1fd3e14 100644 --- a/website/docs/r/secret_manager_secret_version.html.markdown +++ b/website/docs/r/secret_manager_secret_version.html.markdown @@ -250,10 +250,16 @@ The following arguments are supported: * `deletion_policy` - (Optional) The deletion policy for the secret version. Setting `ABANDON` allows the resource to be abandoned rather than deleted. Setting `DISABLE` allows the resource to be -disabled rather than deleted. Default is `DELETE`. Possible values are: +disabled rather than deleted. + +When a 'terraform destroy' or 'terraform apply' would delete the resource, +the command will fail if this field is set to "PREVENT" in Terraform state. + +Default is `DELETE`. Possible values are: * DELETE * DISABLE * ABANDON + * PREVENT * `is_secret_data_base64` - (Optional) If set to 'true', the secret data is expected to be base64-encoded string and would be sent as is. diff --git a/website/docs/r/secure_source_manager_branch_rule.html.markdown b/website/docs/r/secure_source_manager_branch_rule.html.markdown index 4087e1c8e76..3d428f13f2e 100644 --- a/website/docs/r/secure_source_manager_branch_rule.html.markdown +++ b/website/docs/r/secure_source_manager_branch_rule.html.markdown @@ -158,6 +158,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/secure_source_manager_hook.html.markdown b/website/docs/r/secure_source_manager_hook.html.markdown index 8a18967a194..39a6f11ba36 100644 --- a/website/docs/r/secure_source_manager_hook.html.markdown +++ b/website/docs/r/secure_source_manager_hook.html.markdown @@ -152,6 +152,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `push_option` block supports: diff --git a/website/docs/r/secure_source_manager_instance.html.markdown b/website/docs/r/secure_source_manager_instance.html.markdown index f3b27dc8a24..c548210b201 100644 --- a/website/docs/r/secure_source_manager_instance.html.markdown +++ b/website/docs/r/secure_source_manager_instance.html.markdown @@ -679,15 +679,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. -* `deletion_policy` - (Optional) The deletion policy for the instance. Setting `ABANDON` allows the resource -to be abandoned, rather than deleted. Setting `DELETE` deletes the resource -and all its contents. Setting `PREVENT` prevents the resource from accidental -deletion by erroring out during plan. -Default is `PREVENT`. Possible values are: - * DELETE - * PREVENT - * ABANDON - +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to PREVENT. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `private_config` block supports: diff --git a/website/docs/r/secure_source_manager_repository.html.markdown b/website/docs/r/secure_source_manager_repository.html.markdown index 76b9e07d364..2304b144783 100644 --- a/website/docs/r/secure_source_manager_repository.html.markdown +++ b/website/docs/r/secure_source_manager_repository.html.markdown @@ -121,15 +121,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. -* `deletion_policy` - (Optional) The deletion policy for the repository. Setting `ABANDON` allows the resource -to be abandoned, rather than deleted. Setting `DELETE` deletes the resource -and all its contents. Setting `PREVENT` prevents the resource from accidental deletion -by erroring out during plan. -Default is `PREVENT`. Possible values are: - * DELETE - * PREVENT - * ABANDON - +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to PREVENT. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `initial_config` block supports: diff --git a/website/docs/r/security_scanner_scan_config.html.markdown b/website/docs/r/security_scanner_scan_config.html.markdown index eba66de0f39..af76c7fd0e3 100644 --- a/website/docs/r/security_scanner_scan_config.html.markdown +++ b/website/docs/r/security_scanner_scan_config.html.markdown @@ -113,6 +113,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `authentication` block supports: diff --git a/website/docs/r/securityposture_posture.html.markdown b/website/docs/r/securityposture_posture.html.markdown index 97388ebff42..016e2a8bddd 100644 --- a/website/docs/r/securityposture_posture.html.markdown +++ b/website/docs/r/securityposture_posture.html.markdown @@ -166,6 +166,12 @@ The following arguments are supported: (Optional) Description of the posture. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `policy_sets` block supports: diff --git a/website/docs/r/securityposture_posture_deployment.html.markdown b/website/docs/r/securityposture_posture_deployment.html.markdown index c1bd1c1d700..755a35655e3 100644 --- a/website/docs/r/securityposture_posture_deployment.html.markdown +++ b/website/docs/r/securityposture_posture_deployment.html.markdown @@ -72,6 +72,12 @@ The following arguments are supported: (Optional) Description of the posture deployment. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/service_directory_endpoint.html.markdown b/website/docs/r/service_directory_endpoint.html.markdown index e5ac03d707b..8aa61af5d5a 100644 --- a/website/docs/r/service_directory_endpoint.html.markdown +++ b/website/docs/r/service_directory_endpoint.html.markdown @@ -138,6 +138,12 @@ The following arguments are supported: (Optional) The URL to the network, such as projects/PROJECT_NUMBER/locations/global/networks/NETWORK_NAME. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/service_directory_namespace.html.markdown b/website/docs/r/service_directory_namespace.html.markdown index df170504ea9..6a6f219f748 100644 --- a/website/docs/r/service_directory_namespace.html.markdown +++ b/website/docs/r/service_directory_namespace.html.markdown @@ -78,6 +78,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/service_directory_service.html.markdown b/website/docs/r/service_directory_service.html.markdown index 5093c9da41f..1ad2b1a84da 100644 --- a/website/docs/r/service_directory_service.html.markdown +++ b/website/docs/r/service_directory_service.html.markdown @@ -77,6 +77,12 @@ The following arguments are supported: up to 2000 characters, spread across all key-value pairs. Metadata that goes beyond any these limits will be rejected. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/service_networking_connection.html.markdown b/website/docs/r/service_networking_connection.html.markdown index 67e2882f89f..2c3c86323e3 100644 --- a/website/docs/r/service_networking_connection.html.markdown +++ b/website/docs/r/service_networking_connection.html.markdown @@ -73,7 +73,13 @@ The following arguments are supported: this service provider. Note that invoking this method with a different range when connection is already established will not reallocate already provisioned service producer subnetworks. -* `deletion_policy` - (Optional) The deletion policy for the service networking connection. Setting to ABANDON allows the resource to be abandoned rather than deleted. This will enable a successful terraform destroy when destroying CloudSQL instances. Use with care as it can lead to dangling resources. + +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE" or any other value, deleting the resource is allowed. * `update_on_creation_fail` - (Optional) When set to true, enforce an update of the reserved peering ranges on the existing service networking connection in case of a new connection creation failure. diff --git a/website/docs/r/service_networking_vpc_service_controls.html.markdown b/website/docs/r/service_networking_vpc_service_controls.html.markdown index e59765a61f0..adb825a63bc 100644 --- a/website/docs/r/service_networking_vpc_service_controls.html.markdown +++ b/website/docs/r/service_networking_vpc_service_controls.html.markdown @@ -128,6 +128,12 @@ The following arguments are supported: (Optional) The id of the Google Cloud project containing the consumer network. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/service_usage_consumer_quota_override.html.markdown b/website/docs/r/service_usage_consumer_quota_override.html.markdown index f76a0a9703e..e7fdfefc39b 100644 --- a/website/docs/r/service_usage_consumer_quota_override.html.markdown +++ b/website/docs/r/service_usage_consumer_quota_override.html.markdown @@ -142,6 +142,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/site_verification_owner.html.markdown b/website/docs/r/site_verification_owner.html.markdown index 82ed0a8932c..73d1b758e59 100644 --- a/website/docs/r/site_verification_owner.html.markdown +++ b/website/docs/r/site_verification_owner.html.markdown @@ -110,6 +110,13 @@ The following arguments are supported: (Required) The email of the user to be added as an owner. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + - - - diff --git a/website/docs/r/site_verification_web_resource.html.markdown b/website/docs/r/site_verification_web_resource.html.markdown index d26c05b1b3e..6a917e57703 100644 --- a/website/docs/r/site_verification_web_resource.html.markdown +++ b/website/docs/r/site_verification_web_resource.html.markdown @@ -84,6 +84,12 @@ The following arguments are supported: Possible values are: `ANALYTICS`, `DNS_CNAME`, `DNS_TXT`, `FILE`, `META`, `TAG_MANAGER`. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `site` block supports: diff --git a/website/docs/r/sourcerepo_repository.html.markdown b/website/docs/r/sourcerepo_repository.html.markdown index 538b81a3359..d82d69224ea 100644 --- a/website/docs/r/sourcerepo_repository.html.markdown +++ b/website/docs/r/sourcerepo_repository.html.markdown @@ -91,6 +91,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `create_ignore_already_exists` - (Optional) If set to true, skip repository creation if a repository with the same name already exists. diff --git a/website/docs/r/spanner_backup_schedule.html.markdown b/website/docs/r/spanner_backup_schedule.html.markdown index 9cd32e305f7..d2427298fb2 100644 --- a/website/docs/r/spanner_backup_schedule.html.markdown +++ b/website/docs/r/spanner_backup_schedule.html.markdown @@ -193,6 +193,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `spec` block supports: diff --git a/website/docs/r/spanner_database.html.markdown b/website/docs/r/spanner_database.html.markdown index c7632aeb582..5c578fb8a0d 100644 --- a/website/docs/r/spanner_database.html.markdown +++ b/website/docs/r/spanner_database.html.markdown @@ -125,6 +125,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `deletion_protection` - (Optional) Whether Terraform will be prevented from destroying the database. Defaults to true. When a`terraform destroy` or `terraform apply` would delete the database, the command will fail if this field is not set to false in Terraform state. diff --git a/website/docs/r/spanner_instance.html.markdown b/website/docs/r/spanner_instance.html.markdown index fe4c76c58f4..55a20a6a4ea 100644 --- a/website/docs/r/spanner_instance.html.markdown +++ b/website/docs/r/spanner_instance.html.markdown @@ -166,6 +166,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `force_destroy` - (Optional) When deleting a spanner instance, this boolean option will delete all backups of this instance. This must be set to true if you created a backup manually in the console. diff --git a/website/docs/r/spanner_instance_config.html.markdown b/website/docs/r/spanner_instance_config.html.markdown index c617be3b503..03322289316 100644 --- a/website/docs/r/spanner_instance_config.html.markdown +++ b/website/docs/r/spanner_instance_config.html.markdown @@ -92,6 +92,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `replicas` block supports: diff --git a/website/docs/r/spanner_instance_partition.html.markdown b/website/docs/r/spanner_instance_partition.html.markdown index 2e4917f47cf..4eb4c79691b 100644 --- a/website/docs/r/spanner_instance_partition.html.markdown +++ b/website/docs/r/spanner_instance_partition.html.markdown @@ -142,6 +142,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `autoscaling_config` block supports: diff --git a/website/docs/r/sql_database.html.markdown b/website/docs/r/sql_database.html.markdown index 3efaaa2db1f..3e5e4e3af67 100644 --- a/website/docs/r/sql_database.html.markdown +++ b/website/docs/r/sql_database.html.markdown @@ -116,11 +116,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. -* `deletion_policy` - (Optional) The deletion policy for the database. Setting ABANDON allows the resource -to be abandoned rather than deleted. This is useful for Postgres, where databases cannot be -deleted from the API if there are users other than cloudsqlsuperuser with access. Possible -values are: "ABANDON", "DELETE". Defaults to "DELETE". - +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/sql_database_instance.html.markdown b/website/docs/r/sql_database_instance.html.markdown index eedf3cbbaa3..939e3c8c0e7 100644 --- a/website/docs/r/sql_database_instance.html.markdown +++ b/website/docs/r/sql_database_instance.html.markdown @@ -434,6 +434,13 @@ includes an up-to-date reference of supported versions. **NOTE:** Restoring from a backup is an imperative action and not recommended via Terraform. Adding or modifying this block during resource creation/update will trigger the restore action after the resource is created/updated. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + The `settings` block supports: * `tier` - (Required) The machine type to use. See [tiers](https://cloud.google.com/sql/docs/admin-api/v1beta4/tiers) diff --git a/website/docs/r/sql_source_representation_instance.html.markdown b/website/docs/r/sql_source_representation_instance.html.markdown index a7504353580..f015752ad0b 100644 --- a/website/docs/r/sql_source_representation_instance.html.markdown +++ b/website/docs/r/sql_source_representation_instance.html.markdown @@ -131,6 +131,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/sql_ssl_cert.html.markdown b/website/docs/r/sql_ssl_cert.html.markdown index 34aedcb9669..d3e1a6df3fa 100644 --- a/website/docs/r/sql_ssl_cert.html.markdown +++ b/website/docs/r/sql_ssl_cert.html.markdown @@ -61,6 +61,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/sql_user.html.markdown b/website/docs/r/sql_user.html.markdown index 10c79498815..d6164e07367 100644 --- a/website/docs/r/sql_user.html.markdown +++ b/website/docs/r/sql_user.html.markdown @@ -175,11 +175,14 @@ The following arguments are supported: [Postgres](https://cloud.google.com/sql/docs/postgres/admin-api/rest/v1beta4/users#sqlusertype) and [MySQL](https://cloud.google.com/sql/docs/mysql/admin-api/rest/v1beta4/users#sqlusertype). -* `deletion_policy` - (Optional) The deletion policy for the user. - Setting `ABANDON` allows the resource to be abandoned rather than deleted. This is useful +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. This is useful for Postgres, where users cannot be deleted from the API if they have been granted SQL roles. - Possible values are: `ABANDON`. + When set to "DELETE", deleting the resource is allowed. - - - diff --git a/website/docs/r/storage_anywhere_cache.html.markdown b/website/docs/r/storage_anywhere_cache.html.markdown index 21626350fe7..115f8175f26 100644 --- a/website/docs/r/storage_anywhere_cache.html.markdown +++ b/website/docs/r/storage_anywhere_cache.html.markdown @@ -84,6 +84,12 @@ The following arguments are supported: (Optional) Whether or not the cache ingests data as the data is written to the bucket. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/storage_batch_operations_job.html.markdown b/website/docs/r/storage_batch_operations_job.html.markdown index f18590e88fb..79c2a6c932b 100644 --- a/website/docs/r/storage_batch_operations_job.html.markdown +++ b/website/docs/r/storage_batch_operations_job.html.markdown @@ -103,6 +103,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `delete_protection` - (Optional) If set to `true`, the storage batch operation job will not be deleted and new job will be created. diff --git a/website/docs/r/storage_bucket.html.markdown b/website/docs/r/storage_bucket.html.markdown index fe08881eb66..807e4daea9e 100644 --- a/website/docs/r/storage_bucket.html.markdown +++ b/website/docs/r/storage_bucket.html.markdown @@ -252,6 +252,13 @@ The following arguments are supported: * `ip_filter` - (Optional) The bucket IP filtering configuration. Specifies the network sources that can access the bucket, as well as its underlying objects. Structure is [documented below](#nested_ip_filter). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + The `lifecycle_rule` block supports: * `action` - (Required) The Lifecycle Rule's action configuration. A single block of this type is supported. Structure is [documented below](#nested_action). diff --git a/website/docs/r/storage_bucket_access_control.html.markdown b/website/docs/r/storage_bucket_access_control.html.markdown index 64536ba5ce4..caf54f879d9 100644 --- a/website/docs/r/storage_bucket_access_control.html.markdown +++ b/website/docs/r/storage_bucket_access_control.html.markdown @@ -101,6 +101,12 @@ The following arguments are supported: The access permission for the entity. Possible values are: `OWNER`, `READER`, `WRITER`. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/storage_bucket_acl.html.markdown b/website/docs/r/storage_bucket_acl.html.markdown index 26118e891f9..03fac6af65c 100644 --- a/website/docs/r/storage_bucket_acl.html.markdown +++ b/website/docs/r/storage_bucket_acl.html.markdown @@ -63,6 +63,13 @@ resource "google_storage_bucket_acl" "image-store-acl" { * `default_acl` - (Optional) Configure this ACL to be the default ACL. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + ## Attributes Reference Only the arguments listed above are exposed as attributes. diff --git a/website/docs/r/storage_bucket_object.html.markdown b/website/docs/r/storage_bucket_object.html.markdown index 88716aaac5c..d30d9c4ccf6 100644 --- a/website/docs/r/storage_bucket_object.html.markdown +++ b/website/docs/r/storage_bucket_object.html.markdown @@ -127,7 +127,13 @@ One of the following is required: * `force_empty_content_type` - (Optional) When set to true, it ensure the object's Content-Type is empty. -* `deletion_policy` - (Optional) When set to ABANDON, the object won't be deleted from storage bucket. Instead, it will only be removed from terraform's state file. + +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `contexts` - (Optional) Contexts attached to an object, in key-value pairs. For more information about object contexts, see [Object contexts overview](https://cloud.google.com/storage/docs/object-contexts). Structure is [documented below](#nested_contexts). diff --git a/website/docs/r/storage_control_folder_intelligence_config.html.markdown b/website/docs/r/storage_control_folder_intelligence_config.html.markdown index b28ddaff56c..63ee426ffb7 100644 --- a/website/docs/r/storage_control_folder_intelligence_config.html.markdown +++ b/website/docs/r/storage_control_folder_intelligence_config.html.markdown @@ -67,6 +67,12 @@ The following arguments are supported: Filter over location and bucket using include or exclude semantics. Resources that match the include or exclude filter are exclusively included or excluded from the Storage Intelligence plan. Structure is [documented below](#nested_filter). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `filter` block supports: diff --git a/website/docs/r/storage_control_organization_intelligence_config.html.markdown b/website/docs/r/storage_control_organization_intelligence_config.html.markdown index 8973bdd84a8..52ee9e8ac06 100644 --- a/website/docs/r/storage_control_organization_intelligence_config.html.markdown +++ b/website/docs/r/storage_control_organization_intelligence_config.html.markdown @@ -67,6 +67,12 @@ The following arguments are supported: Filter over location and bucket using include or exclude semantics. Resources that match the include or exclude filter are exclusively included or excluded from the Storage Intelligence plan. Structure is [documented below](#nested_filter). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `filter` block supports: diff --git a/website/docs/r/storage_control_project_intelligence_config.html.markdown b/website/docs/r/storage_control_project_intelligence_config.html.markdown index 87a80b4668f..5d4eef9f35d 100644 --- a/website/docs/r/storage_control_project_intelligence_config.html.markdown +++ b/website/docs/r/storage_control_project_intelligence_config.html.markdown @@ -64,6 +64,12 @@ The following arguments are supported: Filter over location and bucket using include or exclude semantics. Resources that match the include or exclude filter are exclusively included or excluded from the Storage Intelligence plan. Structure is [documented below](#nested_filter). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `filter` block supports: diff --git a/website/docs/r/storage_default_object_access_control.html.markdown b/website/docs/r/storage_default_object_access_control.html.markdown index f2e84ba34b8..312a2014ee3 100644 --- a/website/docs/r/storage_default_object_access_control.html.markdown +++ b/website/docs/r/storage_default_object_access_control.html.markdown @@ -96,6 +96,12 @@ The following arguments are supported: (Optional) The name of the object, if applied to an object. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/storage_default_object_acl.html.markdown b/website/docs/r/storage_default_object_acl.html.markdown index d514874e5b9..64a2e539ed1 100644 --- a/website/docs/r/storage_default_object_acl.html.markdown +++ b/website/docs/r/storage_default_object_acl.html.markdown @@ -63,6 +63,13 @@ resource "google_storage_default_object_acl" "image-store-default-acl" { See [GCS Object ACL documentation](https://cloud.google.com/storage/docs/json_api/v1/objectAccessControls) for more details. Omitting the field is the same as providing an empty list. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + ## Attributes Reference Only the arguments listed above are exposed as attributes. diff --git a/website/docs/r/storage_folder.html.markdown b/website/docs/r/storage_folder.html.markdown index c94f88743ed..3b222ae0239 100644 --- a/website/docs/r/storage_folder.html.markdown +++ b/website/docs/r/storage_folder.html.markdown @@ -76,6 +76,12 @@ The following arguments are supported: trailing '/'. For example, `example_dir/example_dir2/`, `example@#/`, `a-b/d-f/`. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `force_destroy` - (Optional) If set to true, items within folder if any will be force destroyed. diff --git a/website/docs/r/storage_hmac_key.html.markdown b/website/docs/r/storage_hmac_key.html.markdown index 58c3f64498d..e020a72bc59 100644 --- a/website/docs/r/storage_hmac_key.html.markdown +++ b/website/docs/r/storage_hmac_key.html.markdown @@ -79,6 +79,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/storage_insights_dataset_config.html.markdown b/website/docs/r/storage_insights_dataset_config.html.markdown index 28f6fee6236..a8ea0311c21 100644 --- a/website/docs/r/storage_insights_dataset_config.html.markdown +++ b/website/docs/r/storage_insights_dataset_config.html.markdown @@ -174,6 +174,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `link_dataset` - (Optional) A boolean terraform only flag to link/unlink dataset. Setting this field to true while creation will automatically link the created dataset as an additional functionality. diff --git a/website/docs/r/storage_insights_report_config.html.markdown b/website/docs/r/storage_insights_report_config.html.markdown index 353865935fb..d2c7637a696 100644 --- a/website/docs/r/storage_insights_report_config.html.markdown +++ b/website/docs/r/storage_insights_report_config.html.markdown @@ -130,6 +130,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `force_destroy` - (Optional) If set, all the inventory report details associated with this report configuration are deleted. diff --git a/website/docs/r/storage_managed_folder.html.markdown b/website/docs/r/storage_managed_folder.html.markdown index d831fc69d38..90780f75864 100644 --- a/website/docs/r/storage_managed_folder.html.markdown +++ b/website/docs/r/storage_managed_folder.html.markdown @@ -77,6 +77,12 @@ The following arguments are supported: trailing '/'. For example, `example_dir/example_dir2/`. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `force_destroy` - (Optional) Allows the deletion of a managed folder even if contains objects. If a non-empty managed folder is deleted, any objects within the folder will remain in a simulated folder with the diff --git a/website/docs/r/storage_object_access_control.html.markdown b/website/docs/r/storage_object_access_control.html.markdown index 9bcc28de904..6fb494e3918 100644 --- a/website/docs/r/storage_object_access_control.html.markdown +++ b/website/docs/r/storage_object_access_control.html.markdown @@ -101,6 +101,12 @@ The following arguments are supported: Possible values are: `OWNER`, `READER`. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/storage_object_acl.html.markdown b/website/docs/r/storage_object_acl.html.markdown index b2b089dd9bb..3122740f8be 100644 --- a/website/docs/r/storage_object_acl.html.markdown +++ b/website/docs/r/storage_object_acl.html.markdown @@ -76,6 +76,12 @@ Must be set if `predefined_acl` is not. adds that role/entity pair to your `terraform plan` results when it is omitted in your config; `terraform plan` will show the correct final state at every point except for at `Create` time, where the object role/entity pair is omitted if not explicitly set. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/storage_transfer_agent_pool.html.markdown b/website/docs/r/storage_transfer_agent_pool.html.markdown index 20346689181..4907bbad354 100644 --- a/website/docs/r/storage_transfer_agent_pool.html.markdown +++ b/website/docs/r/storage_transfer_agent_pool.html.markdown @@ -84,6 +84,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `bandwidth_limit` block supports: diff --git a/website/docs/r/storage_transfer_job.html.markdown b/website/docs/r/storage_transfer_job.html.markdown index 4cc3f213d19..0197187a6c3 100644 --- a/website/docs/r/storage_transfer_job.html.markdown +++ b/website/docs/r/storage_transfer_job.html.markdown @@ -162,6 +162,13 @@ The following arguments are supported: * `logging_config` - (Optional) Logging configuration. Structure [documented below](#nested_logging_config). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. + The `transfer_spec` block supports: * `source_agent_pool_name` - (Optional) Specifies the agent pool name associated with the posix data source. When unspecified, the default name is used. diff --git a/website/docs/r/tags_tag_binding.html.markdown b/website/docs/r/tags_tag_binding.html.markdown index bc19c300f78..b381deca68f 100644 --- a/website/docs/r/tags_tag_binding.html.markdown +++ b/website/docs/r/tags_tag_binding.html.markdown @@ -98,6 +98,12 @@ The following arguments are supported: The TagValue of the TagBinding. Must be either in id format `tagValues/{tag-value-id}`, or namespaced format `{parent-id}/{tag-key-short-name}/{tag-value-short-name}`. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/tags_tag_key.html.markdown b/website/docs/r/tags_tag_key.html.markdown index 4281920d32c..f61c4cc579d 100644 --- a/website/docs/r/tags_tag_key.html.markdown +++ b/website/docs/r/tags_tag_key.html.markdown @@ -75,6 +75,12 @@ The following arguments are supported: (Optional) Regular expression constraint for dynamic tag values, follows RE2 syntax. If present, it implicitly allows dynamic values (constrained by the regex). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/tags_tag_value.html.markdown b/website/docs/r/tags_tag_value.html.markdown index 1e09665d9bb..5c4dd182cd1 100644 --- a/website/docs/r/tags_tag_value.html.markdown +++ b/website/docs/r/tags_tag_value.html.markdown @@ -66,6 +66,12 @@ The following arguments are supported: (Optional) User-assigned description of the TagValue. Must not exceed 256 characters. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/tpu_v2_queued_resource.html.markdown b/website/docs/r/tpu_v2_queued_resource.html.markdown index 1611b1af1f7..0ff93b6822a 100644 --- a/website/docs/r/tpu_v2_queued_resource.html.markdown +++ b/website/docs/r/tpu_v2_queued_resource.html.markdown @@ -127,6 +127,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `tpu` block supports: diff --git a/website/docs/r/tpu_v2_vm.html.markdown b/website/docs/r/tpu_v2_vm.html.markdown index 44aeaf4ad56..3981c37b0c4 100644 --- a/website/docs/r/tpu_v2_vm.html.markdown +++ b/website/docs/r/tpu_v2_vm.html.markdown @@ -261,6 +261,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `network_config` block supports: diff --git a/website/docs/r/transcoder_job.html.markdown b/website/docs/r/transcoder_job.html.markdown index 457a99c2cae..c55acacd91b 100644 --- a/website/docs/r/transcoder_job.html.markdown +++ b/website/docs/r/transcoder_job.html.markdown @@ -790,6 +790,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `config` block supports: diff --git a/website/docs/r/transcoder_job_template.html.markdown b/website/docs/r/transcoder_job_template.html.markdown index fe790f3135d..47e589f5eff 100644 --- a/website/docs/r/transcoder_job_template.html.markdown +++ b/website/docs/r/transcoder_job_template.html.markdown @@ -529,6 +529,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `config` block supports: diff --git a/website/docs/r/vector_search_collection.html.markdown b/website/docs/r/vector_search_collection.html.markdown index 0850b909008..e456b450e12 100644 --- a/website/docs/r/vector_search_collection.html.markdown +++ b/website/docs/r/vector_search_collection.html.markdown @@ -202,6 +202,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `encryption_spec` block supports: diff --git a/website/docs/r/vertex_ai_cache_config.html.markdown b/website/docs/r/vertex_ai_cache_config.html.markdown index 82ece901142..594b241f4a7 100644 --- a/website/docs/r/vertex_ai_cache_config.html.markdown +++ b/website/docs/r/vertex_ai_cache_config.html.markdown @@ -53,6 +53,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/vertex_ai_dataset.html.markdown b/website/docs/r/vertex_ai_dataset.html.markdown index 81dbd6e5a10..77ee5f33cc4 100644 --- a/website/docs/r/vertex_ai_dataset.html.markdown +++ b/website/docs/r/vertex_ai_dataset.html.markdown @@ -83,6 +83,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `encryption_spec` block supports: diff --git a/website/docs/r/vertex_ai_deployment_resource_pool.html.markdown b/website/docs/r/vertex_ai_deployment_resource_pool.html.markdown index cf3a3c9ce5a..50d218ff9bb 100644 --- a/website/docs/r/vertex_ai_deployment_resource_pool.html.markdown +++ b/website/docs/r/vertex_ai_deployment_resource_pool.html.markdown @@ -82,6 +82,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `dedicated_resources` block supports: diff --git a/website/docs/r/vertex_ai_endpoint.html.markdown b/website/docs/r/vertex_ai_endpoint.html.markdown index a7a056084ff..80cf7b30a73 100644 --- a/website/docs/r/vertex_ai_endpoint.html.markdown +++ b/website/docs/r/vertex_ai_endpoint.html.markdown @@ -225,6 +225,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `encryption_spec` block supports: diff --git a/website/docs/r/vertex_ai_endpoint_with_model_garden_deployment.html.markdown b/website/docs/r/vertex_ai_endpoint_with_model_garden_deployment.html.markdown index 934b9036776..83a7e8b8dbf 100644 --- a/website/docs/r/vertex_ai_endpoint_with_model_garden_deployment.html.markdown +++ b/website/docs/r/vertex_ai_endpoint_with_model_garden_deployment.html.markdown @@ -296,6 +296,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `model_config` block supports: diff --git a/website/docs/r/vertex_ai_feature_group.html.markdown b/website/docs/r/vertex_ai_feature_group.html.markdown index 99b37508c2c..8759cd861a4 100644 --- a/website/docs/r/vertex_ai_feature_group.html.markdown +++ b/website/docs/r/vertex_ai_feature_group.html.markdown @@ -116,6 +116,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `big_query` block supports: diff --git a/website/docs/r/vertex_ai_feature_group_feature.html.markdown b/website/docs/r/vertex_ai_feature_group_feature.html.markdown index fff9e43505e..dff548a1e5e 100644 --- a/website/docs/r/vertex_ai_feature_group_feature.html.markdown +++ b/website/docs/r/vertex_ai_feature_group_feature.html.markdown @@ -135,6 +135,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/vertex_ai_feature_online_store.html.markdown b/website/docs/r/vertex_ai_feature_online_store.html.markdown index b2aee3c6ca9..deb5679304e 100644 --- a/website/docs/r/vertex_ai_feature_online_store.html.markdown +++ b/website/docs/r/vertex_ai_feature_online_store.html.markdown @@ -167,6 +167,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `force_destroy` - (Optional) If set to true, any FeatureViews and Features for this FeatureOnlineStore will also be deleted. diff --git a/website/docs/r/vertex_ai_feature_online_store_featureview.html.markdown b/website/docs/r/vertex_ai_feature_online_store_featureview.html.markdown index 679950baeef..91dbdb5febb 100644 --- a/website/docs/r/vertex_ai_feature_online_store_featureview.html.markdown +++ b/website/docs/r/vertex_ai_feature_online_store_featureview.html.markdown @@ -517,6 +517,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `sync_config` block supports: diff --git a/website/docs/r/vertex_ai_featurestore.html.markdown b/website/docs/r/vertex_ai_featurestore.html.markdown index 41ecfb16f1a..80a6107f4f0 100644 --- a/website/docs/r/vertex_ai_featurestore.html.markdown +++ b/website/docs/r/vertex_ai_featurestore.html.markdown @@ -131,6 +131,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `force_destroy` - (Optional) If set to true, any EntityTypes and Features for this Featurestore will also be deleted diff --git a/website/docs/r/vertex_ai_featurestore_entitytype.html.markdown b/website/docs/r/vertex_ai_featurestore_entitytype.html.markdown index 18e530a45c2..14ee5ce9255 100644 --- a/website/docs/r/vertex_ai_featurestore_entitytype.html.markdown +++ b/website/docs/r/vertex_ai_featurestore_entitytype.html.markdown @@ -153,6 +153,12 @@ The following arguments are supported: (Optional, [Beta](../guides/provider_versions.html.markdown)) Config for data retention policy in offline storage. TTL in days for feature values that will be stored in offline storage. The Feature Store offline storage periodically removes obsolete feature values older than offlineStorageTtlDays since the feature generation time. If unset (or explicitly set to 0), default to 4000 days TTL. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `monitoring_config` block supports: diff --git a/website/docs/r/vertex_ai_featurestore_entitytype_feature.html.markdown b/website/docs/r/vertex_ai_featurestore_entitytype_feature.html.markdown index 26795ab770f..741d79f7f09 100644 --- a/website/docs/r/vertex_ai_featurestore_entitytype_feature.html.markdown +++ b/website/docs/r/vertex_ai_featurestore_entitytype_feature.html.markdown @@ -153,6 +153,12 @@ The following arguments are supported: (Optional) Description of the feature. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/vertex_ai_index.html.markdown b/website/docs/r/vertex_ai_index.html.markdown index 812a2fbfdc7..f8b43845af3 100644 --- a/website/docs/r/vertex_ai_index.html.markdown +++ b/website/docs/r/vertex_ai_index.html.markdown @@ -185,6 +185,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `metadata` block supports: diff --git a/website/docs/r/vertex_ai_index_endpoint.html.markdown b/website/docs/r/vertex_ai_index_endpoint.html.markdown index 5f24d13cac6..81fe1281a40 100644 --- a/website/docs/r/vertex_ai_index_endpoint.html.markdown +++ b/website/docs/r/vertex_ai_index_endpoint.html.markdown @@ -161,6 +161,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `private_service_connect_config` block supports: diff --git a/website/docs/r/vertex_ai_index_endpoint_deployed_index.html.markdown b/website/docs/r/vertex_ai_index_endpoint_deployed_index.html.markdown index 383ec7065db..a1b49ecbd3a 100644 --- a/website/docs/r/vertex_ai_index_endpoint_deployed_index.html.markdown +++ b/website/docs/r/vertex_ai_index_endpoint_deployed_index.html.markdown @@ -282,6 +282,12 @@ The following arguments are supported: (Optional) The region of the index endpoint deployment. eg us-central1 +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `automatic_resources` block supports: diff --git a/website/docs/r/vertex_ai_metadata_store.html.markdown b/website/docs/r/vertex_ai_metadata_store.html.markdown index d64f291870d..62fa6701f25 100644 --- a/website/docs/r/vertex_ai_metadata_store.html.markdown +++ b/website/docs/r/vertex_ai_metadata_store.html.markdown @@ -69,6 +69,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `encryption_spec` block supports: diff --git a/website/docs/r/vertex_ai_rag_engine_config.html.markdown b/website/docs/r/vertex_ai_rag_engine_config.html.markdown index f06fa472176..8e36444b1b9 100644 --- a/website/docs/r/vertex_ai_rag_engine_config.html.markdown +++ b/website/docs/r/vertex_ai_rag_engine_config.html.markdown @@ -85,6 +85,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `rag_managed_db_config` block supports: diff --git a/website/docs/r/vertex_ai_reasoning_engine.html.markdown b/website/docs/r/vertex_ai_reasoning_engine.html.markdown index 13ad3f9b83f..902fabe17af 100644 --- a/website/docs/r/vertex_ai_reasoning_engine.html.markdown +++ b/website/docs/r/vertex_ai_reasoning_engine.html.markdown @@ -591,7 +591,14 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. -* `deletion_policy` - (Optional) Optional. The deletion policy for the reasoning engine. Setting this to FORCE allows the reasoning engine to be deleted regardless of child undeleted resources. +* `deletion_policy` - (Optional) Optional. The deletion policy for the reasoning engine. +Setting this to FORCE allows the reasoning engine to be deleted regardless of child undeleted resources. + +When a 'terraform destroy' or 'terraform apply' would delete the resource, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is permitted. diff --git a/website/docs/r/vertex_ai_tensorboard.html.markdown b/website/docs/r/vertex_ai_tensorboard.html.markdown index c5c9bae6d63..9e33dcf6c14 100644 --- a/website/docs/r/vertex_ai_tensorboard.html.markdown +++ b/website/docs/r/vertex_ai_tensorboard.html.markdown @@ -114,6 +114,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `encryption_spec` block supports: diff --git a/website/docs/r/vmwareengine_cluster.html.markdown b/website/docs/r/vmwareengine_cluster.html.markdown index 2add24f2817..4b27645d420 100644 --- a/website/docs/r/vmwareengine_cluster.html.markdown +++ b/website/docs/r/vmwareengine_cluster.html.markdown @@ -411,6 +411,12 @@ The following arguments are supported: for unmount remove 'datastore_mount_config' config from the update of cluster resource Structure is [documented below](#nested_datastore_mount_config). +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `node_type_configs` block supports: diff --git a/website/docs/r/vmwareengine_datastore.html.markdown b/website/docs/r/vmwareengine_datastore.html.markdown index d306682cf36..3dc8b41b97e 100644 --- a/website/docs/r/vmwareengine_datastore.html.markdown +++ b/website/docs/r/vmwareengine_datastore.html.markdown @@ -131,6 +131,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `nfs_datastore` block supports: diff --git a/website/docs/r/vmwareengine_external_access_rule.html.markdown b/website/docs/r/vmwareengine_external_access_rule.html.markdown index c16c82ae87d..45d5281164f 100644 --- a/website/docs/r/vmwareengine_external_access_rule.html.markdown +++ b/website/docs/r/vmwareengine_external_access_rule.html.markdown @@ -175,6 +175,12 @@ The following arguments are supported: (Optional) User-provided description for the external access rule. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `source_ip_ranges` block supports: diff --git a/website/docs/r/vmwareengine_external_address.html.markdown b/website/docs/r/vmwareengine_external_address.html.markdown index 70d9c1a40ae..a3e91687760 100644 --- a/website/docs/r/vmwareengine_external_address.html.markdown +++ b/website/docs/r/vmwareengine_external_address.html.markdown @@ -99,6 +99,12 @@ The following arguments are supported: (Optional) User-provided description for this resource. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/vmwareengine_network.html.markdown b/website/docs/r/vmwareengine_network.html.markdown index 072a8d459cd..2cbf9b113b2 100644 --- a/website/docs/r/vmwareengine_network.html.markdown +++ b/website/docs/r/vmwareengine_network.html.markdown @@ -107,6 +107,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/vmwareengine_network_peering.html.markdown b/website/docs/r/vmwareengine_network_peering.html.markdown index 7b93a2b762f..4012b3f1020 100644 --- a/website/docs/r/vmwareengine_network_peering.html.markdown +++ b/website/docs/r/vmwareengine_network_peering.html.markdown @@ -124,6 +124,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/vmwareengine_network_policy.html.markdown b/website/docs/r/vmwareengine_network_policy.html.markdown index 36147f93035..ab0d67d609b 100644 --- a/website/docs/r/vmwareengine_network_policy.html.markdown +++ b/website/docs/r/vmwareengine_network_policy.html.markdown @@ -118,6 +118,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `internet_access` block supports: diff --git a/website/docs/r/vmwareengine_private_cloud.html.markdown b/website/docs/r/vmwareengine_private_cloud.html.markdown index 00a010e3112..00240863631 100644 --- a/website/docs/r/vmwareengine_private_cloud.html.markdown +++ b/website/docs/r/vmwareengine_private_cloud.html.markdown @@ -147,6 +147,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `deletion_delay_hours` - (Optional) The number of hours to delay this request. You can set this value to an hour between 0 to 8, where setting it to 0 starts the deletion request immediately. If no value is set, a default value is set at the API Level. * `send_deletion_delay_hours_if_zero` - (Optional) While set true, deletion_delay_hours value will be sent in the request even for zero value of the field. This field is only useful for setting 0 value to the deletion_delay_hours field. It can be used both alone and together with deletion_delay_hours. diff --git a/website/docs/r/vmwareengine_subnet.html.markdown b/website/docs/r/vmwareengine_subnet.html.markdown index fe272e8d604..5e690694f90 100644 --- a/website/docs/r/vmwareengine_subnet.html.markdown +++ b/website/docs/r/vmwareengine_subnet.html.markdown @@ -87,6 +87,12 @@ The following arguments are supported: where n ranges from 1 to 5. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/vpc_access_connector.html.markdown b/website/docs/r/vpc_access_connector.html.markdown index 6798f1a2ad9..9ab90454726 100644 --- a/website/docs/r/vpc_access_connector.html.markdown +++ b/website/docs/r/vpc_access_connector.html.markdown @@ -130,6 +130,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `subnet` block supports: diff --git a/website/docs/r/workbench_instance.html.markdown b/website/docs/r/workbench_instance.html.markdown index c9d456c0dfb..fc5e431fdcd 100644 --- a/website/docs/r/workbench_instance.html.markdown +++ b/website/docs/r/workbench_instance.html.markdown @@ -408,6 +408,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `desired_state` - (Optional) Desired state of the Workbench Instance. Set this field to `ACTIVE` to start the Instance, and `STOPPED` to stop the Instance. diff --git a/website/docs/r/workflows_workflow.html.markdown b/website/docs/r/workflows_workflow.html.markdown index 1baae80f3c4..a4c23a13211 100644 --- a/website/docs/r/workflows_workflow.html.markdown +++ b/website/docs/r/workflows_workflow.html.markdown @@ -225,6 +225,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. * `deletion_protection` - (Optional) Whether Terraform will be prevented from destroying the workflow. Defaults to true. When a`terraform destroy` or `terraform apply` would delete the workflow, the command will fail if this field is not set to false in Terraform state. diff --git a/website/docs/r/workload_identity_service_agent.html.markdown b/website/docs/r/workload_identity_service_agent.html.markdown index 69eb10bddec..fe5a4834a49 100644 --- a/website/docs/r/workload_identity_service_agent.html.markdown +++ b/website/docs/r/workload_identity_service_agent.html.markdown @@ -47,6 +47,12 @@ The following arguments are supported: The parent resource path. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/workstations_workstation.html.markdown b/website/docs/r/workstations_workstation.html.markdown index b9fd1c8123b..bb6277803c6 100644 --- a/website/docs/r/workstations_workstation.html.markdown +++ b/website/docs/r/workstations_workstation.html.markdown @@ -150,6 +150,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/website/docs/r/workstations_workstation_cluster.html.markdown b/website/docs/r/workstations_workstation_cluster.html.markdown index 80264c508cd..9546fc3e40e 100644 --- a/website/docs/r/workstations_workstation_cluster.html.markdown +++ b/website/docs/r/workstations_workstation_cluster.html.markdown @@ -265,6 +265,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `private_cluster_config` block supports: diff --git a/website/docs/r/workstations_workstation_config.html.markdown b/website/docs/r/workstations_workstation_config.html.markdown index ef58e788fba..89b1612ce87 100644 --- a/website/docs/r/workstations_workstation_config.html.markdown +++ b/website/docs/r/workstations_workstation_config.html.markdown @@ -839,6 +839,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. The `host` block supports: