Microservice architecture states for one service has one database. However, the database administrator would like to have one credential to access multiple databases. Let’s take a look at how we can solve this with PostgreSQL roles.
Configuring database user for service
Each service can have credentials to access the database.
account can use user
account_service with password
'<SECRET_PASSOWRD>' has access to the
Create a new user for account service:
Grant access to the database tables and sequences:
Configuring role to access multiple databases services
An administrator can have credentials to access multiple databases.
jhon_the_admin with password
'<ADMIN_SECRET_PASSOWRD>' has access to the
Create the admin group:
Link service roles to the admin_group:
Create the admin user:
Link the admin_group role to the admin user: