Skip to content

Instantly share code, notes, and snippets.

@elyasha
Created September 26, 2022 14:19
Show Gist options
  • Save elyasha/ff5621a852de6f6586a0e883e0ebb170 to your computer and use it in GitHub Desktop.
Save elyasha/ff5621a852de6f6586a0e883e0ebb170 to your computer and use it in GitHub Desktop.
Read only creation of a user for RDS postgres cluster
DROP ROLE IF EXISTS readaccess;
CREATE ROLE readaccess;
GRANT USAGE ON SCHEMA public TO readaccess;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readaccess;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO readaccess;
DROP USER IF EXISTS readonly;
CREATE USER readonly WITH PASSWORD 'secret';
GRANT readaccess TO readonly;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment