In this tutorial, you will learn how to configure and connect to Amazon Aurora Serverless.
Amazon Aurora is a relational database service with MySQL and PostgreSQL-compatible editions, which offers the performance and availability of enterprise databases at a fraction of the cost. Aurora Serverless is an on-demand auto-scaling configuration for Aurora. With Aurora Serverless, your database will automatically start up, shut down, and scale up or down capacity based on your application’s needs – so you’re never paying for what you don’t use, while still benefiting from Aurora’s high availability, scale, and speed.
Traditionally, database administration requires a fair amount of guesswork: keeping ahead of unknowable and sometimes volatile compute and storage growth for new applications, managing variable workloads like development and test databases, and keeping lots of database capacity online - only for it to be used 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 AWS Management Console.
In this tutorial, you will create and configure a new Aurora Serverless DB cluster. This tutorial will use Amazon Aurora with MySQL compatibility, but you can follow a similar process for the PostgreSQL edition. To access your new Aurora Serverless cluster, you will create a Cloud9 environment and then enable network traffic to the cluster from your Cloud9 environment. Using the MySQL command line tool installed on your Cloud9 environment, you will login to your cluster. Finally, you will clean up and terminate your Cloud9 environment and Aurora Serverless DB cluster.
This tutorial is not within the free tier and will cost you less than $1 provided you follow the steps in the tutorial and terminate your resources at the close of the tutorial.
This tutorial requires an AWS Account
This tutorial is not within the free tier. It will cost you less than $1 provided you follow the steps in the tutorial and terminate your resources at the close of the tutorial.
Navigate to the RDS console
In this step, you will navigate to the Relational Database Service (RDS) console so you can create an Aurora Serverless DB cluster.
a. Open the AWS Management Console, so you can keep this step-by-step guide open. When the screen loads, enter your user name and password to get started. Then begin typing RDS in the search bar and select RDS to open the service console.
Create an Aurora Serverless DB cluster
In this step, you will use Amazon RDS to create an Aurora Serverless DB cluster.
a. On the Amazon RDS screen, from the navigation bar on the left, select Clusters.
b. From the RDS > Clusters screen, select Create database.
c. On the Select engine screen, select Amazon Aurora. In the Edition radiobuttons, select MySQL compatible. Then select a database version that offers the Serverless option. As of this writing, the option is available with versions 5.6.10a and 2.07.1.
d. In the Setting pane, in the DB cluster identifier field enter MyClusterName.
Set the Master username and Master password fields with values of your choice and store the username and password for further use later.
e. On the Configure advanced settings page, in the Capacity setting pane, you can change the Minimum Aurora capacity unit and the Maximum Aurora capacity unit 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.
Expand the Additional scaling configuration section. You can disable cluster pausing by unchecking the Pause compute capacity after consecutive minutes of inactivity checkbox. Using the hours, minutes, and seconds drop down list boxes, you can change the length of inactivity time until the cluster pauses. By default your cluster will pause after 5 consecutive minutes of inactivity.
For this tutorial, you should leave these default values.
f. On the Network & Security pane, in the Virtual Private Cloud (VPC) list, select Create new VPC.
In the Subnet group list, select Create new DB Subnet Group.
In VPC security groups list, select Create new VPC security group. You will modify this new security group to allow network traffic from your database client to access your new Aurora Serverless cluster in a later step.
Select Create database.
g. The RDS > Clusters screen will load and your MyClusterName cluster will appear as in the creating status. Click on MyClusterName in the cluster list to access detailed information about your cluster.
h. The MyClusterName detail screen will load. This screen contains monitoring information including the Serverless Database Capacity graph that shows the number of Aurora Capacity Units in use over time and Recent Events pane which details scaling and pausing/resume events.
Scroll to the to the Details pane. Record the VPC value and Database endpoint values for use later in the tutorial.
Create a Client Environment with Cloud9
After creating the MyClusterName cluster, your next task is to create a database client inside the same VPC. To complete this task you will create a Cloud9 environment to use as your database client.
a. From the top AWS Web Console menu, select Services. In the search bar, begin typing Cloud9 and select Cloud9 to open the service console.
b. On the AWS Cloud9 screen, select Create environment.
c. On the Name environment screen, in the Name field type MyCloud9Env and select Next step.
d. On the Configure setting screen, leave the environment type as Create a new instance for environment (EC2) and the Instance type as t2.micro.
e. Because Aurora Serverless DB clusters do not have publically accessible endpoints, your MyClusterName can only be accessed from within the same VPC.
To place MyCloud9Env in the same VPC as MyClusterName, scroll down the Configure setting screen and expand the Network settings (advanced) section. From the Network (VPC) drop down, select MyClusterName's VPC which you recorded step 2h.
Select Next step.
On the Review page, select Create environment.
After your new Cloud9 environment has been created, proceed to the next step.
Enable client network access to your Serverless Cluster
In this step, you will enable network access from your Cloud9 environment to your Serverless DB Cluster. To accomplish this task, you will add the security group assigned to MyCloud9Env as a traffic source for the security group assigned to MyClusterName. A security group is a virtual firewall that controls network traffic in your network.
a. To make navigation easier, load the AWS Web Console in another browser tab by clicking here. In the new browser window, on the top menu bar, select Services then type VPC in the search bar and select VPC from the list.
b. On the 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.
As an example, in the screen shot to the right, you would note the security group that ends with 7431. Your Group ID will be different than is pictured in this screen shot.
c. In the list of security groups, select the security group that begins with RDS-Launch-Wizard.
Then select the Inbound Rules tab.
Then select Edit.
d. In the Inbound Rules tab, select Add another 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 that you noted in step 4b. Then select Save.
As an example, in the screen shot to the right, from the list you would select the security group that ends 7431. Your specific Group ID will be different than is pictured in this screen shot.
Connect to your Aurora Serverless DB Cluster
In this step, from your Cloud9 environment you will access your Aurora Serverless DB cluster.
a. Switch back to your MyCloud9Env browser window.
In the bash terminal tab in MyCloud9Env, type in the following command. Substitute your Master username and database endpoint for the values in the command and press Enter.
mysql --user=[your Master username] --password -h [your database endpoint]
When prompted, enter your Master password and press Enter.
You should now be connected to the MyClusterName Aurora Serverless DB cluster!
b. You can issues commands to the Aurora Serverless DB cluster using the connection you have established. For example, you can show the databases on the server by pasting the following command into the MyCloud9Env bash tab:
In this step you will terminate your Aurora DB cluster and Cloud9 environment.
Important: Terminating resources that are not actively being used reduces costs and is a best practice.
a. From the top menu, select Services, then begin typing RDS in the search bar. Select RDS to go back to the Amazon RDS Console.
b. From the Amazon RDS console page, select Clusters from the left navigation list. From the Clusters list, select myclustername. From the Actions menu select Delete Cluster.
When prompted to delete myclustername, select Delete DB Cluster, and follow the prompted instructions to delete the cluster.
c. From the top AWS web console menu, select Services. In the search bar, begin typing Cloud9 and select Cloud9 to open the service console.
d. From the Your environments screen, select MyCloud9Env and select Delete. Confirm the MyCloud9Env deletion.