Connecting to Aurora Serverless

Rupal Bhatt
Rupal Bhatt
Published in
6 min readJan 29, 2019

Our team is building analytics software and even in the beta phase we have gathered millions of records in our tables. The influx of data is unpredictable and the present set up of ingesting data is unreliable. That means constant monitoring and managing database instances and capacity. In the past we have increased capacity anticipating huge influx of data only to pay big bills for slim data. On the other hand, we have also had huge influx of data unexpectedly and had to increase the number of instances in hurry. Constant monitoring takes away precious time and resources. Aurora Serverless comes to our rescue in such situations. It is an on-demand, auto-scaling configuration where the database automatically starts up, shuts down and scales up or down as required. It is ideal for unpredictable workloads. You pay on a per-second basis for the capacity that you use.

However, setting up Aurora Serverless did take some time and effort. If you are starting out to set up Aurora Serverless this post might help you. Please note, here I go into the details of setting up VPC (Virtual Private Cloud), Subnets, Security Groups, Aurora Serverless instance for MySql5.6 (the only one supported by Aurora Serverless when I wrote this blog), setting up EC2 instance and getting Aurora Serverless started on DataGrip.

So let’s get started!

Aurora Serverless Installation:

Setting up VPC:

First on AWS open VPC Dashboard by selecting VPC on services tab.

Here click on Launch VPC wizard

Here click on Launch VPC wizard

Select VPC with Public and Private Subnets

Select VPC with Public and Private Subnets

Here are the changes you need to make on the following screen:

Enter VPC name: vpc4asl

Enter public subnet name : Public web subnet

Enter private subnet name : Private db subnet 1

Select availability zone: US East 2a — for both public and private subnet

Instance type: t2.micro

Key pair name: any existing keypair

If you see this screen in the step two then click on Use a NAT instance instead

And you will see the following screen

Once all the details are filled up click on Create VPC button

Click Ok button and then click subnets from the panel in the left side

Now we create one more subnet in another region

Now you have 3 subnets. This is what it looks like.

Create 2 security groups:

To do this click on create security group and add following:

Click on Create

Edit inbound rules for this security group

Add another security group

Second one is for Private access to database

Click on Create

Edit Inbound rules for this security group

Copy groupid for myvpcsg4web and paste it as source

This is how it finally looks:

Now from your AWS dashboard go to RDS

We need to create new subnets — so here is how to do that

Click subnet groups

Click on Create DB Subnet Group

Click on Add all subnets related to this VPC

Please remove public subnet — That is the one with 10.0.0.0/24 CIDR

Click on Create and you will a screen looking something similar to the one below

Create Aurora Serverless cluster:

Now Create Aurora Serverless cluster

On RDS console select clusters

Click create database button

In the following screen select the following fields:

Virtual private cloud

Subnet group

Choose existing VPC security group

Select the security group we created for db and Remove default

Also remove check mark from enable deletion protection if you intend to delete the database after testing.

Click on Create database button.

This is what your cluster will look like

Create EC2 instance:

Next — from your AWS dashboard go to EC2 console and click on Launch Instance

In Step 1 — select instance with mySql, PHP, PostgresSQL etc..

In the configure instance detail make following changes:

Select network

Subnet

Enable Auto-assign Public IP

No changes on step 4 and 5

Step 6

Click on Select an existing security group

Select existing security group — select the one created for web

No changes on Step 7

Just click on Launch

And select an existing keypair that you may have

Your work on AWS dashboard ends here.

Connect to your Aurora Serverless cluster using Datagrip:

Now you can go to DataGrip and insert EC2 instance detail and Aurora cluster detail as following:

Now you have successfully connected to your database and you can start your work!

--

--