-
Notifications
You must be signed in to change notification settings - Fork 427
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
[Bug]: Unexpected grant in state file #3059
Comments
Hey @dlouseiro. Thanks for reaching out to us. Could you please describe how did you migrate the production accounts (was it just v0.91.0 -> v0.92.0 or a bigger version bump? which option did you pick to migrate the old grant resources or did you not have to migrate them? etc. every detail that you can share will be potentially helpful here because we also cannot reproduce such a situation on our test accounts, so probably we need a better setup - the one closer to what you did on your prod account). |
Ok, in the meantime I figured out the issue, even though it's a weird one. Basically, we have a role So when I was looking at the results of
When I looked at the permission in my test account this was not the case as these accounts are meant simply to run terraform so everything there is applied by terraform (never manually by So, what did I do to make sure these permissions were properly registered in the state? Using an
So the first time I ran the revokes, the result of After these two revokes, I removed these properties from the state and re-ran terraform twice. The first run applied the missing permissions (which I had just revoked), the second run finally returned the expected |
Hey 👋 Regarding the second comment, I'm not really sure what you mean. I also tried to reproduce this behavior, but couldn't. Calling revoke twice when after the first one you have 2 grants, and after the second one none seems like a Snowflake error (stacking grants?). Please try to create clearer steps to reproduce. The first step already removes the resource from the state, which is confusing. Create a step-by-step guide from no configuration on Snowflake and Terraform to the occurring issue. |
Hey @dlouseiro , please try to give us more information (comment above), otherwise I will close the ticket due to long inactivity. |
Closing due to long inactivity. Please create another ticket if the issue still persists. |
Terraform CLI Version
1.5.7
Terraform Provider Version
0.92.0
Terraform Configuration
Category
category:grants
Object type(s)
resource:grant_privileges_to_account_role
Expected Behavior
For the resource to be registered in the state file as something like this:
Actual Behavior
Resource is stored in the state file as:
Steps to Reproduce
terraform state rm 'snowflake_grant_privileges_to_account_role.snowflake_imported_privileges_to_snowflake_monitoring'
terraform apply
(grant is reapplied)terraform apply
againResult received is:
Terraform considers that the
USAGE
grant should be removed, which makes sense as it was never declared in the first place, but somehow terraform stored it in the state.yes
to theterraform apply
. Result: command fails as it's not possible to revokeUSAGE
privilege on theSNOWFLAKE
database.How much impact is this issue causing?
Medium
Logs
No response
Additional Information
Fun fact here is that this only happens in our production account. If I run the exact same steps mentioned above in one of our test accounts, everything goes well and the second
terraform apply
(point 3) does not detect any changes in the state.Workaround applied:
Added a lifecyle in the resource to ignore changes in privileges:
Would you like to implement a fix?
The text was updated successfully, but these errors were encountered: