AWS Relational Database Service (RDS) – PostgreSQL in Cloud

Introduction

In my previous post “Introduction to AWS“, I gave a high level overview about various amazon services and their common uses.

Today, we will go into details of Amazon RDS. We also setup a PostgreSQL instance using this service and connect to it using a tool Azure Data Studio

Amazon RDS is a web service that makes it easier to setup, operate and scale a relational database in the cloud.

This service can help free up time so that it can be refocused to creating business solutions instead of managing hardware and database installations.

You can use AWS RDS with variety of engine e.g. SQL Server, PostgreSQL, MySQL, MariaDB, Oracle and Aurora. There are some settings which are common to all the engines and some which are more specific to a particular database. In this post we will also see how to work with these settings (actually AWS web console makes it very easy to get it setup).

Some of the supporting features of RDS are:

  • Read Replicas
  • Database Backup (Snapshot)
  • Database Monitoring
  • others….

Creating an RDS DB Instance

From your AWS Web Console you can select RDS and choose Standard Create and select a database engine in this case PostgreSQL:

Next, we can choose a template to meet our requirement. We will select Free tier:

Next, we will choose a DB instance name, username and password. These settings are same of other database engines as well:

Next, we can select DB instance class, I am selecting here a very basic one (free tier) which is ok for testing or small PoC application:

For Storage, setting, we can go with the defaults here:

Multi-AZ means having double all the resources. You can see that Multi-AZ is grayed out (this is due to free tier. Selecting this option will result in almost double the cost but it might be a requirement for production scenarios.

We selected free tier in the start, that’s why most of the options are preselected for us as well.

But decisions about choices above normally comes down to a balance of performance needs and budget, both of which may be unknown at this point in the time. That is one of the benefits of using a Platform as a service for your database or any hosted solution for that matter. These choices can be always changed later without significant downtime.

Networking

Next set of configurations is for VPC (Virtual Private Cloud), that this database instance will be accessible from. Defaults here are acceptable for testing purpose, but you can modify those as per your situation.

(e.g., you may have a scenario with an EC2 instance that is hosting your application. Instead of exposing the database instance through a public network, you could add both resources to the same VPC so that the application can communicate with the database over a private network.)

Notice, that I’ve selected yes for Public access. This option allow public accessibility to this db instance.

For Security groups setting, we have selected default. Security groups are part of the VPC that identify the network traffic rules for inbound and outbound traffic. So for public accessibility selection we made is going to be configured within this security group.

For database authentication, default Password authentication is ok for us.

We can click Create Database button at the end of the settings and in few minutes database instance will be running and ready to use. You can see the details of that instance as shown below and I will use this information to connect to it from Azure Data Studio running on my windows machine:

Connecting with Azure Data Studio

Following is the connection dialog in Azure Data Studio for the PostgreSQL instance:

Click Advance to enter Port number:

and Click Connect to make a connection with the db instance. You may see a connection error dialog similar to following:

We need to configure Inbound rules for Security Group to allow incoming traffic for our db instance.

You can go into security group details and Edit Inbound rules from following screen:

Add a new Rules to allow incoming traffic from Anywhere (not a production recommendation) as shown below:

With the inbound rules in place, try to connect again and this time, we are connected successfully:

Now you can start writing some SQL Queries, create databases, connect applications to it etc. You can also check my other article Fun with SQL using Postgres and Azure Data Studio.

Summary

Amazon RDS makes it very easy to spin up databases in cloud and saves you a lot of time by managing a lot of infrastructure and database setup concerns for you. Its easy to start with and you can also customize various settings as per your application requirements. Let me know, if you have some comments or questions. Till next time, Happy Coding.

My Recent Books


Discover more from Hex Quote

Subscribe to get the latest posts sent to your email.

1 thought on “AWS Relational Database Service (RDS) – PostgreSQL in Cloud”

Comments are closed.

Discover more from Hex Quote

Subscribe now to keep reading and get access to the full archive.

Continue reading