Viewing roles and their privileges
You can view predefined roles and their privileges in your RDS for PostgreSQL DB instance using
different commands depending on your PostgreSQL version. To see all predefined roles, you can connect to your RDS for PostgreSQL DB instance and run following commands using the psql
.
For psql
15 and earlier versions
Connect to your RDS for PostgreSQL DB instance and use the \du
command in psql:
postgres=> \du List of roles Role name | Attributes | Member of -----------------+------------------------------------------------------------+------------------------------------------------------ postgres | Create role, Create DB +| {rds_superuser} | Password valid until infinity | rds_ad | Cannot login | {} rds_iam | Cannot login | {} rds_password | Cannot login | {} rds_replication | Cannot login | {} rds_superuser | Cannot login | {pg_monitor,pg_signal_backend,rds_password,rds_replication} rdsadmin | Superuser, Create role, Create DB, Replication, Bypass RLS+| {} | Password valid until infinity |
For psql
16 and later versions
postgres=> \drg+ List of role grants Role name | Member of | Options | Grantor ---------------+-----------------------------+---------------------+---------- postgres | rds_superuser | INHERIT, SET | rdsadmin rds_superuser | pg_checkpoint | ADMIN, INHERIT, SET | rdsadmin rds_superuser | pg_monitor | ADMIN, INHERIT, SET | rdsadmin rds_superuser | pg_signal_backend | ADMIN, INHERIT, SET | rdsadmin rds_superuser | pg_use_reserved_connections | ADMIN, INHERIT, SET | rdsadmin rds_superuser | rds_password | ADMIN, INHERIT, SET | rdsadmin rds_superuser | rds_replication | ADMIN, INHERIT, SET | rdsadmin
To check role membership without version dependency, you can use the following SQL query:
SELECT m.rolname AS "Role name", r.rolname AS "Member of" FROM pg_catalog.pg_roles m JOIN pg_catalog.pg_auth_members pam ON (pam.member = m.oid) LEFT JOIN pg_catalog.pg_roles r ON (pam.roleid = r.oid) LEFT JOIN pg_catalog.pg_roles g ON (pam.grantor = g.oid) WHERE m.rolname !~ '^pg_' ORDER BY 1, 2;
In the output, you can see that rds_superuser
isn't a database user
role (it can't login), but it has the privileges of many other roles. You can also see
that database user postgres
is a member of the rds_superuser
role.
As mentioned previously, postgres
is the default value in the Amazon RDS
console's Create database page. If you chose another name, that
name is shown in the list of roles instead.