How to Connect to the Amazon RDS Aurora Postgres DB Instance

AWS is the cloud-providing platform that is used by millions of individuals as well as industries to run IT-based resources on the cloud. The platform offers the Amazon Relational Database Service or RDS to create database resources on the cloud and use them. The user gets the Endpoints and port number to establish the connection to it and then runs SQL queries on it.

This post demonstrates the process of connecting to the Amazon RDS Aurora PostgreSQL-compatible DB instance.

How to Connect and Use the Amazon RDS Aurora Postgres DB Instance?

To connect and use the Amazon RDS Aurora(PostgreSQL-Compatible) database in AWS, follow this simple guide.

Launch EC2 Instance

The first step to connect to the RDS Aurora database is launching the EC2 instance from the service dashboard:

img

Head into the network settings and allow all traffic to only your IP:

img

Scroll down the page and review the configurations to complete the process by clicking on the “Launch Instance” button:

img

The EC2 instance has been created successfully and the user can view its summary by simply selecting the instance:

img

Create RDS DB Instance

Head into the RDS dashboard from the AWS Management Console to start the process of creating a database:

img

Start the process of creating an Amazon RDS database by clicking on the “Create database” button from the RDS dashboard:

img

Select the creation method for the database from a couple of options provided by the platform such as “Standard create” and “Easy create” options. The user also needs to configure the type of engine for the database which in this case is the “Aurora (PostgreSQL Compatible)” engine:

img

After selecting the engine of the database, choose the size of the DB instance and configure the database identification settings:

img

Set up the EC2 connection to select the EC2 instance created earlier and establish a connection between them:

img

After completing all the configurations, review all the settings before clicking on the “Create database” button to complete the process:

img

Simply click on the name of the database after it is created successfully and its status is “Available”:

img

Head into the database summary page and locate the “Connectivity & security” section to copy the endpoint and port for establishing the connection:

img

Connect AWS RDS Aurora Database

Head back to the EC2 instances page to connect to the EC2 instance by clicking on the “Connect” button:

img

Connection of the EC2 can be established using multiple methods provided by the platform. Here we use the SSH client section to copy the command:

img

Use the copied query and paste it on the Windows terminal after changing the path of the private key pair file from the system:

ssh -i "C:\Users\Lenovo\Desktop\tmkp.pem" ec2-user@ec2-13-215-248-102.ap-southeast-1.compute.amazonaws.com

Running the above code establishes a connection to the EC2 instance:

img

Use the following command to update the instance if there are any new updates available:

sudo dnf update -y
img

Type the following command to install PostgreSQL 15 on the instance:

sudo dnf install postgresql15

Running the above command will prompt the user to confirm the installation process by typing “y” on the terminal:

img

After that, simply use the following command to connect to the Amazon RDS Aurora PostgreSQL Compatible:

psql --host=database.cluster-ro-c8t9edwt9w0h.ap-southeast-1.rds.amazonaws.com --port=5432 --username=postgres

The above code uses the hostname which is provided by the platform on the AWS RDS database page within the endpoint and then uses the port number with the username:

img

Once the user is connected to the AWS Aurora PostgreSQL database, simply use SQL queries to work on it:

SELECT CURRENT_TIMESTAMP;

Executing the above command will display the current time of the PostgreSQL database:

img

That’s all about connecting to the Amazon RDS Aurora PostgreSQL-compatible database instance.

Conclusion

To connect to the AWS RDS Aurora PostgreSQL database instance, launch an EC2 instance from the EC2 dashboard and head into the RDS dashboard. Create an AWS RDS Aurora PostgreSQL-Compatible database by setting up the connection to the EC2 instance. After that, connect to the EC2 dashboard and install PostgreSQL 15 on the EC2 instance and connect to the Aurora PostgreSQL database.