-
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: grant ownership on tasks (#2684)
Changes: - The follow-up grant ownership PR adds support to grant ownership on Tasks. - Add a reminder to the documentation to always copy the state file before applying any state-manipulating functions. - Added GrantOptionFor option during revoke in privilege-granting resources, so only with_grant_option will be removed instead of the whole grant, making the process less destructive ## Test Plan <!-- detail ways in which this PR has been tested or needs to be tested --> * [x] acceptance tests * [x] integration tests ## References * #2670 Another solution for granting ownership `on all tasks` - to be considered in the future. * [Grant Ownership](https://docs.snowflake.com/en/sql-reference/sql/grant-ownership)
- Loading branch information
1 parent
bfa2317
commit 2ba7889
Showing
14 changed files
with
762 additions
and
32 deletions.
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
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
31 changes: 31 additions & 0 deletions
31
pkg/resources/testdata/TestAcc_GrantOwnership/OnAllTasks/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,31 @@ | ||
resource "snowflake_role" "test" { | ||
name = var.account_role_name | ||
} | ||
|
||
resource "snowflake_task" "test" { | ||
database = var.database | ||
schema = var.schema | ||
name = var.task | ||
sql_statement = "SELECT CURRENT_TIMESTAMP" | ||
} | ||
|
||
resource "snowflake_task" "second_test" { | ||
database = var.database | ||
schema = var.schema | ||
name = var.second_task | ||
sql_statement = "SELECT CURRENT_TIMESTAMP" | ||
} | ||
|
||
resource "snowflake_grant_ownership" "test" { | ||
depends_on = [snowflake_task.test, snowflake_task.second_test] | ||
account_role_name = snowflake_role.test.name | ||
|
||
on { | ||
all { | ||
object_type_plural = "TASKS" | ||
in_schema = "\"${var.database}\".\"${var.schema}\"" | ||
} | ||
} | ||
|
||
outbound_privileges = "REVOKE" | ||
} |
19 changes: 19 additions & 0 deletions
19
pkg/resources/testdata/TestAcc_GrantOwnership/OnAllTasks/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,19 @@ | ||
variable "account_role_name" { | ||
type = string | ||
} | ||
|
||
variable "database" { | ||
type = string | ||
} | ||
|
||
variable "schema" { | ||
type = string | ||
} | ||
|
||
variable "task" { | ||
type = string | ||
} | ||
|
||
variable "second_task" { | ||
type = string | ||
} |
20 changes: 20 additions & 0 deletions
20
pkg/resources/testdata/TestAcc_GrantOwnership/OnTask/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,20 @@ | ||
resource "snowflake_role" "test" { | ||
name = var.account_role_name | ||
} | ||
|
||
resource "snowflake_task" "test" { | ||
database = var.database | ||
schema = var.schema | ||
name = var.task | ||
warehouse = var.warehouse | ||
sql_statement = "SELECT CURRENT_TIMESTAMP" | ||
} | ||
|
||
resource "snowflake_grant_ownership" "test" { | ||
account_role_name = snowflake_role.test.name | ||
|
||
on { | ||
object_type = "TASK" | ||
object_name = "\"${snowflake_task.test.database}\".\"${snowflake_task.test.schema}\".\"${snowflake_task.test.name}\"" | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
pkg/resources/testdata/TestAcc_GrantOwnership/OnTask/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,19 @@ | ||
variable "account_role_name" { | ||
type = string | ||
} | ||
|
||
variable "database" { | ||
type = string | ||
} | ||
|
||
variable "schema" { | ||
type = string | ||
} | ||
|
||
variable "task" { | ||
type = string | ||
} | ||
|
||
variable "warehouse" { | ||
type = string | ||
} |
Oops, something went wrong.