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

google_service_usage_consumer_quota_override - Can't set quota overrides if they already exist #10017

Closed
boosh opened this issue Sep 7, 2021 · 2 comments
Labels

Comments

@boosh
Copy link

boosh commented Sep 7, 2021

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request.
  • Please do not leave +1 or me too comments, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.
  • If an issue is assigned to the modular-magician user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If an issue is assigned to a user, that user is claiming responsibility for the issue. If an issue is assigned to hashibot, a community member has claimed the issue already.

Terraform Version

Terraform v1.0.6
on darwin_amd64
...
- Installing hashicorp/google-beta v3.82.0...
- Installed hashicorp/google-beta v3.82.0 (signed by HashiCorp)
- Installing hashicorp/google v3.82.0...
- Installed hashicorp/google v3.82.0 (signed by HashiCorp)

Affected Resource(s)

  • google_service_usage_consumer_quota_override

Terraform Configuration Files

data "google_project" "project" {
  provider = google-beta
}

resource "google_service_usage_consumer_quota_override" "geolocation" {
  provider       = google-beta
  project        = data.google_project.project.project_id
  service        = "geolocation.googleapis.com"
  metric         = "geolocation.googleapis.com%2Fbillable_default"
  limit          = "%2Fd%2Fproject"
  override_value = "1000"
  force          = true
}

Debug Output

Panic Output

Error: Error creating ConsumerQuotaOverride: googleapi: 
Error 409: Cannot create consumer override. 
The override specified in the request already exists. 
Please call UpdateConsumerOverride instead with resource name 'projects/my-project-dev/services/geolocation.googleapis.com/consumerQuotaMetrics/geolocation.googleapis.com%2Fbillable_default/limits/%2Fd%2Fproject/consumerOverrides/Cg1RZW90dU9dZXJyxWRl'.

Expected Behavior

Terraform should have updated the quota.

Actual Behavior

The API returned an error saying the consumer quota override already exists and that Terraform should call the UpdateConsumerOverride API instead.

Steps to Reproduce

  1. Log into the GCP console. Enable the geolocation API (or probably any billable API), then set a quota on "requests per day".
  2. Run the above Terraform and watch it fail

This even occurs if you subsequently delete the quote in the console, because in fact Google doesn't delete the underlying consumerOverride object. E.g here's the offending quota that I set then deleted, as returned by the console:

{
          "name": "projects/12341234/services/geolocation.googleapis.com/consumerQuotaMetrics/geolocation.googleapis.com%2Fbillable_default/limits/%2Fd%2Fproject",
          "unit": "1/d/{project}",
          "metric": "geolocation.googleapis.com/billable_default",
          "quotaBuckets": [
            {
              "effectiveLimit": "-1",
              "defaultLimit": "9223372036854775807",
              "consumerOverride": {
                "name": "projects/12341234/services/geolocation.googleapis.com/consumerQuotaMetrics/geolocation.googleapis.com%2Fbillable_default/limits/%2Fd%2Fproject/consumerOverrides/Cg1RZW90dU9dZXJyxWRl",
                "overrideValue": "-1"
              }
            }
          ]
        }

This means if someone sets a quota (e.g. to find the various parameters to use in Terraform), Terraform is no longer able to manage the quota because it's calling the wrong endpoint if the quota already exists.

Important Factoids

References

  • #0000
@boosh boosh added the bug label Sep 7, 2021
@boosh boosh changed the title Terraform can't set quota overrides if they were created outside Terraform google_service_usage_consumer_quota_override - Can't set quota overrides if they already exist Sep 7, 2021
@boosh
Copy link
Author

boosh commented Sep 7, 2021

Ah it needs manually importing into state, then it works :(

@boosh boosh closed this as completed Sep 7, 2021
@github-actions
Copy link

github-actions bot commented Oct 8, 2021

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.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant