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

database_grant for usage to roles and share(s) constantly being recreated #226

Closed
callumwebb opened this issue Jul 27, 2020 · 3 comments · Fixed by #263
Closed

database_grant for usage to roles and share(s) constantly being recreated #226

callumwebb opened this issue Jul 27, 2020 · 3 comments · Fixed by #263
Labels
bug Used to mark issues with provider's incorrect behavior

Comments

@callumwebb
Copy link

callumwebb commented Jul 27, 2020

When using snowflake_database_grant with privilege = "USAGE", a list of roles and a share, terraform destroys and recreates the grant every time despite the roles and share not changing.

Code

(Showing a relevant stripped down subset from my project, let me know if you need a true minimal reproducible example)

resource "snowflake_database_grant" "db_usage" {
  database_name = snowflake_database.db.name
  privilege     = "USAGE"
  roles = [
    snowflake_role.role1.name,
    snowflake_role.role2.name
  ]
  shares = [
    snowflake_share.data_share.name
  ]
}

resource "snowflake_share" "data_share" {
  name = "DATA_SHARE"   
  accounts = [
    snowflake_managed_account.account.locator
  ]
}

Always results in this plan:

  # snowflake_database_grant.db_usage must be replaced
-/+ resource "snowflake_database_grant" "db_usage" {
        database_name = "DB"
      ~ id            = "DB|||USAGE" -> (known after apply)
        privilege     = "USAGE"
        roles         = [
            "ROLE1",
            "ROLE2",
        ]
      ~ shares        = [ # forces replacement
          + "DATA_SHARE",
        ]
    }

Checking snowflake, both the share and the grant are successfully created, but it seems that terraform thinks the share is missing from the grant every time it runs.

@callumwebb
Copy link
Author

callumwebb commented Jul 27, 2020

An implication of this issue is that we can use the provider to set up grants to shares, but can't revoke them. It's like the share is invisible when it attempts show grants on x to compute the diff. Schema grants are also affected.

@ryanking ryanking added the bug Used to mark issues with provider's incorrect behavior label Jul 29, 2020
@jmak123
Copy link

jmak123 commented Aug 3, 2020

I think the issue is the same as this:
#211

Basically Terraform compiles list/array items with trailing comma which is always different to what it actually writes into tfstate.

@ryanking May be worth consolidating the two issues?

@slocke716
Copy link

This poses a serious problem to our organization right now. I'd love to see this fixed.

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

Successfully merging a pull request may close this issue.

4 participants