-
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
snowflake roles appear as deleted after upgrading from provider 0.84.1 to 0.85.0 #2460
Comments
+1 with this; same issue while upgrading |
Hey @jacobcbeaudin @philippeboyd resource "snowflake_role" "test" {
name = "TEST_ROLE_TEST_UPGRADE"
} |
@sfc-gh-jcieslak honestly not sure how to reproduce it on my end, it happened with a role inside a module, but I'm putting my money on this commit specifically I'll have to reverse engineer the commit to understand what could've gone wrong... |
To clarify, the roles in question were not initially created with version 0.84.1 of the Snowflake provider; they were created with an even earlier version, and since then, we have been consistently upgrading the provider across several versions up to 0.85.0. This iterative upgrade process over multiple versions might be contributing to the observed behavior. Additionally, I should mention that our Terraform configuration uses an S3 remote backend for state storage. This detail might also play a role in how state discrepancies and external changes are detected by Terraform. Given these nuances—specifically the use of an earlier version for initial role creation and the continual provider upgrades, as well as the configuration of an S3 remote backend—could these factors be influencing the issue at hand? |
So, we already checked that commit a few times and couldn't spot any difference in the inner workings of the provider.
We also tried to upgrade from earlier versions like v0.80.0, but still couldn't reproduce the described behavior. Please, try to provide working steps to reproduce the issue. Otherwise, I can only suggest importing the state back with Terraform CLI. It's described in our latest migration guide for the grants, but that applies to any other resource. It's here - if you don't have those resources in your state you can start with 3rd point to import the state back. In the case of the external state storage, maybe @sfc-gh-swinkler knows if that could be the root cause, but I'm assuming that it shouldn't be any different than local state management. |
Thank you for the suggestions and guidance, @sfc-gh-jcieslak. After attempting to replicate the issue in a separate environment without success, it appears that the problem might be unique to the specific state or configuration of the original environment. I also tried following the migration guide to import the role back into the state, but unfortunately, I was unable to import the role successfully. Given the urgency to resolve the issue and considering the inability to replicate or rectify it through suggested methods, I opted to delete the role outside of Terraform and then re-create it. This approach was not ideal, but it allowed us to quickly restore the desired state within a 10-minute maintenance window. |
Could you share the details on error messages or commands that you were running during unsuccessful imports? We would like to take a look at them and adjust migration notes if needed. |
Unfortunately, I no longer have access to those logs. |
Hey @jacobcbeaudin |
Yes, feel free to close this issue |
I know this has been closed for a while but I have been banging my head against this issue so I thought people would appreciate the context I have found. The cause of the issue here for us is a combination of 2 things. The first of those is that we renamed a role. This resulted in our state looking like this: {
"mode": "managed",
"type": "snowflake_role",
"name": "role",
"provider": "provider[\"registry.terraform.io/snowflake-labs/snowflake\"]",
"instances": [
{
"index_key": 0,
"schema_version": 0,
"attributes": {
"comment": "The comment for the role",
"id": "READER_PROD",
"name": "READER",
"tag": []
}
}
]
} So a previous version (v0.66.2) of the Snowflake Terraform provider changed the Then in this commit in file - id := d.Id()
- // If the name is not set (such as during import) then use the id
- name := d.Get("name").(string)
- if name == "" {
- name = id
- }
- builder := snowflake.NewRoleBuilder(db, name)
- role, err := builder.Show()
+ client := sdk.NewClientFromDB(db)
+ id := helpers.DecodeSnowflakeID(d.Id()).(sdk.AccountObjectIdentifier)
+ accountRole, err := client.Roles.ShowByID(ctx, sdk.NewShowByIdRoleRequest(id)) These two things added together results in the situation outlined in this issue. We do not get this issue on roles that have not been renamed as the state has I think the resolution here is for me to manually change the Terraform state to set |
Terraform CLI and Provider Versions
Terraform Configuration
Expected Behavior
I expected my terraform plan to no changes besides deprecated resource warning. I am upgrading from provider version 0.84.1 to 0.85.0
Actual Behavior
Snowflake is saying that the roles it is managing have deleted outside of terraform. When I run
SHOW ROLES;
in snowsql, I see the roles that terraform is saying was deletedSteps to Reproduce
terraform init
terraform plan
How much impact is this issue causing?
Medium
Logs
No response
Additional Information
No response
The text was updated successfully, but these errors were encountered: