-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Add location
attribute to google_tags_tag_binding
#11448
Add location
attribute to google_tags_tag_binding
#11448
Comments
Note: Cloud SQL Instances are supported, per https://cloud.google.com/resource-manager/docs/tags/tags-supported-services. I can't see a guide on attaching one, though, and the Tags API doesn't support a location field. Is it possible that they're using a different format, or you have a REST response from a tag that has been successfully attached to a SQL instance? |
The location attribute is associated with the API endpoint, not to the the payload. I tried to run the CloudSQL gcloud command and I got this error.
|
I am not familiar with the contributing process, but we need to include an optional location parameter to the tags api definition Similar to cloudrun |
Debugging this with I run: $ gcloud resource-manager --log-http tags bindings create --tag-value=tagValues/111458724321 --parent=//compute.googleapis.com/projects/camus-infra/zones/us-central1-a/instances/laz-testing-nat --location=us-central1-a which first calls the compute instances API to pull down the instance info, then POSTs this json payload to {"parent": "//compute.googleapis.com/projects/camus-infra/zones/us-central1-a/instances/2094347600019513919", "tagValue": "tagValues/111458724321"}` So This doesn't seem to be covered in the API docs at https://cloud.google.com/resource-manager/reference/rest/v3/tagBindings/create |
I understand the issue is on the API side and not much can be done until |
@kpocius the gcloud tag binding create documentation states location is only required for non global resources. Based on |
b/247163900 |
I came across this as well, using null local-exec as a workaround for now
I'll have a look next week to see if can contribute with an PR. |
@alextodicescu I'm curious if you were able to make any progress on this? I am going to take a stab at it tomorrow as part of my employer's Open Source Hack Day. |
I haven't made much progress, no been chatting about what changes are required here: #12738 (comment) |
@AarshDhokai has been working on this but there are technical complications that may require refactoring parts of mmv1 core. |
@AarshDhokai could you leave a comment here so I can assign it to you? |
I noticed this in the cloud run YAML: |
As per Riley over at #12738 (comment) it seems like one perspective from the provider maintainers would be to hand write these resources for now. @melinath are you on board with that approach? |
Hey @melinath, just commenting so that you can assign the issue. |
yep looks like that's the plan for now. |
Hey @AarshDhokai wondering what your timeline looks like on this issue. No pressure, just our team has an immediate use for this feature, so I was going to work on it next week if you don't have immediate plans. Don't want to duplicate any work :) Thanks! |
Even if it's clearly indicated that this is supported on a best-effort basis, It would seem the API client the I was hoping to work around the current issue by instantianting specific regional provider aliases. Which would have been a cleaner workaround that calling the gcloud CLI through a provider "google" {
alias = "regional-endpoint-workaround"
resource_manager_custom_endpoint = format("https://%s-cloudresourcemanager.googleapis.com/v3/", local.region)"
}
resource "google_tags_tag_binding" "cloudrun_public_website_all_users_ingress" {
parent = format("//run.googleapis.com/projects/%s/locations/%s/services/%s",
data.google_cloud_run_service.public_website.project,
data.google_cloud_run_service.public_website.location,
data.google_cloud_run_service.public_website.name,
)
tag_value = format("tagValues/%s", data.google_tags_tag_value.all_users_ingress_true.name)
provider = google.regional-endpoint-workaround
} Unfortunately, the global endpoint is still used:
|
Update: so looking at the code, the resource uses a specific The following works: provider "google" {
alias = "regional-endpoint-workaround"
tags_custom_endpoint = format("https://%s-cloudresourcemanager.googleapis.com/v3/", local.region)
}
resource "google_tags_tag_binding" "cloudrun_public_website_all_users_ingress" {
parent = format("//run.googleapis.com/projects/%s/locations/%s/services/%s",
google_project.public_website.number, # permadiff if using the project id
data.google_cloud_run_service.public_website.location,
data.google_cloud_run_service.public_website.name,
)
tag_value = format("tagValues/%s", data.google_tags_tag_value.all_users_ingress_true.name)
provider = google.regional-endpoint-workaround
} Use with caution and only for specific tag resources that need this workaround. Also, unsure what would happen if Google decided to use the resourcemanager v4+ endpoint to manage tags all of a sudden. Better wait for a proper fix. |
for anybody testing out location-scoped bindings (we released it as part of v4.51.0). Zonal resources are still broken since the operation check is still going to the global TagsBasePath instead of the overridden TagsLocationBasePath. The tests included in the PR only test Cloud Run bindings (regional resource) but my testing with zonal resources (compute instances) is still failing |
tested that zonal bindings work now on >=4.57 (specifically compute instances) |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Community Note
Description
Some tag bindings require the location to be specified, ex: Cloud SQL instances. Currently trying to bind a tag to a Cloud SQL instance fails:
New or Affected Resource(s)
resource.google_tags_tag_binding
Potential Terraform Configuration
References
The text was updated successfully, but these errors were encountered: