Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kstromeiraos/26399cd56455d371103874693c89e4df to your computer and use it in GitHub Desktop.
Save kstromeiraos/26399cd56455d371103874693c89e4df to your computer and use it in GitHub Desktop.
Create a read-only user on Redshift
-- 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