-
Notifications
You must be signed in to change notification settings - Fork 426
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
As described in https://docs.snowflake.com/en/user-guide/tasks-graphs#manage-task-graph-ownership, there are two main options. This PR shows the one granting ownership of all tasks at once.
- Loading branch information
1 parent
5035e2f
commit 6fb437b
Showing
9 changed files
with
282 additions
and
5 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
20 changes: 20 additions & 0 deletions
20
pkg/resources/testdata/TestAcc_GrantOwnership/OnTask_Discussion2877/1/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_Discussion2877/1/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 | ||
} |
40 changes: 40 additions & 0 deletions
40
pkg/resources/testdata/TestAcc_GrantOwnership/OnTask_Discussion2877/2/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,40 @@ | ||
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_task" "child" { | ||
database = var.database | ||
schema = var.schema | ||
name = var.child | ||
warehouse = var.warehouse | ||
after = [snowflake_task.test.name] | ||
sql_statement = "SELECT CURRENT_TIMESTAMP" | ||
} | ||
|
||
resource "snowflake_grant_ownership" "test" { | ||
depends_on = [snowflake_task.child] | ||
|
||
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}\"" | ||
} | ||
} | ||
|
||
resource "snowflake_grant_ownership" "child" { | ||
account_role_name = snowflake_role.test.name | ||
|
||
on { | ||
object_type = "TASK" | ||
object_name = "\"${snowflake_task.child.database}\".\"${snowflake_task.child.schema}\".\"${snowflake_task.child.name}\"" | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
pkg/resources/testdata/TestAcc_GrantOwnership/OnTask_Discussion2877/2/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,23 @@ | ||
variable "account_role_name" { | ||
type = string | ||
} | ||
|
||
variable "database" { | ||
type = string | ||
} | ||
|
||
variable "schema" { | ||
type = string | ||
} | ||
|
||
variable "task" { | ||
type = string | ||
} | ||
|
||
variable "child" { | ||
type = string | ||
} | ||
|
||
variable "warehouse" { | ||
type = string | ||
} |
11 changes: 11 additions & 0 deletions
11
pkg/resources/testdata/TestAcc_GrantOwnership/OnTask_Discussion2877/3/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,11 @@ | ||
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" | ||
} |
23 changes: 23 additions & 0 deletions
23
pkg/resources/testdata/TestAcc_GrantOwnership/OnTask_Discussion2877/3/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,23 @@ | ||
variable "account_role_name" { | ||
type = string | ||
} | ||
|
||
variable "database" { | ||
type = string | ||
} | ||
|
||
variable "schema" { | ||
type = string | ||
} | ||
|
||
variable "task" { | ||
type = string | ||
} | ||
|
||
variable "child" { | ||
type = string | ||
} | ||
|
||
variable "warehouse" { | ||
type = string | ||
} |
32 changes: 32 additions & 0 deletions
32
pkg/resources/testdata/TestAcc_GrantOwnership/OnTask_Discussion2877/4/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,32 @@ | ||
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_task" "child" { | ||
database = var.database | ||
schema = var.schema | ||
name = var.child | ||
warehouse = var.warehouse | ||
after = [snowflake_task.test.name] | ||
sql_statement = "SELECT CURRENT_TIMESTAMP" | ||
} | ||
|
||
resource "snowflake_grant_ownership" "test" { | ||
depends_on = [snowflake_task.test, snowflake_task.child] | ||
account_role_name = snowflake_role.test.name | ||
|
||
on { | ||
all { | ||
object_type_plural = "TASKS" | ||
in_schema = "\"${var.database}\".\"${var.schema}\"" | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
pkg/resources/testdata/TestAcc_GrantOwnership/OnTask_Discussion2877/4/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,23 @@ | ||
variable "account_role_name" { | ||
type = string | ||
} | ||
|
||
variable "database" { | ||
type = string | ||
} | ||
|
||
variable "schema" { | ||
type = string | ||
} | ||
|
||
variable "task" { | ||
type = string | ||
} | ||
|
||
variable "child" { | ||
type = string | ||
} | ||
|
||
variable "warehouse" { | ||
type = string | ||
} |