How To Create Amazon Aurora DB Cluster For PostgreSQL

In this blog post , We will learn how to create amazon aurora db cluster for PostgreSQL using AWS console.

Related Articles

Create RDS instances using aws console

Create RDS Instance using Terraform

Create Read replica for RDS DB instances

What Is Aurora?

Amazon Aurora is a fully managed relational database engine which is compatible of MySQL and PostgreSQL.

Aurora has a high performance storage sub-systems, Hence MySQL and PostgreSQL databases engines can take advantages of fast distributed storage.

The storage can automatically scale up to 64 TB.

Amazon Aurora also provides DB clustering and replication.

High Availability

When we setup Aurora cluster , We will be having two endpoints.

  • Writer endpoint – which is used for read and write connections.
  • Reader endpoint – which is used for read-only connections.

We will also get the instance endpoints while we setup aurora cluster.

If we are using instance endpoints in our applications , In case of failure we need to manually change the endpoints in the application code.

But with the Writer & reader endpoints , It is capable of managing DB instance failover automatically and also better than the instance endpoints.

If the primary DB instance fails , Aurora automatically fail over to a new primary DB instance.It will either create a new primary DB instance or It will promote the existing aurora replica to new primary DB instance.

Creating Amazon Aurora DB Cluster

Amazon aurora DB cluster is compatible with both MySQL and PostgreSQL DB engines.

In this tutorial , We will setup aurora DB cluster for PostgreSQL DB engine.

While creating a cluster , The DB cluster contains a primary writer DB instance and upto 15 reader DB instances (Read replica)

Read replicas can be either created in the same region as of master or we can create red replica in different AWS region with the latency of less than 1 second.

Prerequisites

We can either use the existing VPC and the subnet group to create the aurora db cluster. Else we can,

Create a VPC with Public and Private subnets

Create Custom subnet group from new VPC.

To create subnet groups , Login to RDS console.

In the navigation pane , Choose Subnet groups

Aurora DB Cluster

Click Create DB Subnet group

provide a name for the subnet group and then choose the VPC that you have created.

For Add subnets , We must choose atleast 1 subnet from different availability zones and then click Create

Now we start creating the aurora DB cluster for PostgreSQL.

In the navigation pane , Choose Databases , Click Create database

In the Create database page , Choose a database creation method , For this guide , I am choosing Standard Create

Aurora DB Cluster

For Engine options , Choose Amazon Aurora

Aurora DB Cluster

For Edition , Choose Amazon Aurora with PostgreSQL compatibility

For version , Choose the version of Aurora (PostgreSQL) that is compatible with the application.

For Templates , Choose Production , For high availability , fast and consistent performance.

Aurora DB Cluster

Under Settings , For DB cluster identifier , Provide a name for the DB cluster

For Credentials settings , Set a Master username and password.

Aurora DB Cluster

For DB instance size , Choose the DB instance class as per your requirement.

Aurora DB Cluster

For Availability & durability , As a DB cluster , We have to create a replica in different availability zone , which will be a standby replica.

It will automatically fail over in case of the primary failure.

Aurora DB Cluster

For Connectivity , Choose the VPC that you have created.

Under Additional connectivity configuration , Choose the Subnet group that you have created.

For Publicly accessible , Choose No , It is always recommended to host the databases private.As we don’t want to expose the databases to the public network.

Aurora DB Cluster

For VPC security group , Create a new security group , Allowing port 5432 only to the certain Instances or subnets.

For Database authentication , Choose Password authentication

Under Additional configuration

If required , We can configure Backup strategy , Encryption , Monitoring and Logging.

And finally click Create database

The Aurora PostgreSQL DB cluster is created.

If you click the identifier of the regional Role , Under Connectivity & Security , We can find Writer and reader endpoints.

We can use the reader and the writer endpoints with the applications.

Again from the main console , If you click the DB identifier of the Writer , We can find the Writer Instance endpoint.

If you click the DB identifier of the Reader (which will be in different availability zone), We can find the Reader Instance endpoint.

To manually test the failover for the DB cluster.

Choose the identifier of Writer Role and Under Actions , Choose Failover

It will ask for the confirmation , Choose Failover

Aurora DB Cluster

You can find the Role of the instances are changed , But the endpoints remain the same.

Conclusion

We have successfully created the Aurora DB cluster for PostgreSQL using AWS console and also we have manually tested the fail over of the DB instances.

Hope you find it helpful.

Please check out my other articles.