DEV Community

Revathi Joshi for AWS Community Builders

Posted on

Create and Connect to RDS Aurora Serverless MySQL Database thru cloud9

Amazon Aurora is a relational database service, fully compatible with MySQL and PostgreSQL, which offers the performance and availability of enterprise databases at a fraction of the cost.

Amazon Aurora Serverless is an on-demand, auto-scaling configuration for Aurora, available for the Aurora MySQL-compatible edition, where the database automatically starts up, shuts down, and scales capacity up or down based on your application's needs. Run your database in the cloud without managing any database instances.

In the past, database administration required a lot of guess work - on how much the applications would grow, on how much compute capacity and storage they would require, and on how to manage workloads like development and test databases, which they would use this infrequently.

With Aurora Serverless, you can eliminate the guesswork. Aurora Serverless grows your database storage and compute capacity when your application needs it, and shrinks capacity when your app needs less. You pay on a per-second basis for the database capacity you use when the database is active, and migrate between standard and serverless configurations with a few clicks in the Amazon Web Services Management Console.

In this article, I am going to show you how to create and configure a new Aurora Serverless DB cluster, access it thru Cloud9 environment, and using MySQL command line tool installed on your Cloud9 environment, how you will login to your cluster.

Please visit my GitHub Repository for Aurora articles on various topics being updated on constant basis.

Let’s get started!

Objectives:

1. Create an Aurora Serverless DB cluster.

2. Create a Cloud9 environment to use as your database client.

3. Connect to your Aurora Cluster thru Cloud9 security group

4. Connect to your Aurora Serverless DB Cluster.

5. Cleanup

Pre-requisites:

  • AWS user account with admin access, not a root account.
  • Cloud9 IDE with AWS CLI.

Resources Used:

Amazon Aurora documentation

Steps for implementation to this project:

1. Create an Aurora Serverless DB cluster

  • Log into AWS Management Console / search and select Amazon RDS Console / Create Database /

Under Choose a database creation method /
Standard create:

Under Engine options /
Engine type: Amazon Aurora
Edition: Amazon Aurora MySQL-Compatible Edition
Engine version: Show versions that support Serverless v2
Available versions: Aurora MySQL 3.02.0 (compatible with MySQL 8.0.23)

Under Templates /
Dev/Test

Under Settings
DB cluster identifier: database-1

Under Credentials Settings
Master username: admin
Master password:
Confirm master password:

Under Instance configuration
DB instance class: Serverless
Capacity range: you can change the Minimum Aurora capacity unit (ACUs) and the Maximum Aurora capacity unit (ACUs) settings.

Each Aurora capacity unit is equivalent to a specific compute and memory configuration. Aurora Serverless will automatically scale between the minimum and maximium capacity settings based on your cluster's CPU utilitization, connections, and available memory.

Under Connectivity
Virtual private cloud (VPC): Create new VPC

Under DB Subnet group
Create new DB Subnet Group

Under VPC security group
Create new VPC security group: sg-aurora
Later on, You will modify this new security group to allow network traffic from your database client to access your new Aurora Serverless cluster.

Under Additional configuration / Database options
Initial database name: myaurora

  • Create database

Image description

On Amazon RDS Console / click database-1

Note down VPC value and Database endpoint, VPC security group

Image description

2. Create a Cloud9 environment to use as your database client.

  • Log into AWS Management Console / search and select Cloud9 / Create environment /

Under Create environment / Details /
Name: myCloud9env

Under Network settings / VPC settings
Amazon Virtual Private Cloud (VPC): Network (VPC) drop down, select VPC that you have created

  • Create

Image description

3. Connect to your Aurora Cluster thru Cloud9 security group

  • A security group is a virtual firewall that controls network traffic in your network.

  • you will add the MyCloud9Env security group as a traffic source for the MyClusterName security group

  • On VPC Dashboard page / in the left navigation select Security groups

  • In the Group Name column, find the security group that begins with aws-cloud9-MyCloud9Env. Note the Group ID of this security group.

Image description

  • list of security groups, select the security group that begins with sg-aurora.

  • Then select the Inbound Rules tab.

  • Then select Edit.

Image description

  • Unser Edit inbound rules / In the Inbound Rules / Add rule

  • In the Type column, select MySQL/Aurora (3306) from the drop down list.

  • Then click into the Source column field and a drop down list will appear. Select the security Group ID of myCloud9env

  • Save rules

Image description

4. Connect to your Aurora Serverless DB Cluster.

  • Open myCloud9env, type the following command.

mysql --user=[your Master username] --password -h [your database endpoint]

  • Enter master password, when prompted

Image description

  • You are connected to the myaurora Aurora Serverless DB cluster!

  • Issue command

show databases;

Image description

Cleanup.

  • To reduce costs, terminate resources

1. Delete database-1 without taking a snapshot.

2. Delete myCloud9env

What we have done so far

  • We have successfully demonstrated how to create and configure a new Aurora Serverless DB cluster, accessed it thru Cloud9 environment, and using MySQL command line tool installed on your Cloud9 environment, logged onto your cluster.

Top comments (0)