diff --git a/mmv1/api/metadata/metadata.go b/mmv1/api/metadata/metadata.go index 98783a918367..cc0a7484f466 100644 --- a/mmv1/api/metadata/metadata.go +++ b/mmv1/api/metadata/metadata.go @@ -35,6 +35,12 @@ func FromResource(r api.Resource) Metadata { ApiField: "selfLink", }) } + if !r.DeletionPolicyExclude && !r.ExcludeDelete { + m.Fields = append(m.Fields, Field{ + Field: "deletion_policy", + ProviderOnly: true, + }) + } return m } diff --git a/mmv1/api/metadata/metadata_test.go b/mmv1/api/metadata/metadata_test.go index c2e2201a4c26..a5e7969f62b7 100644 --- a/mmv1/api/metadata/metadata_test.go +++ b/mmv1/api/metadata/metadata_test.go @@ -21,8 +21,10 @@ func TestFromResource(t *testing.T) { wantMetadata Metadata }{ { - name: "empty resource", - resource: api.Resource{}, + name: "empty resource", + resource: api.Resource{ + DeletionPolicyExclude: true, + }, wantMetadata: Metadata{ Resource: "google_product_", GenerationType: "mmv1", @@ -55,6 +57,10 @@ func TestFromResource(t *testing.T) { { ApiField: "field", }, + { + Field: "deletion_policy", + ProviderOnly: true, + }, }, }, }, @@ -87,6 +93,10 @@ func TestFromResource(t *testing.T) { { ApiField: "selfLink", }, + { + Field: "deletion_policy", + ProviderOnly: true, + }, }, }, }, diff --git a/mmv1/api/resource.go b/mmv1/api/resource.go index b2013f2073c7..bffb7033da2b 100644 --- a/mmv1/api/resource.go +++ b/mmv1/api/resource.go @@ -298,6 +298,19 @@ type Resource struct { // public ca external account keys ExcludeRead bool `yaml:"exclude_read,omitempty"` + // Set to true for resources that are excluded from universal deletion policy due to differing + // behavior on a universal option or use a different data type + DeletionPolicyExclude bool `yaml:"deletion_policy_exclude,omitempty"` + + // Set to true for resources that have deletion policy fields with custom options that are + // compatible with the universal deletion policy + // if set to true, use implement `deletion_policy` within the yaml of the resource + DeletionPolicyCustomDocs bool `yaml:"deletion_policy_custom_docs,omitempty"` + + // Set to the default deletion policy value for the resource. + // By default this will be "DELETE". + DeletionPolicyDefault string `yaml:"deletion_policy_default,omitempty"` + // Set to true for resources that wish to disable automatic generation of default provider // value customdiff functions // TODO rewrite: 1 instance used @@ -492,6 +505,11 @@ func (r *Resource) setShallowDefaults() { if r.Timeouts == nil { r.Timeouts = NewTimeouts() // This only sets defaults if Timeouts is nil } + if !r.DeletionPolicyExclude { + if r.DeletionPolicyDefault == "" { + r.DeletionPolicyDefault = "DELETE" + } + } } // SetDefault sets default values for this Resource and all its properties. diff --git a/mmv1/products/alloydb/Cluster.yaml b/mmv1/products/alloydb/Cluster.yaml index 6ccb872bfbb4..2dc355c435b8 100644 --- a/mmv1/products/alloydb/Cluster.yaml +++ b/mmv1/products/alloydb/Cluster.yaml @@ -60,6 +60,8 @@ custom_code: pre_update: 'templates/terraform/pre_update/alloydb_cluster.go.tmpl' pre_delete: 'templates/terraform/pre_delete/alloydb_cluster.go.tmpl' test_constants: 'templates/terraform/test_constants/import_tpgcompute.go.tmpl' +deletion_policy_default: "DEFAULT" +deletion_policy_custom_docs: true # Skipping the sweeper because we need to force-delete clusters. exclude_sweeper: true include_in_tgc_next: true @@ -139,9 +141,17 @@ virtual_fields: 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 type: String - default_value: "DEFAULT" + #excluded from generation due to Universal Deletion Policy + exclude: true - name: 'deletion_protection' description: | Whether Terraform will be prevented from destroying the cluster. diff --git a/mmv1/products/chronicle/DataTable.yaml b/mmv1/products/chronicle/DataTable.yaml index 74626a2aa8ad..624de0d07b0e 100644 --- a/mmv1/products/chronicle/DataTable.yaml +++ b/mmv1/products/chronicle/DataTable.yaml @@ -23,6 +23,8 @@ import_format: update_verb: PATCH update_mask: true +deletion_policy_default: "DEFAULT" +deletion_policy_custom_docs: true references: guides: 'Google SecOps Guides': 'https://cloud.google.com/chronicle/docs/secops/secops-overview' @@ -52,9 +54,17 @@ virtual_fields: 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 type: String - default_value: "DEFAULT" + #excluded from generation due to Universal Deletion Policy + exclude: true parameters: - name: location diff --git a/mmv1/products/chronicle/Rule.yaml b/mmv1/products/chronicle/Rule.yaml index fa65eb4e0513..b6107bd7b6ee 100644 --- a/mmv1/products/chronicle/Rule.yaml +++ b/mmv1/products/chronicle/Rule.yaml @@ -27,7 +27,8 @@ import_format: update_verb: PATCH update_mask: true autogen_status: UnVsZQ== - +deletion_policy_default: "DEFAULT" +deletion_policy_custom_docs: true examples: - name: 'chronicle_rule_basic' primary_resource_id: example @@ -61,11 +62,19 @@ virtual_fields: 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 type: String - default_value: "DEFAULT" + #excluded from generation due to Universal Deletion Policy + exclude: true parameters: - name: location diff --git a/mmv1/products/containerattached/Cluster.yaml b/mmv1/products/containerattached/Cluster.yaml index e93a3c8a045c..f1b0ef7cf57d 100644 --- a/mmv1/products/containerattached/Cluster.yaml +++ b/mmv1/products/containerattached/Cluster.yaml @@ -45,6 +45,7 @@ custom_code: constants: 'templates/terraform/constants/containerattached_cluster_diff.go.tmpl' pre_update: 'templates/terraform/pre_update/containerattached_update.go.tmpl' pre_delete: 'templates/terraform/pre_delete/container_attached_deletion_policy.go.tmpl' +deletion_policy_custom_docs: true examples: - name: 'container_attached_cluster_basic' primary_resource_id: 'primary' @@ -71,9 +72,18 @@ examples: - 'deletion_policy' virtual_fields: - name: 'deletion_policy' - description: 'Policy to determine what flags to send on delete. Possible values: DELETE, DELETE_IGNORE_ERRORS' + description: | + 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'. type: String - default_value: "DELETE" + #excluded from generation due to Universal Deletion Policy + exclude: true parameters: properties: - name: 'location' diff --git a/mmv1/products/dataform/Repository.yaml b/mmv1/products/dataform/Repository.yaml index 2e727e26363d..40cfe692e7ea 100644 --- a/mmv1/products/dataform/Repository.yaml +++ b/mmv1/products/dataform/Repository.yaml @@ -37,6 +37,7 @@ iam_policy: min_version: 'beta' custom_code: pre_delete: 'templates/terraform/pre_delete/dataform_repository.go.tmpl' +deletion_policy_custom_docs: true examples: - name: 'dataform_repository' primary_resource_id: 'dataform_repository' @@ -92,11 +93,17 @@ virtual_fields: - name: 'deletion_policy' type: Enum description: | - 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`. - default_value: 'DELETE' - enum_values: - - 'DELETE' - - 'FORCE' + 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`. + #excluded from generation due to Universal Deletion Policy + exclude: true parameters: - name: 'region' type: String diff --git a/mmv1/products/datastream/PrivateConnection.yaml b/mmv1/products/datastream/PrivateConnection.yaml index 9ce58699aaa1..f85005489896 100644 --- a/mmv1/products/datastream/PrivateConnection.yaml +++ b/mmv1/products/datastream/PrivateConnection.yaml @@ -27,6 +27,8 @@ create_url: 'projects/{{project}}/locations/{{location}}/privateConnections?priv immutable: true import_format: - 'projects/{{project}}/locations/{{location}}/privateConnections/{{private_connection_id}}' +deletion_policy_custom_docs: true +deletion_policy_default: "FORCE" timeouts: insert_minutes: 30 update_minutes: 30 @@ -81,9 +83,14 @@ virtual_fields: 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". type: String - default_value: "FORCE" + exclude: true parameters: - name: 'privateConnectionId' type: String diff --git a/mmv1/products/firebase/AndroidApp.yaml b/mmv1/products/firebase/AndroidApp.yaml index 6a35168fa7ab..998739a6d6dd 100644 --- a/mmv1/products/firebase/AndroidApp.yaml +++ b/mmv1/products/firebase/AndroidApp.yaml @@ -81,14 +81,6 @@ examples: ignore_read_extra: - 'project' - 'deletion_policy' -virtual_fields: - - name: 'deletion_policy' - description: | - (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`. - type: String - default_value: "DELETE" parameters: properties: - name: 'name' diff --git a/mmv1/products/firebase/AppleApp.yaml b/mmv1/products/firebase/AppleApp.yaml index b594bcfa85cb..02b79c9943bd 100644 --- a/mmv1/products/firebase/AppleApp.yaml +++ b/mmv1/products/firebase/AppleApp.yaml @@ -86,14 +86,6 @@ examples: ignore_read_extra: - 'project' - 'deletion_policy' -virtual_fields: - - name: 'deletion_policy' - description: | - (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`. - type: String - default_value: "DELETE" parameters: properties: - name: 'name' diff --git a/mmv1/products/firebase/WebApp.yaml b/mmv1/products/firebase/WebApp.yaml index 5f2271e3c5f4..5061a0c7bcbe 100644 --- a/mmv1/products/firebase/WebApp.yaml +++ b/mmv1/products/firebase/WebApp.yaml @@ -79,14 +79,6 @@ examples: ignore_read_extra: - 'project' - 'deletion_policy' -virtual_fields: - - name: 'deletion_policy' - description: | - 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` - type: String - default_value: "DELETE" parameters: properties: - name: 'name' diff --git a/mmv1/products/firebasedataconnect/Service.yaml b/mmv1/products/firebasedataconnect/Service.yaml index a44ab4265ef0..bf50833cae1e 100644 --- a/mmv1/products/firebasedataconnect/Service.yaml +++ b/mmv1/products/firebasedataconnect/Service.yaml @@ -61,6 +61,8 @@ async: resource_inside_response: true include_project: false autogen_status: U2VydmljZQ== +deletion_policy_default: "DEFAULT" +deletion_policy_custom_docs: true parameters: - name: location type: String @@ -130,12 +132,20 @@ properties: virtual_fields: - name: deletion_policy type: String - default_value: DEFAULT 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 + + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set 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 + #excluded from generation due to Universal Deletion Policy + exclude: true custom_code: pre_delete: templates/terraform/pre_delete/firebasedataconnect_service.go.tmpl diff --git a/mmv1/products/firestore/Database.yaml b/mmv1/products/firestore/Database.yaml index 67296bc41675..9c5b07534100 100644 --- a/mmv1/products/firestore/Database.yaml +++ b/mmv1/products/firestore/Database.yaml @@ -49,6 +49,8 @@ async: resource_inside_response: true custom_code: pre_delete: 'templates/terraform/pre_delete/firestore_database.go.tmpl' +# TODO: remove this default in the 8.0.0 major release +deletion_policy_default: "ABANDON" examples: - name: 'firestore_default_database' primary_resource_id: 'database' @@ -177,19 +179,6 @@ examples: - 'project' - 'etag' - 'deletion_policy' -virtual_fields: - - name: 'deletion_policy' - 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`. - type: String - default_value: "ABANDON" - # `deletion_policy` is deprecated and will be removed in a future major release. - # Once that release happens, you should use `delete_protection_state` instead. - # For now though, setting this field is necessary if you wish for your Firestore databases to be deleted upon `terraform destroy`. parameters: properties: - name: 'name' diff --git a/mmv1/products/firestore/Index.yaml b/mmv1/products/firestore/Index.yaml index a819873fd84d..94b696f5e8f1 100644 --- a/mmv1/products/firestore/Index.yaml +++ b/mmv1/products/firestore/Index.yaml @@ -52,7 +52,6 @@ custom_code: encoder: 'templates/terraform/encoders/index.go.tmpl' custom_import: 'templates/terraform/custom_import/index_self_link_as_name_set_project.go.tmpl' custom_create: 'templates/terraform/custom_create/firestore_index.go.tmpl' - pre_delete: 'templates/terraform/pre_delete/firestore_index.go.tmpl' error_retry_predicates: - 'transport_tpg.FirestoreIndex409Retry' examples: @@ -144,18 +143,6 @@ virtual_fields: default_value: false description: "Whether to skip waiting for the index to be created." ignore_read: true - - name: 'deletion_policy' - type: Enum - default_value: 'DELETE' - ignore_read: true - enum_values: - - '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`. parameters: # Firestore uses a custom create function. Any new fields must be explicitly handled there. properties: diff --git a/mmv1/products/looker/Instance.yaml b/mmv1/products/looker/Instance.yaml index abaa59c3956c..fcb9473290e9 100644 --- a/mmv1/products/looker/Instance.yaml +++ b/mmv1/products/looker/Instance.yaml @@ -38,6 +38,8 @@ async: base_url: '{{op_id}}' result: resource_inside_response: true +deletion_policy_default: "DEFAULT" +deletion_policy_custom_docs: true exclude_sweeper: true error_abort_predicates: @@ -110,13 +112,21 @@ examples: - 'deletion_policy' virtual_fields: - name: 'deletion_policy' - default_value: "DEFAULT" type: String 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 + 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 + exclude: true custom_code: pre_delete: templates/terraform/pre_delete/looker_instance.go.tmpl test_constants: 'templates/terraform/test_constants/import_tpgcompute.go.tmpl' diff --git a/mmv1/products/netapp/Volume.yaml b/mmv1/products/netapp/Volume.yaml index 4ad3b14d5c15..12d8b4cddd8b 100644 --- a/mmv1/products/netapp/Volume.yaml +++ b/mmv1/products/netapp/Volume.yaml @@ -51,6 +51,8 @@ custom_code: pre_delete: 'templates/terraform/pre_delete/netapp_volume_force_delete.go.tmpl' pre_update: 'templates/terraform/pre_update/netapp_volume_update.go.tmpl' constants: 'templates/terraform/constants/netapp_volume.go.tmpl' +deletion_policy_default: "DEFAULT" +deletion_policy_custom_docs: true examples: - name: 'netapp_volume_basic' primary_resource_id: 'test_volume' @@ -68,9 +70,16 @@ virtual_fields: 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. type: String - default_value: "DEFAULT" + exclude: true parameters: - name: 'location' type: String diff --git a/mmv1/products/secretmanager/SecretVersion.yaml b/mmv1/products/secretmanager/SecretVersion.yaml index 74ae3d4cd6ac..164643375de9 100644 --- a/mmv1/products/secretmanager/SecretVersion.yaml +++ b/mmv1/products/secretmanager/SecretVersion.yaml @@ -54,6 +54,7 @@ custom_code: exclude_sweeper: true # exluding resource_identity due to custom_import exclude_identity_generation: true +deletion_policy_custom_docs: true examples: - name: 'secret_version_basic' primary_resource_id: 'secret-version-basic' @@ -103,12 +104,18 @@ virtual_fields: 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: + 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 type: String - default_value: "DELETE" + exclude: true - name: 'is_secret_data_base64' type: Boolean immutable: true diff --git a/mmv1/products/secretmanagerregional/RegionalSecretVersion.yaml b/mmv1/products/secretmanagerregional/RegionalSecretVersion.yaml index 86feca1dbcbf..30d5b1289d65 100644 --- a/mmv1/products/secretmanagerregional/RegionalSecretVersion.yaml +++ b/mmv1/products/secretmanagerregional/RegionalSecretVersion.yaml @@ -47,6 +47,7 @@ custom_code: pre_delete: 'templates/terraform/pre_delete/regional_secret_version_deletion_policy.go.tmpl' custom_import: 'templates/terraform/custom_import/regional_secret_version.go.tmpl' constants: 'templates/terraform/constants/regional_secret_version.go.tmpl' +deletion_policy_custom_docs: true # Sweeper skipped as this resource has customized deletion. # exluding resource_identity due to custom_import exclude_identity_generation: true @@ -90,14 +91,20 @@ examples: virtual_fields: - name: 'deletion_policy' description: | - The deletion policy for the regional secret version. Setting `ABANDON` allows the resource + 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 type: String - default_value: "DELETE" + exclude: true - name: 'is_secret_data_base64' type: Boolean immutable: true diff --git a/mmv1/products/securesourcemanager/Instance.yaml b/mmv1/products/securesourcemanager/Instance.yaml index 58eca7139b5f..57dbe11ce4a9 100644 --- a/mmv1/products/securesourcemanager/Instance.yaml +++ b/mmv1/products/securesourcemanager/Instance.yaml @@ -53,6 +53,7 @@ iam_policy: - '{{instance_id}}' custom_code: pre_delete: 'templates/terraform/pre_delete/securesourcemanager_deletion_policy.go.tmpl' +deletion_policy_default: "PREVENT" examples: - name: 'secure_source_manager_instance_basic' primary_resource_id: 'default' @@ -188,19 +189,6 @@ parameters: url_param_only: true required: true immutable: true -virtual_fields: - - name: 'deletion_policy' - type: String - 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_value: 'PREVENT' properties: - name: 'name' type: String diff --git a/mmv1/products/securesourcemanager/Repository.yaml b/mmv1/products/securesourcemanager/Repository.yaml index 929cfbd4ef36..5420836e2f24 100644 --- a/mmv1/products/securesourcemanager/Repository.yaml +++ b/mmv1/products/securesourcemanager/Repository.yaml @@ -45,8 +45,7 @@ iam_policy: import_format: - 'projects/{{project}}/locations/{{location}}/repositories/{{repository_id}}' - '{{repository_id}}' -custom_code: - pre_delete: 'templates/terraform/pre_delete/securesourcemanager_deletion_policy.go.tmpl' +deletion_policy_default: "PREVENT" examples: - name: 'secure_source_manager_repository_basic' primary_resource_id: 'default' @@ -87,19 +86,6 @@ parameters: The ID for the Repository. url_param_only: true required: true -virtual_fields: - - name: 'deletion_policy' - type: String - 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_value: 'PREVENT' properties: - name: 'name' type: String diff --git a/mmv1/products/sql/Database.yaml b/mmv1/products/sql/Database.yaml index 7a74376617a1..4f5029b530a4 100644 --- a/mmv1/products/sql/Database.yaml +++ b/mmv1/products/sql/Database.yaml @@ -39,7 +39,6 @@ async: resource_inside_response: false collection_url_key: 'items' custom_code: - pre_delete: 'templates/terraform/pre_delete/sql_database_deletion_policy.tmpl' pre_read: 'templates/terraform/pre_read/sql_database_activation_policy.tmpl' # Sweeper skipped as this resource has customized deletion. exclude_sweeper: true @@ -67,16 +66,6 @@ examples: 'deletion_protection': 'false' ignore_read_extra: - 'deletion_policy' -virtual_fields: - # TODO: make this an enum in a future major version. If using this field as a reference, look at PerInstanceConfig's minimal_action field for enum configuration. - - name: 'deletion_policy' - 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". - type: String - default_value: "DELETE" parameters: - name: 'instance' type: String diff --git a/mmv1/products/vertexai/ReasoningEngine.yaml b/mmv1/products/vertexai/ReasoningEngine.yaml index 01880fa87283..c8af0f45b414 100644 --- a/mmv1/products/vertexai/ReasoningEngine.yaml +++ b/mmv1/products/vertexai/ReasoningEngine.yaml @@ -25,6 +25,7 @@ self_link: 'projects/{{project}}/locations/{{region}}/reasoningEngines/{{name}}' create_url: 'projects/{{project}}/locations/{{region}}/reasoningEngines' update_verb: 'PATCH' update_mask: true +deletion_policy_custom_docs: true timeouts: insert_minutes: 20 update_minutes: 20 @@ -142,10 +143,16 @@ custom_code: virtual_fields: - name: 'deletion_policy' 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. - type: Enum - enum_values: - - 'FORCE' + 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. + type: String + exclude: true iam_policy: method_name_separator: ':' fetch_iam_policy_verb: 'POST' diff --git a/mmv1/templates/terraform/pre_delete/firestore_database.go.tmpl b/mmv1/templates/terraform/pre_delete/firestore_database.go.tmpl index 2f396d07df3d..93cf63940568 100644 --- a/mmv1/templates/terraform/pre_delete/firestore_database.go.tmpl +++ b/mmv1/templates/terraform/pre_delete/firestore_database.go.tmpl @@ -1,7 +1,3 @@ -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)) } diff --git a/mmv1/templates/terraform/pre_delete/regional_secret_version_deletion_policy.go.tmpl b/mmv1/templates/terraform/pre_delete/regional_secret_version_deletion_policy.go.tmpl index 63b88d34db56..57bfac2273f1 100644 --- a/mmv1/templates/terraform/pre_delete/regional_secret_version_deletion_policy.go.tmpl +++ b/mmv1/templates/terraform/pre_delete/regional_secret_version_deletion_policy.go.tmpl @@ -12,9 +12,7 @@ */ -}} 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/mmv1/templates/terraform/pre_delete/secret_version_deletion_policy.go.tmpl b/mmv1/templates/terraform/pre_delete/secret_version_deletion_policy.go.tmpl index cba329bad5ed..333bb71a04e9 100644 --- a/mmv1/templates/terraform/pre_delete/secret_version_deletion_policy.go.tmpl +++ b/mmv1/templates/terraform/pre_delete/secret_version_deletion_policy.go.tmpl @@ -11,10 +11,7 @@ limitations under the License. */ -}} 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/mmv1/templates/terraform/resource.go.tmpl b/mmv1/templates/terraform/resource.go.tmpl index 8ebed9a5de15..9e5f4edca5c0 100644 --- a/mmv1/templates/terraform/resource.go.tmpl +++ b/mmv1/templates/terraform/resource.go.tmpl @@ -104,7 +104,7 @@ func Resource{{ $.ResourceName -}}() *schema.Resource { return &schema.Resource{ Create: resource{{ $.ResourceName -}}Create, Read: resource{{ $.ResourceName -}}Read, -{{- if or (or $.Updatable $.RootLabels) $.VirtualFields }} +{{- if or (or $.Updatable $.RootLabels (and (not $.ExcludeDelete) (not $.DeletionPolicyExclude))) $.VirtualFields }} Update: resource{{ $.ResourceName -}}Update, {{- end}} Delete: resource{{ $.ResourceName -}}Delete, @@ -161,6 +161,9 @@ func Resource{{ $.ResourceName -}}() *schema.Resource { {{- end -}} {{if and ($.HasZone) (not $.ExcludeDefaultCdiff) }} tpgresource.DefaultProviderZone, +{{- end }} +{{- if and (not $.ExcludeDelete) (not $.DeletionPolicyExclude)}} + tpgresource.DefaultProviderDeletionPolicy("{{$.DeletionPolicyDefault}}"), {{- end }} ), {{- end}} @@ -212,8 +215,10 @@ func Resource{{ $.ResourceName -}}() *schema.Resource { {{template "SchemaFields" $prop -}} {{- end }} {{- range $prop := $.VirtualFields }} + {{- if not $prop.Exclude }} {{template "SchemaFields" $prop -}} {{- end }} + {{- end }} {{- if $.CustomCode.ExtraSchemaEntry }} {{ customTemplate $ $.CustomCode.ExtraSchemaEntry false -}} {{- end}} @@ -230,6 +235,24 @@ func Resource{{ $.ResourceName -}}() *schema.Resource { Type: schema.TypeString, Computed: true, }, +{{- end}} +{{- if and (not $.ExcludeDelete) (not $.DeletionPolicyExclude)}} + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + {{- if $.DeletionPolicyCustomDocs}} + Description: `This field uses a custom implementation please refer to documentation under /hashicorp/terraform-provider-google-beta/website/docs/r/{{ underscore $.ResourceName}}.html.markdown for specifics`, + {{else}} + Description: `Whether Terraform will be prevented from destroying the instance. Defaults to "{{$.DeletionPolicyDefault}}". +When a 'terraform destroy' or 'terraform apply' would delete the instance, +the command will fail if this field is set to "PREVENT" in Terraform state. +When set to "ABANDON", the command will remove the resource from Terraform +management without updating or deleting the resource in the API. +When set to "DELETE", deleting the resource is allowed. +`, + {{- end}} + }, {{- end}} }, UseJSONNumber: true, @@ -742,7 +765,7 @@ func resource{{ $.ResourceName -}}Read(d *schema.ResourceData, meta interface{}) return nil } {{ end}} -{{- if $.VirtualFields }} +{{- if or $.VirtualFields (and (not $.ExcludeDelete) (not $.DeletionPolicyExclude)) }} // Explicitly set virtual fields to default values if unset {{- range $prop := $.VirtualFields }} @@ -754,6 +777,20 @@ func resource{{ $.ResourceName -}}Read(d *schema.ResourceData, meta interface{}) } {{- end}} {{- end}} +{{- if and (not $.ExcludeDelete) (not $.DeletionPolicyExclude)}} + if _, ok := d.GetOkExists("deletion_policy"); !ok { + //prioritize config's value if present + if config.DeletionPolicy != ""{ + if err := d.Set("deletion_policy", config.DeletionPolicy); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + }else{ + if err := d.Set("deletion_policy", "{{ $.DeletionPolicyDefault -}}"); err != nil { + return fmt.Errorf("Error setting deletion_policy: %s", err) + } + } + } +{{- end}} {{- end}} {{- if $.HasProject }} if err := d.Set("project", project); err != nil { @@ -815,7 +852,21 @@ func resource{{ $.ResourceName -}}Read(d *schema.ResourceData, meta interface{}) {{if $.Updatable -}} func resource{{ $.ResourceName -}}Update(d *schema.ResourceData, meta interface{}) error { -{{- if and ($.GetAsync) (and ($.GetAsync.IsA "OpAsync") ($.GetAsync.IncludeProject) ($.GetAsync.Allow "update")) -}} +{{- if and (not $.ExcludeDelete) (not $.DeletionPolicyExclude)}} + clientSideFields := map[string]bool{"deletion_policy": true} + clientSideOnly := true + for field := range Resource{{ $.ResourceName -}}().Schema { + if d.HasChange(field) && !clientSideFields[field] { + clientSideOnly = false + break + } + } + if clientSideOnly { + log.Print("[DEBUG] Only client-side changes detected. Cancelling update operation.") + return resource{{ $.ResourceName -}}Read(d, meta) + } +{{- end}} +{{ if and ($.GetAsync) (and ($.GetAsync.IsA "OpAsync") ($.GetAsync.IncludeProject) ($.GetAsync.Allow "update")) -}} var project string {{- end}} config := meta.(*transport_tpg.Config) @@ -1176,9 +1227,9 @@ if d.HasChange("{{ join ($.PropertyNamesToStrings (index $CustomUpdateProps $gro return resource{{ $.ResourceName -}}Read(d, meta) {{- end }}{{/*if CustomUpdate*/}} } -{{ else if or $.RootLabels $.VirtualFields -}}{{/*if not immutable*/}} +{{ else if or $.RootLabels $.VirtualFields (and (not $.ExcludeDelete) (not $.DeletionPolicyExclude)) -}}{{/*if not immutable*/}} func resource{{ $.ResourceName -}}Update(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 resource{{ $.ResourceName -}}Read(d, meta) } @@ -1192,6 +1243,15 @@ func resource{{ $.ResourceName }}Delete(d *schema.ResourceData, meta interface{} return nil {{- else }} +{{- if and (not $.ExcludeDelete) (not $.DeletionPolicyExclude)}} + if d.Get("deletion_policy").(string) == "PREVENT" { + return fmt.Errorf("cannot destroy {{$.ResourceName}} without setting deletion_policy=\"DELETE\" and running `terraform apply`") + } + if d.Get("deletion_policy").(string) == "ABANDON" { + log.Printf("[DEBUG] deletion_policy set to \"ABANDON\", removing {{ $.Name }} %q from Terraform state without deletion", d.Id()) + return nil + } +{{- end }} {{- if and ($.GetAsync) (and (and ($.GetAsync.IsA "OpAsync") $.GetAsync.IncludeProject) ($.GetAsync.Allow "delete")) }} var project string {{- end }} diff --git a/mmv1/templates/terraform/resource.html.markdown.tmpl b/mmv1/templates/terraform/resource.html.markdown.tmpl index e4a0ae88244c..9439393556e8 100644 --- a/mmv1/templates/terraform/resource.html.markdown.tmpl +++ b/mmv1/templates/terraform/resource.html.markdown.tmpl @@ -125,6 +125,14 @@ The following arguments are supported: If it is not provided, the provider project is used. {{ "" }} {{- end }} +{{- if and (not $.DeletionPolicyExclude) (not $.DeletionPolicyCustomDocs)}} +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to {{$.DeletionPolicyDefault}}. + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. +{{- end }} {{- range $f := $.VirtualFields }} * `{{$f.Name}}` - (Optional) {{$f.Description}} {{- end }} diff --git a/mmv1/third_party/terraform/acctest/test_utils.go.tmpl b/mmv1/third_party/terraform/acctest/test_utils.go.tmpl index d4ecc0102735..14ed847da949 100644 --- a/mmv1/third_party/terraform/acctest/test_utils.go.tmpl +++ b/mmv1/third_party/terraform/acctest/test_utils.go.tmpl @@ -64,7 +64,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/mmv1/third_party/terraform/acctest/vcr_utils.go b/mmv1/third_party/terraform/acctest/vcr_utils.go index 863082dc71b2..33b1551010f2 100644 --- a/mmv1/third_party/terraform/acctest/vcr_utils.go +++ b/mmv1/third_party/terraform/acctest/vcr_utils.go @@ -176,6 +176,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/mmv1/third_party/terraform/fwmodels/provider_model.go.tmpl b/mmv1/third_party/terraform/fwmodels/provider_model.go.tmpl index c9533ff6d47f..3f534561472b 100644 --- a/mmv1/third_party/terraform/fwmodels/provider_model.go.tmpl +++ b/mmv1/third_party/terraform/fwmodels/provider_model.go.tmpl @@ -31,6 +31,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/mmv1/third_party/terraform/fwprovider/framework_provider.go.tmpl b/mmv1/third_party/terraform/fwprovider/framework_provider.go.tmpl index 5ac64737e347..78494578dfbc 100644 --- a/mmv1/third_party/terraform/fwprovider/framework_provider.go.tmpl +++ b/mmv1/third_party/terraform/fwprovider/framework_provider.go.tmpl @@ -150,6 +150,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/mmv1/third_party/terraform/provider/provider.go.tmpl b/mmv1/third_party/terraform/provider/provider.go.tmpl index 80ea1a983f87..c9b0bc0e5990 100644 --- a/mmv1/third_party/terraform/provider/provider.go.tmpl +++ b/mmv1/third_party/terraform/provider/provider.go.tmpl @@ -144,6 +144,11 @@ func Provider() *schema.Provider { Optional: true, }, + "deletion_policy": { + Type: schema.TypeString, + Optional: true, + }, + "request_reason": { Type: schema.TypeString, Optional: true, @@ -288,6 +293,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/mmv1/third_party/terraform/services/apigee/resource_apigee_api.go b/mmv1/third_party/terraform/services/apigee/resource_apigee_api.go index 3bc8623bc5e4..27129c7607f3 100644 --- a/mmv1/third_party/terraform/services/apigee/resource_apigee_api.go +++ b/mmv1/third_party/terraform/services/apigee/resource_apigee_api.go @@ -34,6 +34,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, @@ -133,6 +134,9 @@ func ResourceApigeeApi() *schema.Resource { return true }, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, UseJSONNumber: true, } @@ -206,6 +210,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) } @@ -262,6 +271,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 } @@ -284,6 +298,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/mmv1/third_party/terraform/services/apigee/resource_apigee_api_meta.yaml b/mmv1/third_party/terraform/services/apigee/resource_apigee_api_meta.yaml index 386ec1bbe0d9..66e24fa9d4e1 100644 --- a/mmv1/third_party/terraform/services/apigee/resource_apigee_api_meta.yaml +++ b/mmv1/third_party/terraform/services/apigee/resource_apigee_api_meta.yaml @@ -14,3 +14,5 @@ fields: - api_field: 'name' - field: 'org_id' - api_field: 'revision' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/apigee/resource_apigee_flowhook.go b/mmv1/third_party/terraform/services/apigee/resource_apigee_flowhook.go index 563d84e9258d..2161cc78555e 100644 --- a/mmv1/third_party/terraform/services/apigee/resource_apigee_flowhook.go +++ b/mmv1/third_party/terraform/services/apigee/resource_apigee_flowhook.go @@ -6,6 +6,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" @@ -16,6 +17,7 @@ func ResourceApigeeFlowhook() *schema.Resource { return &schema.Resource{ Create: resourceApigeeFlowhookCreate, Read: resourceApigeeFlowhookRead, + Update: resourceApigeeFlowhookUpdate, Delete: resourceApigeeFlowhookDelete, Importer: &schema.ResourceImporter{ @@ -27,6 +29,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, @@ -65,6 +71,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, } @@ -179,10 +188,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/mmv1/third_party/terraform/services/apigee/resource_apigee_flowhook_meta.yaml b/mmv1/third_party/terraform/services/apigee/resource_apigee_flowhook_meta.yaml index 22564c10c27d..d14117eb09f0 100644 --- a/mmv1/third_party/terraform/services/apigee/resource_apigee_flowhook_meta.yaml +++ b/mmv1/third_party/terraform/services/apigee/resource_apigee_flowhook_meta.yaml @@ -10,3 +10,5 @@ fields: - api_field: 'flowHookPoint' - field: 'org_id' - field: 'sharedflow' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/apigee/resource_apigee_keystores_aliases_pkcs12.go b/mmv1/third_party/terraform/services/apigee/resource_apigee_keystores_aliases_pkcs12.go index 268ce2366f95..b94ee013e485 100644 --- a/mmv1/third_party/terraform/services/apigee/resource_apigee_keystores_aliases_pkcs12.go +++ b/mmv1/third_party/terraform/services/apigee/resource_apigee_keystores_aliases_pkcs12.go @@ -10,6 +10,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" @@ -20,6 +21,7 @@ func ResourceApigeeKeystoresAliasesPkcs12() *schema.Resource { return &schema.Resource{ Create: ResourceApigeeKeystoresAliasesPkcs12Create, Read: ResourceApigeeKeystoresAliasesPkcs12Read, + Update: ResourceApigeeKeystoresAliasesPkcs12Update, Delete: ResourceApigeeKeystoresAliasesPkcs12Delete, Importer: &schema.ResourceImporter{ @@ -31,6 +33,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, @@ -156,6 +162,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, } @@ -255,10 +264,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/mmv1/third_party/terraform/services/apigee/resource_apigee_keystores_aliases_pkcs12_meta.yaml b/mmv1/third_party/terraform/services/apigee/resource_apigee_keystores_aliases_pkcs12_meta.yaml index a84e08585112..d1b3e64ec389 100644 --- a/mmv1/third_party/terraform/services/apigee/resource_apigee_keystores_aliases_pkcs12_meta.yaml +++ b/mmv1/third_party/terraform/services/apigee/resource_apigee_keystores_aliases_pkcs12_meta.yaml @@ -23,3 +23,5 @@ fields: - field: 'org_id' - field: 'password' - api_field: 'type' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/apigee/resource_apigee_sharedflow.go b/mmv1/third_party/terraform/services/apigee/resource_apigee_sharedflow.go index f7be59caa89a..9371396b7f48 100644 --- a/mmv1/third_party/terraform/services/apigee/resource_apigee_sharedflow.go +++ b/mmv1/third_party/terraform/services/apigee/resource_apigee_sharedflow.go @@ -34,6 +34,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, @@ -134,6 +135,9 @@ func ResourceApigeeSharedFlow() *schema.Resource { return true }, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, UseJSONNumber: true, } @@ -205,6 +209,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) } @@ -261,6 +270,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 } @@ -284,6 +298,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/mmv1/third_party/terraform/services/apigee/resource_apigee_sharedflow_deployment.go b/mmv1/third_party/terraform/services/apigee/resource_apigee_sharedflow_deployment.go index bb8091b997ce..42e7df28bbbe 100644 --- a/mmv1/third_party/terraform/services/apigee/resource_apigee_sharedflow_deployment.go +++ b/mmv1/third_party/terraform/services/apigee/resource_apigee_sharedflow_deployment.go @@ -5,6 +5,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" @@ -28,6 +29,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, @@ -58,6 +63,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, } @@ -140,6 +148,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 } @@ -150,6 +162,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 @@ -188,6 +204,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/mmv1/third_party/terraform/services/apigee/resource_apigee_sharedflow_deployment_meta.yaml b/mmv1/third_party/terraform/services/apigee/resource_apigee_sharedflow_deployment_meta.yaml index 727f7bb85556..1b7c68ccf306 100644 --- a/mmv1/third_party/terraform/services/apigee/resource_apigee_sharedflow_deployment_meta.yaml +++ b/mmv1/third_party/terraform/services/apigee/resource_apigee_sharedflow_deployment_meta.yaml @@ -9,3 +9,5 @@ fields: - api_field: 'revision' - field: 'service_account' - field: 'sharedflow_id' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/apigee/resource_apigee_sharedflow_meta.yaml b/mmv1/third_party/terraform/services/apigee/resource_apigee_sharedflow_meta.yaml index 2bfc6283ce6b..87d833cb8ec4 100644 --- a/mmv1/third_party/terraform/services/apigee/resource_apigee_sharedflow_meta.yaml +++ b/mmv1/third_party/terraform/services/apigee/resource_apigee_sharedflow_meta.yaml @@ -14,3 +14,5 @@ fields: - api_field: 'name' - field: 'org_id' - api_field: 'revision' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/apikeys/resource_apikeys_key.go b/mmv1/third_party/terraform/services/apikeys/resource_apikeys_key.go index 81443af61e01..2bbcc0fc91a9 100644 --- a/mmv1/third_party/terraform/services/apikeys/resource_apikeys_key.go +++ b/mmv1/third_party/terraform/services/apikeys/resource_apikeys_key.go @@ -33,6 +33,7 @@ func ResourceApikeysKey() *schema.Resource { }, CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -86,6 +87,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 }, } } @@ -335,9 +340,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 { @@ -385,6 +399,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/mmv1/third_party/terraform/services/apikeys/resource_apikeys_key_meta.yaml b/mmv1/third_party/terraform/services/apikeys/resource_apikeys_key_meta.yaml index e378775095be..4dcb1b97b4f8 100644 --- a/mmv1/third_party/terraform/services/apikeys/resource_apikeys_key_meta.yaml +++ b/mmv1/third_party/terraform/services/apikeys/resource_apikeys_key_meta.yaml @@ -17,3 +17,5 @@ fields: - api_field: 'restrictions.serverKeyRestrictions.allowedIps' - api_field: 'uid' - api_field: 'serviceAccountEmail' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/assuredworkloads/resource_assured_workloads_workload.go.tmpl b/mmv1/third_party/terraform/services/assuredworkloads/resource_assured_workloads_workload.go.tmpl index 4969975c90b4..777e182a2ae5 100644 --- a/mmv1/third_party/terraform/services/assuredworkloads/resource_assured_workloads_workload.go.tmpl +++ b/mmv1/third_party/terraform/services/assuredworkloads/resource_assured_workloads_workload.go.tmpl @@ -32,6 +32,7 @@ func ResourceAssuredWorkloadsWorkload() *schema.Resource { }, CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -216,6 +217,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 }, } } @@ -576,10 +580,20 @@ func resourceAssuredWorkloadsWorkloadRead(d *schema.ResourceData, meta interface if err = d.Set("terraform_labels", flattenAssuredWorkloadsWorkloadTerraformLabels(res.Labels, d)); err != nil { 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{ @@ -654,6 +668,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/mmv1/third_party/terraform/services/assuredworkloads/resource_assured_workloads_workload_meta.yaml.tmpl b/mmv1/third_party/terraform/services/assuredworkloads/resource_assured_workloads_workload_meta.yaml.tmpl index 45d8544b3e16..c79de60db2b2 100644 --- a/mmv1/third_party/terraform/services/assuredworkloads/resource_assured_workloads_workload_meta.yaml.tmpl +++ b/mmv1/third_party/terraform/services/assuredworkloads/resource_assured_workloads_workload_meta.yaml.tmpl @@ -47,3 +47,5 @@ fields: provider_only: true - api_field: 'violationNotificationsEnabled' - api_field: 'workloadOptions.kajEnrollmentType' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/bigquery/resource_bigquery_table.go.tmpl b/mmv1/third_party/terraform/services/bigquery/resource_bigquery_table.go.tmpl index 1ec563438a98..666163f54bc4 100644 --- a/mmv1/third_party/terraform/services/bigquery/resource_bigquery_table.go.tmpl +++ b/mmv1/third_party/terraform/services/bigquery/resource_bigquery_table.go.tmpl @@ -686,6 +686,7 @@ func ResourceBigQueryTable() *schema.Resource { State: resourceBigQueryTableImport, }, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), tpgresource.DefaultProviderProject, resourceBigQueryTableSchemaCustomizeDiff, tpgresource.SetLabelsDiff, @@ -1837,6 +1838,9 @@ func ResourceBigQueryTable() *schema.Resource { }, }, }, +//UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), +//UDP schema end }, UseJSONNumber: true, } @@ -2382,6 +2386,11 @@ func resourceBigQueryTableRead(d *schema.ResourceData, meta interface{}) error { return fmt.Errorf("Error setting external_catalog_table_options: %s", err) } } + + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil{ + return err + } + return nil } @@ -2413,7 +2422,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] { @@ -2553,6 +2562,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/mmv1/third_party/terraform/services/bigquery/resource_bigquery_table_meta.yaml b/mmv1/third_party/terraform/services/bigquery/resource_bigquery_table_meta.yaml index 768050c65bcf..95bd7082d5a5 100644 --- a/mmv1/third_party/terraform/services/bigquery/resource_bigquery_table_meta.yaml +++ b/mmv1/third_party/terraform/services/bigquery/resource_bigquery_table_meta.yaml @@ -134,3 +134,5 @@ fields: - api_field: 'type' - api_field: 'view.query' - api_field: 'view.useLegacySql' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/bigtable/resource_bigtable_authorized_view.go b/mmv1/third_party/terraform/services/bigtable/resource_bigtable_authorized_view.go index 3638d7dcddfa..9aa3981ec5d8 100644 --- a/mmv1/third_party/terraform/services/bigtable/resource_bigtable_authorized_view.go +++ b/mmv1/third_party/terraform/services/bigtable/resource_bigtable_authorized_view.go @@ -56,6 +56,7 @@ func ResourceBigtableAuthorizedView() *schema.Resource { }, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), tpgresource.DefaultProviderProject, ), @@ -122,6 +123,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, } @@ -253,10 +257,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 { @@ -320,6 +333,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/mmv1/third_party/terraform/services/bigtable/resource_bigtable_authorized_view_meta.yaml b/mmv1/third_party/terraform/services/bigtable/resource_bigtable_authorized_view_meta.yaml index bea00f8ed23f..6bcc6d8b446f 100644 --- a/mmv1/third_party/terraform/services/bigtable/resource_bigtable_authorized_view_meta.yaml +++ b/mmv1/third_party/terraform/services/bigtable/resource_bigtable_authorized_view_meta.yaml @@ -13,3 +13,5 @@ fields: - field: 'subset_view.family_subsets.qualifiers' - api_field: 'subsetView.rowPrefixes' - field: 'table_name' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/bigtable/resource_bigtable_gc_policy.go b/mmv1/third_party/terraform/services/bigtable/resource_bigtable_gc_policy.go index 3f1198cf7308..a0ae9eb231b3 100644 --- a/mmv1/third_party/terraform/services/bigtable/resource_bigtable_gc_policy.go +++ b/mmv1/third_party/terraform/services/bigtable/resource_bigtable_gc_policy.go @@ -10,6 +10,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" @@ -95,12 +96,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), @@ -209,14 +212,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, @@ -233,6 +231,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 { @@ -370,6 +373,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 } @@ -437,15 +444,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/mmv1/third_party/terraform/services/bigtable/resource_bigtable_gc_policy_meta.yaml b/mmv1/third_party/terraform/services/bigtable/resource_bigtable_gc_policy_meta.yaml index e2f3144c6ae5..553cdf72a6a5 100644 --- a/mmv1/third_party/terraform/services/bigtable/resource_bigtable_gc_policy_meta.yaml +++ b/mmv1/third_party/terraform/services/bigtable/resource_bigtable_gc_policy_meta.yaml @@ -6,6 +6,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/mmv1/third_party/terraform/services/bigtable/resource_bigtable_instance.go b/mmv1/third_party/terraform/services/bigtable/resource_bigtable_instance.go index b04950754daa..d67a7289fe53 100644 --- a/mmv1/third_party/terraform/services/bigtable/resource_bigtable_instance.go +++ b/mmv1/third_party/terraform/services/bigtable/resource_bigtable_instance.go @@ -54,6 +54,7 @@ func ResourceBigtableInstance() *schema.Resource { }, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), tpgresource.DefaultProviderProject, resourceBigtableInstanceClusterReorderTypeList, resourceBigtableInstanceUniqueClusterID, @@ -224,7 +225,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, @@ -393,10 +396,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 { @@ -464,6 +476,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/mmv1/third_party/terraform/services/bigtable/resource_bigtable_instance_meta.yaml b/mmv1/third_party/terraform/services/bigtable/resource_bigtable_instance_meta.yaml index 64a6a50b96b8..c0a18b6b18bb 100644 --- a/mmv1/third_party/terraform/services/bigtable/resource_bigtable_instance_meta.yaml +++ b/mmv1/third_party/terraform/services/bigtable/resource_bigtable_instance_meta.yaml @@ -29,3 +29,5 @@ fields: - api_field: 'tags' - field: 'terraform_labels' provider_only: true + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/bigtable/resource_bigtable_table.go b/mmv1/third_party/terraform/services/bigtable/resource_bigtable_table.go index 17de347888a0..96b6135fe6b9 100644 --- a/mmv1/third_party/terraform/services/bigtable/resource_bigtable_table.go +++ b/mmv1/third_party/terraform/services/bigtable/resource_bigtable_table.go @@ -54,6 +54,7 @@ func ResourceBigtableTable() *schema.Resource { }, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), tpgresource.DefaultProviderProject, abpDiffFunc, ), @@ -168,6 +169,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, } @@ -441,6 +445,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 } @@ -487,6 +495,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 { @@ -632,6 +645,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/mmv1/third_party/terraform/services/bigtable/resource_bigtable_table_meta.yaml b/mmv1/third_party/terraform/services/bigtable/resource_bigtable_table_meta.yaml index 0e42b54d1066..ae71259d2170 100644 --- a/mmv1/third_party/terraform/services/bigtable/resource_bigtable_table_meta.yaml +++ b/mmv1/third_party/terraform/services/bigtable/resource_bigtable_table_meta.yaml @@ -18,3 +18,5 @@ fields: - api_field: 'rowKeySchema' json: true - field: 'split_keys' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/cloudbuild/resource_cloudbuild_worker_pool.go b/mmv1/third_party/terraform/services/cloudbuild/resource_cloudbuild_worker_pool.go index 23e81af94bce..f52c0e67d4b2 100644 --- a/mmv1/third_party/terraform/services/cloudbuild/resource_cloudbuild_worker_pool.go +++ b/mmv1/third_party/terraform/services/cloudbuild/resource_cloudbuild_worker_pool.go @@ -36,6 +36,7 @@ func ResourceCloudbuildWorkerPool() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, tpgresource.SetAnnotationsDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -139,6 +140,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 }, } } @@ -354,9 +358,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 { @@ -407,6 +420,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/mmv1/third_party/terraform/services/cloudbuild/resource_cloudbuild_worker_pool_meta.yaml b/mmv1/third_party/terraform/services/cloudbuild/resource_cloudbuild_worker_pool_meta.yaml index dca7d6eaad31..32c9b11d3a9e 100644 --- a/mmv1/third_party/terraform/services/cloudbuild/resource_cloudbuild_worker_pool_meta.yaml +++ b/mmv1/third_party/terraform/services/cloudbuild/resource_cloudbuild_worker_pool_meta.yaml @@ -32,3 +32,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/mmv1/third_party/terraform/services/clouddeploy/resource_clouddeploy_delivery_pipeline.go b/mmv1/third_party/terraform/services/clouddeploy/resource_clouddeploy_delivery_pipeline.go index e2250feb5697..98c8e24b20ca 100644 --- a/mmv1/third_party/terraform/services/clouddeploy/resource_clouddeploy_delivery_pipeline.go +++ b/mmv1/third_party/terraform/services/clouddeploy/resource_clouddeploy_delivery_pipeline.go @@ -37,6 +37,7 @@ func ResourceClouddeployDeliveryPipeline() *schema.Resource { tpgresource.DefaultProviderProject, tpgresource.SetLabelsDiff, tpgresource.SetAnnotationsDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -145,6 +146,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 }, } } @@ -1089,9 +1093,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 { @@ -1142,6 +1155,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/mmv1/third_party/terraform/services/clouddeploy/resource_clouddeploy_delivery_pipeline_meta.yaml b/mmv1/third_party/terraform/services/clouddeploy/resource_clouddeploy_delivery_pipeline_meta.yaml index a2402b90dc47..0a024e2cdf40 100644 --- a/mmv1/third_party/terraform/services/clouddeploy/resource_clouddeploy_delivery_pipeline_meta.yaml +++ b/mmv1/third_party/terraform/services/clouddeploy/resource_clouddeploy_delivery_pipeline_meta.yaml @@ -111,3 +111,5 @@ fields: provider_only: true - api_field: 'uid' - api_field: 'updateTime' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/clouddeploy/resource_clouddeploy_target.go b/mmv1/third_party/terraform/services/clouddeploy/resource_clouddeploy_target.go index d14fcee69f28..ab74f67e278d 100644 --- a/mmv1/third_party/terraform/services/clouddeploy/resource_clouddeploy_target.go +++ b/mmv1/third_party/terraform/services/clouddeploy/resource_clouddeploy_target.go @@ -37,6 +37,7 @@ func ResourceClouddeployTarget() *schema.Resource { tpgresource.DefaultProviderProject, tpgresource.SetLabelsDiff, tpgresource.SetAnnotationsDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -204,6 +205,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 }, } } @@ -645,9 +649,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 { @@ -705,6 +718,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/mmv1/third_party/terraform/services/clouddeploy/resource_clouddeploy_target_meta.yaml b/mmv1/third_party/terraform/services/clouddeploy/resource_clouddeploy_target_meta.yaml index 036814635ff4..da9bc1a3cb1a 100644 --- a/mmv1/third_party/terraform/services/clouddeploy/resource_clouddeploy_target_meta.yaml +++ b/mmv1/third_party/terraform/services/clouddeploy/resource_clouddeploy_target_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/mmv1/third_party/terraform/services/cloudfunctions/resource_cloudfunctions_function.go b/mmv1/third_party/terraform/services/cloudfunctions/resource_cloudfunctions_function.go index 00ddd116c0ab..7c24a20d72bc 100644 --- a/mmv1/third_party/terraform/services/cloudfunctions/resource_cloudfunctions_function.go +++ b/mmv1/third_party/terraform/services/cloudfunctions/resource_cloudfunctions_function.go @@ -144,6 +144,7 @@ func ResourceCloudFunctionsFunction() *schema.Resource { }, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), tpgresource.DefaultProviderProject, tpgresource.DefaultProviderRegion, tpgresource.SetLabelsDiff, @@ -534,6 +535,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, } @@ -868,11 +872,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 { @@ -1065,6 +1078,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/mmv1/third_party/terraform/services/cloudfunctions/resource_cloudfunctions_function_meta.yaml b/mmv1/third_party/terraform/services/cloudfunctions/resource_cloudfunctions_function_meta.yaml index 7e815ad9e358..66cc41aa17b8 100644 --- a/mmv1/third_party/terraform/services/cloudfunctions/resource_cloudfunctions_function_meta.yaml +++ b/mmv1/third_party/terraform/services/cloudfunctions/resource_cloudfunctions_function_meta.yaml @@ -53,3 +53,5 @@ fields: - api_field: 'vpcConnectorEgressSettings' - field: 'automatic_update_policy' - api_field: 'onDeployUpdatePolicy.runtimeVersion' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/composer/resource_composer_environment.go.tmpl b/mmv1/third_party/terraform/services/composer/resource_composer_environment.go.tmpl index 924e300565b6..f5064b4b6815 100644 --- a/mmv1/third_party/terraform/services/composer/resource_composer_environment.go.tmpl +++ b/mmv1/third_party/terraform/services/composer/resource_composer_environment.go.tmpl @@ -160,6 +160,7 @@ func ResourceComposerEnvironment() *schema.Resource { }, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), tpgresource.DefaultProviderProject, tpgresource.DefaultProviderRegion, tpgresource.SetLabelsDiff, @@ -1079,6 +1080,9 @@ func ResourceComposerEnvironment() *schema.Resource { }, }, }, +//UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), +//UDP schema end }, UseJSONNumber: true, } @@ -1199,10 +1203,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 { @@ -1629,6 +1643,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/mmv1/third_party/terraform/services/composer/resource_composer_environment_meta.yaml.tmpl b/mmv1/third_party/terraform/services/composer/resource_composer_environment_meta.yaml.tmpl index ffc9885d4088..152011dac829 100644 --- a/mmv1/third_party/terraform/services/composer/resource_composer_environment_meta.yaml.tmpl +++ b/mmv1/third_party/terraform/services/composer/resource_composer_environment_meta.yaml.tmpl @@ -98,3 +98,5 @@ fields: - api_field: 'storageConfig.bucket' - field: 'terraform_labels' provider_only: true + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/composer/resource_composer_user_workloads_secret.go.tmpl b/mmv1/third_party/terraform/services/composer/resource_composer_user_workloads_secret.go.tmpl index bccd08fff93a..c2b2f75c4ca6 100644 --- a/mmv1/third_party/terraform/services/composer/resource_composer_user_workloads_secret.go.tmpl +++ b/mmv1/third_party/terraform/services/composer/resource_composer_user_workloads_secret.go.tmpl @@ -36,6 +36,7 @@ func ResourceComposerUserWorkloadsSecret() *schema.Resource { }, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), tpgresource.DefaultProviderProject, tpgresource.DefaultProviderRegion, ), @@ -76,7 +77,10 @@ func ResourceComposerUserWorkloadsSecret() *schema.Resource { Sensitive: true, Description: `A map of the secret data.`, }, - }, +//UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), +//UDP schema end + }, } } @@ -144,10 +148,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 { @@ -181,6 +195,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/mmv1/third_party/terraform/services/composer/resource_composer_user_workloads_secret_meta.yaml.tmpl b/mmv1/third_party/terraform/services/composer/resource_composer_user_workloads_secret_meta.yaml.tmpl index ed3331a6c445..0eefaf0f0ae5 100644 --- a/mmv1/third_party/terraform/services/composer/resource_composer_user_workloads_secret_meta.yaml.tmpl +++ b/mmv1/third_party/terraform/services/composer/resource_composer_user_workloads_secret_meta.yaml.tmpl @@ -13,3 +13,5 @@ fields: - api_field: 'name' - field: 'project' - field: 'region' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/compute/data_source_google_compute_instance_group.go b/mmv1/third_party/terraform/services/compute/data_source_google_compute_instance_group.go index b95eccbcb0dd..9b137d65c902 100644 --- a/mmv1/third_party/terraform/services/compute/data_source_google_compute_instance_group.go +++ b/mmv1/third_party/terraform/services/compute/data_source_google_compute_instance_group.go @@ -79,6 +79,11 @@ func DataSourceGoogleComputeInstanceGroup() *schema.Resource { Type: schema.TypeInt, Computed: true, }, + + "deletion_policy": { + Type: schema.TypeString, + Computed: true, + }, }, } } diff --git a/mmv1/third_party/terraform/services/compute/resource_compute_attached_disk.go.tmpl b/mmv1/third_party/terraform/services/compute/resource_compute_attached_disk.go.tmpl index a59374f59ddb..d31260ed6a01 100644 --- a/mmv1/third_party/terraform/services/compute/resource_compute_attached_disk.go.tmpl +++ b/mmv1/third_party/terraform/services/compute/resource_compute_attached_disk.go.tmpl @@ -21,6 +21,7 @@ func ResourceComputeAttachedDisk() *schema.Resource { return &schema.Resource{ Create: resourceAttachedDiskCreate, Read: resourceAttachedDiskRead, + Update: resourceAttachedDiskUpdate, Delete: resourceAttachedDiskDelete, Importer: &schema.ResourceImporter{ @@ -33,6 +34,7 @@ func ResourceComputeAttachedDisk() *schema.Resource { }, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), tpgresource.DefaultProviderProject, computeAttachedDiskDefaultProviderZone, ), @@ -88,7 +90,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, } @@ -219,11 +223,30 @@ func resourceAttachedDiskRead(d *schema.ResourceData, meta interface{}) error { if err := d.Set("disk", diskPath); err != nil { 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/mmv1/third_party/terraform/services/compute/resource_compute_attached_disk_meta.yaml.tmpl b/mmv1/third_party/terraform/services/compute/resource_compute_attached_disk_meta.yaml.tmpl index a884a93bc311..d1bf506b370a 100644 --- a/mmv1/third_party/terraform/services/compute/resource_compute_attached_disk_meta.yaml.tmpl +++ b/mmv1/third_party/terraform/services/compute/resource_compute_attached_disk_meta.yaml.tmpl @@ -19,3 +19,5 @@ fields: field: 'mode' - field: 'project' - api_field: 'zone' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/compute/resource_compute_disk_async_replication.go b/mmv1/third_party/terraform/services/compute/resource_compute_disk_async_replication.go index 533a6cff96f4..f7cd007b5e80 100644 --- a/mmv1/third_party/terraform/services/compute/resource_compute_disk_async_replication.go +++ b/mmv1/third_party/terraform/services/compute/resource_compute_disk_async_replication.go @@ -10,6 +10,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" ) @@ -18,12 +19,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), @@ -60,6 +66,9 @@ func ResourceComputeDiskAsyncReplication() *schema.Resource { }, }, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, UseJSONNumber: true, } @@ -272,10 +281,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/mmv1/third_party/terraform/services/compute/resource_compute_disk_async_replication_meta.yaml.tmpl b/mmv1/third_party/terraform/services/compute/resource_compute_disk_async_replication_meta.yaml.tmpl index 69d33886b644..23e13e99e07f 100644 --- a/mmv1/third_party/terraform/services/compute/resource_compute_disk_async_replication_meta.yaml.tmpl +++ b/mmv1/third_party/terraform/services/compute/resource_compute_disk_async_replication_meta.yaml.tmpl @@ -13,3 +13,5 @@ fields: field: 'secondary_disk.disk' - api_field: 'resourceStatus.asyncSecondaryDisks' field: 'secondary_disk.state' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/compute/resource_compute_instance.go.tmpl b/mmv1/third_party/terraform/services/compute/resource_compute_instance.go.tmpl index 9905532a2944..36da4568f5f7 100644 --- a/mmv1/third_party/terraform/services/compute/resource_compute_instance.go.tmpl +++ b/mmv1/third_party/terraform/services/compute/resource_compute_instance.go.tmpl @@ -1693,8 +1693,12 @@ be from 0 to 999,999,999 inclusive.`, Description: `Specifies whether the disks restored from source snapshots or source machine image should erase Windows specific VSS signature.`, }, {{- end }} +//UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), +//UDP schema end }, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), tpgresource.DefaultProviderProject, tpgresource.DefaultProviderZone, customdiff.If( @@ -2376,10 +2380,20 @@ 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 { @@ -3608,6 +3622,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/mmv1/third_party/terraform/services/compute/resource_compute_instance_from_machine_image_meta.yaml.tmpl b/mmv1/third_party/terraform/services/compute/resource_compute_instance_from_machine_image_meta.yaml.tmpl index 4a71c14cda16..bc13336e0570 100644 --- a/mmv1/third_party/terraform/services/compute/resource_compute_instance_from_machine_image_meta.yaml.tmpl +++ b/mmv1/third_party/terraform/services/compute/resource_compute_instance_from_machine_image_meta.yaml.tmpl @@ -264,4 +264,6 @@ fields: {{- if ne $.TargetVersionName "ga" }} - api_field: 'eraseWindowsVssSignature' {{- end }} + - field: 'deletion_policy' + provider_only: true {{ end }} \ No newline at end of file diff --git a/mmv1/third_party/terraform/services/compute/resource_compute_instance_from_template_meta.yaml.tmpl b/mmv1/third_party/terraform/services/compute/resource_compute_instance_from_template_meta.yaml.tmpl index a7c0bd88a2a0..dc5e2acb9a88 100644 --- a/mmv1/third_party/terraform/services/compute/resource_compute_instance_from_template_meta.yaml.tmpl +++ b/mmv1/third_party/terraform/services/compute/resource_compute_instance_from_template_meta.yaml.tmpl @@ -277,3 +277,5 @@ fields: {{- if ne $.TargetVersionName "ga" }} - api_field: 'eraseWindowsVssSignature' {{- end }} + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/compute/resource_compute_instance_group.go.tmpl b/mmv1/third_party/terraform/services/compute/resource_compute_instance_group.go.tmpl index d7d438fc9913..30c6616b1028 100644 --- a/mmv1/third_party/terraform/services/compute/resource_compute_instance_group.go.tmpl +++ b/mmv1/third_party/terraform/services/compute/resource_compute_instance_group.go.tmpl @@ -39,6 +39,7 @@ func ResourceComputeInstanceGroup() *schema.Resource { }, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), tpgresource.DefaultProviderProject, tpgresource.DefaultProviderZone, ), @@ -127,6 +128,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, } @@ -405,10 +409,20 @@ func resourceComputeInstanceGroupRead(d *schema.ResourceData, meta interface{}) if err := d.Set("self_link", instanceGroup.SelfLink); err != nil { 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 { @@ -547,6 +561,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/mmv1/third_party/terraform/services/compute/resource_compute_instance_group_manager.go.tmpl b/mmv1/third_party/terraform/services/compute/resource_compute_instance_group_manager.go.tmpl index ef3e0c2a3b51..222d24da86ee 100644 --- a/mmv1/third_party/terraform/services/compute/resource_compute_instance_group_manager.go.tmpl +++ b/mmv1/third_party/terraform/services/compute/resource_compute_instance_group_manager.go.tmpl @@ -38,6 +38,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), @@ -641,6 +642,9 @@ func ResourceComputeInstanceGroupManager() *schema.Resource { }, }, }, +//UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), +//UDP schema end }, UseJSONNumber: true, } @@ -1051,6 +1055,11 @@ func resourceComputeInstanceGroupManagerRead(d *schema.ResourceData, meta interf return fmt.Errorf("Error setting wait_for_instances_status in state: %s", err.Error()) } } + + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil{ + return err + } + return nil } diff --git a/mmv1/third_party/terraform/services/compute/resource_compute_instance_group_manager_meta.yaml.tmpl b/mmv1/third_party/terraform/services/compute/resource_compute_instance_group_manager_meta.yaml.tmpl index 4dba069eefb9..9a030a3b0bb3 100644 --- a/mmv1/third_party/terraform/services/compute/resource_compute_instance_group_manager_meta.yaml.tmpl +++ b/mmv1/third_party/terraform/services/compute/resource_compute_instance_group_manager_meta.yaml.tmpl @@ -98,3 +98,5 @@ fields: - field: 'wait_for_instances_status' provider_only: true - api_field: 'zone' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/compute/resource_compute_instance_group_meta.yaml.tmpl b/mmv1/third_party/terraform/services/compute/resource_compute_instance_group_meta.yaml.tmpl index ba2bac8da7de..e095ed5ae81f 100644 --- a/mmv1/third_party/terraform/services/compute/resource_compute_instance_group_meta.yaml.tmpl +++ b/mmv1/third_party/terraform/services/compute/resource_compute_instance_group_meta.yaml.tmpl @@ -22,3 +22,5 @@ fields: - api_field: 'selfLink' - api_field: 'size' - api_field: 'zone' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/compute/resource_compute_instance_meta.yaml.tmpl b/mmv1/third_party/terraform/services/compute/resource_compute_instance_meta.yaml.tmpl index 88696add0a62..43bb507ba76a 100644 --- a/mmv1/third_party/terraform/services/compute/resource_compute_instance_meta.yaml.tmpl +++ b/mmv1/third_party/terraform/services/compute/resource_compute_instance_meta.yaml.tmpl @@ -279,4 +279,6 @@ fields: - api_field: 'zone' {{- if ne $.TargetVersionName "ga" }} - api_field: 'eraseWindowsVssSignature' -{{- end }} \ No newline at end of file +{{- end }} + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/compute/resource_compute_instance_template.go.tmpl b/mmv1/third_party/terraform/services/compute/resource_compute_instance_template.go.tmpl index 9619fe9ef2cc..9621b914e727 100644 --- a/mmv1/third_party/terraform/services/compute/resource_compute_instance_template.go.tmpl +++ b/mmv1/third_party/terraform/services/compute/resource_compute_instance_template.go.tmpl @@ -71,6 +71,7 @@ func ResourceComputeInstanceTemplate() *schema.Resource { }, SchemaVersion: 1, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), tpgresource.DefaultProviderProject, resourceComputeInstanceTemplateSourceImageCustomizeDiff, resourceComputeInstanceTemplateScratchDiskCustomizeDiff, diff --git a/mmv1/third_party/terraform/services/compute/resource_compute_network_peering.go.tmpl b/mmv1/third_party/terraform/services/compute/resource_compute_network_peering.go.tmpl index 62dde79499b0..6daca68084c0 100644 --- a/mmv1/third_party/terraform/services/compute/resource_compute_network_peering.go.tmpl +++ b/mmv1/third_party/terraform/services/compute/resource_compute_network_peering.go.tmpl @@ -8,6 +8,7 @@ import ( "time" "reflect" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "google.golang.org/api/googleapi" @@ -41,6 +42,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, @@ -122,6 +127,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, } @@ -226,10 +234,20 @@ 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 { @@ -270,6 +288,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/mmv1/third_party/terraform/services/compute/resource_compute_network_peering_meta.yaml.tmpl b/mmv1/third_party/terraform/services/compute/resource_compute_network_peering_meta.yaml.tmpl index 6416fbf1d956..0e343d87035d 100644 --- a/mmv1/third_party/terraform/services/compute/resource_compute_network_peering_meta.yaml.tmpl +++ b/mmv1/third_party/terraform/services/compute/resource_compute_network_peering_meta.yaml.tmpl @@ -29,3 +29,5 @@ fields: field: 'state_details' - api_field: 'peerings.updateStrategy' field: 'update_strategy' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/compute/resource_compute_project_default_network_tier.go.tmpl b/mmv1/third_party/terraform/services/compute/resource_compute_project_default_network_tier.go.tmpl index a0db629c9a1d..ff8c4f0bc579 100644 --- a/mmv1/third_party/terraform/services/compute/resource_compute_project_default_network_tier.go.tmpl +++ b/mmv1/third_party/terraform/services/compute/resource_compute_project_default_network_tier.go.tmpl @@ -36,6 +36,7 @@ func ResourceComputeProjectDefaultNetworkTier() *schema.Resource { }, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), tpgresource.DefaultProviderProject, ), @@ -119,7 +120,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/mmv1/third_party/terraform/services/compute/resource_compute_project_metadata.go.tmpl b/mmv1/third_party/terraform/services/compute/resource_compute_project_metadata.go.tmpl index 3919a6ca0dc5..0f1fd7cbe951 100644 --- a/mmv1/third_party/terraform/services/compute/resource_compute_project_metadata.go.tmpl +++ b/mmv1/third_party/terraform/services/compute/resource_compute_project_metadata.go.tmpl @@ -36,6 +36,7 @@ func ResourceComputeProjectMetadata() *schema.Resource { }, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), tpgresource.DefaultProviderProject, ), @@ -56,12 +57,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 { @@ -118,11 +127,23 @@ 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 { - config := meta.(*transport_tpg.Config) + + 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/mmv1/third_party/terraform/services/compute/resource_compute_project_metadata_item.go.tmpl b/mmv1/third_party/terraform/services/compute/resource_compute_project_metadata_item.go.tmpl index a2e0cd299f54..b0d1772ce0c6 100644 --- a/mmv1/third_party/terraform/services/compute/resource_compute_project_metadata_item.go.tmpl +++ b/mmv1/third_party/terraform/services/compute/resource_compute_project_metadata_item.go.tmpl @@ -37,6 +37,7 @@ func ResourceComputeProjectMetadataItem() *schema.Resource { }, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), tpgresource.DefaultProviderProject, ), @@ -59,6 +60,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{ @@ -130,10 +134,20 @@ 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 { @@ -158,7 +172,14 @@ func resourceComputeProjectMetadataItemUpdate(d *schema.ResourceData, meta inter } func resourceComputeProjectMetadataItemDelete(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) + + 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/mmv1/third_party/terraform/services/compute/resource_compute_project_metadata_item_meta.yaml.tmpl b/mmv1/third_party/terraform/services/compute/resource_compute_project_metadata_item_meta.yaml.tmpl index 7a537992ce82..090375662550 100644 --- a/mmv1/third_party/terraform/services/compute/resource_compute_project_metadata_item_meta.yaml.tmpl +++ b/mmv1/third_party/terraform/services/compute/resource_compute_project_metadata_item_meta.yaml.tmpl @@ -13,3 +13,5 @@ fields: - field: 'project' - api_field: 'commonInstanceMetadata.items' field: 'value' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/compute/resource_compute_project_metadata_meta.yaml.tmpl b/mmv1/third_party/terraform/services/compute/resource_compute_project_metadata_meta.yaml.tmpl index eb9602ed55c0..9ec11f835f88 100644 --- a/mmv1/third_party/terraform/services/compute/resource_compute_project_metadata_meta.yaml.tmpl +++ b/mmv1/third_party/terraform/services/compute/resource_compute_project_metadata_meta.yaml.tmpl @@ -11,3 +11,5 @@ fields: - api_field: 'commonInstanceMetadata.items' field: 'metadata' - field: 'project' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/compute/resource_compute_region_instance_group_manager.go.tmpl b/mmv1/third_party/terraform/services/compute/resource_compute_region_instance_group_manager.go.tmpl index 78a20daeef16..c56fedfd59c4 100644 --- a/mmv1/third_party/terraform/services/compute/resource_compute_region_instance_group_manager.go.tmpl +++ b/mmv1/third_party/terraform/services/compute/resource_compute_region_instance_group_manager.go.tmpl @@ -38,6 +38,7 @@ func ResourceComputeRegionInstanceGroupManager() *schema.Resource { }, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), tpgresource.DefaultProviderProject, tpgresource.DefaultProviderRegion, customdiff.ForceNewIfChange("resource_policies.0.workload_policy", ForceNewResourcePoliciesWorkloadPolicyIfNewIsEmpty), @@ -981,6 +982,9 @@ func ResourceComputeRegionInstanceGroupManager() *schema.Resource { }, }, {{- end }} + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), +//UDP schema end }, UseJSONNumber: true, } @@ -1275,10 +1279,20 @@ 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) @@ -1457,7 +1471,14 @@ func resourceComputeRegionInstanceGroupManagerUpdate(d *schema.ResourceData, met } func resourceComputeRegionInstanceGroupManagerDelete(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) + + 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/mmv1/third_party/terraform/services/compute/resource_compute_region_instance_group_manager_meta.yaml.tmpl b/mmv1/third_party/terraform/services/compute/resource_compute_region_instance_group_manager_meta.yaml.tmpl index cdcaeeab84ed..aaeb4cd5b518 100644 --- a/mmv1/third_party/terraform/services/compute/resource_compute_region_instance_group_manager_meta.yaml.tmpl +++ b/mmv1/third_party/terraform/services/compute/resource_compute_region_instance_group_manager_meta.yaml.tmpl @@ -181,3 +181,5 @@ fields: provider_only: true - field: 'wait_for_instances_status' provider_only: true + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/compute/resource_compute_region_instance_template.go.tmpl b/mmv1/third_party/terraform/services/compute/resource_compute_region_instance_template.go.tmpl index 33c2b0afea1a..6fef422b4f04 100644 --- a/mmv1/third_party/terraform/services/compute/resource_compute_region_instance_template.go.tmpl +++ b/mmv1/third_party/terraform/services/compute/resource_compute_region_instance_template.go.tmpl @@ -35,6 +35,7 @@ func ResourceComputeRegionInstanceTemplate() *schema.Resource { }, SchemaVersion: 1, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), tpgresource.DefaultProviderProject, tpgresource.DefaultProviderRegion, resourceComputeInstanceTemplateSourceImageCustomizeDiff, @@ -1274,6 +1275,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, } @@ -1420,7 +1424,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) } @@ -1669,11 +1673,23 @@ 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 { - config := meta.(*transport_tpg.Config) + + 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/mmv1/third_party/terraform/services/compute/resource_compute_region_instance_template_meta.yaml.tmpl b/mmv1/third_party/terraform/services/compute/resource_compute_region_instance_template_meta.yaml.tmpl index 609bf832d441..3f5339dcefaa 100644 --- a/mmv1/third_party/terraform/services/compute/resource_compute_region_instance_template_meta.yaml.tmpl +++ b/mmv1/third_party/terraform/services/compute/resource_compute_region_instance_template_meta.yaml.tmpl @@ -262,3 +262,5 @@ fields: api_field: 'properties.tags.fingerprint' - field: 'terraform_labels' provider_only: true + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/compute/resource_compute_router_interface.go.tmpl b/mmv1/third_party/terraform/services/compute/resource_compute_router_interface.go.tmpl index dd77dff98249..ae79933d3a16 100644 --- a/mmv1/third_party/terraform/services/compute/resource_compute_router_interface.go.tmpl +++ b/mmv1/third_party/terraform/services/compute/resource_compute_router_interface.go.tmpl @@ -27,6 +27,7 @@ func ResourceComputeRouterInterface() *schema.Resource { return &schema.Resource{ Create: resourceComputeRouterInterfaceCreate, Read: resourceComputeRouterInterfaceRead, + Update: resourceComputeRouterInterfaceUpdate, Delete: resourceComputeRouterInterfaceDelete, Importer: &schema.ResourceImporter{ State: resourceComputeRouterInterfaceImportState, @@ -38,6 +39,7 @@ func ResourceComputeRouterInterface() *schema.Resource { }, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), tpgresource.DefaultProviderProject, tpgresource.DefaultProviderRegion, ), @@ -126,6 +128,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, } @@ -300,6 +305,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 } } @@ -309,8 +319,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 { - config := meta.(*transport_tpg.Config) + + 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/mmv1/third_party/terraform/services/compute/resource_compute_router_interface_meta.yaml.tmpl b/mmv1/third_party/terraform/services/compute/resource_compute_router_interface_meta.yaml.tmpl index 622a2b99028a..78eef05fe15d 100644 --- a/mmv1/third_party/terraform/services/compute/resource_compute_router_interface_meta.yaml.tmpl +++ b/mmv1/third_party/terraform/services/compute/resource_compute_router_interface_meta.yaml.tmpl @@ -26,3 +26,5 @@ fields: field: 'subnetwork' - api_field: 'interfaces.linkedVpnTunnel' field: 'vpn_tunnel' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/compute/resource_compute_router_peer.go.tmpl b/mmv1/third_party/terraform/services/compute/resource_compute_router_peer.go.tmpl index 41ec680b5462..94079ce7e53c 100644 --- a/mmv1/third_party/terraform/services/compute/resource_compute_router_peer.go.tmpl +++ b/mmv1/third_party/terraform/services/compute/resource_compute_router_peer.go.tmpl @@ -50,6 +50,7 @@ func ResourceComputeRouterBgpPeer() *schema.Resource { }, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), tpgresource.DefaultProviderProject, ), @@ -372,6 +373,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, } @@ -768,11 +772,21 @@ func resourceComputeRouterBgpPeerRead(d *schema.ResourceData, meta interface{}) if err := d.Set("md5_authentication_key", flattenNestedComputeRouterBgpPeerMd5AuthenticationKey(res["md5AuthenticationKeyName"], d, config)); err != nil { 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 { @@ -1003,6 +1017,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/mmv1/third_party/terraform/services/compute/resource_compute_router_peer_meta.yaml.tmpl b/mmv1/third_party/terraform/services/compute/resource_compute_router_peer_meta.yaml.tmpl index 3ef534b50ba3..c34929973c1c 100644 --- a/mmv1/third_party/terraform/services/compute/resource_compute_router_peer_meta.yaml.tmpl +++ b/mmv1/third_party/terraform/services/compute/resource_compute_router_peer_meta.yaml.tmpl @@ -76,3 +76,5 @@ fields: provider_only: true - field: 'zero_custom_learned_route_priority' provider_only: true + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/compute/resource_compute_security_policy.go.tmpl b/mmv1/third_party/terraform/services/compute/resource_compute_security_policy.go.tmpl index 5657fad7eb40..d46cb89be225 100644 --- a/mmv1/third_party/terraform/services/compute/resource_compute_security_policy.go.tmpl +++ b/mmv1/third_party/terraform/services/compute/resource_compute_security_policy.go.tmpl @@ -65,6 +65,7 @@ func ResourceComputeSecurityPolicy() *schema.Resource { State: resourceSecurityPolicyStateImporter, }, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), tpgresource.DefaultProviderProject, tpgresource.SetLabelsDiff, rulesCustomizeDiff, @@ -731,6 +732,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, } @@ -949,10 +953,20 @@ 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 { @@ -1154,7 +1168,14 @@ func resourceComputeSecurityPolicyUpdate(d *schema.ResourceData, meta interface{ } func resourceComputeSecurityPolicyDelete(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) + + 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/mmv1/third_party/terraform/services/compute/resource_compute_security_policy_meta.yaml.tmpl b/mmv1/third_party/terraform/services/compute/resource_compute_security_policy_meta.yaml.tmpl index 83a9bda86085..fac884a84881 100644 --- a/mmv1/third_party/terraform/services/compute/resource_compute_security_policy_meta.yaml.tmpl +++ b/mmv1/third_party/terraform/services/compute/resource_compute_security_policy_meta.yaml.tmpl @@ -135,4 +135,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/mmv1/third_party/terraform/services/compute/resource_compute_shared_vpc_host_project.go b/mmv1/third_party/terraform/services/compute/resource_compute_shared_vpc_host_project.go index 9768140966b4..fa5b2cf423b1 100644 --- a/mmv1/third_party/terraform/services/compute/resource_compute_shared_vpc_host_project.go +++ b/mmv1/third_party/terraform/services/compute/resource_compute_shared_vpc_host_project.go @@ -5,6 +5,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" @@ -15,6 +16,7 @@ func ResourceComputeSharedVpcHostProject() *schema.Resource { return &schema.Resource{ Create: resourceComputeSharedVpcHostProjectCreate, Read: resourceComputeSharedVpcHostProjectRead, + Update: resourceComputeSharedVpcHostProjectUpdate, Delete: resourceComputeSharedVpcHostProjectDelete, Importer: &schema.ResourceImporter{ State: schema.ImportStatePassthrough, @@ -25,6 +27,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, @@ -32,6 +38,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, } @@ -84,10 +93,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/mmv1/third_party/terraform/services/compute/resource_compute_shared_vpc_host_project_meta.yaml.tmpl b/mmv1/third_party/terraform/services/compute/resource_compute_shared_vpc_host_project_meta.yaml.tmpl index a5a2ad7ab3be..60ea13165497 100644 --- a/mmv1/third_party/terraform/services/compute/resource_compute_shared_vpc_host_project_meta.yaml.tmpl +++ b/mmv1/third_party/terraform/services/compute/resource_compute_shared_vpc_host_project_meta.yaml.tmpl @@ -9,3 +9,5 @@ api_version: 'v1' api_resource_type_kind: 'Project' fields: - field: 'project' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/compute/resource_compute_target_pool.go.tmpl b/mmv1/third_party/terraform/services/compute/resource_compute_target_pool.go.tmpl index 9b0a736e5b8d..ec7d67ca6c03 100644 --- a/mmv1/third_party/terraform/services/compute/resource_compute_target_pool.go.tmpl +++ b/mmv1/third_party/terraform/services/compute/resource_compute_target_pool.go.tmpl @@ -41,6 +41,7 @@ func ResourceComputeTargetPool() *schema.Resource { }, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), tpgresource.DefaultProviderProject, tpgresource.DefaultProviderRegion, ), @@ -140,6 +141,9 @@ func ResourceComputeTargetPool() *schema.Resource { Description: `The resource URL for the security policy associated with this target pool.`, }, {{- end }} + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, UseJSONNumber: true, } @@ -304,6 +308,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 { @@ -552,11 +561,23 @@ func resourceComputeTargetPoolRead(d *schema.ResourceData, meta interface{}) err return fmt.Errorf("Error setting security_policy: %s", err) } {{- end }} + + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil{ + return err + } + return nil } func resourceComputeTargetPoolDelete(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) + + 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/mmv1/third_party/terraform/services/compute/resource_compute_target_pool_meta.yaml.tmpl b/mmv1/third_party/terraform/services/compute/resource_compute_target_pool_meta.yaml.tmpl index 81b695c08317..cea78c62a803 100644 --- a/mmv1/third_party/terraform/services/compute/resource_compute_target_pool_meta.yaml.tmpl +++ b/mmv1/third_party/terraform/services/compute/resource_compute_target_pool_meta.yaml.tmpl @@ -21,3 +21,5 @@ fields: {{- end }} - api_field: 'selfLink' - api_field: 'sessionAffinity' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/compute/resource_project_usage_export_bucket.go.tmpl b/mmv1/third_party/terraform/services/compute/resource_project_usage_export_bucket.go.tmpl index 93e9e8a06025..73473763c928 100644 --- a/mmv1/third_party/terraform/services/compute/resource_project_usage_export_bucket.go.tmpl +++ b/mmv1/third_party/terraform/services/compute/resource_project_usage_export_bucket.go.tmpl @@ -23,6 +23,7 @@ func ResourceProjectUsageBucket() *schema.Resource { return &schema.Resource{ Create: resourceProjectUsageBucketCreate, Read: resourceProjectUsageBucketRead, + Update: resourceProjectUsageBucketUpdate, Delete: resourceProjectUsageBucketDelete, Importer: &schema.ResourceImporter{ State: resourceProjectUsageBucketImportState, @@ -35,6 +36,7 @@ func ResourceProjectUsageBucket() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -57,6 +59,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, } @@ -94,6 +99,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 } @@ -130,7 +140,21 @@ 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/mmv1/third_party/terraform/services/compute/resource_project_usage_export_bucket_meta.yaml.tmpl b/mmv1/third_party/terraform/services/compute/resource_project_usage_export_bucket_meta.yaml.tmpl index 9d229708fa20..c1bf06bc340c 100644 --- a/mmv1/third_party/terraform/services/compute/resource_project_usage_export_bucket_meta.yaml.tmpl +++ b/mmv1/third_party/terraform/services/compute/resource_project_usage_export_bucket_meta.yaml.tmpl @@ -13,3 +13,5 @@ fields: - api_field: 'usageExportLocation.reportNamePrefix' field: 'prefix' - field: 'project' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/container/resource_container_cluster.go.tmpl b/mmv1/third_party/terraform/services/container/resource_container_cluster.go.tmpl index b766c3131c28..2647439338d3 100644 --- a/mmv1/third_party/terraform/services/container/resource_container_cluster.go.tmpl +++ b/mmv1/third_party/terraform/services/container/resource_container_cluster.go.tmpl @@ -231,6 +231,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), @@ -2863,6 +2864,9 @@ func ResourceContainerCluster() *schema.Resource { }, }, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, } } @@ -3857,10 +3861,20 @@ 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 { @@ -5654,7 +5668,14 @@ func resourceContainerClusterUpdate(d *schema.ResourceData, meta interface{}) er } func resourceContainerClusterDelete(d *schema.ResourceData, meta interface{}) error { - if d.Get("deletion_protection").(bool) { + + 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.") } config := meta.(*transport_tpg.Config) diff --git a/mmv1/third_party/terraform/services/container/resource_container_cluster_meta.yaml.tmpl b/mmv1/third_party/terraform/services/container/resource_container_cluster_meta.yaml.tmpl index 495fad013924..471875e99261 100644 --- a/mmv1/third_party/terraform/services/container/resource_container_cluster_meta.yaml.tmpl +++ b/mmv1/third_party/terraform/services/container/resource_container_cluster_meta.yaml.tmpl @@ -881,3 +881,5 @@ fields: - api_field: 'workloadAltsConfig.enableAlts' {{- end }} - api_field: 'workloadIdentityConfig.workloadPool' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/container/resource_container_node_pool.go.tmpl b/mmv1/third_party/terraform/services/container/resource_container_node_pool.go.tmpl index 2715948f80ce..7d99509454ea 100644 --- a/mmv1/third_party/terraform/services/container/resource_container_node_pool.go.tmpl +++ b/mmv1/third_party/terraform/services/container/resource_container_node_pool.go.tmpl @@ -201,6 +201,7 @@ func ResourceContainerNodePool() *schema.Resource { }, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), tpgresource.DefaultProviderProject, resourceNodeConfigEmptyGuestAccelerator, nodePoolAcceleratorNetworkProfileCustomizeDiff, @@ -235,6 +236,9 @@ func ResourceContainerNodePool() *schema.Resource { Type: schema.TypeString, Computed: true, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }), } } @@ -940,11 +944,21 @@ func resourceContainerNodePoolRead(d *schema.ResourceData, meta interface{}) err if err := d.Set("project", nodePoolInfo.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 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 { @@ -984,6 +998,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/mmv1/third_party/terraform/services/container/resource_container_node_pool_meta.yaml.tmpl b/mmv1/third_party/terraform/services/container/resource_container_node_pool_meta.yaml.tmpl index 064962f9616a..3e016d02753b 100644 --- a/mmv1/third_party/terraform/services/container/resource_container_node_pool_meta.yaml.tmpl +++ b/mmv1/third_party/terraform/services/container/resource_container_node_pool_meta.yaml.tmpl @@ -334,3 +334,5 @@ fields: - api_field: 'upgradeSettings.maxUnavailable' - api_field: 'upgradeSettings.strategy' - api_field: 'version' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/containeraws/resource_container_aws_cluster.go.tmpl b/mmv1/third_party/terraform/services/containeraws/resource_container_aws_cluster.go.tmpl index b1206dee38fd..52b4109a9c98 100644 --- a/mmv1/third_party/terraform/services/containeraws/resource_container_aws_cluster.go.tmpl +++ b/mmv1/third_party/terraform/services/containeraws/resource_container_aws_cluster.go.tmpl @@ -33,6 +33,7 @@ func ResourceContainerAwsCluster() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, tpgresource.SetAnnotationsDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -186,6 +187,9 @@ func ResourceContainerAwsCluster() *schema.Resource { Description: "Output only. Workload Identity settings.", Elem: ContainerAwsClusterWorkloadIdentityConfigSchema(), }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, } } @@ -828,10 +832,20 @@ func resourceContainerAwsClusterRead(d *schema.ResourceData, meta interface{}) e if err = d.Set("workload_identity_config", flattenContainerAwsClusterWorkloadIdentityConfig(res.WorkloadIdentityConfig)); err != nil { 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 { @@ -888,6 +902,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/mmv1/third_party/terraform/services/containeraws/resource_container_aws_cluster_meta.yaml.tmpl b/mmv1/third_party/terraform/services/containeraws/resource_container_aws_cluster_meta.yaml.tmpl index f25424849a69..9e4b6e9019c4 100644 --- a/mmv1/third_party/terraform/services/containeraws/resource_container_aws_cluster_meta.yaml.tmpl +++ b/mmv1/third_party/terraform/services/containeraws/resource_container_aws_cluster_meta.yaml.tmpl @@ -60,3 +60,5 @@ fields: - api_field: 'workloadIdentityConfig.identityProvider' - api_field: 'workloadIdentityConfig.issuerUri' - api_field: 'workloadIdentityConfig.workloadPool' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/containeraws/resource_container_aws_node_pool.go.tmpl b/mmv1/third_party/terraform/services/containeraws/resource_container_aws_node_pool.go.tmpl index d8410aea4021..f5818ad0e6b5 100644 --- a/mmv1/third_party/terraform/services/containeraws/resource_container_aws_node_pool.go.tmpl +++ b/mmv1/third_party/terraform/services/containeraws/resource_container_aws_node_pool.go.tmpl @@ -36,6 +36,7 @@ func ResourceContainerAwsNodePool() *schema.Resource { dcl.ResourceContainerAwsNodePoolCustomizeDiffFunc, {{- end }} tpgresource.SetAnnotationsDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -184,6 +185,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 }, } } @@ -751,10 +756,20 @@ func resourceContainerAwsNodePoolRead(d *schema.ResourceData, meta interface{}) if err = d.Set("update_time", res.UpdateTime); err != nil { 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 { @@ -810,6 +825,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/mmv1/third_party/terraform/services/containeraws/resource_container_aws_node_pool_meta.yaml.tmpl b/mmv1/third_party/terraform/services/containeraws/resource_container_aws_node_pool_meta.yaml.tmpl index 17c7c8cf1cbf..e090ad4c4bf1 100644 --- a/mmv1/third_party/terraform/services/containeraws/resource_container_aws_node_pool_meta.yaml.tmpl +++ b/mmv1/third_party/terraform/services/containeraws/resource_container_aws_node_pool_meta.yaml.tmpl @@ -57,3 +57,5 @@ fields: - api_field: 'updateSettings.surgeSettings.maxUnavailable' - api_field: 'updateTime' - api_field: 'version' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/containerazure/resource_container_azure_client.go b/mmv1/third_party/terraform/services/containerazure/resource_container_azure_client.go index 1075ed9c0dca..2889aa754114 100644 --- a/mmv1/third_party/terraform/services/containerazure/resource_container_azure_client.go +++ b/mmv1/third_party/terraform/services/containerazure/resource_container_azure_client.go @@ -21,6 +21,7 @@ func ResourceContainerAzureClient() *schema.Resource { return &schema.Resource{ Create: resourceContainerAzureClientCreate, Read: resourceContainerAzureClientRead, + Update: resourceContainerAzureClientUpdate, Delete: resourceContainerAzureClientDelete, Importer: &schema.ResourceImporter{ @@ -33,6 +34,7 @@ func ResourceContainerAzureClient() *schema.Resource { }, CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -90,6 +92,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 }, } } @@ -208,10 +213,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/mmv1/third_party/terraform/services/containerazure/resource_container_azure_client_meta.yaml b/mmv1/third_party/terraform/services/containerazure/resource_container_azure_client_meta.yaml index 733b8c81196f..25fd9e89cf2e 100644 --- a/mmv1/third_party/terraform/services/containerazure/resource_container_azure_client_meta.yaml +++ b/mmv1/third_party/terraform/services/containerazure/resource_container_azure_client_meta.yaml @@ -12,3 +12,5 @@ fields: - field: 'project' - api_field: 'tenantId' - api_field: 'uid' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/containerazure/resource_container_azure_cluster.go.tmpl b/mmv1/third_party/terraform/services/containerazure/resource_container_azure_cluster.go.tmpl index f21a48531609..c108e8009589 100644 --- a/mmv1/third_party/terraform/services/containerazure/resource_container_azure_cluster.go.tmpl +++ b/mmv1/third_party/terraform/services/containerazure/resource_container_azure_cluster.go.tmpl @@ -33,6 +33,7 @@ func ResourceContainerAzureCluster() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, tpgresource.SetAnnotationsDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -204,6 +205,9 @@ func ResourceContainerAzureCluster() *schema.Resource { Description: "Output only. Workload Identity settings.", Elem: ContainerAzureClusterWorkloadIdentityConfigSchema(), }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, } } @@ -739,10 +743,20 @@ func resourceContainerAzureClusterRead(d *schema.ResourceData, meta interface{}) if err = d.Set("workload_identity_config", flattenContainerAzureClusterWorkloadIdentityConfig(res.WorkloadIdentityConfig)); err != nil { 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 { @@ -801,6 +815,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/mmv1/third_party/terraform/services/containerazure/resource_container_azure_cluster_meta.yaml.tmpl b/mmv1/third_party/terraform/services/containerazure/resource_container_azure_cluster_meta.yaml.tmpl index 54598e64ffe5..9dbe855b6ece 100644 --- a/mmv1/third_party/terraform/services/containerazure/resource_container_azure_cluster_meta.yaml.tmpl +++ b/mmv1/third_party/terraform/services/containerazure/resource_container_azure_cluster_meta.yaml.tmpl @@ -48,3 +48,5 @@ fields: - api_field: 'workloadIdentityConfig.identityProvider' - api_field: 'workloadIdentityConfig.issuerUri' - api_field: 'workloadIdentityConfig.workloadPool' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/containerazure/resource_container_azure_node_pool.go.tmpl b/mmv1/third_party/terraform/services/containerazure/resource_container_azure_node_pool.go.tmpl index e4e8a904ee08..da7eafce4355 100644 --- a/mmv1/third_party/terraform/services/containerazure/resource_container_azure_node_pool.go.tmpl +++ b/mmv1/third_party/terraform/services/containerazure/resource_container_azure_node_pool.go.tmpl @@ -33,6 +33,7 @@ func ResourceContainerAzureNodePool() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, tpgresource.SetAnnotationsDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -170,6 +171,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 }, } } @@ -491,10 +495,20 @@ func resourceContainerAzureNodePoolRead(d *schema.ResourceData, meta interface{} if err = d.Set("update_time", res.UpdateTime); err != nil { 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 { @@ -549,6 +563,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/mmv1/third_party/terraform/services/containerazure/resource_container_azure_node_pool_meta.yaml.tmpl b/mmv1/third_party/terraform/services/containerazure/resource_container_azure_node_pool_meta.yaml.tmpl index ef92715fe513..7a81177055ab 100644 --- a/mmv1/third_party/terraform/services/containerazure/resource_container_azure_node_pool_meta.yaml.tmpl +++ b/mmv1/third_party/terraform/services/containerazure/resource_container_azure_node_pool_meta.yaml.tmpl @@ -34,3 +34,5 @@ fields: - api_field: 'uid' - api_field: 'updateTime' - api_field: 'version' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/dataflow/resource_dataflow_flex_template_job.go.tmpl b/mmv1/third_party/terraform/services/dataflow/resource_dataflow_flex_template_job.go.tmpl index a87a61fd4036..5cd39ca0058b 100644 --- a/mmv1/third_party/terraform/services/dataflow/resource_dataflow_flex_template_job.go.tmpl +++ b/mmv1/third_party/terraform/services/dataflow/resource_dataflow_flex_template_job.go.tmpl @@ -259,6 +259,9 @@ func ResourceDataflowFlexTemplateJob() *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, } @@ -523,6 +526,11 @@ func resourceDataflowFlexTemplateJobRead(d *schema.ResourceData, meta interface{ d.SetId("") return nil } + + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil{ + return err + } + return nil } @@ -571,6 +579,11 @@ func resourceDataflowFlexTemplateJobUpdate(d *schema.ResourceData, meta interfac if resourceDataflowJobIsVirtualUpdate(d, ResourceDataflowFlexTemplateJob().Schema) { return nil } + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceDataflowFlexTemplateJob) { + return ResourceDataflowFlexTemplateJob().Read(d, meta) + } + if jobHasUpdate(d, ResourceDataflowFlexTemplateJob().Schema) { config := meta.(*transport_tpg.Config) @@ -637,6 +650,13 @@ func resourceDataflowFlexTemplateJobUpdate(d *schema.ResourceData, meta interfac } func resourceDataflowFlexTemplateJobDelete(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/mmv1/third_party/terraform/services/dataflow/resource_dataflow_flex_template_job_meta.yaml.tmpl b/mmv1/third_party/terraform/services/dataflow/resource_dataflow_flex_template_job_meta.yaml.tmpl index 46885b19677f..9947a9660d9b 100644 --- a/mmv1/third_party/terraform/services/dataflow/resource_dataflow_flex_template_job_meta.yaml.tmpl +++ b/mmv1/third_party/terraform/services/dataflow/resource_dataflow_flex_template_job_meta.yaml.tmpl @@ -37,4 +37,6 @@ fields: provider_only: true - api_field: 'transformNameMapping' - api_field: 'type' + - field: 'deletion_policy' + provider_only: true {{ end }} \ No newline at end of file diff --git a/mmv1/third_party/terraform/services/dataflow/resource_dataflow_job.go b/mmv1/third_party/terraform/services/dataflow/resource_dataflow_job.go index fcf75950664e..e45cd52d4979 100644 --- a/mmv1/third_party/terraform/services/dataflow/resource_dataflow_job.go +++ b/mmv1/third_party/terraform/services/dataflow/resource_dataflow_job.go @@ -91,6 +91,7 @@ func ResourceDataflowJob() *schema.Resource { Update: schema.DefaultTimeout(10 * time.Minute), }, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), tpgresource.SetLabelsDiff, resourceDataflowJobTypeCustomizeDiff, ), @@ -278,6 +279,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, } @@ -445,6 +449,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 } @@ -455,6 +463,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) @@ -511,6 +523,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/mmv1/third_party/terraform/services/dataflow/resource_dataflow_job_meta.yaml b/mmv1/third_party/terraform/services/dataflow/resource_dataflow_job_meta.yaml index 3e0b303eaf15..6492fffc296d 100644 --- a/mmv1/third_party/terraform/services/dataflow/resource_dataflow_job_meta.yaml +++ b/mmv1/third_party/terraform/services/dataflow/resource_dataflow_job_meta.yaml @@ -31,3 +31,5 @@ fields: - api_field: 'transformNameMapping' - api_field: 'type' - field: 'zone' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/dataplex/resource_dataplex_asset.go b/mmv1/third_party/terraform/services/dataplex/resource_dataplex_asset.go index 7bfc3c68bff4..d5bca65607c0 100644 --- a/mmv1/third_party/terraform/services/dataplex/resource_dataplex_asset.go +++ b/mmv1/third_party/terraform/services/dataplex/resource_dataplex_asset.go @@ -36,6 +36,7 @@ func ResourceDataplexAsset() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, tpgresource.SetLabelsDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -166,6 +167,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 }, } } @@ -573,9 +577,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 { @@ -628,6 +641,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/mmv1/third_party/terraform/services/dataplex/resource_dataplex_asset_meta.yaml b/mmv1/third_party/terraform/services/dataplex/resource_dataplex_asset_meta.yaml index dce96244aa71..642ce793fc5f 100644 --- a/mmv1/third_party/terraform/services/dataplex/resource_dataplex_asset_meta.yaml +++ b/mmv1/third_party/terraform/services/dataplex/resource_dataplex_asset_meta.yaml @@ -48,3 +48,5 @@ fields: provider_only: true - api_field: 'uid' - api_field: 'updateTime' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/dataplex/resource_dataplex_lake.go b/mmv1/third_party/terraform/services/dataplex/resource_dataplex_lake.go index 16e8e03ef66b..2823388170d2 100644 --- a/mmv1/third_party/terraform/services/dataplex/resource_dataplex_lake.go +++ b/mmv1/third_party/terraform/services/dataplex/resource_dataplex_lake.go @@ -36,6 +36,7 @@ func ResourceDataplexLake() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, tpgresource.SetLabelsDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -144,6 +145,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 }, } } @@ -356,9 +360,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 { @@ -408,6 +421,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/mmv1/third_party/terraform/services/dataplex/resource_dataplex_lake_meta.yaml b/mmv1/third_party/terraform/services/dataplex/resource_dataplex_lake_meta.yaml index 977e7aaeb14c..6a5317633da5 100644 --- a/mmv1/third_party/terraform/services/dataplex/resource_dataplex_lake_meta.yaml +++ b/mmv1/third_party/terraform/services/dataplex/resource_dataplex_lake_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/mmv1/third_party/terraform/services/dataplex/resource_dataplex_zone.go b/mmv1/third_party/terraform/services/dataplex/resource_dataplex_zone.go index 76bd82560dbc..11456271f9b9 100644 --- a/mmv1/third_party/terraform/services/dataplex/resource_dataplex_zone.go +++ b/mmv1/third_party/terraform/services/dataplex/resource_dataplex_zone.go @@ -36,6 +36,7 @@ func ResourceDataplexZone() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, tpgresource.SetLabelsDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -154,6 +155,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 }, } } @@ -445,9 +449,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 { @@ -500,6 +513,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/mmv1/third_party/terraform/services/dataplex/resource_dataplex_zone_meta.yaml b/mmv1/third_party/terraform/services/dataplex/resource_dataplex_zone_meta.yaml index 45cc3eda9aa0..f8177d1da57d 100644 --- a/mmv1/third_party/terraform/services/dataplex/resource_dataplex_zone_meta.yaml +++ b/mmv1/third_party/terraform/services/dataplex/resource_dataplex_zone_meta.yaml @@ -34,3 +34,5 @@ fields: - api_field: 'type' - api_field: 'uid' - api_field: 'updateTime' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/dataproc/resource_dataproc_cluster.go b/mmv1/third_party/terraform/services/dataproc/resource_dataproc_cluster.go index a089c5fb9dbe..9a1feb7df5a9 100644 --- a/mmv1/third_party/terraform/services/dataproc/resource_dataproc_cluster.go +++ b/mmv1/third_party/terraform/services/dataproc/resource_dataproc_cluster.go @@ -199,6 +199,7 @@ func ResourceDataprocCluster() *schema.Resource { }, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), tpgresource.DefaultProviderProject, // User labels are not supported in Dataproc Virtual Cluster tpgresource.SetLabelsDiffWithoutAttributionLabel, @@ -2036,6 +2037,9 @@ by Dataproc`, }, }, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, UseJSONNumber: true, } @@ -3010,6 +3014,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 { @@ -3201,6 +3210,10 @@ func resourceDataprocClusterRead(d *schema.ResourceData, meta interface{}) error return err } + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil { + return err + } + return nil } @@ -3842,6 +3855,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/mmv1/third_party/terraform/services/dataproc/resource_dataproc_cluster_meta.yaml b/mmv1/third_party/terraform/services/dataproc/resource_dataproc_cluster_meta.yaml index 7a5bef75c48a..995380a9c134 100644 --- a/mmv1/third_party/terraform/services/dataproc/resource_dataproc_cluster_meta.yaml +++ b/mmv1/third_party/terraform/services/dataproc/resource_dataproc_cluster_meta.yaml @@ -152,3 +152,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/mmv1/third_party/terraform/services/dataproc/resource_dataproc_job.go b/mmv1/third_party/terraform/services/dataproc/resource_dataproc_job.go index 9f09bb3756b6..11ddb6352d84 100644 --- a/mmv1/third_party/terraform/services/dataproc/resource_dataproc_job.go +++ b/mmv1/third_party/terraform/services/dataproc/resource_dataproc_job.go @@ -32,6 +32,7 @@ func ResourceDataprocJob() *schema.Resource { }, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), tpgresource.DefaultProviderProject, tpgresource.SetLabelsDiff, ), @@ -213,6 +214,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, } @@ -413,10 +417,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/mmv1/third_party/terraform/services/dataproc/resource_dataproc_job_meta.yaml b/mmv1/third_party/terraform/services/dataproc/resource_dataproc_job_meta.yaml index 409d58798690..038263234ade 100644 --- a/mmv1/third_party/terraform/services/dataproc/resource_dataproc_job_meta.yaml +++ b/mmv1/third_party/terraform/services/dataproc/resource_dataproc_job_meta.yaml @@ -75,3 +75,5 @@ fields: provider_only: true - field: 'wait_for_completion' provider_only: true + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/dataproc/resource_dataproc_workflow_template.go.tmpl b/mmv1/third_party/terraform/services/dataproc/resource_dataproc_workflow_template.go.tmpl index 2ca6fad78138..96e354b52f58 100644 --- a/mmv1/third_party/terraform/services/dataproc/resource_dataproc_workflow_template.go.tmpl +++ b/mmv1/third_party/terraform/services/dataproc/resource_dataproc_workflow_template.go.tmpl @@ -32,6 +32,7 @@ func ResourceDataprocWorkflowTemplate() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, tpgresource.SetLabelsDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), SchemaVersion: 1, StateUpgraders: []schema.StateUpgrader{ @@ -147,6 +148,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 }, } } @@ -2322,6 +2326,11 @@ func resourceDataprocWorkflowTemplateRead(d *schema.ResourceData, meta interface if err = d.Set("update_time", res.UpdateTime); err != nil { return fmt.Errorf("error setting update_time in state: %s", err) } + + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil{ + return err + } + return nil } @@ -2332,6 +2341,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/mmv1/third_party/terraform/services/dataproc/resource_dataproc_workflow_template_meta.yaml.tmpl b/mmv1/third_party/terraform/services/dataproc/resource_dataproc_workflow_template_meta.yaml.tmpl index 35bb465f38b0..d5f866670807 100644 --- a/mmv1/third_party/terraform/services/dataproc/resource_dataproc_workflow_template_meta.yaml.tmpl +++ b/mmv1/third_party/terraform/services/dataproc/resource_dataproc_workflow_template_meta.yaml.tmpl @@ -187,3 +187,5 @@ fields: provider_only: true - api_field: 'updateTime' - api_field: 'version' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/dns/resource_dns_record_set.go b/mmv1/third_party/terraform/services/dns/resource_dns_record_set.go index 5c6d4efff85d..7eda84568fbf 100644 --- a/mmv1/third_party/terraform/services/dns/resource_dns_record_set.go +++ b/mmv1/third_party/terraform/services/dns/resource_dns_record_set.go @@ -97,6 +97,7 @@ func ResourceDnsRecordSet() *schema.Resource { }, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), tpgresource.DefaultProviderProject, ), @@ -243,6 +244,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, } @@ -477,10 +481,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 { @@ -567,6 +582,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/mmv1/third_party/terraform/services/dns/resource_dns_record_set_meta.yaml.tmpl b/mmv1/third_party/terraform/services/dns/resource_dns_record_set_meta.yaml.tmpl index 49cb9682f4f9..7f53537d4df1 100644 --- a/mmv1/third_party/terraform/services/dns/resource_dns_record_set_meta.yaml.tmpl +++ b/mmv1/third_party/terraform/services/dns/resource_dns_record_set_meta.yaml.tmpl @@ -56,3 +56,5 @@ fields: - api_field: 'rrdatas' - api_field: 'ttl' - api_field: 'type' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/firebaserules/resource_firebaserules_release.go b/mmv1/third_party/terraform/services/firebaserules/resource_firebaserules_release.go index 2da190a1def1..eafcb089767d 100644 --- a/mmv1/third_party/terraform/services/firebaserules/resource_firebaserules_release.go +++ b/mmv1/third_party/terraform/services/firebaserules/resource_firebaserules_release.go @@ -20,6 +20,7 @@ func ResourceFirebaserulesRelease() *schema.Resource { return &schema.Resource{ Create: resourceFirebaserulesReleaseCreate, Read: resourceFirebaserulesReleaseRead, + Update: resourceFirebaserulesReleaseUpdate, Delete: resourceFirebaserulesReleaseDelete, Importer: &schema.ResourceImporter{ @@ -32,6 +33,7 @@ func ResourceFirebaserulesRelease() *schema.Resource { }, CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -76,6 +78,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 }, } } @@ -184,10 +189,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/mmv1/third_party/terraform/services/firebaserules/resource_firebaserules_release_meta.yaml b/mmv1/third_party/terraform/services/firebaserules/resource_firebaserules_release_meta.yaml index 5caf910a758c..bef01cb66c6f 100644 --- a/mmv1/third_party/terraform/services/firebaserules/resource_firebaserules_release_meta.yaml +++ b/mmv1/third_party/terraform/services/firebaserules/resource_firebaserules_release_meta.yaml @@ -10,3 +10,5 @@ fields: - field: 'project' - api_field: 'rulesetName' - api_field: 'updateTime' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/firebaserules/resource_firebaserules_ruleset.go b/mmv1/third_party/terraform/services/firebaserules/resource_firebaserules_ruleset.go index 2059d81bca50..b60d01987ff2 100644 --- a/mmv1/third_party/terraform/services/firebaserules/resource_firebaserules_ruleset.go +++ b/mmv1/third_party/terraform/services/firebaserules/resource_firebaserules_ruleset.go @@ -20,6 +20,7 @@ func ResourceFirebaserulesRuleset() *schema.Resource { return &schema.Resource{ Create: resourceFirebaserulesRulesetCreate, Read: resourceFirebaserulesRulesetRead, + Update: resourceFirebaserulesRulesetUpdate, Delete: resourceFirebaserulesRulesetDelete, Importer: &schema.ResourceImporter{ @@ -32,6 +33,7 @@ func ResourceFirebaserulesRuleset() *schema.Resource { }, CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -71,6 +73,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 }, } } @@ -247,10 +252,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/mmv1/third_party/terraform/services/firebaserules/resource_firebaserules_ruleset_meta.yaml b/mmv1/third_party/terraform/services/firebaserules/resource_firebaserules_ruleset_meta.yaml index 32dfa7a247b7..45bc3811176c 100644 --- a/mmv1/third_party/terraform/services/firebaserules/resource_firebaserules_ruleset_meta.yaml +++ b/mmv1/third_party/terraform/services/firebaserules/resource_firebaserules_ruleset_meta.yaml @@ -12,3 +12,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/mmv1/third_party/terraform/services/gkehub/resource_gke_hub_feature_membership.go.tmpl b/mmv1/third_party/terraform/services/gkehub/resource_gke_hub_feature_membership.go.tmpl index b551a9291458..dcda4a312283 100644 --- a/mmv1/third_party/terraform/services/gkehub/resource_gke_hub_feature_membership.go.tmpl +++ b/mmv1/third_party/terraform/services/gkehub/resource_gke_hub_feature_membership.go.tmpl @@ -100,6 +100,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 }, } } @@ -895,10 +898,20 @@ func resourceGkeHubFeatureMembershipRead(d *schema.ResourceData, meta interface{ if err = d.Set("project", res.Project); err != nil { 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 { @@ -956,6 +969,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/mmv1/third_party/terraform/services/gkehub/resource_gke_hub_feature_membership_meta.yaml.tmpl b/mmv1/third_party/terraform/services/gkehub/resource_gke_hub_feature_membership_meta.yaml.tmpl index 834d4d26de9d..713ff0903129 100644 --- a/mmv1/third_party/terraform/services/gkehub/resource_gke_hub_feature_membership_meta.yaml.tmpl +++ b/mmv1/third_party/terraform/services/gkehub/resource_gke_hub_feature_membership_meta.yaml.tmpl @@ -76,3 +76,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/mmv1/third_party/terraform/services/logging/resource_logging_billing_account_bucket_config_meta.yaml b/mmv1/third_party/terraform/services/logging/resource_logging_billing_account_bucket_config_meta.yaml index 6e63d27557f0..b000cffa09bc 100644 --- a/mmv1/third_party/terraform/services/logging/resource_logging_billing_account_bucket_config_meta.yaml +++ b/mmv1/third_party/terraform/services/logging/resource_logging_billing_account_bucket_config_meta.yaml @@ -19,3 +19,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/mmv1/third_party/terraform/services/logging/resource_logging_billing_account_sink.go b/mmv1/third_party/terraform/services/logging/resource_logging_billing_account_sink.go index c4a2e679e8ac..884a90a2c873 100644 --- a/mmv1/third_party/terraform/services/logging/resource_logging_billing_account_sink.go +++ b/mmv1/third_party/terraform/services/logging/resource_logging_billing_account_sink.go @@ -3,6 +3,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" @@ -19,6 +20,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{ @@ -65,10 +69,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 { @@ -88,6 +101,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/mmv1/third_party/terraform/services/logging/resource_logging_billing_account_sink_meta.yaml b/mmv1/third_party/terraform/services/logging/resource_logging_billing_account_sink_meta.yaml index b32994002366..5be76c2eeab0 100644 --- a/mmv1/third_party/terraform/services/logging/resource_logging_billing_account_sink_meta.yaml +++ b/mmv1/third_party/terraform/services/logging/resource_logging_billing_account_sink_meta.yaml @@ -18,3 +18,5 @@ fields: - api_field: 'filter' - api_field: 'name' - api_field: 'writerIdentity' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/logging/resource_logging_bucket_config.go b/mmv1/third_party/terraform/services/logging/resource_logging_bucket_config.go index 6aa57eb95346..4a8fedc7e281 100644 --- a/mmv1/third_party/terraform/services/logging/resource_logging_bucket_config.go +++ b/mmv1/third_party/terraform/services/logging/resource_logging_bucket_config.go @@ -112,6 +112,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) @@ -130,6 +133,7 @@ func ResourceLoggingBucketConfig(parentType string, parentSpecificSchema map[str Schema: tpgresource.MergeSchemas(loggingBucketConfigSchema, parentSpecificSchema), UseJSONNumber: true, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), tpgresource.DefaultProviderProject, ), } @@ -319,10 +323,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 { @@ -376,6 +399,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/mmv1/third_party/terraform/services/logging/resource_logging_folder_bucket_config_meta.yaml b/mmv1/third_party/terraform/services/logging/resource_logging_folder_bucket_config_meta.yaml index ff41624155f3..5086c7b4208f 100644 --- a/mmv1/third_party/terraform/services/logging/resource_logging_folder_bucket_config_meta.yaml +++ b/mmv1/third_party/terraform/services/logging/resource_logging_folder_bucket_config_meta.yaml @@ -19,3 +19,5 @@ fields: - field: 'location' - api_field: 'name' - api_field: 'retentionDays' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/logging/resource_logging_folder_sink.go b/mmv1/third_party/terraform/services/logging/resource_logging_folder_sink.go index 8adff2e77501..052514d90674 100644 --- a/mmv1/third_party/terraform/services/logging/resource_logging_folder_sink.go +++ b/mmv1/third_party/terraform/services/logging/resource_logging_folder_sink.go @@ -4,6 +4,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" @@ -18,6 +19,9 @@ func ResourceLoggingFolderSink() *schema.Resource { Delete: resourceLoggingFolderSinkDelete, Update: resourceLoggingFolderSinkUpdate, Schema: resourceLoggingSinkSchema(), + CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), + ), Importer: &schema.ResourceImporter{ State: resourceLoggingSinkImportState("folder"), }, @@ -94,10 +98,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 { @@ -117,6 +130,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/mmv1/third_party/terraform/services/logging/resource_logging_folder_sink_meta.yaml b/mmv1/third_party/terraform/services/logging/resource_logging_folder_sink_meta.yaml index 35869fd00a44..6c2476e3a80e 100644 --- a/mmv1/third_party/terraform/services/logging/resource_logging_folder_sink_meta.yaml +++ b/mmv1/third_party/terraform/services/logging/resource_logging_folder_sink_meta.yaml @@ -20,3 +20,5 @@ fields: - api_field: 'interceptChildren' - api_field: 'name' - api_field: 'writerIdentity' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/logging/resource_logging_organization_bucket_config_meta.yaml b/mmv1/third_party/terraform/services/logging/resource_logging_organization_bucket_config_meta.yaml index a1643a2c6f45..47c577d8d356 100644 --- a/mmv1/third_party/terraform/services/logging/resource_logging_organization_bucket_config_meta.yaml +++ b/mmv1/third_party/terraform/services/logging/resource_logging_organization_bucket_config_meta.yaml @@ -19,3 +19,5 @@ fields: - api_field: 'name' - field: 'organization' - api_field: 'retentionDays' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/logging/resource_logging_organization_sink.go b/mmv1/third_party/terraform/services/logging/resource_logging_organization_sink.go index 213dceb7b353..61c83572daa9 100644 --- a/mmv1/third_party/terraform/services/logging/resource_logging_organization_sink.go +++ b/mmv1/third_party/terraform/services/logging/resource_logging_organization_sink.go @@ -4,6 +4,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" @@ -17,6 +18,9 @@ func ResourceLoggingOrganizationSink() *schema.Resource { Delete: resourceLoggingOrganizationSinkDelete, Update: resourceLoggingOrganizationSinkUpdate, Schema: resourceLoggingSinkSchema(), + CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), + ), Importer: &schema.ResourceImporter{ State: resourceLoggingSinkImportState("org_id"), }, @@ -93,10 +97,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 { @@ -116,6 +129,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/mmv1/third_party/terraform/services/logging/resource_logging_organization_sink_meta.yaml b/mmv1/third_party/terraform/services/logging/resource_logging_organization_sink_meta.yaml index 07c08cd01e42..19610a15ffca 100644 --- a/mmv1/third_party/terraform/services/logging/resource_logging_organization_sink_meta.yaml +++ b/mmv1/third_party/terraform/services/logging/resource_logging_organization_sink_meta.yaml @@ -20,3 +20,5 @@ fields: - api_field: 'name' - field: 'org_id' - api_field: 'writerIdentity' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/logging/resource_logging_project_bucket_config.go b/mmv1/third_party/terraform/services/logging/resource_logging_project_bucket_config.go index 398fa48bfb0e..9eca5da97454 100644 --- a/mmv1/third_party/terraform/services/logging/resource_logging_project_bucket_config.go +++ b/mmv1/third_party/terraform/services/logging/resource_logging_project_bucket_config.go @@ -129,6 +129,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/mmv1/third_party/terraform/services/logging/resource_logging_project_bucket_config_meta.yaml b/mmv1/third_party/terraform/services/logging/resource_logging_project_bucket_config_meta.yaml index 5345dfd58438..c7b5c3dd67f4 100644 --- a/mmv1/third_party/terraform/services/logging/resource_logging_project_bucket_config_meta.yaml +++ b/mmv1/third_party/terraform/services/logging/resource_logging_project_bucket_config_meta.yaml @@ -21,3 +21,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/mmv1/third_party/terraform/services/logging/resource_logging_project_sink.go b/mmv1/third_party/terraform/services/logging/resource_logging_project_sink.go index 607238c5e267..c9fec7cf5da8 100644 --- a/mmv1/third_party/terraform/services/logging/resource_logging_project_sink.go +++ b/mmv1/third_party/terraform/services/logging/resource_logging_project_sink.go @@ -10,6 +10,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" ) @@ -17,12 +18,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"), }, @@ -171,10 +175,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 { @@ -205,6 +219,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/mmv1/third_party/terraform/services/logging/resource_logging_project_sink_meta.yaml b/mmv1/third_party/terraform/services/logging/resource_logging_project_sink_meta.yaml index 92db479c651f..14a59668903e 100644 --- a/mmv1/third_party/terraform/services/logging/resource_logging_project_sink_meta.yaml +++ b/mmv1/third_party/terraform/services/logging/resource_logging_project_sink_meta.yaml @@ -20,3 +20,5 @@ fields: - field: 'project' - field: 'unique_writer_identity' - api_field: 'writerIdentity' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/logging/resource_logging_sink.go b/mmv1/third_party/terraform/services/logging/resource_logging_sink.go index 98a9ebf339cc..4553c12ce6c7 100644 --- a/mmv1/third_party/terraform/services/logging/resource_logging_sink.go +++ b/mmv1/third_party/terraform/services/logging/resource_logging_sink.go @@ -4,6 +4,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" ) @@ -100,6 +102,10 @@ func resourceLoggingSinkSchema() map[string]*schema.Schema { }, }, }, + + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end } } diff --git a/mmv1/third_party/terraform/services/monitoring/resource_monitoring_dashboard.go b/mmv1/third_party/terraform/services/monitoring/resource_monitoring_dashboard.go index ca5bbcd94e7e..fc650055dba5 100644 --- a/mmv1/third_party/terraform/services/monitoring/resource_monitoring_dashboard.go +++ b/mmv1/third_party/terraform/services/monitoring/resource_monitoring_dashboard.go @@ -76,6 +76,7 @@ func ResourceMonitoringDashboard() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -97,6 +98,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, } @@ -184,10 +188,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 { @@ -230,6 +243,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/mmv1/third_party/terraform/services/monitoring/resource_monitoring_dashboard_meta.yaml b/mmv1/third_party/terraform/services/monitoring/resource_monitoring_dashboard_meta.yaml index de65faeba1cd..bd3a86441bab 100644 --- a/mmv1/third_party/terraform/services/monitoring/resource_monitoring_dashboard_meta.yaml +++ b/mmv1/third_party/terraform/services/monitoring/resource_monitoring_dashboard_meta.yaml @@ -8,3 +8,5 @@ fields: api_field: '*' json: true - field: 'project' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/networkmanagement/data_source_network_management_connectivity_tests_test.go b/mmv1/third_party/terraform/services/networkmanagement/data_source_network_management_connectivity_tests_test.go index a75e3452e821..d9e518685696 100644 --- a/mmv1/third_party/terraform/services/networkmanagement/data_source_network_management_connectivity_tests_test.go +++ b/mmv1/third_party/terraform/services/networkmanagement/data_source_network_management_connectivity_tests_test.go @@ -34,6 +34,7 @@ func TestAccNetworkManagementConnectivityTests_basic(t *testing.T) { "project": {}, "terraform_labels.%": {}, "terraform_labels.goog-terraform-provisioned": {}, + "deletion_policy": {}, }, ), ), @@ -49,6 +50,7 @@ func TestAccNetworkManagementConnectivityTests_basic(t *testing.T) { "project": {}, "terraform_labels.%": {}, "terraform_labels.goog-terraform-provisioned": {}, + "deletion_policy": {}, }, ), ), diff --git a/mmv1/third_party/terraform/services/osconfig/resource_os_config_os_policy_assignment.go b/mmv1/third_party/terraform/services/osconfig/resource_os_config_os_policy_assignment.go index cf379c41699e..4615be4145da 100644 --- a/mmv1/third_party/terraform/services/osconfig/resource_os_config_os_policy_assignment.go +++ b/mmv1/third_party/terraform/services/osconfig/resource_os_config_os_policy_assignment.go @@ -34,6 +34,7 @@ func ResourceOSConfigOSPolicyAssignment() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -1064,6 +1065,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, } @@ -1272,10 +1276,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 { @@ -1386,6 +1399,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/mmv1/third_party/terraform/services/osconfig/resource_os_config_os_policy_assignment_meta.yaml b/mmv1/third_party/terraform/services/osconfig/resource_os_config_os_policy_assignment_meta.yaml index bc32a0ba5f6c..499fe16bc059 100644 --- a/mmv1/third_party/terraform/services/osconfig/resource_os_config_os_policy_assignment_meta.yaml +++ b/mmv1/third_party/terraform/services/osconfig/resource_os_config_os_policy_assignment_meta.yaml @@ -109,3 +109,5 @@ fields: - api_field: 'rolloutState' - field: 'skip_await_rollout' - api_field: 'uid' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/parametermanager/data_source_parameter_manager_parameters_test.go b/mmv1/third_party/terraform/services/parametermanager/data_source_parameter_manager_parameters_test.go index bcb8c8f0cc3a..6c3422aac887 100644 --- a/mmv1/third_party/terraform/services/parametermanager/data_source_parameter_manager_parameters_test.go +++ b/mmv1/third_party/terraform/services/parametermanager/data_source_parameter_manager_parameters_test.go @@ -30,8 +30,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": {}, }, ), ), @@ -87,8 +88,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/mmv1/third_party/terraform/services/parametermanagerregional/data_source_parameter_manager_regional_parameters_test.go b/mmv1/third_party/terraform/services/parametermanagerregional/data_source_parameter_manager_regional_parameters_test.go index 5a21fbc6cde4..156ef15a1f99 100644 --- a/mmv1/third_party/terraform/services/parametermanagerregional/data_source_parameter_manager_regional_parameters_test.go +++ b/mmv1/third_party/terraform/services/parametermanagerregional/data_source_parameter_manager_regional_parameters_test.go @@ -30,8 +30,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": {}, }, ), ), @@ -89,8 +90,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/mmv1/third_party/terraform/services/recaptchaenterprise/resource_recaptcha_enterprise_key.go b/mmv1/third_party/terraform/services/recaptchaenterprise/resource_recaptcha_enterprise_key.go index 90dc53350a54..6e7b91bb458d 100644 --- a/mmv1/third_party/terraform/services/recaptchaenterprise/resource_recaptcha_enterprise_key.go +++ b/mmv1/third_party/terraform/services/recaptchaenterprise/resource_recaptcha_enterprise_key.go @@ -36,6 +36,7 @@ func ResourceRecaptchaEnterpriseKey() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, tpgresource.SetLabelsDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -129,6 +130,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 }, } } @@ -455,9 +459,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 { @@ -509,6 +522,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/mmv1/third_party/terraform/services/recaptchaenterprise/resource_recaptcha_enterprise_key_meta.yaml b/mmv1/third_party/terraform/services/recaptchaenterprise/resource_recaptcha_enterprise_key_meta.yaml index 90e52b25a5a9..bc9b9ae86b73 100644 --- a/mmv1/third_party/terraform/services/recaptchaenterprise/resource_recaptcha_enterprise_key_meta.yaml +++ b/mmv1/third_party/terraform/services/recaptchaenterprise/resource_recaptcha_enterprise_key_meta.yaml @@ -26,6 +26,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/mmv1/third_party/terraform/services/resourcemanager/data_source_google_folder.go b/mmv1/third_party/terraform/services/resourcemanager/data_source_google_folder.go index ce15202be784..cfe239473558 100644 --- a/mmv1/third_party/terraform/services/resourcemanager/data_source_google_folder.go +++ b/mmv1/third_party/terraform/services/resourcemanager/data_source_google_folder.go @@ -64,6 +64,10 @@ func DataSourceGoogleFolder() *schema.Resource { Type: schema.TypeString, Computed: true, }, + "deletion_policy": { + Type: schema.TypeString, + Computed: true, + }, }, } } diff --git a/mmv1/third_party/terraform/services/resourcemanager/list_google_service_account.go b/mmv1/third_party/terraform/services/resourcemanager/list_google_service_account.go index 0caba8bd657d..573e547eba15 100644 --- a/mmv1/third_party/terraform/services/resourcemanager/list_google_service_account.go +++ b/mmv1/third_party/terraform/services/resourcemanager/list_google_service_account.go @@ -91,7 +91,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/mmv1/third_party/terraform/services/resourcemanager/resource_google_billing_subaccount.go b/mmv1/third_party/terraform/services/resourcemanager/resource_google_billing_subaccount.go index 79a43f868613..4534d73c7366 100644 --- a/mmv1/third_party/terraform/services/resourcemanager/resource_google_billing_subaccount.go +++ b/mmv1/third_party/terraform/services/resourcemanager/resource_google_billing_subaccount.go @@ -5,8 +5,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" @@ -26,6 +26,10 @@ func ResourceBillingSubaccount() *schema.Resource { State: schema.ImportStatePassthrough, }, + CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy(""), + ), + Schema: map[string]*schema.Schema{ "display_name": { Type: schema.TypeString, @@ -37,12 +41,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, @@ -115,10 +116,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 { @@ -138,6 +148,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/mmv1/third_party/terraform/services/resourcemanager/resource_google_billing_subaccount_meta.yaml b/mmv1/third_party/terraform/services/resourcemanager/resource_google_billing_subaccount_meta.yaml index 54acc37b05a3..9f80ce507521 100644 --- a/mmv1/third_party/terraform/services/resourcemanager/resource_google_billing_subaccount_meta.yaml +++ b/mmv1/third_party/terraform/services/resourcemanager/resource_google_billing_subaccount_meta.yaml @@ -6,7 +6,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/mmv1/third_party/terraform/services/resourcemanager/resource_google_folder.go b/mmv1/third_party/terraform/services/resourcemanager/resource_google_folder.go index 5e5845f7f1ad..e8871624a68a 100644 --- a/mmv1/third_party/terraform/services/resourcemanager/resource_google_folder.go +++ b/mmv1/third_party/terraform/services/resourcemanager/resource_google_folder.go @@ -6,6 +6,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" @@ -27,6 +28,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), @@ -93,6 +98,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, } @@ -201,6 +209,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 } @@ -211,7 +223,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] { @@ -274,6 +286,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/mmv1/third_party/terraform/services/resourcemanager/resource_google_folder_meta.yaml b/mmv1/third_party/terraform/services/resourcemanager/resource_google_folder_meta.yaml index 467d4c9b6159..5e23a436ec84 100644 --- a/mmv1/third_party/terraform/services/resourcemanager/resource_google_folder_meta.yaml +++ b/mmv1/third_party/terraform/services/resourcemanager/resource_google_folder_meta.yaml @@ -14,3 +14,5 @@ fields: - api_field: 'name' - api_field: 'parent' - api_field: 'tags' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/resourcemanager/resource_google_folder_organization_policy.go b/mmv1/third_party/terraform/services/resourcemanager/resource_google_folder_organization_policy.go index 928111d35b10..7be4c2ce86e6 100644 --- a/mmv1/third_party/terraform/services/resourcemanager/resource_google_folder_organization_policy.go +++ b/mmv1/third_party/terraform/services/resourcemanager/resource_google_folder_organization_policy.go @@ -4,6 +4,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" @@ -30,6 +31,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{ @@ -39,6 +44,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, @@ -125,10 +133,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) } @@ -141,6 +158,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/mmv1/third_party/terraform/services/resourcemanager/resource_google_folder_organization_policy_meta.yaml b/mmv1/third_party/terraform/services/resourcemanager/resource_google_folder_organization_policy_meta.yaml index 6c28890c3407..5ffcc0aa1d6a 100644 --- a/mmv1/third_party/terraform/services/resourcemanager/resource_google_folder_organization_policy_meta.yaml +++ b/mmv1/third_party/terraform/services/resourcemanager/resource_google_folder_organization_policy_meta.yaml @@ -17,3 +17,5 @@ fields: - field: 'restore_policy.default' - api_field: 'updateTime' - field: 'version' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/resourcemanager/resource_google_organization_iam_custom_role.go b/mmv1/third_party/terraform/services/resourcemanager/resource_google_organization_iam_custom_role.go index 98251ec9d56e..8138fc2b152d 100644 --- a/mmv1/third_party/terraform/services/resourcemanager/resource_google_organization_iam_custom_role.go +++ b/mmv1/third_party/terraform/services/resourcemanager/resource_google_organization_iam_custom_role.go @@ -3,6 +3,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" @@ -33,6 +34,10 @@ func ResourceGoogleOrganizationIamCustomRole() *schema.Resource { State: schema.ImportStatePassthrough, }, + CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), + ), + Schema: map[string]*schema.Schema{ "role_id": { Type: schema.TypeString, @@ -82,6 +87,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, } @@ -180,10 +188,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 { @@ -224,6 +241,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/mmv1/third_party/terraform/services/resourcemanager/resource_google_organization_iam_custom_role_meta.yaml b/mmv1/third_party/terraform/services/resourcemanager/resource_google_organization_iam_custom_role_meta.yaml index 4752a35a2b44..478e57f9aa19 100644 --- a/mmv1/third_party/terraform/services/resourcemanager/resource_google_organization_iam_custom_role_meta.yaml +++ b/mmv1/third_party/terraform/services/resourcemanager/resource_google_organization_iam_custom_role_meta.yaml @@ -12,3 +12,5 @@ fields: - field: 'role_id' - api_field: 'stage' - api_field: 'title' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/resourcemanager/resource_google_organization_policy.go b/mmv1/third_party/terraform/services/resourcemanager/resource_google_organization_policy.go index 43d119933ec1..6a74ecfae172 100644 --- a/mmv1/third_party/terraform/services/resourcemanager/resource_google_organization_policy.go +++ b/mmv1/third_party/terraform/services/resourcemanager/resource_google_organization_policy.go @@ -5,6 +5,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" @@ -165,6 +166,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{ @@ -173,6 +178,9 @@ func ResourceGoogleOrganizationPolicy() *schema.Resource { Required: true, ForceNew: true, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }), UseJSONNumber: true, } @@ -235,10 +243,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) } @@ -251,6 +268,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/mmv1/third_party/terraform/services/resourcemanager/resource_google_organization_policy_meta.yaml b/mmv1/third_party/terraform/services/resourcemanager/resource_google_organization_policy_meta.yaml index b91c4f6ba9ab..7b126dac08a5 100644 --- a/mmv1/third_party/terraform/services/resourcemanager/resource_google_organization_policy_meta.yaml +++ b/mmv1/third_party/terraform/services/resourcemanager/resource_google_organization_policy_meta.yaml @@ -17,3 +17,5 @@ fields: - field: 'restore_policy.default' - api_field: 'updateTime' - field: 'version' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/resourcemanager/resource_google_project.go b/mmv1/third_party/terraform/services/resourcemanager/resource_google_project.go index c025fb368b78..10a8f08c23eb 100644 --- a/mmv1/third_party/terraform/services/resourcemanager/resource_google_project.go +++ b/mmv1/third_party/terraform/services/resourcemanager/resource_google_project.go @@ -46,6 +46,7 @@ func ResourceGoogleProject() *schema.Resource { Delete: resourceGoogleProjectDelete, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("PREVENT"), tpgresource.SetLabelsDiff, ), @@ -72,8 +73,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), @@ -323,11 +324,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/mmv1/third_party/terraform/services/resourcemanager/resource_google_project_iam_custom_role.go b/mmv1/third_party/terraform/services/resourcemanager/resource_google_project_iam_custom_role.go index 7b04cf48c4ba..f6314b8a26c0 100644 --- a/mmv1/third_party/terraform/services/resourcemanager/resource_google_project_iam_custom_role.go +++ b/mmv1/third_party/terraform/services/resourcemanager/resource_google_project_iam_custom_role.go @@ -28,6 +28,7 @@ func ResourceGoogleProjectIamCustomRole() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -80,6 +81,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, } @@ -180,10 +184,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 { @@ -223,6 +236,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/mmv1/third_party/terraform/services/resourcemanager/resource_google_project_iam_custom_role_meta.yaml b/mmv1/third_party/terraform/services/resourcemanager/resource_google_project_iam_custom_role_meta.yaml index 8b73e1e6340c..d34bfdd5abe5 100644 --- a/mmv1/third_party/terraform/services/resourcemanager/resource_google_project_iam_custom_role_meta.yaml +++ b/mmv1/third_party/terraform/services/resourcemanager/resource_google_project_iam_custom_role_meta.yaml @@ -12,3 +12,5 @@ fields: - field: 'role_id' - api_field: 'stage' - api_field: 'title' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/resourcemanager/resource_google_project_organization_policy.go b/mmv1/third_party/terraform/services/resourcemanager/resource_google_project_organization_policy.go index 29f7b4239d94..0a25e5c486c9 100644 --- a/mmv1/third_party/terraform/services/resourcemanager/resource_google_project_organization_policy.go +++ b/mmv1/third_party/terraform/services/resourcemanager/resource_google_project_organization_policy.go @@ -4,6 +4,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" @@ -30,6 +31,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{ @@ -39,6 +44,9 @@ func ResourceGoogleProjectOrganizationPolicy() *schema.Resource { ForceNew: true, Description: `The project ID.`, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, ), UseJSONNumber: true, @@ -122,10 +130,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) } @@ -138,6 +155,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/mmv1/third_party/terraform/services/resourcemanager/resource_google_project_organization_policy_meta.yaml b/mmv1/third_party/terraform/services/resourcemanager/resource_google_project_organization_policy_meta.yaml index 8195fa41dd15..89d3d6d6fa64 100644 --- a/mmv1/third_party/terraform/services/resourcemanager/resource_google_project_organization_policy_meta.yaml +++ b/mmv1/third_party/terraform/services/resourcemanager/resource_google_project_organization_policy_meta.yaml @@ -17,3 +17,5 @@ fields: - field: 'restore_policy.default' - api_field: 'updateTime' - field: 'version' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/resourcemanager/resource_google_project_service.go.tmpl b/mmv1/third_party/terraform/services/resourcemanager/resource_google_project_service.go.tmpl index 953927755435..f7b3d7a58c4c 100644 --- a/mmv1/third_party/terraform/services/resourcemanager/resource_google_project_service.go.tmpl +++ b/mmv1/third_party/terraform/services/resourcemanager/resource_google_project_service.go.tmpl @@ -95,6 +95,7 @@ func ResourceGoogleProjectService() *schema.Resource { }, CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), tpgresource.DefaultProviderProject, ), @@ -128,6 +129,9 @@ func ResourceGoogleProjectService() *schema.Resource { Optional: true, }, {{- end }} + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, UseJSONNumber: true, } @@ -238,6 +242,11 @@ 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("") @@ -245,6 +254,13 @@ func resourceGoogleProjectServiceRead(d *schema.ResourceData, meta interface{}) } 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/mmv1/third_party/terraform/services/resourcemanager/resource_google_project_service_meta.yaml.tmpl b/mmv1/third_party/terraform/services/resourcemanager/resource_google_project_service_meta.yaml.tmpl index 6ba459f1c3f6..3c31df6a8582 100644 --- a/mmv1/third_party/terraform/services/resourcemanager/resource_google_project_service_meta.yaml.tmpl +++ b/mmv1/third_party/terraform/services/resourcemanager/resource_google_project_service_meta.yaml.tmpl @@ -13,3 +13,5 @@ fields: - field: 'disable_on_destroy' - field: 'project' - field: 'service' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/resourcemanager/resource_google_service_account.go b/mmv1/third_party/terraform/services/resourcemanager/resource_google_service_account.go index 8a36837e81ea..f83a56b4c0b3 100644 --- a/mmv1/third_party/terraform/services/resourcemanager/resource_google_service_account.go +++ b/mmv1/third_party/terraform/services/resourcemanager/resource_google_service_account.go @@ -35,6 +35,7 @@ func ResourceGoogleServiceAccount() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, resourceServiceAccountCustomDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Identity: &schema.ResourceIdentity{ @@ -111,6 +112,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, } @@ -157,7 +161,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{ @@ -172,7 +176,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. @@ -227,10 +231,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) } @@ -259,6 +263,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, @@ -266,6 +274,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 { @@ -285,6 +300,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/mmv1/third_party/terraform/services/resourcemanager/resource_google_service_account_key.go b/mmv1/third_party/terraform/services/resourcemanager/resource_google_service_account_key.go index 1f0dced69c39..0efbe3851323 100644 --- a/mmv1/third_party/terraform/services/resourcemanager/resource_google_service_account_key.go +++ b/mmv1/third_party/terraform/services/resourcemanager/resource_google_service_account_key.go @@ -10,6 +10,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" @@ -19,7 +20,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": { @@ -93,6 +100,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, } @@ -191,10 +201,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/mmv1/third_party/terraform/services/resourcemanager/resource_google_service_account_key_meta.yaml b/mmv1/third_party/terraform/services/resourcemanager/resource_google_service_account_key_meta.yaml index cd9d8dde4c7c..7b1cb130f82b 100644 --- a/mmv1/third_party/terraform/services/resourcemanager/resource_google_service_account_key_meta.yaml +++ b/mmv1/third_party/terraform/services/resourcemanager/resource_google_service_account_key_meta.yaml @@ -15,3 +15,5 @@ fields: - field: 'service_account_id' - field: 'valid_after' - field: 'valid_before' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/resourcemanager/resource_google_service_account_meta.yaml b/mmv1/third_party/terraform/services/resourcemanager/resource_google_service_account_meta.yaml index d08cb722b1e3..74c39593e4f5 100644 --- a/mmv1/third_party/terraform/services/resourcemanager/resource_google_service_account_meta.yaml +++ b/mmv1/third_party/terraform/services/resourcemanager/resource_google_service_account_meta.yaml @@ -16,3 +16,5 @@ fields: - api_field: 'name' - field: 'project' - api_field: 'uniqueId' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/runtimeconfig/resource_runtimeconfig_config.go.tmpl b/mmv1/third_party/terraform/services/runtimeconfig/resource_runtimeconfig_config.go.tmpl index e0d66c629462..c86f807310c0 100644 --- a/mmv1/third_party/terraform/services/runtimeconfig/resource_runtimeconfig_config.go.tmpl +++ b/mmv1/third_party/terraform/services/runtimeconfig/resource_runtimeconfig_config.go.tmpl @@ -30,6 +30,7 @@ func ResourceRuntimeconfigConfig() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -54,6 +55,9 @@ func ResourceRuntimeconfigConfig() *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, } @@ -128,11 +132,21 @@ func resourceRuntimeconfigConfigRead(d *schema.ResourceData, meta interface{}) e 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 resourceRuntimeconfigConfigUpdate(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceRuntimeconfigConfig) { + return ResourceRuntimeconfigConfig().Read(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -158,6 +172,13 @@ func resourceRuntimeconfigConfigUpdate(d *schema.ResourceData, meta interface{}) } func resourceRuntimeconfigConfigDelete(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/mmv1/third_party/terraform/services/runtimeconfig/resource_runtimeconfig_config_meta.yaml.tmpl b/mmv1/third_party/terraform/services/runtimeconfig/resource_runtimeconfig_config_meta.yaml.tmpl index e1494d0f17f8..d08f7bb79a88 100644 --- a/mmv1/third_party/terraform/services/runtimeconfig/resource_runtimeconfig_config_meta.yaml.tmpl +++ b/mmv1/third_party/terraform/services/runtimeconfig/resource_runtimeconfig_config_meta.yaml.tmpl @@ -8,4 +8,6 @@ fields: - api_field: 'description' - api_field: 'name' - field: 'project' + - field: 'deletion_policy' + provider_only: true {{ end }} \ No newline at end of file diff --git a/mmv1/third_party/terraform/services/runtimeconfig/resource_runtimeconfig_variable.go.tmpl b/mmv1/third_party/terraform/services/runtimeconfig/resource_runtimeconfig_variable.go.tmpl index efd2cbcde7c3..cbf4463df35d 100644 --- a/mmv1/third_party/terraform/services/runtimeconfig/resource_runtimeconfig_variable.go.tmpl +++ b/mmv1/third_party/terraform/services/runtimeconfig/resource_runtimeconfig_variable.go.tmpl @@ -27,6 +27,7 @@ func ResourceRuntimeconfigVariable() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -71,6 +72,10 @@ func ResourceRuntimeconfigVariable() *schema.Resource { Computed: true, Description: `The timestamp in RFC3339 UTC "Zulu" format, accurate to nanoseconds, representing when the variable was last updated. Example: "2016-10-09T12:33:37.578138407Z".`, }, + + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, UseJSONNumber: true, } @@ -114,11 +119,21 @@ func resourceRuntimeconfigVariableRead(d *schema.ResourceData, meta interface{}) if err != nil { return err } + + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil{ + return err + } + return setRuntimeConfigVariableToResourceData(d, *createdVariable) } func resourceRuntimeconfigVariableUpdate(d *schema.ResourceData, meta interface{}) error { + + if tpgresource.DeletionPolicyPreUpdate(d, ResourceRuntimeconfigVariable) { + return ResourceRuntimeconfigVariable().Read(d, meta) + } + config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { @@ -147,6 +162,13 @@ func resourceRuntimeconfigVariableUpdate(d *schema.ResourceData, meta interface{ } func resourceRuntimeconfigVariableDelete(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/mmv1/third_party/terraform/services/runtimeconfig/resource_runtimeconfig_variable_meta.yaml.tmpl b/mmv1/third_party/terraform/services/runtimeconfig/resource_runtimeconfig_variable_meta.yaml.tmpl index 4eb70ab23814..6f9e36f73d3f 100644 --- a/mmv1/third_party/terraform/services/runtimeconfig/resource_runtimeconfig_variable_meta.yaml.tmpl +++ b/mmv1/third_party/terraform/services/runtimeconfig/resource_runtimeconfig_variable_meta.yaml.tmpl @@ -11,4 +11,6 @@ fields: - api_field: 'text' - api_field: 'updateTime' - api_field: 'value' + - field: 'deletion_policy' + provider_only: true {{ end }} \ No newline at end of file diff --git a/mmv1/third_party/terraform/services/secretmanager/data_source_secret_manager_secrets_test.go b/mmv1/third_party/terraform/services/secretmanager/data_source_secret_manager_secrets_test.go index a58b2cfd1bba..90b5900d33dd 100644 --- a/mmv1/third_party/terraform/services/secretmanager/data_source_secret_manager_secrets_test.go +++ b/mmv1/third_party/terraform/services/secretmanager/data_source_secret_manager_secrets_test.go @@ -30,8 +30,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": {}, }, ), ), @@ -96,8 +97,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/mmv1/third_party/terraform/services/secretmanagerregional/data_source_secret_manager_regional_secrets_test.go b/mmv1/third_party/terraform/services/secretmanagerregional/data_source_secret_manager_regional_secrets_test.go index a3ed4127b7ac..ea064fd5020c 100644 --- a/mmv1/third_party/terraform/services/secretmanagerregional/data_source_secret_manager_regional_secrets_test.go +++ b/mmv1/third_party/terraform/services/secretmanagerregional/data_source_secret_manager_regional_secrets_test.go @@ -31,8 +31,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": {}, }, ), ), @@ -89,8 +90,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/mmv1/third_party/terraform/services/servicemanagement/resource_endpoints_service.go b/mmv1/third_party/terraform/services/servicemanagement/resource_endpoints_service.go index ce9003f77cbb..9fee26e8502c 100644 --- a/mmv1/third_party/terraform/services/servicemanagement/resource_endpoints_service.go +++ b/mmv1/third_party/terraform/services/servicemanagement/resource_endpoints_service.go @@ -12,6 +12,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" @@ -148,8 +149,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, } } @@ -284,6 +291,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 @@ -354,6 +366,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 { @@ -398,6 +417,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/mmv1/third_party/terraform/services/servicemanagement/resource_endpoints_service_meta.yaml b/mmv1/third_party/terraform/services/servicemanagement/resource_endpoints_service_meta.yaml index 11381d516efe..93207047e49d 100644 --- a/mmv1/third_party/terraform/services/servicemanagement/resource_endpoints_service_meta.yaml +++ b/mmv1/third_party/terraform/services/servicemanagement/resource_endpoints_service_meta.yaml @@ -20,3 +20,5 @@ fields: - field: 'project' - field: 'protoc_output_base64' - api_field: 'serviceName' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/servicenetworking/data_source_google_service_networking_peered_dns_domain.go b/mmv1/third_party/terraform/services/servicenetworking/data_source_google_service_networking_peered_dns_domain.go index f800644e51ea..6b0b44228826 100644 --- a/mmv1/third_party/terraform/services/servicenetworking/data_source_google_service_networking_peered_dns_domain.go +++ b/mmv1/third_party/terraform/services/servicenetworking/data_source_google_service_networking_peered_dns_domain.go @@ -1,6 +1,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" ) @@ -33,6 +35,9 @@ func DataSourceGoogleServiceNetworkingPeeredDNSDomain() *schema.Resource { Type: schema.TypeString, Computed: true, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, } } diff --git a/mmv1/third_party/terraform/services/servicenetworking/resource_google_service_networking_peered_dns_domain.go b/mmv1/third_party/terraform/services/servicenetworking/resource_google_service_networking_peered_dns_domain.go index 1044866b7bc3..780375c67e18 100644 --- a/mmv1/third_party/terraform/services/servicenetworking/resource_google_service_networking_peered_dns_domain.go +++ b/mmv1/third_party/terraform/services/servicenetworking/resource_google_service_networking_peered_dns_domain.go @@ -21,6 +21,7 @@ func ResourceGoogleServiceNetworkingPeeredDNSDomain() *schema.Resource { return &schema.Resource{ Create: resourceGoogleServiceNetworkingPeeredDNSDomainCreate, Read: resourceGoogleServiceNetworkingPeeredDNSDomainRead, + Update: resourceGoogleServiceNetworkingPeeredDNSDomainUpdate, Delete: resourceGoogleServiceNetworkingPeeredDNSDomainDelete, Importer: &schema.ResourceImporter{ @@ -35,6 +36,7 @@ func ResourceGoogleServiceNetworkingPeeredDNSDomain() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -74,6 +76,9 @@ func ResourceGoogleServiceNetworkingPeeredDNSDomain() *schema.Resource { Type: schema.TypeString, Computed: true, }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, UseJSONNumber: true, } @@ -214,10 +219,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/mmv1/third_party/terraform/services/servicenetworking/resource_google_service_networking_peered_dns_domain_meta.yaml b/mmv1/third_party/terraform/services/servicenetworking/resource_google_service_networking_peered_dns_domain_meta.yaml index 34fba011bff2..93a599822cb4 100644 --- a/mmv1/third_party/terraform/services/servicenetworking/resource_google_service_networking_peered_dns_domain_meta.yaml +++ b/mmv1/third_party/terraform/services/servicenetworking/resource_google_service_networking_peered_dns_domain_meta.yaml @@ -10,3 +10,5 @@ fields: - field: 'parent' - field: 'project' - field: 'service' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/servicenetworking/resource_service_networking_connection.go b/mmv1/third_party/terraform/services/servicenetworking/resource_service_networking_connection.go index 0368acfdc44a..7de22784def2 100644 --- a/mmv1/third_party/terraform/services/servicenetworking/resource_service_networking_connection.go +++ b/mmv1/third_party/terraform/services/servicenetworking/resource_service_networking_connection.go @@ -16,8 +16,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" ) @@ -37,6 +37,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), @@ -71,12 +74,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, @@ -239,10 +239,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 { @@ -300,8 +309,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/mmv1/third_party/terraform/services/servicenetworking/resource_service_networking_connection_meta.yaml b/mmv1/third_party/terraform/services/servicenetworking/resource_service_networking_connection_meta.yaml index 802ea09a6bcc..1714fcdebdf9 100644 --- a/mmv1/third_party/terraform/services/servicenetworking/resource_service_networking_connection_meta.yaml +++ b/mmv1/third_party/terraform/services/servicenetworking/resource_service_networking_connection_meta.yaml @@ -5,6 +5,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/mmv1/third_party/terraform/services/siteverification/resource_site_verification_owner.go b/mmv1/third_party/terraform/services/siteverification/resource_site_verification_owner.go index a34954aa59b7..cfcc9d8447f4 100644 --- a/mmv1/third_party/terraform/services/siteverification/resource_site_verification_owner.go +++ b/mmv1/third_party/terraform/services/siteverification/resource_site_verification_owner.go @@ -16,6 +16,7 @@ func ResourceSiteVerificationOwner() *schema.Resource { return &schema.Resource{ Create: resourceSiteVerificationOwnerCreate, Read: resourceSiteVerificationOwnerRead, + Update: resourceSiteVerificationOwnerUpdate, Delete: resourceSiteVerificationOwnerDelete, Importer: &schema.ResourceImporter{ @@ -41,6 +42,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, } @@ -180,10 +184,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/mmv1/third_party/terraform/services/siteverification/resource_site_verification_owner_meta.yaml b/mmv1/third_party/terraform/services/siteverification/resource_site_verification_owner_meta.yaml index 2030861c3b26..44085f7f1f7b 100644 --- a/mmv1/third_party/terraform/services/siteverification/resource_site_verification_owner_meta.yaml +++ b/mmv1/third_party/terraform/services/siteverification/resource_site_verification_owner_meta.yaml @@ -6,3 +6,5 @@ api_resource_type_kind: 'WebResource' fields: - field: 'email' - field: 'web_resource_id' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/sql/data_source_sql_database_instances_test.go b/mmv1/third_party/terraform/services/sql/data_source_sql_database_instances_test.go index deb031ea7a9c..c948a746b737 100644 --- a/mmv1/third_party/terraform/services/sql/data_source_sql_database_instances_test.go +++ b/mmv1/third_party/terraform/services/sql/data_source_sql_database_instances_test.go @@ -33,6 +33,7 @@ func TestAccDataSourceSqlDatabaseInstances_basic(t *testing.T) { map[string]struct{}{ "deletion_protection": {}, "id": {}, + "deletion_policy": {}, }, ), ), @@ -63,6 +64,7 @@ func TestAccDataSourceSqlDatabaseInstances_databaseVersionFilter(t *testing.T) { map[string]struct{}{ "deletion_protection": {}, "id": {}, + "deletion_policy": {}, }, ), ), @@ -93,6 +95,7 @@ func TestAccDataSourceSqlDatabaseInstances_regionFilter(t *testing.T) { map[string]struct{}{ "deletion_protection": {}, "id": {}, + "deletion_policy": {}, }, ), ), @@ -124,6 +127,7 @@ func TestAccDataSourceSqlDatabaseInstances_tierFilter(t *testing.T) { "deletion_protection": {}, "id": {}, "settings.0.version": {}, + "deletion_policy": {}, }, ), ), diff --git a/mmv1/third_party/terraform/services/sql/resource_sql_database_instance.go.tmpl b/mmv1/third_party/terraform/services/sql/resource_sql_database_instance.go.tmpl index 770ca8e40236..03df5e944cf8 100644 --- a/mmv1/third_party/terraform/services/sql/resource_sql_database_instance.go.tmpl +++ b/mmv1/third_party/terraform/services/sql/resource_sql_database_instance.go.tmpl @@ -234,6 +234,7 @@ func ResourceSqlDatabaseInstance() *schema.Resource { pitrSupportDbCustomizeDiff, nodeCountCustomDiff, autoUpgradeEnabledCustomizeDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -1493,6 +1494,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, } @@ -2417,6 +2421,11 @@ func resourceSqlDatabaseInstanceRead(d *schema.ResourceData, meta interface{}) e return fmt.Errorf("Error setting dns_names: %s", err) } d.SetId(instance.Name) + + if err := tpgresource.DeletionPolicyReadDefault(d, config, "DELETE"); err != nil{ + return err + } + return nil } @@ -2430,6 +2439,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 { @@ -2923,6 +2937,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/mmv1/third_party/terraform/services/sql/resource_sql_database_instance_meta.yaml.tmpl b/mmv1/third_party/terraform/services/sql/resource_sql_database_instance_meta.yaml.tmpl index 5f9447be0818..2c64189b6669 100644 --- a/mmv1/third_party/terraform/services/sql/resource_sql_database_instance_meta.yaml.tmpl +++ b/mmv1/third_party/terraform/services/sql/resource_sql_database_instance_meta.yaml.tmpl @@ -202,3 +202,5 @@ fields: - api_field: 'settings.userLabels' - api_field: 'settings.settingsVersion' field: 'settings.version' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/sql/resource_sql_ssl_cert.go b/mmv1/third_party/terraform/services/sql/resource_sql_ssl_cert.go index 51ddd1377d5f..6b8271c11cb9 100644 --- a/mmv1/third_party/terraform/services/sql/resource_sql_ssl_cert.go +++ b/mmv1/third_party/terraform/services/sql/resource_sql_ssl_cert.go @@ -18,6 +18,7 @@ func ResourceSqlSslCert() *schema.Resource { return &schema.Resource{ Create: resourceSqlSslCertCreate, Read: resourceSqlSslCertRead, + Update: resourceSqlSslCertUpdate, Delete: resourceSqlSslCertDelete, SchemaVersion: 1, @@ -29,6 +30,7 @@ func ResourceSqlSslCert() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -98,6 +100,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, } @@ -207,10 +212,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/mmv1/third_party/terraform/services/sql/resource_sql_ssl_cert_meta.yaml b/mmv1/third_party/terraform/services/sql/resource_sql_ssl_cert_meta.yaml index 1b7a6a0e2b54..1fa6abed58a7 100644 --- a/mmv1/third_party/terraform/services/sql/resource_sql_ssl_cert_meta.yaml +++ b/mmv1/third_party/terraform/services/sql/resource_sql_ssl_cert_meta.yaml @@ -14,3 +14,5 @@ fields: - field: 'project' - field: 'server_ca_cert' - api_field: 'sha1Fingerprint' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/sql/resource_sql_user.go b/mmv1/third_party/terraform/services/sql/resource_sql_user.go index a274951b71a9..af6495642993 100644 --- a/mmv1/third_party/terraform/services/sql/resource_sql_user.go +++ b/mmv1/third_party/terraform/services/sql/resource_sql_user.go @@ -14,7 +14,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" ) @@ -61,6 +60,7 @@ func ResourceSqlUser() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), SchemaVersion: 1, @@ -200,14 +200,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, @@ -448,6 +443,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 } @@ -491,6 +491,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 { @@ -574,9 +579,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/mmv1/third_party/terraform/services/sql/resource_sql_user_meta.yaml b/mmv1/third_party/terraform/services/sql/resource_sql_user_meta.yaml index c385260d1fd7..b5dda22358e4 100644 --- a/mmv1/third_party/terraform/services/sql/resource_sql_user_meta.yaml +++ b/mmv1/third_party/terraform/services/sql/resource_sql_user_meta.yaml @@ -5,6 +5,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/mmv1/third_party/terraform/services/storage/resource_storage_bucket.go.tmpl b/mmv1/third_party/terraform/services/storage/resource_storage_bucket.go.tmpl index 00520e61c489..07df37a4688a 100644 --- a/mmv1/third_party/terraform/services/storage/resource_storage_bucket.go.tmpl +++ b/mmv1/third_party/terraform/services/storage/resource_storage_bucket.go.tmpl @@ -64,6 +64,7 @@ func ResourceStorageBucket() *schema.Resource { CustomizeDiff: customdiff.All( customdiff.ForceNewIfChange("retention_policy.0.is_locked", isPolicyLocked), tpgresource.SetLabelsDiff, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Timeouts: &schema.ResourceTimeout{ @@ -694,7 +695,10 @@ func ResourceStorageBucket() *schema.Resource { } return false }, - }, + }, + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, UseJSONNumber: true, } @@ -1007,6 +1011,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 { @@ -1208,6 +1217,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 { @@ -2506,6 +2522,11 @@ func setStorageBucket(d *schema.ResourceData, config *transport_tpg.Config, res if err := d.Set("ip_filter", flattenBucketIpFilter(res.IpFilter)); err != nil { 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/mmv1/third_party/terraform/services/storage/resource_storage_bucket_acl.go b/mmv1/third_party/terraform/services/storage/resource_storage_bucket_acl.go index 74bf6a8e7dce..ea5dad331e4d 100644 --- a/mmv1/third_party/terraform/services/storage/resource_storage_bucket_acl.go +++ b/mmv1/third_party/terraform/services/storage/resource_storage_bucket_acl.go @@ -11,6 +11,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" @@ -18,11 +19,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": { @@ -54,6 +58,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, } @@ -275,10 +282,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 { @@ -375,6 +391,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/mmv1/third_party/terraform/services/storage/resource_storage_bucket_acl_meta.yaml b/mmv1/third_party/terraform/services/storage/resource_storage_bucket_acl_meta.yaml index 3e08e3339b17..99dafdb21743 100644 --- a/mmv1/third_party/terraform/services/storage/resource_storage_bucket_acl_meta.yaml +++ b/mmv1/third_party/terraform/services/storage/resource_storage_bucket_acl_meta.yaml @@ -8,3 +8,5 @@ fields: - field: 'default_acl' - field: 'predefined_acl' - field: 'role_entity' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/storage/resource_storage_bucket_meta.yaml b/mmv1/third_party/terraform/services/storage/resource_storage_bucket_meta.yaml index 0a98e679de75..2f07fab941d6 100644 --- a/mmv1/third_party/terraform/services/storage/resource_storage_bucket_meta.yaml +++ b/mmv1/third_party/terraform/services/storage/resource_storage_bucket_meta.yaml @@ -98,3 +98,5 @@ fields: - api_field: 'versioning.enabled' - api_field: 'website.mainPageSuffix' - api_field: 'website.notFoundPage' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/storage/resource_storage_bucket_object.go b/mmv1/third_party/terraform/services/storage/resource_storage_bucket_object.go index a22afa858f8e..e11dde705af3 100644 --- a/mmv1/third_party/terraform/services/storage/resource_storage_bucket_object.go +++ b/mmv1/third_party/terraform/services/storage/resource_storage_bucket_object.go @@ -16,7 +16,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" @@ -36,6 +35,7 @@ func ResourceStorageBucketObject() *schema.Resource { CustomizeDiff: customdiff.All( resourceStorageBucketObjectCustomizeDiff, validateContexts, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Timeouts: &schema.ResourceTimeout{ @@ -352,12 +352,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, } @@ -465,6 +462,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 { @@ -622,12 +624,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/mmv1/third_party/terraform/services/storage/resource_storage_default_object_acl.go b/mmv1/third_party/terraform/services/storage/resource_storage_default_object_acl.go index 31c8cc817338..896d703b2f09 100644 --- a/mmv1/third_party/terraform/services/storage/resource_storage_default_object_acl.go +++ b/mmv1/third_party/terraform/services/storage/resource_storage_default_object_acl.go @@ -3,6 +3,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" @@ -17,6 +18,10 @@ func ResourceStorageDefaultObjectAcl() *schema.Resource { Update: resourceStorageDefaultObjectAclCreateUpdate, Delete: resourceStorageDefaultObjectAclDelete, + CustomizeDiff: customdiff.All( + tpgresource.DefaultProviderDeletionPolicy("DELETE"), + ), + Schema: map[string]*schema.Schema{ "bucket": { Type: schema.TypeString, @@ -33,12 +38,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 { @@ -109,11 +123,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/mmv1/third_party/terraform/services/storage/resource_storage_default_object_acl_meta.yaml b/mmv1/third_party/terraform/services/storage/resource_storage_default_object_acl_meta.yaml index a76369719824..97ea8b93f09d 100644 --- a/mmv1/third_party/terraform/services/storage/resource_storage_default_object_acl_meta.yaml +++ b/mmv1/third_party/terraform/services/storage/resource_storage_default_object_acl_meta.yaml @@ -6,3 +6,5 @@ api_resource_type_kind: 'ObjectAccessControl' fields: - field: 'bucket' - field: 'role_entity' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/storage/resource_storage_object_acl.go b/mmv1/third_party/terraform/services/storage/resource_storage_object_acl.go index 4dcba4c4fe1b..ac233431fb9c 100644 --- a/mmv1/third_party/terraform/services/storage/resource_storage_object_acl.go +++ b/mmv1/third_party/terraform/services/storage/resource_storage_object_acl.go @@ -9,6 +9,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" @@ -16,11 +17,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": { @@ -52,6 +56,10 @@ func ResourceStorageObjectAcl() *schema.Resource { }, ConflictsWith: []string{"predefined_acl"}, }, + + //UDP schema start + "deletion_policy": tpgresource.DeletionPolicySchemaEntry("DELETE"), + //UDP schema end }, UseJSONNumber: true, } @@ -198,11 +206,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 { @@ -261,6 +278,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/mmv1/third_party/terraform/services/storage/resource_storage_object_acl_meta.yaml b/mmv1/third_party/terraform/services/storage/resource_storage_object_acl_meta.yaml index 1571519d6ef1..286b57efcc4a 100644 --- a/mmv1/third_party/terraform/services/storage/resource_storage_object_acl_meta.yaml +++ b/mmv1/third_party/terraform/services/storage/resource_storage_object_acl_meta.yaml @@ -8,3 +8,5 @@ fields: - field: 'object' - field: 'predefined_acl' - field: 'role_entity' + - field: 'deletion_policy' + provider_only: true diff --git a/mmv1/third_party/terraform/services/storagetransfer/resource_storage_transfer_job.go b/mmv1/third_party/terraform/services/storagetransfer/resource_storage_transfer_job.go index 8861c5188f51..b5e0ad7e3a42 100644 --- a/mmv1/third_party/terraform/services/storagetransfer/resource_storage_transfer_job.go +++ b/mmv1/third_party/terraform/services/storagetransfer/resource_storage_transfer_job.go @@ -122,6 +122,7 @@ func ResourceStorageTransferJob() *schema.Resource { CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, + tpgresource.DefaultProviderDeletionPolicy("DELETE"), ), Schema: map[string]*schema.Schema{ @@ -442,6 +443,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, } @@ -1131,10 +1135,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 { @@ -1248,6 +1261,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/mmv1/third_party/terraform/services/storagetransfer/resource_storage_transfer_job_meta.yaml b/mmv1/third_party/terraform/services/storagetransfer/resource_storage_transfer_job_meta.yaml index 5950abca6af8..9bf9ba4ae234 100644 --- a/mmv1/third_party/terraform/services/storagetransfer/resource_storage_transfer_job_meta.yaml +++ b/mmv1/third_party/terraform/services/storagetransfer/resource_storage_transfer_job_meta.yaml @@ -109,3 +109,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/mmv1/third_party/terraform/services/tags/resource_tags_location_tag_binding.go.tmpl b/mmv1/third_party/terraform/services/tags/resource_tags_location_tag_binding.go.tmpl index 0bbc4432c47b..ca5b69b76a9b 100644 --- a/mmv1/third_party/terraform/services/tags/resource_tags_location_tag_binding.go.tmpl +++ b/mmv1/third_party/terraform/services/tags/resource_tags_location_tag_binding.go.tmpl @@ -13,6 +13,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" ) @@ -20,6 +21,7 @@ func ResourceTagsLocationTagBinding() *schema.Resource { return &schema.Resource{ Create: resourceTagsLocationTagBindingCreate, Read: resourceTagsLocationTagBindingRead, + Update: resourceTagsLocationTagBindingUpdate, Delete: resourceTagsLocationTagBindingDelete, Importer: &schema.ResourceImporter{ @@ -31,6 +33,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, @@ -57,6 +63,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, } @@ -272,11 +281,30 @@ func resourceTagsLocationTagBindingRead(d *schema.ResourceData, meta interface{} // Do not change the existing d.Get("tag_value") format to maintain backward compatibility. 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/mmv1/third_party/terraform/services/tags/resource_tags_location_tag_binding_meta.yaml b/mmv1/third_party/terraform/services/tags/resource_tags_location_tag_binding_meta.yaml index d8466f80dda2..466d99f5a6b3 100644 --- a/mmv1/third_party/terraform/services/tags/resource_tags_location_tag_binding_meta.yaml +++ b/mmv1/third_party/terraform/services/tags/resource_tags_location_tag_binding_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/mmv1/third_party/terraform/tpgresource/utils.go b/mmv1/third_party/terraform/tpgresource/utils.go index 6585aad6d3be..697bf73fff4c 100644 --- a/mmv1/third_party/terraform/tpgresource/utils.go +++ b/mmv1/third_party/terraform/tpgresource/utils.go @@ -154,6 +154,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) } @@ -901,6 +983,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/mmv1/third_party/terraform/transport/config.go.tmpl b/mmv1/third_party/terraform/transport/config.go.tmpl index 176b1ab46e87..e5e8d448ad8b 100644 --- a/mmv1/third_party/terraform/transport/config.go.tmpl +++ b/mmv1/third_party/terraform/transport/config.go.tmpl @@ -199,6 +199,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/mmv1/third_party/terraform/website/docs/r/apigee_api.html.markdown b/mmv1/third_party/terraform/website/docs/r/apigee_api.html.markdown index 6193bf056d3f..8efce648d710 100644 --- a/mmv1/third_party/terraform/website/docs/r/apigee_api.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/apigee_api.html.markdown @@ -53,6 +53,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/mmv1/third_party/terraform/website/docs/r/apigee_flowhook.html.markdown b/mmv1/third_party/terraform/website/docs/r/apigee_flowhook.html.markdown index 10bfd452b5b5..dbe396035941 100644 --- a/mmv1/third_party/terraform/website/docs/r/apigee_flowhook.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/apigee_flowhook.html.markdown @@ -44,6 +44,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/mmv1/third_party/terraform/website/docs/r/apigee_keystores_aliases_pkcs12.html.markdown b/mmv1/third_party/terraform/website/docs/r/apigee_keystores_aliases_pkcs12.html.markdown index 2e5879d69f4d..fbc16311823b 100644 --- a/mmv1/third_party/terraform/website/docs/r/apigee_keystores_aliases_pkcs12.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/apigee_keystores_aliases_pkcs12.html.markdown @@ -39,6 +39,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/mmv1/third_party/terraform/website/docs/r/apigee_sharedflow.html.markdown b/mmv1/third_party/terraform/website/docs/r/apigee_sharedflow.html.markdown index bec53e7f9b7a..ef14b92f30b5 100644 --- a/mmv1/third_party/terraform/website/docs/r/apigee_sharedflow.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/apigee_sharedflow.html.markdown @@ -126,6 +126,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/mmv1/third_party/terraform/website/docs/r/apigee_sharedflow_deployment.html.markdown b/mmv1/third_party/terraform/website/docs/r/apigee_sharedflow_deployment.html.markdown index e512322624e8..35642fbaa086 100644 --- a/mmv1/third_party/terraform/website/docs/r/apigee_sharedflow_deployment.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/apigee_sharedflow_deployment.html.markdown @@ -36,6 +36,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/mmv1/third_party/terraform/website/docs/r/apikeys_key.html.markdown b/mmv1/third_party/terraform/website/docs/r/apikeys_key.html.markdown index 261ce7030cf0..6b7d0d2c51d0 100644 --- a/mmv1/third_party/terraform/website/docs/r/apikeys_key.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/apikeys_key.html.markdown @@ -155,6 +155,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/mmv1/third_party/terraform/website/docs/r/assured_workloads_workload.html.markdown b/mmv1/third_party/terraform/website/docs/r/assured_workloads_workload.html.markdown index 7fc0c7c39137..8444bfba4e24 100644 --- a/mmv1/third_party/terraform/website/docs/r/assured_workloads_workload.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/assured_workloads_workload.html.markdown @@ -200,6 +200,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/mmv1/third_party/terraform/website/docs/r/bigquery_table.html.markdown b/mmv1/third_party/terraform/website/docs/r/bigquery_table.html.markdown index e3afb3209553..54cf7374dcdc 100644 --- a/mmv1/third_party/terraform/website/docs/r/bigquery_table.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/bigquery_table.html.markdown @@ -128,6 +128,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/mmv1/third_party/terraform/website/docs/r/bigtable_authorized_view.html.markdown b/mmv1/third_party/terraform/website/docs/r/bigtable_authorized_view.html.markdown index a08d26f7039d..a5d7d3d096cd 100644 --- a/mmv1/third_party/terraform/website/docs/r/bigtable_authorized_view.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/bigtable_authorized_view.html.markdown @@ -98,6 +98,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/mmv1/third_party/terraform/website/docs/r/bigtable_gc_policy.html.markdown b/mmv1/third_party/terraform/website/docs/r/bigtable_gc_policy.html.markdown index d6490d4f72b3..4256e1ec5647 100644 --- a/mmv1/third_party/terraform/website/docs/r/bigtable_gc_policy.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/bigtable_gc_policy.html.markdown @@ -161,10 +161,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/mmv1/third_party/terraform/website/docs/r/bigtable_instance.html.markdown b/mmv1/third_party/terraform/website/docs/r/bigtable_instance.html.markdown index 4f524b69f0ac..47c9bfa4b869 100644 --- a/mmv1/third_party/terraform/website/docs/r/bigtable_instance.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/bigtable_instance.html.markdown @@ -114,6 +114,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/mmv1/third_party/terraform/website/docs/r/bigtable_table.html.markdown b/mmv1/third_party/terraform/website/docs/r/bigtable_table.html.markdown index ef0f71085b91..a8a674bad295 100644 --- a/mmv1/third_party/terraform/website/docs/r/bigtable_table.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/bigtable_table.html.markdown @@ -101,6 +101,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/mmv1/third_party/terraform/website/docs/r/cloudbuild_worker_pool.html.markdown b/mmv1/third_party/terraform/website/docs/r/cloudbuild_worker_pool.html.markdown index 50005f52291f..e81daf78c5d1 100644 --- a/mmv1/third_party/terraform/website/docs/r/cloudbuild_worker_pool.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/cloudbuild_worker_pool.html.markdown @@ -92,7 +92,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/mmv1/third_party/terraform/website/docs/r/clouddeploy_delivery_pipeline.html.markdown b/mmv1/third_party/terraform/website/docs/r/clouddeploy_delivery_pipeline.html.markdown index 8a361fa093ca..394c46d880b4 100644 --- a/mmv1/third_party/terraform/website/docs/r/clouddeploy_delivery_pipeline.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/clouddeploy_delivery_pipeline.html.markdown @@ -274,7 +274,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/mmv1/third_party/terraform/website/docs/r/clouddeploy_target.html.markdown b/mmv1/third_party/terraform/website/docs/r/clouddeploy_target.html.markdown index 148a70be6de9..f2dabe7393dc 100644 --- a/mmv1/third_party/terraform/website/docs/r/clouddeploy_target.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/clouddeploy_target.html.markdown @@ -189,7 +189,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/mmv1/third_party/terraform/website/docs/r/cloudfunctions_function.html.markdown b/mmv1/third_party/terraform/website/docs/r/cloudfunctions_function.html.markdown index 5e046ace814b..8a5988975e82 100644 --- a/mmv1/third_party/terraform/website/docs/r/cloudfunctions_function.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/cloudfunctions_function.html.markdown @@ -183,6 +183,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/mmv1/third_party/terraform/website/docs/r/composer_environment.html.markdown b/mmv1/third_party/terraform/website/docs/r/composer_environment.html.markdown index 8fe18d19f732..290529e334db 100644 --- a/mmv1/third_party/terraform/website/docs/r/composer_environment.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/composer_environment.html.markdown @@ -458,6 +458,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/mmv1/third_party/terraform/website/docs/r/composer_user_workloads_secret.html.markdown b/mmv1/third_party/terraform/website/docs/r/composer_user_workloads_secret.html.markdown index 337ced525b87..0ee115ba1cbe 100644 --- a/mmv1/third_party/terraform/website/docs/r/composer_user_workloads_secret.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/composer_user_workloads_secret.html.markdown @@ -66,6 +66,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/mmv1/third_party/terraform/website/docs/r/compute_attached_disk.html.markdown b/mmv1/third_party/terraform/website/docs/r/compute_attached_disk.html.markdown index 4ec98cbfab7e..27b50dd0eaa8 100644 --- a/mmv1/third_party/terraform/website/docs/r/compute_attached_disk.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/compute_attached_disk.html.markdown @@ -113,6 +113,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/mmv1/third_party/terraform/website/docs/r/compute_disk_async_replication.html.markdown b/mmv1/third_party/terraform/website/docs/r/compute_disk_async_replication.html.markdown index e552268ac51a..774c7ec44870 100644 --- a/mmv1/third_party/terraform/website/docs/r/compute_disk_async_replication.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/compute_disk_async_replication.html.markdown @@ -49,6 +49,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/mmv1/third_party/terraform/website/docs/r/compute_instance.html.markdown b/mmv1/third_party/terraform/website/docs/r/compute_instance.html.markdown index cf8e167cde7e..d9b30cba75fb 100644 --- a/mmv1/third_party/terraform/website/docs/r/compute_instance.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/compute_instance.html.markdown @@ -256,6 +256,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/mmv1/third_party/terraform/website/docs/r/compute_instance_group.html.markdown b/mmv1/third_party/terraform/website/docs/r/compute_instance_group.html.markdown index 5d846e846bbd..82aeed9dcb7a 100644 --- a/mmv1/third_party/terraform/website/docs/r/compute_instance_group.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/compute_instance_group.html.markdown @@ -146,6 +146,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/mmv1/third_party/terraform/website/docs/r/compute_instance_group_manager.html.markdown b/mmv1/third_party/terraform/website/docs/r/compute_instance_group_manager.html.markdown index a25ff4d45d11..73ed263295b6 100644 --- a/mmv1/third_party/terraform/website/docs/r/compute_instance_group_manager.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/compute_instance_group_manager.html.markdown @@ -258,6 +258,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/mmv1/third_party/terraform/website/docs/r/compute_network_peering.html.markdown b/mmv1/third_party/terraform/website/docs/r/compute_network_peering.html.markdown index 03aabfac59f1..8bc6fc19a08e 100644 --- a/mmv1/third_party/terraform/website/docs/r/compute_network_peering.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/compute_network_peering.html.markdown @@ -71,6 +71,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/mmv1/third_party/terraform/website/docs/r/compute_project_metadata.html.markdown b/mmv1/third_party/terraform/website/docs/r/compute_project_metadata.html.markdown index 2692f87100e1..33ab5b07eef5 100644 --- a/mmv1/third_party/terraform/website/docs/r/compute_project_metadata.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/compute_project_metadata.html.markdown @@ -57,6 +57,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/mmv1/third_party/terraform/website/docs/r/compute_project_metadata_item.html.markdown b/mmv1/third_party/terraform/website/docs/r/compute_project_metadata_item.html.markdown index ff0556f2663f..5b57ed1c241b 100644 --- a/mmv1/third_party/terraform/website/docs/r/compute_project_metadata_item.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/compute_project_metadata_item.html.markdown @@ -33,6 +33,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/mmv1/third_party/terraform/website/docs/r/compute_region_instance_group_manager.html.markdown b/mmv1/third_party/terraform/website/docs/r/compute_region_instance_group_manager.html.markdown index 43d3ce5e8154..078529504303 100644 --- a/mmv1/third_party/terraform/website/docs/r/compute_region_instance_group_manager.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/compute_region_instance_group_manager.html.markdown @@ -137,6 +137,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/mmv1/third_party/terraform/website/docs/r/compute_region_instance_template.html.markdown b/mmv1/third_party/terraform/website/docs/r/compute_region_instance_template.html.markdown index 16e254d4ab36..bd3ecc9af3f7 100644 --- a/mmv1/third_party/terraform/website/docs/r/compute_region_instance_template.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/compute_region_instance_template.html.markdown @@ -395,6 +395,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/mmv1/third_party/terraform/website/docs/r/compute_router_interface.html.markdown b/mmv1/third_party/terraform/website/docs/r/compute_router_interface.html.markdown index 31f2f87926cc..56a051bb2fdc 100644 --- a/mmv1/third_party/terraform/website/docs/r/compute_router_interface.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/compute_router_interface.html.markdown @@ -69,6 +69,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/mmv1/third_party/terraform/website/docs/r/compute_router_peer.html.markdown b/mmv1/third_party/terraform/website/docs/r/compute_router_peer.html.markdown index f1789bc85e2a..3284122f2553 100644 --- a/mmv1/third_party/terraform/website/docs/r/compute_router_peer.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/compute_router_peer.html.markdown @@ -535,6 +535,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/mmv1/third_party/terraform/website/docs/r/compute_security_policy.html.markdown b/mmv1/third_party/terraform/website/docs/r/compute_security_policy.html.markdown index 3242cbda2623..6bd6dd90b880 100644 --- a/mmv1/third_party/terraform/website/docs/r/compute_security_policy.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/compute_security_policy.html.markdown @@ -226,6 +226,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/mmv1/third_party/terraform/website/docs/r/compute_shared_vpc_host_project.html.markdown b/mmv1/third_party/terraform/website/docs/r/compute_shared_vpc_host_project.html.markdown index 88d09437ee39..cfb1d63447fd 100644 --- a/mmv1/third_party/terraform/website/docs/r/compute_shared_vpc_host_project.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/compute_shared_vpc_host_project.html.markdown @@ -41,6 +41,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/mmv1/third_party/terraform/website/docs/r/compute_target_pool.html.markdown b/mmv1/third_party/terraform/website/docs/r/compute_target_pool.html.markdown index ab3e71390ba4..db3e3e2e6ffa 100644 --- a/mmv1/third_party/terraform/website/docs/r/compute_target_pool.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/compute_target_pool.html.markdown @@ -75,6 +75,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/mmv1/third_party/terraform/website/docs/r/container_aws_cluster.html.markdown b/mmv1/third_party/terraform/website/docs/r/container_aws_cluster.html.markdown index 66fbf2744973..4de667204b42 100644 --- a/mmv1/third_party/terraform/website/docs/r/container_aws_cluster.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/container_aws_cluster.html.markdown @@ -324,7 +324,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/mmv1/third_party/terraform/website/docs/r/container_aws_node_pool.html.markdown b/mmv1/third_party/terraform/website/docs/r/container_aws_node_pool.html.markdown index 986f1f4b164d..30375eefe511 100644 --- a/mmv1/third_party/terraform/website/docs/r/container_aws_node_pool.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/container_aws_node_pool.html.markdown @@ -533,7 +533,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/mmv1/third_party/terraform/website/docs/r/container_azure_client.html.markdown b/mmv1/third_party/terraform/website/docs/r/container_azure_client.html.markdown index fce523a2c3e2..1b68feea9d48 100644 --- a/mmv1/third_party/terraform/website/docs/r/container_azure_client.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/container_azure_client.html.markdown @@ -50,6 +50,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/mmv1/third_party/terraform/website/docs/r/container_azure_cluster.html.markdown b/mmv1/third_party/terraform/website/docs/r/container_azure_cluster.html.markdown index 091b0c590615..5a776ac55abe 100644 --- a/mmv1/third_party/terraform/website/docs/r/container_azure_cluster.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/container_azure_cluster.html.markdown @@ -167,7 +167,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/mmv1/third_party/terraform/website/docs/r/container_azure_node_pool.html.markdown b/mmv1/third_party/terraform/website/docs/r/container_azure_node_pool.html.markdown index 127c6371f325..8ee7da64894e 100644 --- a/mmv1/third_party/terraform/website/docs/r/container_azure_node_pool.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/container_azure_node_pool.html.markdown @@ -154,7 +154,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/mmv1/third_party/terraform/website/docs/r/container_cluster.html.markdown b/mmv1/third_party/terraform/website/docs/r/container_cluster.html.markdown index e3499abf02ed..9b9a52d0b1bb 100644 --- a/mmv1/third_party/terraform/website/docs/r/container_cluster.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/container_cluster.html.markdown @@ -447,6 +447,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/mmv1/third_party/terraform/website/docs/r/container_node_pool.html.markdown b/mmv1/third_party/terraform/website/docs/r/container_node_pool.html.markdown index 6157d8648961..fe7dbf368231 100644 --- a/mmv1/third_party/terraform/website/docs/r/container_node_pool.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/container_node_pool.html.markdown @@ -175,6 +175,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/mmv1/third_party/terraform/website/docs/r/dataflow_flex_template_job.html.markdown b/mmv1/third_party/terraform/website/docs/r/dataflow_flex_template_job.html.markdown index 5ec2ddd69467..a2cf91af1bfe 100644 --- a/mmv1/third_party/terraform/website/docs/r/dataflow_flex_template_job.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/dataflow_flex_template_job.html.markdown @@ -152,6 +152,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/mmv1/third_party/terraform/website/docs/r/dataflow_job.html.markdown b/mmv1/third_party/terraform/website/docs/r/dataflow_job.html.markdown index 98421f823577..18288b2401fe 100644 --- a/mmv1/third_party/terraform/website/docs/r/dataflow_job.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/dataflow_job.html.markdown @@ -124,6 +124,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/mmv1/third_party/terraform/website/docs/r/dataplex_asset.html.markdown b/mmv1/third_party/terraform/website/docs/r/dataplex_asset.html.markdown index 847fcf9d7e4c..ef88109a02a8 100644 --- a/mmv1/third_party/terraform/website/docs/r/dataplex_asset.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/dataplex_asset.html.markdown @@ -105,7 +105,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/mmv1/third_party/terraform/website/docs/r/dataplex_lake.html.markdown b/mmv1/third_party/terraform/website/docs/r/dataplex_lake.html.markdown index aa9140250af2..4c805e785afb 100644 --- a/mmv1/third_party/terraform/website/docs/r/dataplex_lake.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/dataplex_lake.html.markdown @@ -64,6 +64,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/mmv1/third_party/terraform/website/docs/r/dataplex_zone.html.markdown b/mmv1/third_party/terraform/website/docs/r/dataplex_zone.html.markdown index 80977fc6d17b..849a3f6a7c92 100644 --- a/mmv1/third_party/terraform/website/docs/r/dataplex_zone.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/dataplex_zone.html.markdown @@ -73,7 +73,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/mmv1/third_party/terraform/website/docs/r/dataproc_cluster.html.markdown b/mmv1/third_party/terraform/website/docs/r/dataproc_cluster.html.markdown index ebc95e0994ac..6c2ebad42f02 100644 --- a/mmv1/third_party/terraform/website/docs/r/dataproc_cluster.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/dataproc_cluster.html.markdown @@ -156,6 +156,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/mmv1/third_party/terraform/website/docs/r/dataproc_job.html.markdown b/mmv1/third_party/terraform/website/docs/r/dataproc_job.html.markdown index e54719f3c400..48a2b07dff8b 100644 --- a/mmv1/third_party/terraform/website/docs/r/dataproc_job.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/dataproc_job.html.markdown @@ -117,6 +117,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/mmv1/third_party/terraform/website/docs/r/dataproc_workflow_template.html.markdown b/mmv1/third_party/terraform/website/docs/r/dataproc_workflow_template.html.markdown index 51ff8476d647..42b1eaa72069 100644 --- a/mmv1/third_party/terraform/website/docs/r/dataproc_workflow_template.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/dataproc_workflow_template.html.markdown @@ -155,6 +155,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/mmv1/third_party/terraform/website/docs/r/dns_record_set.html.markdown b/mmv1/third_party/terraform/website/docs/r/dns_record_set.html.markdown index 019f2b93d9e7..9d4b01976ac5 100644 --- a/mmv1/third_party/terraform/website/docs/r/dns_record_set.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/dns_record_set.html.markdown @@ -315,6 +315,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/mmv1/third_party/terraform/website/docs/r/firebaserules_release.html.markdown b/mmv1/third_party/terraform/website/docs/r/firebaserules_release.html.markdown index 815a3e1adda8..6d40961401d3 100644 --- a/mmv1/third_party/terraform/website/docs/r/firebaserules_release.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/firebaserules_release.html.markdown @@ -120,7 +120,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/mmv1/third_party/terraform/website/docs/r/firebaserules_ruleset.html.markdown b/mmv1/third_party/terraform/website/docs/r/firebaserules_ruleset.html.markdown index f1b3ff4a0887..0b5e75f9779c 100644 --- a/mmv1/third_party/terraform/website/docs/r/firebaserules_ruleset.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/firebaserules_ruleset.html.markdown @@ -71,7 +71,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/mmv1/third_party/terraform/website/docs/r/gke_hub_feature_membership.html.markdown b/mmv1/third_party/terraform/website/docs/r/gke_hub_feature_membership.html.markdown index d9c75fad74e9..aea722b0a299 100644 --- a/mmv1/third_party/terraform/website/docs/r/gke_hub_feature_membership.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/gke_hub_feature_membership.html.markdown @@ -358,6 +358,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/mmv1/third_party/terraform/website/docs/r/google_billing_subaccount.html.markdown b/mmv1/third_party/terraform/website/docs/r/google_billing_subaccount.html.markdown index 3ee7bcb3d6b1..fdfc88859ee7 100644 --- a/mmv1/third_party/terraform/website/docs/r/google_billing_subaccount.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/google_billing_subaccount.html.markdown @@ -26,7 +26,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/mmv1/third_party/terraform/website/docs/r/google_folder.html.markdown b/mmv1/third_party/terraform/website/docs/r/google_folder.html.markdown index 29825e8f5164..ebb2273b64a6 100644 --- a/mmv1/third_party/terraform/website/docs/r/google_folder.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/google_folder.html.markdown @@ -59,6 +59,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/mmv1/third_party/terraform/website/docs/r/google_folder_organization_policy.html.markdown b/mmv1/third_party/terraform/website/docs/r/google_folder_organization_policy.html.markdown index b2a8d0622a1f..1b0a89e5d1e1 100644 --- a/mmv1/third_party/terraform/website/docs/r/google_folder_organization_policy.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/google_folder_organization_policy.html.markdown @@ -100,6 +100,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/mmv1/third_party/terraform/website/docs/r/google_organization_iam_custom_role.html.markdown b/mmv1/third_party/terraform/website/docs/r/google_organization_iam_custom_role.html.markdown index 1e419d9e4252..1f08a77c3421 100644 --- a/mmv1/third_party/terraform/website/docs/r/google_organization_iam_custom_role.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/google_organization_iam_custom_role.html.markdown @@ -50,6 +50,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/mmv1/third_party/terraform/website/docs/r/google_organization_policy.html.markdown b/mmv1/third_party/terraform/website/docs/r/google_organization_policy.html.markdown index f963cb47bbf8..9bcc5bfbd131 100644 --- a/mmv1/third_party/terraform/website/docs/r/google_organization_policy.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/google_organization_policy.html.markdown @@ -99,6 +99,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/mmv1/third_party/terraform/website/docs/r/google_project_iam_custom_role.html.markdown b/mmv1/third_party/terraform/website/docs/r/google_project_iam_custom_role.html.markdown index 9c18717b0d2a..98c994c8e298 100644 --- a/mmv1/third_party/terraform/website/docs/r/google_project_iam_custom_role.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/google_project_iam_custom_role.html.markdown @@ -50,6 +50,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/mmv1/third_party/terraform/website/docs/r/google_project_iam_member_remove.html.markdown b/mmv1/third_party/terraform/website/docs/r/google_project_iam_member_remove.html.markdown index 4d9b3888df5b..24314642d403 100644 --- a/mmv1/third_party/terraform/website/docs/r/google_project_iam_member_remove.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/google_project_iam_member_remove.html.markdown @@ -53,3 +53,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/mmv1/third_party/terraform/website/docs/r/google_project_organization_policy.html.markdown b/mmv1/third_party/terraform/website/docs/r/google_project_organization_policy.html.markdown index 67eb3c515d6b..6b1de9ab2b77 100644 --- a/mmv1/third_party/terraform/website/docs/r/google_project_organization_policy.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/google_project_organization_policy.html.markdown @@ -99,6 +99,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/mmv1/third_party/terraform/website/docs/r/google_project_service.html.markdown b/mmv1/third_party/terraform/website/docs/r/google_project_service.html.markdown index 14af21053cea..67f2b6753707 100644 --- a/mmv1/third_party/terraform/website/docs/r/google_project_service.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/google_project_service.html.markdown @@ -60,6 +60,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/mmv1/third_party/terraform/website/docs/r/google_service_account.html.markdown b/mmv1/third_party/terraform/website/docs/r/google_service_account.html.markdown index bdfabc635e50..50930b6b4a65 100644 --- a/mmv1/third_party/terraform/website/docs/r/google_service_account.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/google_service_account.html.markdown @@ -53,6 +53,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/mmv1/third_party/terraform/website/docs/r/google_service_account_key.html.markdown b/mmv1/third_party/terraform/website/docs/r/google_service_account_key.html.markdown index 0cb3eb5ac28c..ad30a9743ee6 100644 --- a/mmv1/third_party/terraform/website/docs/r/google_service_account_key.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/google_service_account_key.html.markdown @@ -101,6 +101,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/mmv1/third_party/terraform/website/docs/r/google_service_networking_peered_dns_domain.html.markdown b/mmv1/third_party/terraform/website/docs/r/google_service_networking_peered_dns_domain.html.markdown index d4ebc11299bc..898bed8a1e40 100644 --- a/mmv1/third_party/terraform/website/docs/r/google_service_networking_peered_dns_domain.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/google_service_networking_peered_dns_domain.html.markdown @@ -38,6 +38,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/mmv1/third_party/terraform/website/docs/r/google_tags_location_tag_binding.html.markdown b/mmv1/third_party/terraform/website/docs/r/google_tags_location_tag_binding.html.markdown index ee094e88618c..a2926dcf2ff3 100644 --- a/mmv1/third_party/terraform/website/docs/r/google_tags_location_tag_binding.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/google_tags_location_tag_binding.html.markdown @@ -112,6 +112,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/mmv1/third_party/terraform/website/docs/r/logging_billing_account_bucket_config.html.markdown b/mmv1/third_party/terraform/website/docs/r/logging_billing_account_bucket_config.html.markdown index 2f481874d40f..80350856125f 100644 --- a/mmv1/third_party/terraform/website/docs/r/logging_billing_account_bucket_config.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/logging_billing_account_bucket_config.html.markdown @@ -59,6 +59,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/mmv1/third_party/terraform/website/docs/r/logging_billing_account_sink.html.markdown b/mmv1/third_party/terraform/website/docs/r/logging_billing_account_sink.html.markdown index 97f1b3717c24..1a71eb717d5a 100644 --- a/mmv1/third_party/terraform/website/docs/r/logging_billing_account_sink.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/logging_billing_account_sink.html.markdown @@ -72,6 +72,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/mmv1/third_party/terraform/website/docs/r/logging_folder_bucket_config.html.markdown b/mmv1/third_party/terraform/website/docs/r/logging_folder_bucket_config.html.markdown index e73a8ebd95cf..7b895d3d67e6 100644 --- a/mmv1/third_party/terraform/website/docs/r/logging_folder_bucket_config.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/logging_folder_bucket_config.html.markdown @@ -49,6 +49,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/mmv1/third_party/terraform/website/docs/r/logging_folder_sink.html.markdown b/mmv1/third_party/terraform/website/docs/r/logging_folder_sink.html.markdown index 3741d6632d54..012e4d1e7d2a 100644 --- a/mmv1/third_party/terraform/website/docs/r/logging_folder_sink.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/logging_folder_sink.html.markdown @@ -84,6 +84,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/mmv1/third_party/terraform/website/docs/r/logging_organization_bucket_config.html.markdown b/mmv1/third_party/terraform/website/docs/r/logging_organization_bucket_config.html.markdown index 9255da93ea42..17e23660339d 100644 --- a/mmv1/third_party/terraform/website/docs/r/logging_organization_bucket_config.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/logging_organization_bucket_config.html.markdown @@ -48,6 +48,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/mmv1/third_party/terraform/website/docs/r/logging_organization_sink.html.markdown b/mmv1/third_party/terraform/website/docs/r/logging_organization_sink.html.markdown index f9600f68555d..c0dc3fcc407e 100644 --- a/mmv1/third_party/terraform/website/docs/r/logging_organization_sink.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/logging_organization_sink.html.markdown @@ -74,6 +74,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/mmv1/third_party/terraform/website/docs/r/logging_project_bucket_config.html.markdown b/mmv1/third_party/terraform/website/docs/r/logging_project_bucket_config.html.markdown index 2e57e1993f01..b546a04a802f 100644 --- a/mmv1/third_party/terraform/website/docs/r/logging_project_bucket_config.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/logging_project_bucket_config.html.markdown @@ -131,6 +131,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/mmv1/third_party/terraform/website/docs/r/logging_project_sink.html.markdown b/mmv1/third_party/terraform/website/docs/r/logging_project_sink.html.markdown index a883fa8c6d6b..ac8f4be226cd 100644 --- a/mmv1/third_party/terraform/website/docs/r/logging_project_sink.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/logging_project_sink.html.markdown @@ -203,6 +203,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/mmv1/third_party/terraform/website/docs/r/monitoring_dashboard.html.markdown b/mmv1/third_party/terraform/website/docs/r/monitoring_dashboard.html.markdown index b1b72bb9d2e0..55b4fb095450 100644 --- a/mmv1/third_party/terraform/website/docs/r/monitoring_dashboard.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/monitoring_dashboard.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/mmv1/third_party/terraform/website/docs/r/os_config_os_policy_assignment.html.markdown b/mmv1/third_party/terraform/website/docs/r/os_config_os_policy_assignment.html.markdown index 229383c34847..e5be5713bf2e 100644 --- a/mmv1/third_party/terraform/website/docs/r/os_config_os_policy_assignment.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/os_config_os_policy_assignment.html.markdown @@ -130,6 +130,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/mmv1/third_party/terraform/website/docs/r/project_usage_export_bucket.html.markdown b/mmv1/third_party/terraform/website/docs/r/project_usage_export_bucket.html.markdown index b360a36f9185..2899183e4875 100644 --- a/mmv1/third_party/terraform/website/docs/r/project_usage_export_bucket.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/project_usage_export_bucket.html.markdown @@ -36,6 +36,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/mmv1/third_party/terraform/website/docs/r/recaptcha_enterprise_key.html.markdown b/mmv1/third_party/terraform/website/docs/r/recaptcha_enterprise_key.html.markdown index e364fee56129..57f8d08eb47c 100644 --- a/mmv1/third_party/terraform/website/docs/r/recaptcha_enterprise_key.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/recaptcha_enterprise_key.html.markdown @@ -198,7 +198,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/mmv1/third_party/terraform/website/docs/r/runtimeconfig_config.html.markdown b/mmv1/third_party/terraform/website/docs/r/runtimeconfig_config.html.markdown index 5ac4cfd51112..eadd0840d515 100644 --- a/mmv1/third_party/terraform/website/docs/r/runtimeconfig_config.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/runtimeconfig_config.html.markdown @@ -42,6 +42,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/mmv1/third_party/terraform/website/docs/r/runtimeconfig_variable.html.markdown b/mmv1/third_party/terraform/website/docs/r/runtimeconfig_variable.html.markdown index f768471c0cdc..ebd114bcf29a 100644 --- a/mmv1/third_party/terraform/website/docs/r/runtimeconfig_variable.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/runtimeconfig_variable.html.markdown @@ -69,6 +69,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/mmv1/third_party/terraform/website/docs/r/service_networking_connection.html.markdown b/mmv1/third_party/terraform/website/docs/r/service_networking_connection.html.markdown index 78af668080cb..0f0639fba6c1 100644 --- a/mmv1/third_party/terraform/website/docs/r/service_networking_connection.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/service_networking_connection.html.markdown @@ -59,7 +59,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/mmv1/third_party/terraform/website/docs/r/site_verification_owner.html.markdown b/mmv1/third_party/terraform/website/docs/r/site_verification_owner.html.markdown index d1eec2889f13..f8a6a32576e7 100644 --- a/mmv1/third_party/terraform/website/docs/r/site_verification_owner.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/site_verification_owner.html.markdown @@ -96,6 +96,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/mmv1/third_party/terraform/website/docs/r/sql_database_instance.html.markdown b/mmv1/third_party/terraform/website/docs/r/sql_database_instance.html.markdown index 136d417a2097..57051080ecb3 100644 --- a/mmv1/third_party/terraform/website/docs/r/sql_database_instance.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/sql_database_instance.html.markdown @@ -420,6 +420,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/mmv1/third_party/terraform/website/docs/r/sql_ssl_cert.html.markdown b/mmv1/third_party/terraform/website/docs/r/sql_ssl_cert.html.markdown index 156e29ba10e4..58788fea847f 100644 --- a/mmv1/third_party/terraform/website/docs/r/sql_ssl_cert.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/sql_ssl_cert.html.markdown @@ -47,6 +47,12 @@ The following arguments are supported: * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. +* `deletion_policy` - (Optional) Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". + When a 'terraform destroy' or 'terraform apply' would delete the resource, + the command will fail if this field is set to "PREVENT" in Terraform state. + When set to "ABANDON", the command will remove the resource from Terraform + management without updating or deleting the resource in the API. + When set to "DELETE", deleting the resource is allowed. ## Attributes Reference diff --git a/mmv1/third_party/terraform/website/docs/r/sql_user.html.markdown b/mmv1/third_party/terraform/website/docs/r/sql_user.html.markdown index 62330dee50dd..be7e6440ad4d 100644 --- a/mmv1/third_party/terraform/website/docs/r/sql_user.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/sql_user.html.markdown @@ -161,11 +161,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/mmv1/third_party/terraform/website/docs/r/storage_bucket.html.markdown b/mmv1/third_party/terraform/website/docs/r/storage_bucket.html.markdown index 48525bf17c91..b1fab6bc9651 100644 --- a/mmv1/third_party/terraform/website/docs/r/storage_bucket.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/storage_bucket.html.markdown @@ -238,6 +238,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/mmv1/third_party/terraform/website/docs/r/storage_bucket_acl.html.markdown b/mmv1/third_party/terraform/website/docs/r/storage_bucket_acl.html.markdown index e5ae8ba871ec..768d822f111d 100644 --- a/mmv1/third_party/terraform/website/docs/r/storage_bucket_acl.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/storage_bucket_acl.html.markdown @@ -49,6 +49,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/mmv1/third_party/terraform/website/docs/r/storage_bucket_object.html.markdown b/mmv1/third_party/terraform/website/docs/r/storage_bucket_object.html.markdown index 8802718e1093..3d2d810ee209 100644 --- a/mmv1/third_party/terraform/website/docs/r/storage_bucket_object.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/storage_bucket_object.html.markdown @@ -113,7 +113,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/mmv1/third_party/terraform/website/docs/r/storage_default_object_acl.html.markdown b/mmv1/third_party/terraform/website/docs/r/storage_default_object_acl.html.markdown index ecac34f2d89d..6824efe3e1dc 100644 --- a/mmv1/third_party/terraform/website/docs/r/storage_default_object_acl.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/storage_default_object_acl.html.markdown @@ -49,6 +49,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/mmv1/third_party/terraform/website/docs/r/storage_object_acl.html.markdown b/mmv1/third_party/terraform/website/docs/r/storage_object_acl.html.markdown index 368f1e7fdacb..9b10ec646ec9 100644 --- a/mmv1/third_party/terraform/website/docs/r/storage_object_acl.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/storage_object_acl.html.markdown @@ -62,6 +62,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/mmv1/third_party/terraform/website/docs/r/storage_transfer_job.html.markdown b/mmv1/third_party/terraform/website/docs/r/storage_transfer_job.html.markdown index f506647350d2..a004ac000ab8 100644 --- a/mmv1/third_party/terraform/website/docs/r/storage_transfer_job.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/storage_transfer_job.html.markdown @@ -148,6 +148,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/tools/diff-processor/detector/detector.go b/tools/diff-processor/detector/detector.go index 383cdf8bb152..be3537960f4f 100644 --- a/tools/diff-processor/detector/detector.go +++ b/tools/diff-processor/detector/detector.go @@ -62,6 +62,13 @@ func getChangedFieldsFromSchemaDiff(schemaDiff diff.SchemaDiff) map[string]Resou // Skip the project field. continue } + if field == "deletion_policy" { + //Skip tests for deletion policy. + //With the addition of the universal policy, these don't need to be detected on a resource basis. + // + //To-Do: don't skip if `deletion_policy_exclude` is flagged + continue + } // Ignore condition fields on iam resources because we always generate them whether or not // they're supported. // Longer-term fix tracked at https://github.com/hashicorp/terraform-provider-google/issues/18412