How to Create a PostgreSQL Database in RDS
The process of creating an RDS database is just as easy as creating other AWS resources such as EC2. The only prerequisite you need to create a database in RDS is an active AWS account. The following steps are all you need to spin up a PostgreSQL database in RDS.
Connecting to an RDS PostgreSQL Database
Connecting to PostgreSQL with web technologies like Node.js is very easy, and you can also connect with the PostgreSQL GUI tool PgAdmin4. To test the newly created RDS PostgreSQL instance with a connection, this section uses PgAdmin4 to connect to the database. Follow the steps below to test the database connection.
Login to PgAdmin4, and register a new server. Give the server a name and navigate to the connection tab. This is where you need the endpoint URL and port of the PostgreSQL instance. You’ll also need the authentication credentials you configured when creating the database. Navigate to your RDS dashboard and open the database instance properties by clicking on the database name. The screen displayed shows the Connection & Security properties of your RDS database. Copy the Endpoint string and paste it into the Hostname/Address field in PgAdmin4. Then input the value 5432 in the port field. The Maintenance database is the initial database that PgAdmin connects to (by default, the value to put here is postgres). Fill in your database authentication credentials (username and password) and leave every other setting as default. Before saving, you have to edit the VPC security group settings for your database to allow all kinds of traffic from your IP address. To do this, navigate back to the Connectivity & Security properties of your RDS database, then click on the security group to view its configuration. Go to the inbound rules tab and click on Edit inbound rules. On the screen that shows up, add a new rule that allows all traffic and select My IP in the source. This ensures that RDS will only allow connections from your computer. You can always add a new IP address in case you switch computers or deploy your application on another computer. Go back to PgAdmin4, then click save and wait while it tries to establish a connection with the database. A successful connection adds your database to PgAdmin’s list of servers as shown below:
After PgAdmin has connected to the database, you can run queries and do whatever you want with the database.
Launching and Connecting to Databases With RDS
You can use PgAdmin4 to connect and manage your databases. You can also connect directly to your RDS database from an application using the same connection details.