terraform-google-modules / terraform-google-scheduled-function

Sets up a scheduled job to trigger events and run functions
https://registry.terraform.io/modules/terraform-google-modules/scheduled-function/google
Apache License 2.0
69 stars 46 forks source link

project cleaner fails to delete org-level tag keys and values when associated with resources #234

Open eeaton opened 2 months ago

eeaton commented 2 months ago

TL;DR

https://github.com/terraform-google-modules/terraform-google-scheduled-function/blob/cb74689a8e8ed39bf82f0e4c74744692fa10eee4/modules/project_cleanup/function_source/main.go#L522

This functionality in project_cleanup attempts to delete tags without removing their association. This fails if the tag is associated with any existing or deleted resources.

Expected behavior

When the cleanup function is referenced with clean_up_org_level_tag_keys set to true, it should be able to delete tag keys and values.

Observed behavior

The delete method fails when tags still have a resource association. This occurs even when the associated resource has been deleted.

ERROR 2024-06-04T14:18:26.666958Z [protoPayload.serviceName: cloudresourcemanager.googleapis.com] [protoPayload.methodName: google.cloud.resourcemanager.v3.TagValues.DeleteTagValue] [protoPayload.resourceName: tagValues/281484311440934] [protoPayload.authenticationInfo.principalEmail: project-cleaner-function@cft-project-manager-e86e.iam.gserviceaccount.com] Cannot delete tag value, tagValues/281484311440934, because it is still attached to resources in 'global' region. To delete this tag value, remove all holds and then remove it from all resources. At least one binding was found to an active or deleted resource in the 'global' region.

Terraform Configuration

n/a, the issue is in go code

Terraform Version

n/a, the issue is in go code

Additional information

No response

apeabody commented 1 month ago

Adding @daniel-cit