terraform-provider-snowflake
terraform-provider-snowflake copied to clipboard
`snowflake_role_grants` updates state to incorrect
Provider Version
0.33.1
Terraform Version
v1.1.9
Describe the bug
When trying to change the name of snowflake_role,
snowflake_role_grants updates the terraform state to incorrect.
After the update, we cannot change the state anymore.
Expected behavior
updates snowflake_role_grants with no errors.
Code samples and commands
step1. run terrafom apply as below at first.
resource "snowflake_role" "test" {
name = "GRANTS_TEST"
}
resource "snowflake_role_grants" "test" {
role_name = snowflake_role.test.name
roles = [
"ACCOUNTADMIN"
]
}
step2. change the name "GRANTS_TEST" -> "GRANTS_TEST_2"
resource "snowflake_role" "test" {
name = "GRANTS_TEST_2"
}
resource "snowflake_role_grants" "test" {
role_name = snowflake_role.test.name
roles = [
"ACCOUNTADMIN"
]
}
step3. run terraform apply, and output the error.
(even with this error message, resources on snowflake were successfully updated)
terraform apply -auto-approve=false
snowflake_role_grants.test: Refreshing state... [id=GRANTS_TEST||||ACCOUNTADMIN|false]
snowflake_role.test: Refreshing state... [id=GRANTS_TEST2]
╷
│ Error: 002003 (02000): SQL compilation error:
│ Role 'GRANTS_TEST' does not exist or not authorized.
│
│ with snowflake_role_grants.test,
│ on role.tf line 5, in resource "snowflake_role_grants" "test":
│ 5: resource "snowflake_role_grants" "test" {
│
╵
Workaround
step0. do Code samples and commands
step1. rm the grants state
terraform state rm snowflake_role_grants.test
step2. import the grants state from snowflake
terraform import snowflake_role_grants.test GRANTS_TEST_2
step3. run terraform apply
terraform apply
Tried to use create_before_destroy, but no effect for this error.
Please let me know if there is a better solution for this error..
@sadahry - We are also facing the same issue, Please let me know if u find any resolution
We are closing this issue as part of a cleanup described in announcement. If you believe that the issue is still valid in v0.89.0, please open a new ticket.