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_database_role + on_schema_object + object_type_plural + SECRETS gives 'Error: 001003 (42000): SQL compilation error' #3090

Open
1 task
jarach opened this issue Sep 18, 2024 · 3 comments
Labels
bug Used to mark issues with provider's incorrect behavior

Comments

@jarach
Copy link

jarach commented Sep 18, 2024

Terraform CLI Version

1.9.5

Terraform Provider Version

0.94.1

Terraform Configuration

resource "snowflake_database_role" "test" {
  database = "DEV_HME_RAW_DB"
  name     = "DBR_TEST_SC"
}

resource "snowflake_grant_privileges_to_database_role" "test" {
  database_role_name = "${snowflake_database_role.test.database}.${snowflake_database_role.test.name}"
  on_schema_object {
    all {
      object_type_plural = "SECRETS"
      in_schema = "DEV_HME_RAW_DB.SECRETS_SC"
    }
  }
  privileges         = ["READ"]
}

Category

category:grants

Object type(s)

resource:grant_privileges_to_database_role

Expected Behavior

Grant privileges to ALL SECRETS in DATABASE.SCHEMA

Actual Behavior

Error: An error occurred when granting privileges to database role

with module.main.snowflake_grant_privileges_to_database_role.test,
on ....\modules\main\test.tf line 7, in resource "snowflake_grant_privileges_to_database_role" "test":
7: resource "snowflake_grant_privileges_to_database_role" "test" {

Id: "DEV_HME_RAW_DB"."DBR_TEST_SC"|false|false|READ|OnSchemaObject|OnAll|SECRETS|InSchema|"DEV_HME_RAW_DB"."SECRETS_SC"
Database role name: {DEV_HME_RAW_DB DBR_TEST_SC}
Error: 001003 (42000): SQL compilation error:
syntax error line 1 at position 26 unexpected 'IN'.

Steps to Reproduce

Apply provided terraform piece of code.

How much impact is this issue causing?

Low

Logs

No response

Additional Information

'snowflake_grant_privileges_to_database_role' is working for other schema object like: TABLES, VIEWS, STAGES, etc.

Would you like to implement a fix?

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

sfc-gh-jmichalak commented Sep 19, 2024

Hi @jarach 👋

It seems like it's an error on the Snowflake side. According to the docs, a query like GRANT READ ON ALL SECRETS IN SCHEMA "TEST"."PUBLIC" TO DATABASE ROLE "TEST"."TEST3" should work, but it does not.

Please create a general Snowflake ticket for that. It would be great if you CC @sfc-gh-jmichalak @sfc-gh-asawicki @sfc-gh-jcieslak . We would like to know the result of it.

When this is fixed on the Snowflake side, it should work in the provider too, so I think no action is required on the provider side.

@jarach
Copy link
Author

jarach commented Sep 20, 2024

I opened a ticket #00851941. I was not able to add you on CC (to Watchers). I'll let you know the results.

@jarach
Copy link
Author

jarach commented Sep 21, 2024

Official answer from Snowflake support:

Unfortunately, these commands are currently not supported. A feature request for supporting bulk grants on SECRETS objects has been submitted to our engineering team. Currently, it's under review. I don't have any ETA when it will be available. I have copied this email to your Account Manager for visibility. Please follow up with your account team for future updates on this feature request. Please let us know if you have any additional questions or if you are agreeable to resolving the case.

I asked to either correct documentation or implement the "feature" as soon as possible.

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