Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle location tag bindings of removed resources #8310

Conversation

modular-magician
Copy link
Collaborator

Currently, the google_tags_location_tag_binding resource will cause any plans to fail whenever the resource (parent) it was for is deleted outside of Terraform. Specifically, it results in errors like these during the read operation:

│ Error: Error when reading or editing TagsLocationTagBinding "<some-id>": googleapi: Error 403: The caller does not have permission
│ Details:
│ [
│   {
│     "@type": "type.googleapis.com/google.rpc.ResourceInfo",
│     "description": "permission [storage.buckets.listTagBindings] required (or the resource may not exist in this location)",
│     "resourceName": "//storage.googleapis.com/projects/_/buckets/<bucket-name>"
│   }
│ ]
│
│   with google_tags_location_tag_binding.binding,
│   on main.tf line 24, in resource "google_tags_location_tag_binding" "binding":
│   24: resource "google_tags_location_tag_binding" "binding" {
│
╵

The correct Terraform behavior would be that it recognizes this resource has been removed and drops it from the state. This PR implements that behavior, allowing plan operations to succeed even when the related resource was removed externally.

I tested the change successfully against my own test files, as well as the reproduction snippet from the linked issue.

Fixes hashicorp/terraform-provider-google#15928.

Release Note Template for Downstream PRs (will be copied)

tags:  removed `google_tags_location_tag_binding` resource from the Terraform state when its parent resource has been removed outside of Terraform

Derived from GoogleCloudPlatform/magic-modules#11857

[upstream:02d6c9752d76d013abce23b70d741332d1cdd3c3]

Signed-off-by: Modular Magician <magic-modules@google.com>
@modular-magician modular-magician merged commit 37f3790 into hashicorp:main Sep 30, 2024
4 checks passed
@modular-magician modular-magician deleted the downstream-pr-02d6c9752d76d013abce23b70d741332d1cdd3c3 branch November 16, 2024 02:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

google_tags_location_tag_binding does not behave appropriately when a binding is removed outside of tf
1 participant