Create application users and roles in Aurora PostgreSQL-Compatible
Created by Abhishek Verma (AWS)
Environment: PoC or pilot | Source: Any database | Target: PostgreSQL database |
R Type: Re-architect | Workload: Open-source | Technologies: Migration; Databases |
AWS services: Amazon RDS; Amazon Aurora |
Summary
When you migrate to Amazon Aurora PostgreSQL-Compatible Edition, the database users and roles that exist on the source database must be created in the Aurora PostgreSQL-Compatible database. You can create the users and roles in Aurora PostgreSQL-Compatible by using two different approaches:
Use similar users and roles in the target as in the source database. In this approach, the data definition languages (DDLs) are extracted for users and roles from the source database. Then they are transformed and applied to the target Aurora PostgreSQL-Compatible database. For example, the blog post Use SQL to map users, roles, and grants from Oracle to PostgreSQL
covers using extraction from an Oracle source database engine. Use standardized users and roles that are commonly used during development, administration, and for performing other related operations in the database. This includes read-only, read/write, development, administration, and deployment operations performed by the respective users.
This pattern contains the grants required for users and roles creation in Aurora PostgreSQL-Compatible required for the standardized users and roles approach. The user and role creation steps are aligned to the security policy of granting least privilege to the database users. The following table lists the users, their corresponding roles, and their details on the database.
Users | Roles | Purpose |
|
| Used for read-only access on the schema |
|
| Used for the write and read operations on the schema |
|
| Used for the development purpose on the schema |
|
| Used for performing administrator operations on the database |
|
| Used for creating the objects under the |
Prerequisites and limitations
Prerequisites
An active Amazon Web Services (AWS) account
A PostgreSQL database, Amazon Aurora PostgreSQL-Compatible Edition database, or Amazon Relational Database Service (Amazon RDS) for PostgreSQL database
Product versions
All versions of PostgreSQL
Architecture
Source technology stack
Any database
Target technology stack
Amazon Aurora PostgreSQL-Compatible
Target architecture
The following diagram shows user roles and the schema architecture in the Aurora PostgreSQL-Compatible database.
Automation and scale
This pattern contains the users, roles, and schema creation script, which you can run multiple times without any impact to existing users of the source or target database.
Tools
AWS services
Amazon Aurora PostgreSQL-Compatible Edition is a fully managed, ACID-compliant relational database engine that helps you set up, operate, and scale PostgreSQL deployments.
Other services
psql
is a terminal-based front-end tool that is installed with every PostgreSQL Database installation. It has a command line interface for running SQL, PL-PGSQL, and operating system commands. pgAdmin
is an open-source management tool for PostgreSQL. It provides a graphical interface that helps you create, maintain, and use database objects.
Epics
Task | Description | Skills required |
---|---|---|
Create the deployment user. | The deployment user
| DBA |
Create the read-only user. | The read-only user
| DBA |
Create the read/write user. | The read/write user
| |
Create the admin user. | The admin user
| DBA |
Create the development user. | The development user
| DBA |
Related resources
PostgreSQL documentation
Additional information
PostgreSQL 14 enhancement
PostgreSQL 14 provides a set of predefined roles that give access to certain commonly needed, privileged capabilities and information. Administrators (including roles that have the CREATE ROLE
privilege) can grant these roles or other roles in their environment to users, providing them with access to the specified capabilities and information.
Administrators can grant users access to these roles using the GRANT
command. For example, to grant the pg_signal_backend
role to Admin_User
, you can run the following command.
GRANT pg_signal_backend TO Admin_User;
The pg_signal_backend
role is intended to allow administrators to enable trusted, non-superuser roles to send signals to other backends. For more information, see PostgreSQL 14 enhancement
Fine-tuning access
In some cases, it might be necessary to provide more granular access to the users (for example, table-based access or column-based access). In such cases, additional roles can be created to grant those privileges to the users. For more information, see PostgreSQL Grants