-
-
Save ku1ik/c9f3c3ceb8648ebc1c6f182c3b0706d6 to your computer and use it in GitHub Desktop.
How to create a read only user in AWS RDS PostgreSQL and a user with superuser privileges on AWS RDS PostgreSQL
This file contains hidden or 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
-- | |
-- Read only | |
-- | |
-- Create a group | |
CREATE ROLE ro_group; | |
-- Grant access to existing tables | |
GRANT USAGE ON SCHEMA public TO ro_group; | |
GRANT SELECT ON ALL TABLES IN SCHEMA public TO ro_group; | |
GRANT SELECT ON ALL SEQUENCES IN SCHEMA public TO ro_group; | |
-- Grant access to future tables | |
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO ro_group; | |
-- Create a final user with password | |
CREATE USER ro WITH PASSWORD 'secret'; | |
GRANT ro_group TO ro; | |
-- | |
-- Superuser | |
-- | |
-- Create a final user with password | |
CREATE USER postgres_adm WITH PASSWORD 'secret'; | |
GRANT rds_superuser to postgres_adm; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment