-
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
Terraform not detecting the correct Project ID when modifying Org Policy #17998
Comments
Hi @jado06! As I'm checking in this and the other references it is more troubleshooting than a bug issue. Your own code was replicated successfully without errors. I suggest you to check your permissions and environment variables as the other users commented and something that is more important is to read the error message that describes the next:
It basically says that you need to check the quota of this service in your account configurations, because it is a service which is not set by default, and finally it gives you a link to learn how to fix it. |
I'm not sure how you were able to replicate my code without errors, however, that link you mentioned says to use: Another thing to mention is that the error message clearly shows
After doing some research on the credentials files for ADC, I noticed that the incorrect project number from the error
I'm not certain on how Terraform does this behind the scenes, but my theory is that it is potentially pulling the project ID from the wrong line, which is why we're seeing the number from the |
Yes, in some point of your terraform config you have something related to the authentication that is causing issues, because with the most basic code after a This is the terraform code used to replicate this scenario:
|
Thanks, I'll try to replicate again sometime in the next week and get back to you with the results. |
Did this work? i have the same issue |
@zebo3k Yes, I did end up finding a solution! Thanks for reminding me to post it. Since part of my terraform code involved providing the user with the org admin role ( (This also explains why @ggtisc did not run into the same issue, likely because they already had the role, and didn't need to wait for it to propagate) |
Thanks for your answer @jado06 |
How do we explain that my error shows EXACTLY the same project number? I'm not associated with @jado06 in any way, so why would my error be pointing to the exact same project?
I also provided myself with Organisation Policy Administrator access, but no luck there |
I happen to have the same exact error: │Error: Error creating Policy: googleapi: Error 403: Your application is authenticating by using local Application Default │Credentials. The orgpolicy.googleapis.com API requires a quota project, which is not set by default. To learn how to set your │quota project, see https://cloud.google.com/docs/authentication/adc-troubleshooting/user-creds . Role and project quota already assigned. |
I encountered a similar orgpolicy.googleapis.com 403 error with the same "consumer": "projects/7640********", "service": "SERVICE_DISABLED" output. I was deploying org policy custom constraints. https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/org_policy_custom_constraint ##################### |
@YancyGodoy @flamein see my previous post. |
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
Terraform Version
Terraform v1.8.2
Affected Resource(s)
google_org_policy_policy
Terraform Configuration
Debug Output
Expected Behavior
Using Terraform in my local terminal, I'm trying to disable the
Disable Service Account Key Creation
policy for a specific project and stop it from inheriting the policy from the parent organization.Actual Behavior
What I noticed from the error message is that the project number from
projects/7640********
does not match my project number. I also noticed that it's pulling that number from the first portions of theclient_id
in theapplication_default_credentials.json
file.Steps to reproduce
gcloud auth login $USER
gcloud auth application-default login $USER
gcloud auth application-default set-quota-project $PROJECT
terraform init
terraform apply
Important Factoids
Org Policy API
is already enabled on this project.Org Policy Admin
role.Did I stumble into a bug? Seems like someone from Google reported the same issue back in February but it was not fixed.
References
The text was updated successfully, but these errors were encountered: