How to Connect a DB Instance Running on PostgreSQL in AWS RDS

A database instance on the AWS platform acts as the building block to build an environment for creating multiple databases on the cloud. A Database instance contains many databases on the cloud which is an isolated database environment for the user. The user can connect to the DB instance running on the PostgreSQL using the AWS CLI command.

This guide will explain connecting a DB instance running on PostgreSQL in AWS RDS.

How to Connect a DB Instance Running on PostgreSQL in AWS RDS?

To create a DB instance, Visit the “RDS” service by clicking its name from the AWS Management Console:

img

Click on the “Create database” to start the configuration of the database:

img

Select the database creation method from the “Standard create” and “Easy create” methods:

img

Select the “PostgreSQL” engine to run the DB instance on it:

img

Select the engine version of PostgreSQL and select the “Free tier” template:

img

Type the name of the database instance with its username:

img

Set the password for the user and confirm it also:

img

Configure the DB instance by selecting its class and type:

img

Locate the storage section and configure its settings from the platform:

img

Set the connectivity of the compute resource and network type:

img

Select the VPC and subnet group of the database instance with public accessibility:

img

Set the security groups with inbound rules attached to them:

img

Set the password authentication as the password has been set for the user previously:

img

Specify the Retention period and AWS KMS key in the Monitoring section:

img

Review the configurations of the DB instance and click on the “Create database” button to complete the creation process:

img

The database has been created successfully now click on its name to access the summary:

img

Click on the “Connectivity & security” section under the Summary section:

img

Copy the “Endpoint” to be used in the AWS CLI command to connect to it:

img

Use the following command to connect to it and simply change the endpoint and Username according to your DB instance:

psql -h database.c6d50j4forkq.ap-southeast-1.rds.amazonaws.com -U postgres

Running the above command will ask the user to provide the password in order to connect to the PostgreSQL DB Instance:

img

That’s all about connecting to the DB instance running on the PostgreSQL in AWS RDS.

Conclusion

To connect to the DB instance on PostgreSQL in AWS RDS, create a database instance from its dashboard. Configure the DB instance by choosing the PostgreSQL engine type and then add Username with a password attached to it. Once the database is created, use the endpoint, Master Username in the “psql” command and specify the password for the user. This guide has demonstrated the process of connecting to the DB instance running on PostgreSQL in AWS RDS.