-
Notifications
You must be signed in to change notification settings - Fork 427
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: create a workaround for granting privileges on all pipes (#2477)
`granting privileges on all pipes to role/database role` is not allowed in Snowflake. As it was just one case, we decided to create an internal workaround that would make `on_all pipes` work as it was supported by Snowflake. The workaround works as follows: - check if on_all pipes are called - fetch pipes (in database or in schema; depending on what was in the original request) - loop through the pipes and grant/revoke privileges on them - created integration tests for the SDK and acceptance tests for `snowflake_grant_privileges_to_role`, `snowflake_grant_privileges_to_account_role`, and `snowflake_grant_privileges_to_database_role` > Note: grant on_future pipes works as intended [Reference](https://docs.snowflake.com/en/sql-reference/sql/grant-privilege#required-parameters) (check the text at the bottom of <object_type>)
- Loading branch information
1 parent
672c97d
commit 64f2346
Showing
11 changed files
with
688 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
pkg/resources/testdata/TestAcc_GrantPrivilegesToAccountRole/OnAllPipes/test.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
resource "snowflake_grant_privileges_to_account_role" "test" { | ||
account_role_name = var.name | ||
privileges = var.privileges | ||
with_grant_option = var.with_grant_option | ||
|
||
on_schema_object { | ||
all { | ||
object_type_plural = "PIPES" | ||
in_database = var.database | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
pkg/resources/testdata/TestAcc_GrantPrivilegesToAccountRole/OnAllPipes/variables.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
variable "name" { | ||
type = string | ||
} | ||
|
||
variable "privileges" { | ||
type = list(string) | ||
} | ||
|
||
variable "database" { | ||
type = string | ||
} | ||
|
||
variable "with_grant_option" { | ||
type = bool | ||
} |
12 changes: 12 additions & 0 deletions
12
pkg/resources/testdata/TestAcc_GrantPrivilegesToDatabaseRole/OnAllPipes/test.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
resource "snowflake_grant_privileges_to_database_role" "test" { | ||
database_role_name = "\"${var.database}\".\"${var.name}\"" | ||
privileges = var.privileges | ||
with_grant_option = var.with_grant_option | ||
|
||
on_schema_object { | ||
all { | ||
object_type_plural = "PIPES" | ||
in_database = "\"${var.database}\"" | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
pkg/resources/testdata/TestAcc_GrantPrivilegesToDatabaseRole/OnAllPipes/variables.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
variable "name" { | ||
type = string | ||
} | ||
|
||
variable "privileges" { | ||
type = list(string) | ||
} | ||
|
||
variable "database" { | ||
type = string | ||
} | ||
|
||
variable "with_grant_option" { | ||
type = bool | ||
} |
12 changes: 12 additions & 0 deletions
12
pkg/resources/testdata/TestAcc_GrantPrivilegesToRole/OnAllPipes/test.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
resource "snowflake_grant_privileges_to_role" "test" { | ||
role_name = var.name | ||
privileges = var.privileges | ||
with_grant_option = var.with_grant_option | ||
|
||
on_schema_object { | ||
all { | ||
object_type_plural = "PIPES" | ||
in_database = var.database | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
pkg/resources/testdata/TestAcc_GrantPrivilegesToRole/OnAllPipes/variables.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
variable "name" { | ||
type = string | ||
} | ||
|
||
variable "privileges" { | ||
type = list(string) | ||
} | ||
|
||
variable "database" { | ||
type = string | ||
} | ||
|
||
variable "with_grant_option" { | ||
type = bool | ||
} |
Oops, something went wrong.