Source:
How to Create a Read-Only Database User in Postgres for Analytics and Reporting
createuser -U postgres -D -R -S aws_user
alter user aws_user with encrypted password 'MY PASSWORD';
grant connect on database dwhmbqt to aws_user;
do
$$
declare
_query text;
_schema text;
begin
for _schema in select nspname from pg_namespace where nspname ~ '_db$' loop
_query := format('grant usage on schema %I to aws_user', _schema);
raise notice '%', _query;
execute _query;
end loop;
end;
$$
do
$$
declare
_query text;
_schema text;
begin
for _schema in select nspname from pg_namespace where nspname ~ '_db$' loop
_query := format('grant select on all tables in schema %I to aws_user', _schema);
raise notice '%', _query;
execute _query;
end loop;
end;
$$
Then in pg_hba.conf:
host dwhmbqt aws_user 10.192.0.0/16 md5