-
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
Error 400: Requested policy version (1) cannot be less than the existing policy version (3) #5218
Comments
@Lirt can you post the full debug log? |
Hi @edwardmedia here is the relevant part |
@Lirt |
@edwardmedia I'm sorry, I have it in code, but I accidently missed it. I updated the description now. |
@Lirt can you post the |
@Lirt, do you have any IAM Conditions set on the policy? Also, are you using the google provider or the google-beta provider with that module? |
@danawillow We tried IAM conditions but not on policies that are bugged. Currently we are using stable provider, but I also tried beta. It didn't help. |
This should make sense now. The exact error I got is listed in documentation - When I display version of bugged IAM policy, I get gcloud beta iam service-accounts get-iam-policy [email protected] bindings:
- members:
- serviceAccount:myproject.svc.id.goog[.../...]
role: roles/iam.workloadIdentityUser
etag: ASDF=
version: 1 The error log says I tried to use beta-provider 2.20.1 again and IT WORKS! (my bad I must have made some mistake before). There must be a bug somewhere I guess. |
@Lirt I am glad you have found the reason. I am closing this issue now. You may reopen it if you feel a need for more help. Thanks |
I am seeing a similar issue. The strange thing is that the version of the IAM policy is still 1. Not sure why this is cropping up |
@Lirt and @pratikmallya (and anyone else encountering this), if you have a support contract, customer engineer, or account rep with Google Cloud can you reach out to them? I'd like to get the IAM team's perspective on this behavior, and using an official GCP support channel will help get the right information to the right people. |
@danawillow I do, will open a support ticket. Thanks! This actually worked after using the provider mentioned by @Lirt. But yeah its rather strange that it just broke. |
What provider version were you using before, and which one are you using now that worked? |
Yeah I think the reason it's working now is that we started reading policy version 3 around then in the beta provider. |
@danawillow Did we start reading policy version 3 for the GA provider? Is that planned? |
@morgante We haven't, and I haven't really thought about it much. If a user has conditions enabled (which as far as I know is the only way to get a version 3 policy) and then tries to use TPG to make modifications to it, it would clobber the conditions, so I'm a bit hesitant to read at version 3 until conditions are GA. How would a user end up in a situation when using TPG that their policy is at version 3? |
@danawillow It was raised on the module here, @Lirt could you provide more context? I can definitely imagine a scenario where we'd see issues with this:
I think the complexity is that I believe the entire policy is versioned to v3 even if only one membership has conditions. |
Got it, that makes sense. I think in the interest of safety, I'd still prefer to wait until the conditions GA, though if it becomes too unusable this way we can reevaluate. |
Hmm, it seems like a rather severe bug that a working Terraform resource ( |
If they aren't using conditions, then their policy version should be 1, and TPG and TPGB are both viable options. If they are using conditions, and they're using it on the binding referenced by that resource, they have to use TPGB since that's what has conditions support. So the circumstance we're dealing with, as you said, is a binding that doesn't have a condition on it but somewhere else in the same policy does, and that other part of the policy isn't being managed in Terraform. Do you expect that to be a common setup? In this case, the options for the user are:
I'm willing to be convinced that this is a common enough setup and the risk of clobbering a condition is low enough that we should go ahead and do it, but I'm not quite there yet. |
I think the complication is that IAM for a resource (particularly an org or project) isn't necessarily managed all in a single Terraform config. If that were the case, I think it'd be easy to simply upgrade to TPGB. However, there are definitely cases where some memberships are managed elsewhere. I agree that clobbering is an issue though. Maybe we can leave this open for a bit and see who else reports it?
Would it be possible to simply not touch the condition from TPG? ie. if a condition exists simply leave it as is (but don't support adding/updating conditions)? |
@morgante Just like you said. Conditions were tested in UI for some temporary account and all other iam policies / members in terraform got broken. |
Hi @Lirt ! We encountered this problem today. We checked our UI and deleted a user with conditions and all worked ! Thx for your comment which guide us to this solution ;) |
We are seeing this with:
Is there a recommended version to upgrade to? I see 2.20.0 has breaking changes. |
@danawillow FYI, I've opened a Google Support ticket as this appears to have migrated to the non-beta version and is blocking updates to our environments. I see there were changes in GoogleCloudPlatform/magic-modules#3003 |
@billyfoss this specific issue happens when there exists an IAM binding with a condition, but you're trying to read at a version of the provider that doesn't support reading those sorts of bindings. In order to fix it, you would either need to remove the conditional binding (so that the policy becomes a version 1 policy again) or use a version of the provider that reads version 3 policies. The Does any of that work for you? I also want to bring up the Provider Versions guide in case you have hesitancies about using the beta provider, since I think that page addresses some of the concerns that people have. |
@danawillow I tried moving to 2.20.x and was reminded of #4951 which is why I pinned to 2.19.0. |
Hmm ok. Are you using both |
We have references to both providers, but currently only using the “google” provider. I’ve used your advice and configured the iam resources to use the google beta provider and it seemed to resolve the issue in one environment. I’m debugging why it is still failing in the original environment. I’ll update tomorrow. |
I was still seeing the issue because I had a resource that was going to be removed, so it was not getting updated with the google-beta provider. Terraform was still refreshing its state with the google provider. In summary, the advice from @danawillow worked great to get us past this.
For resources that need to handle the new IAM Policy Version 3, specific the google-beta provider.
Other resources will default to the google provider. This prevents our load balancer configuration from being impacted by #4951 introduced in 2.20.x. If you have an IAM based resource that is being deleted, you may need to manually remove it and remove it from the tfstate file as Terraform will continue to use the google 2.19 provider for state refresh.
Thank you for all the help in getting past this. |
Glad to hear that it worked! A couple additional notes:
|
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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks! |
[issue-type:bug-report]
Community Note
Terraform Version
Terraform v0.12.18
Affected Resource(s)
One of
Terraform Configuration Files
Debug Output
Expected Behavior
Succesful plan
Actual Behavior
Error 400: Requested policy version (1) cannot be less than the existing policy version (3).
Steps to Reproduce
terraform plan
Important Factoids
Since I didn't manually alter any IAM setting I think that there is a different issue.
It may be connected with the new
condition
feature, which uses IAM policy version3
.The text was updated successfully, but these errors were encountered: