-
Notifications
You must be signed in to change notification settings - Fork 4
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
[SNOW-198] Create ownership database roles for data warehouse #104
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
0503d2b
Create ownership database roles for data warehouse
philerooski 62c8b0b
Move future grants to versioned script
philerooski 71e8616
grant ownership of data warehouse DB to DB admin
philerooski ab4634f
Update readme with privilege management contrib info
philerooski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
---- SYNAPSE_DATA_WAREHOUSE ---- | ||
-- SYNAPSE | ||
GRANT OWNERSHIP | ||
ON FUTURE TABLES | ||
IN SCHEMA SYNAPSE_DATA_WAREHOUSE.SYNAPSE | ||
TO DATABASE ROLE SYNAPSE_DATA_WAREHOUSE.SYNAPSE_ALL_ADMIN; | ||
GRANT OWNERSHIP | ||
ON FUTURE DYNAMIC TABLES | ||
IN SCHEMA SYNAPSE_DATA_WAREHOUSE.SYNAPSE | ||
TO DATABASE ROLE SYNAPSE_DATA_WAREHOUSE.SYNAPSE_ALL_ADMIN; | ||
GRANT OWNERSHIP | ||
ON FUTURE STAGES | ||
IN SCHEMA SYNAPSE_DATA_WAREHOUSE.SYNAPSE | ||
TO DATABASE ROLE SYNAPSE_DATA_WAREHOUSE.SYNAPSE_ALL_ADMIN; | ||
GRANT OWNERSHIP | ||
ON FUTURE VIEWS | ||
IN SCHEMA SYNAPSE_DATA_WAREHOUSE.SYNAPSE | ||
TO DATABASE ROLE SYNAPSE_DATA_WAREHOUSE.SYNAPSE_ALL_ADMIN; | ||
GRANT OWNERSHIP | ||
ON FUTURE TASKS | ||
IN SCHEMA SYNAPSE_DATA_WAREHOUSE.SYNAPSE | ||
TO DATABASE ROLE SYNAPSE_DATA_WAREHOUSE.SYNAPSE_ALL_ADMIN; | ||
|
||
-- SYNAPSE_RAW | ||
GRANT OWNERSHIP | ||
ON FUTURE TABLES | ||
IN SCHEMA SYNAPSE_DATA_WAREHOUSE.SYNAPSE_RAW | ||
TO DATABASE ROLE SYNAPSE_DATA_WAREHOUSE.SYNAPSE_RAW_ALL_ADMIN; | ||
GRANT OWNERSHIP | ||
ON FUTURE STAGES | ||
IN SCHEMA SYNAPSE_DATA_WAREHOUSE.SYNAPSE_RAW | ||
TO DATABASE ROLE SYNAPSE_DATA_WAREHOUSE.SYNAPSE_RAW_ALL_ADMIN; | ||
GRANT OWNERSHIP | ||
ON FUTURE STREAMS | ||
IN SCHEMA SYNAPSE_DATA_WAREHOUSE.SYNAPSE_RAW | ||
TO DATABASE ROLE SYNAPSE_DATA_WAREHOUSE.SYNAPSE_RAW_ALL_ADMIN; | ||
GRANT OWNERSHIP | ||
ON FUTURE VIEWS | ||
IN SCHEMA SYNAPSE_DATA_WAREHOUSE.SYNAPSE_RAW | ||
TO DATABASE ROLE SYNAPSE_DATA_WAREHOUSE.SYNAPSE_RAW_ALL_ADMIN; | ||
GRANT OWNERSHIP | ||
ON FUTURE TASKS | ||
IN SCHEMA SYNAPSE_DATA_WAREHOUSE.SYNAPSE_RAW | ||
TO DATABASE ROLE SYNAPSE_DATA_WAREHOUSE.SYNAPSE_RAW_ALL_ADMIN; | ||
|
||
-- SCHEMACHANGE | ||
GRANT OWNERSHIP | ||
ON FUTURE TABLES | ||
IN SCHEMA SYNAPSE_DATA_WAREHOUSE.SCHEMACHANGE | ||
TO DATABASE ROLE SYNAPSE_DATA_WAREHOUSE.SCHEMACHANGE_ALL_ADMIN; | ||
|
||
---- SYNAPSE_DATA_WAREHOUSE_DEV ---- | ||
-- SYNAPSE | ||
GRANT OWNERSHIP | ||
ON FUTURE TABLES | ||
IN SCHEMA SYNAPSE_DATA_WAREHOUSE_DEV.SYNAPSE | ||
TO DATABASE ROLE SYNAPSE_DATA_WAREHOUSE_DEV.SYNAPSE_ALL_ADMIN; | ||
GRANT OWNERSHIP | ||
ON FUTURE DYNAMIC TABLES | ||
IN SCHEMA SYNAPSE_DATA_WAREHOUSE_DEV.SYNAPSE | ||
TO DATABASE ROLE SYNAPSE_DATA_WAREHOUSE_DEV.SYNAPSE_ALL_ADMIN; | ||
GRANT OWNERSHIP | ||
ON FUTURE STAGES | ||
IN SCHEMA SYNAPSE_DATA_WAREHOUSE_DEV.SYNAPSE | ||
TO DATABASE ROLE SYNAPSE_DATA_WAREHOUSE_DEV.SYNAPSE_ALL_ADMIN; | ||
GRANT OWNERSHIP | ||
ON FUTURE VIEWS | ||
IN SCHEMA SYNAPSE_DATA_WAREHOUSE_DEV.SYNAPSE | ||
TO DATABASE ROLE SYNAPSE_DATA_WAREHOUSE_DEV.SYNAPSE_ALL_ADMIN; | ||
GRANT OWNERSHIP | ||
ON FUTURE TASKS | ||
IN SCHEMA SYNAPSE_DATA_WAREHOUSE_DEV.SYNAPSE | ||
TO DATABASE ROLE SYNAPSE_DATA_WAREHOUSE_DEV.SYNAPSE_ALL_ADMIN; | ||
|
||
-- SYNAPSE_RAW | ||
GRANT OWNERSHIP | ||
ON FUTURE TABLES | ||
IN SCHEMA SYNAPSE_DATA_WAREHOUSE_DEV.SYNAPSE_RAW | ||
TO DATABASE ROLE SYNAPSE_DATA_WAREHOUSE_DEV.SYNAPSE_RAW_ALL_ADMIN; | ||
GRANT OWNERSHIP | ||
ON FUTURE STAGES | ||
IN SCHEMA SYNAPSE_DATA_WAREHOUSE_DEV.SYNAPSE_RAW | ||
TO DATABASE ROLE SYNAPSE_DATA_WAREHOUSE_DEV.SYNAPSE_RAW_ALL_ADMIN; | ||
GRANT OWNERSHIP | ||
ON FUTURE STREAMS | ||
IN SCHEMA SYNAPSE_DATA_WAREHOUSE_DEV.SYNAPSE_RAW | ||
TO DATABASE ROLE SYNAPSE_DATA_WAREHOUSE_DEV.SYNAPSE_RAW_ALL_ADMIN; | ||
GRANT OWNERSHIP | ||
ON FUTURE TASKS | ||
IN SCHEMA SYNAPSE_DATA_WAREHOUSE_DEV.SYNAPSE_RAW | ||
TO DATABASE ROLE SYNAPSE_DATA_WAREHOUSE_DEV.SYNAPSE_RAW_ALL_ADMIN; | ||
|
||
-- SCHEMACHANGE | ||
GRANT OWNERSHIP | ||
ON FUTURE TABLES | ||
IN SCHEMA SYNAPSE_DATA_WAREHOUSE_DEV.SCHEMACHANGE | ||
TO DATABASE ROLE SYNAPSE_DATA_WAREHOUSE_DEV.SCHEMACHANGE_ALL_ADMIN; |
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
25 changes: 25 additions & 0 deletions
25
synapse_data_warehouse/database_roles/V2.31.0__database_access_roles.sql
thomasyu888 marked this conversation as resolved.
Show resolved
Hide resolved
|
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,25 @@ | ||
USE DATABASE {{ database_name }}; --noqa: JJ01,PRS,TMP | ||
|
||
-- Create database roles which will own the respective namespace's objects | ||
CREATE OR REPLACE DATABASE ROLE SYNAPSE_ALL_ADMIN; | ||
CREATE OR REPLACE DATABASE ROLE SYNAPSE_RAW_ALL_ADMIN; | ||
CREATE OR REPLACE DATABASE ROLE SCHEMACHANGE_ALL_ADMIN; | ||
jaymedina marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
-- Grant ownership of the database roles to the database admin | ||
GRANT OWNERSHIP | ||
ON DATABASE ROLE SYNAPSE_ALL_ADMIN | ||
TO ROLE {{ database_name }}_ADMIN; --noqa: JJ01,PRS,TMP | ||
GRANT OWNERSHIP | ||
ON DATABASE ROLE SYNAPSE_RAW_ALL_ADMIN | ||
TO ROLE {{ database_name }}_ADMIN; --noqa: JJ01,PRS,TMP | ||
GRANT OWNERSHIP | ||
ON DATABASE ROLE SCHEMACHANGE_ALL_ADMIN | ||
TO ROLE {{ database_name }}_ADMIN; --noqa: JJ01,PRS,TMP | ||
|
||
-- Grant database roles to account roles | ||
GRANT DATABASE ROLE SYNAPSE_ALL_ADMIN | ||
TO ROLE {{ database_name }}_ADMIN; --noqa: JJ01,PRS,TMP | ||
GRANT DATABASE ROLE SYNAPSE_RAW_ALL_ADMIN | ||
TO ROLE {{ database_name }}_ADMIN; --noqa: JJ01,PRS,TMP | ||
GRANT DATABASE ROLE SCHEMACHANGE_ALL_ADMIN | ||
TO ROLE {{ database_name }}_ADMIN; --noqa: JJ01,PRS,TMP |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just logged onto the DPE_SERVICE account and noticed it has SYSADMIN access but no SECURITYADMIN access, so I feel compelled to ask: Are we sure the
$SNOWFLAKE_ACCOUNT
we use for these schemachange operations has access to SECURITYADMIN role? I don't see this role used elsewhere so asking just in case.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. Looks like we've never had to use SECURITYADMIN to manage grants before. Everything has been done as the owner of an object granting privileges upon that object. I'll open another PR.