Created
May 28, 2018 16:23
-
-
Save kstromeiraos/26399cd56455d371103874693c89e4df to your computer and use it in GitHub Desktop.
Create a read-only user on Redshift
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
-- Create Read-Only Group | |
CREATE GROUP ro_group; | |
-- Create User | |
CREATE USER ro_user WITH password 'XXX'; | |
-- Add User to Read-Only Group | |
ALTER GROUP ro_group ADD USER ro_user; | |
-- Grant Usage permission to Read-Only Group to specific Schema | |
GRANT USAGE ON SCHEMA "ro_schema" TO GROUP ro_group; | |
-- Grant Select permission to Read-Only Group to specific Schema | |
GRANT SELECT ON ALL TABLES IN SCHEMA "ro_schema" TO GROUP ro_group; | |
-- Alter Default Privileges to maintain the permissions on new tables | |
ALTER DEFAULT PRIVILEGES IN SCHEMA "ro_schema" GRANT SELECT ON TABLES TO GROUP ro_group; | |
-- Revoke CREATE privileges from group | |
REVOKE CREATE ON SCHEMA "ro_schema" FROM GROUP ro_group; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment