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.
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 Databases.
b. From the RDS > Databases screen, select Create database.
c. On the Create database screen, select the following options:
d. In the Templates pane, select Dev/Test for this tutorial.e. In the Settings pane, in the DB cluster identifier field enter MyClusterName.
- For Choose a database creation method select Standard create.
- For Engine options, select Amazon Aurora.
- In the Edition radio buttons, select Amazon Aurora MySQL-Compatible Edition.
- Then select a database version that offers the Serverless option. As of this writing, the option is available with versions 5.7 and 2.10.2
Set the Master username and Master password fields with values of your choice and store the username and password for further use later.
f. In the Instance configuration section, keep the default values.
Memory optimized instances accelerate performance for workloads that process large data sets in memory.
Burstable performance instances provide a baseline level of CPU performance with the ability to burst above the baseline.
g. In the Availability & durability section, keep the default value.
h. In the Connectivity section, in the Virtual private cloud (VPC) list, select Create new VPC. In the Subnet group list, select Create new DB Subnet Group. For the Public access radio buttons, keep the default value. In VPC security group list, select Create new VPC security group and enter MyClusterGroup. You will modify this security group to allow network traffic from your database client to access your new Aurora Serverless cluster in a later step. For the Availability Zone list, keep the default No preference.
Keep remaining default selections and select Create database.
i. The RDS > Databases screen will load and your MyClusterName cluster will appear as in the creating status. Click on myclustername-instance-1 in the cluster list to access detailed information about your cluster.j. The MyClusterName detail screen will load. This screen contains tabs to view connectivity & security, monitoring information, logs and events, configuration details, and maintenance and backups, and tags.
From the Connectivity & security tab, record the VPC value and Endpoint values for use later in the tutorial.
Create a Client Environment with Cloud9After 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 AWS Management Console, begin typing Cloud9 in the search bar 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 EC2 instance for environment (direct access), the Instance type as t2.micro, and the Platform as Amazon Linux 2.e. Because Aurora Serverless DB clusters do not have publicly 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 2j.Select Next step.
After your new Cloud9 environment has been created, proceed to the next step.
Enable client network access to your Serverless ClusterIn 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, 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 4e0d. 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 MyClusterGroup.Then select the Inbound Rules tab.Then select Edit inbound rules.
d. On the Inbound Rules page, select Add rule.
In the Type column, select MySQL/Aurora 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 rules.As an example, in the screen shot to the right, from the list you would select the security group that ends 4e0d. 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, 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 Databases from the left navigation list. From the Clusters list, select myclustername-instance-1. From the Actions menu select Delete. In the prompt, confirm deletion by typing delete me into the appropriate field.c. From the top menu, begin typing Cloud9 in the search bar and select Cloud9 to open the service console.
d. From the Your environments screen, select MyCloud9Env and select Delete. Confirm the MyCloud9Env deletion.
Congratulations! You have learned how to configure, deploy, and delete your Docker-enabled application to Amazon ECS. Amazon ECS is a highly scalable, high performance container management service that supports Docker containers and allows you to easily run applications on a managed cluster of Amazon EC2 instances.