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:
Click on the “Create database” to start the configuration of the database:
Select the database creation method from the “Standard create” and “Easy create” methods:
Select the “PostgreSQL” engine to run the DB instance on it:
Select the engine version of PostgreSQL and select the “Free tier” template:
Type the name of the database instance with its username:
Set the password for the user and confirm it also:
Configure the DB instance by selecting its class and type:
Locate the storage section and configure its settings from the platform:
Set the connectivity of the compute resource and network type:
Select the VPC and subnet group of the database instance with public accessibility:
Set the security groups with inbound rules attached to them:
Set the password authentication as the password has been set for the user previously:
Specify the Retention period and AWS KMS key in the Monitoring section:
Review the configurations of the DB instance and click on the “Create database” button to complete the creation process:
The database has been created successfully now click on its name to access the summary:
Click on the “Connectivity & security” section under the Summary section:
Copy the “Endpoint” to be used in the AWS CLI command to connect to it:
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:
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.