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

[Bug]: snowflake_grant_privileges_to_account_role revoke of IMPORTED PRIVILEGES fails #2991

Closed
1 task
simonepm opened this issue Aug 12, 2024 · 3 comments
Closed
1 task
Assignees
Labels
bug Used to mark issues with provider's incorrect behavior

Comments

@simonepm
Copy link

simonepm commented Aug 12, 2024

Terraform CLI Version

1.9.3

Terraform Provider Version

0.94.1

Terraform Configuration

resource "snowflake_grant_privileges_to_account_role" "GRANT_IMPORTED_PRIVILEGES_ON_DATABASE_DATABASE_NAME_TO_ROLE_PUBLIC" {
  provider = snowflake.ACCOUNTADMIN
  privileges = ["IMPORTED PRIVILEGES"]
  account_role_name = "PUBLIC"
  on_account_object {
    object_type = "DATABASE"
    object_name = snowflake_shared_database.DATABASE_NAME.name
  }
}
Error: Failed to revoke privileges
snowflake_grant_privileges_to_account_role.GRANT_IMPORTED_PRIVILEGES_ON_DATABASE_DATABASE_NAME_TO_ROLE_PUBLIC,
on main.tf line 41, in resource "snowflake_grant_privileges_to_account_role" "GRANT_IMPORTED_PRIVILEGES_ON_DATABASE_DATABASE_NAME_TO_ROLE_PUBLIC":
resource "snowflake_grant_privileges_to_account_role" "GRANT_IMPORTED_PRIVILEGES_ON_DATABASE_DATABASE_NAME_TO_ROLE_PUBLIC"
Id: "PUBLIC"|false|false|IMPORTED
PRIVILEGES|OnAccountObject|DATABASE|"DATABASE_NAME"
Privileges to add: [IMPORTED PRIVILEGES]
Error: 001003 (42000): SQL compilation error:
syntax error line 1 at position 24 unexpected 'IMPORTED'.

Category

category:resource

Object type(s)

resource:grant_privileges_to_account_role

Expected Behavior

Expected to successfully revoke the IMPORTED PRIVILEGES on database.

Actual Behavior

syntax error line 1 at position 24 unexpected 'IMPORTED'.

Steps to Reproduce

Grant and then revoke snowflake_grant_privileges_to_account_role privileges = ["IMPORTED PRIVILEGES"] on an imported database from share to account role PUBLIC.

How much impact is this issue causing?

Medium

Logs

No response

Additional Information

No response

Would you like to implement a fix?

  • Yeah, I'll take it 😎
@simonepm simonepm added the bug Used to mark issues with provider's incorrect behavior label Aug 12, 2024
@sfc-gh-jmichalak
Copy link
Collaborator

Hi @simonepm 👋, Could you provide a Terraform command that fails? Also, please include logs (run Terraform with TF_LOG=DEBUG). I just tested revoking imported privileges and it should work.

@simonepm
Copy link
Author

@sfc-gh-jmichalak thanks, I am also not able to reproduce it again now! Murphy's law at its best, thanks a sorry!
If happens again I will provide the log, so the edge case will be more clear!
Thanks,
S.

@simonepm
Copy link
Author

simonepm commented Aug 12, 2024

@sfc-gh-jmichalak I found new info:

When from_share is in the format 'LOCATOR.SHARE', instead of 'ORG.ACCOUNT.SHARE':

resource "snowflake_shared_database" "DATABASE_NAME" {
  provider = snowflake.ACCOUNTADMIN
  name = "DATABASE_NAME"
  from_share = "<LOCATOR>.<SHARE>"
}

From second apply on, snowflake_shared_database gets updated everytime as LOCATOR.SHARE is automatically stored in the ORG.ACCOUNT.SHARE format on first apply.

If there is a snowflake_grant_privileges_to_account_role that accesses object_name from the resource directly, the revoke due to the update of the dependent object breaks:

resource "snowflake_grant_privileges_to_account_role" "GRANT_IMPORTED_PRIVILEGES_ON_DATABASE_DATABASE_NAME_TO_ROLE_PUBLIC" {
  privileges = ["IMPORTED PRIVILEGES"]
  account_role_name = "PUBLIC"
  on_account_object {
    object_type = "DATABASE"
    object_name = snowflake_shared_database.DATABASE_NAME.name
  }
}

Instead, if we put a depends_on, it works:

resource "snowflake_grant_privileges_to_account_role" "GRANT_IMPORTED_PRIVILEGES_ON_DATABASE_DATABASE_NAME_TO_ROLE_PUBLIC" {
  privileges = ["IMPORTED PRIVILEGES"]
  account_role_name = "PUBLIC"
  on_account_object {
    object_type = "DATABASE"
    object_name = "DATABASE_NAME"
  }
  depends_on = [snowflake_shared_database.DATABASE_NAME]
}

I will try to collect some logs and in case re-open the issue.

@sfc-gh-jmichalak sfc-gh-jmichalak self-assigned this Oct 23, 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

2 participants