hashicorp / terraform-provider-google

Terraform Provider for Google Cloud Platform
https://registry.terraform.io/providers/hashicorp/google/latest/docs
Mozilla Public License 2.0
2.36k stars 1.75k forks source link

`firestore_field`: unable to delete after applying the resource #20397

Open BBBmau opened 2 days ago

BBBmau commented 2 days ago

Community Note

Terraform Version & Provider Version(s)

Terraform v1.9.8 on

Affected Resource(s)

google_firestore_field

Terraform Configuration

resource "google_firestore_database" "default" {
  name        = "testdb"
  location_id = "us-west2"
  type        = "FIRESTORE_NATIVE"
}

resource "google_firestore_field" "wildcard_exemption" {
  project    = google_firestore_database.default.project
  database   = google_firestore_database.default.name
  collection = "testcollection"
  field      = "*"
  index_config {}
}

Debug Output

2024-11-19T11:53:36.208-0800 [DEBUG] provider.terraform-provider-google_v6.12.0_x5: -----------------------------------------------------
2024-11-19T11:53:36.477-0800 [DEBUG] provider.terraform-provider-google_v6.12.0_x5: 2024/11/19 11:53:36 [DEBUG] Google API Response Details:
2024-11-19T11:53:36.477-0800 [DEBUG] provider.terraform-provider-google_v6.12.0_x5: ---[ RESPONSE ]--------------------------------------
2024-11-19T11:53:36.477-0800 [DEBUG] provider.terraform-provider-google_v6.12.0_x5: HTTP/2.0 400 Bad Request
2024-11-19T11:53:36.477-0800 [DEBUG] provider.terraform-provider-google_v6.12.0_x5: Alt-Svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
2024-11-19T11:53:36.477-0800 [DEBUG] provider.terraform-provider-google_v6.12.0_x5: Cache-Control: private
2024-11-19T11:53:36.477-0800 [DEBUG] provider.terraform-provider-google_v6.12.0_x5: Content-Type: application/json; charset=UTF-8
2024-11-19T11:53:36.477-0800 [DEBUG] provider.terraform-provider-google_v6.12.0_x5: Date: Tue, 19 Nov 2024 19:53:36 GMT
2024-11-19T11:53:36.477-0800 [DEBUG] provider.terraform-provider-google_v6.12.0_x5: Server: ESF
2024-11-19T11:53:36.477-0800 [DEBUG] provider.terraform-provider-google_v6.12.0_x5: Vary: Origin
2024-11-19T11:53:36.477-0800 [DEBUG] provider.terraform-provider-google_v6.12.0_x5: Vary: X-Origin
2024-11-19T11:53:36.477-0800 [DEBUG] provider.terraform-provider-google_v6.12.0_x5: Vary: Referer
2024-11-19T11:53:36.477-0800 [DEBUG] provider.terraform-provider-google_v6.12.0_x5: X-Content-Type-Options: nosniff
2024-11-19T11:53:36.477-0800 [DEBUG] provider.terraform-provider-google_v6.12.0_x5: X-Debug-Tracking-Id: 2862105657178788352;o=0
2024-11-19T11:53:36.477-0800 [DEBUG] provider.terraform-provider-google_v6.12.0_x5: X-Frame-Options: SAMEORIGIN
2024-11-19T11:53:36.477-0800 [DEBUG] provider.terraform-provider-google_v6.12.0_x5: X-Xss-Protection: 0
2024-11-19T11:53:36.477-0800 [DEBUG] provider.terraform-provider-google_v6.12.0_x5
2024-11-19T11:53:36.477-0800 [DEBUG] provider.terraform-provider-google_v6.12.0_x5: {
2024-11-19T11:53:36.477-0800 [DEBUG] provider.terraform-provider-google_v6.12.0_x5:   "error": {
2024-11-19T11:53:36.477-0800 [DEBUG] provider.terraform-provider-google_v6.12.0_x5:     "code": 400,
2024-11-19T11:53:36.477-0800 [DEBUG] provider.terraform-provider-google_v6.12.0_x5:     "message": "Updating ttl other than single field level is not supported: UpdateFieldConfigurationRequest{ref=SingleFieldRef{referenceType=ReferenceType{kind=testcollection}}, indexingMode=IndexingMode{revert}, expirationMode=DISABLE, validateOnly=false}",
2024-11-19T11:53:36.477-0800 [DEBUG] provider.terraform-provider-google_v6.12.0_x5:     "status": "INVALID_ARGUMENT"
2024-11-19T11:53:36.477-0800 [DEBUG] provider.terraform-provider-google_v6.12.0_x5:   }
2024-11-19T11:53:36.477-0800 [DEBUG] provider.terraform-provider-google_v6.12.0_x5: }
2024-11-19T11:53:36.477-0800 [DEBUG] provider.terraform-provider-google_v6.12.0_x5
2024-11-19T11:53:36.477-0800 [DEBUG] provider.terraform-provider-google_v6.12.0_x5: -----------------------------------------------------
2024-11-19T11:53:36.477-0800 [DEBUG] provider.terraform-provider-google_v6.12.0_x5: 2024/11/19 11:53:36 [DEBUG] Retry Transport: Stopping retries, last request failed with non-retryable error: googleapi: got HTTP response code 400 with body: HTTP/2.0 400 Bad Request
2024-11-19T11:53:36.477-0800 [DEBUG] provider.terraform-provider-google_v6.12.0_x5: Alt-Svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
2024-11-19T11:53:36.477-0800 [DEBUG] provider.terraform-provider-google_v6.12.0_x5: Cache-Control: private
2024-11-19T11:53:36.477-0800 [DEBUG] provider.terraform-provider-google_v6.12.0_x5: Content-Type: application/json; charset=UTF-8
2024-11-19T11:53:36.477-0800 [DEBUG] provider.terraform-provider-google_v6.12.0_x5: Date: Tue, 19 Nov 2024 19:53:36 GMT
2024-11-19T11:53:36.477-0800 [DEBUG] provider.terraform-provider-google_v6.12.0_x5: Server: ESF
2024-11-19T11:53:36.477-0800 [DEBUG] provider.terraform-provider-google_v6.12.0_x5: Vary: Origin
2024-11-19T11:53:36.477-0800 [DEBUG] provider.terraform-provider-google_v6.12.0_x5: Vary: X-Origin
2024-11-19T11:53:36.477-0800 [DEBUG] provider.terraform-provider-google_v6.12.0_x5: Vary: Referer
2024-11-19T11:53:36.477-0800 [DEBUG] provider.terraform-provider-google_v6.12.0_x5: X-Content-Type-Options: nosniff
2024-11-19T11:53:36.477-0800 [DEBUG] provider.terraform-provider-google_v6.12.0_x5: X-Debug-Tracking-Id: 2862105657178788352;o=0
2024-11-19T11:53:36.477-0800 [DEBUG] provider.terraform-provider-google_v6.12.0_x5: X-Frame-Options: SAMEORIGIN
2024-11-19T11:53:36.477-0800 [DEBUG] provider.terraform-provider-google_v6.12.0_x5: X-Xss-Protection: 0
2024-11-19T11:53:36.477-0800 [DEBUG] provider.terraform-provider-google_v6.12.0_x5
2024-11-19T11:53:36.477-0800 [DEBUG] provider.terraform-provider-google_v6.12.0_x5: {
2024-11-19T11:53:36.477-0800 [DEBUG] provider.terraform-provider-google_v6.12.0_x5:   "error": {
2024-11-19T11:53:36.477-0800 [DEBUG] provider.terraform-provider-google_v6.12.0_x5:     "code": 400,
2024-11-19T11:53:36.477-0800 [DEBUG] provider.terraform-provider-google_v6.12.0_x5:     "message": "Updating ttl other than single field level is not supported: UpdateFieldConfigurationRequest{ref=SingleFieldRef{referenceType=ReferenceType{kind=testcollection}}, indexingMode=IndexingMode{revert}, expirationMode=DISABLE, validateOnly=false}",
2024-11-19T11:53:36.477-0800 [DEBUG] provider.terraform-provider-google_v6.12.0_x5:     "status": "INVALID_ARGUMENT"
2024-11-19T11:53:36.477-0800 [DEBUG] provider.terraform-provider-google_v6.12.0_x5:   }
2024-11-19T11:53:36.477-0800 [DEBUG] provider.terraform-provider-google_v6.12.0_x5: }
2024-11-19T11:53:36.477-0800 [DEBUG] provider.terraform-provider-google_v6.12.0_x5: 2024/11/19 11:53:36 [DEBUG] Retry Transport: Returning after 1 attempts
2024-11-19T11:53:36.477-0800 [ERROR] provider.terraform-provider-google_v6.12.0_x5: Response contains error diagnostic: tf_req_id=a898027b-ae8b-2286-5401-97345134c215 tf_resource_type=google_firestore_field @caller=github.com/hashicorp/terraform-plugin-go@v0.23.0/tfprotov5/internal/diag/diagnostics.go:58 @module=sdk.proto diagnostic_detail="" diagnostic_severity=ERROR diagnostic_summary="Error deleting Field \"projects/hc-terraform-testing/databases/testdb/collectionGroups/testcollection/fields/*\": googleapi: Error 400: Updating ttl other than single field level is not supported: UpdateFieldConfigurationRequest{ref=SingleFieldRef{referenceType=ReferenceType{kind=testcollection}}, indexingMode=IndexingMode{revert}, expirationMode=DISABLE, validateOnly=false}" tf_proto_version=5.6 tf_provider_addr=registry.terraform.io/hashicorp/google tf_rpc=ApplyResourceChange timestamp=2024-11-19T11:53:36.477-0800
2024-11-19T11:53:36.487-0800 [DEBUG] State storage *statemgr.Filesystem declined to persist a state snapshot
2024-11-19T11:53:36.487-0800 [ERROR] vertex "google_firestore_field.wildcard_exemption (destroy)" error: Error deleting Field "projects/hc-terraform-testing/databases/testdb/collectionGroups/testcollection/fields/*": googleapi: Error 400: Updating ttl other than single field level is not supported: UpdateFieldConfigurationRequest{ref=SingleFieldRef{referenceType=ReferenceType{kind=testcollection}}, indexingMode=IndexingMode{revert}, expirationMode=DISABLE, validateOnly=false}
â•·
│ Error: Error deleting Field "projects/hc-terraform-testing/databases/testdb/collectionGroups/testcollection/fields/*": googleapi: Error 400: Updating ttl other than single field level is not supported: UpdateFieldConfigurationRequest{ref=SingleFieldRef{referenceType=ReferenceType{kind=testcollection}}, indexingMode=IndexingMode{revert}, expirationMode=DISABLE, validateOnly=false}

Expected Behavior

should just delete successfully

Actual Behavior

returns error:

│ Error: Error deleting Field "projects/hc-terraform-testing/databases/testdb/collectionGroups/testcollection/fields/*": googleapi: Error 400: Updating ttl other than single field level is not supported: UpdateFieldConfigurationRequest{ref=SingleFieldRef{referenceType=ReferenceType{kind=testcollection}}, indexingMode=IndexingMode{revert}, expirationMode=DISABLE, validateOnly=false}

Steps to reproduce

  1. terraform apply
  2. comment out google_firestore_field or run terraform destroy

Important Factoids

could be due to having fields = "*" though I'm pretty sure it has to do with the updateMask being set incorrectly when wanting to delete a field: /v1/projects/hc-terraform-testing/databases/testdb/collectionGroups/testcollection/fields/*?alt=json&updateMask=indexConfig%2CttlConfig

References

No response

b/380082409

ggtisc commented 1 day ago

Confirmed issue!

It is not possible to delete the resources after creation through terraform