Skip to content
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_role_grants updates state to incorrect #1204

Closed
sadahry opened this issue Sep 7, 2022 · 3 comments
Closed

snowflake_role_grants updates state to incorrect #1204

sadahry opened this issue Sep 7, 2022 · 3 comments
Labels
bug Used to mark issues with provider's incorrect behavior

Comments

@sadahry
Copy link

sadahry commented Sep 7, 2022

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
@sadahry sadahry added the bug Used to mark issues with provider's incorrect behavior label Sep 7, 2022
@sadahry
Copy link
Author

sadahry commented Sep 7, 2022

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..

@Dinesh-Rupchandani
Copy link

@sadahry - We are also facing the same issue, Please let me know if u find any resolution

@sfc-gh-asawicki
Copy link
Collaborator

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.

@sfc-gh-asawicki sfc-gh-asawicki closed this as not planned Won't fix, can't repro, duplicate, stale Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Used to mark issues with provider's incorrect behavior
Projects
None yet
Development

No branches or pull requests

3 participants