Restrict access to databases or tables in Aiven for PostgreSQL®
You can restrict access to Aiven for PostgreSQL® databases and tables by setting up read-only permissions for specific user's roles.
Set read-only access in a schema
-
Modify default permissions for a user's role in a particular schema.
alter default privileges for role name_of_role in schema name_of_schema YOUR_GRANT_OR_REVOKE_PERMISSIONS
-
Apply the new read-only access setting to your existing database objects that uses the affected schema.
grant select on all tables in schema name_of_schema to NAME_OF_READ_ONLY_ROLE
Set read-only access in a database
You can set up the read-only access for a specific user's role in a particular database.
- Create a database which will be used as a template
create database ro_<name>_template...
. - For the new template database, set permissions and roles that you want as default ones in the template.
- When creating a database, use
create database NAME with template = 'ro_<name>_template'
.