image
Aurora Serverless Database Cluster DEMO

Contents

DVA-C02 Introduction
Amazon MemoryDB for Redis

The course is part of this learning path

Start course
Difficulty
Intermediate
Duration
2h 37m
Students
789
Ratings
4.6/5
starstarstarstarstar-half
Description

This course provides detail on the AWS Database services relevant to the AWS Certified Developer - Associate exam. This includes Amazon RDS, Aurora, DynamoDB, MemoryDB for Redis, and ElastiCache.

Want more? Try a lab playground or do a Lab Challenge!

Learning Objectives

  • Obtain a solid understanding of the following Amazon database services: Amazon RDS, Aurora, DynamoDB, MemoryDB for Redis, and ElastiCache
  • Create an Amazon RDS database
  • Create a DynamoDB database
  • Create an ElastiCache cluster
Transcript

Let's take a quick look at a demo that shows how easy it is to set up and use an Aurora Serverless database cluster.

In this example I’ll perform the following sequence:

  1. Launch a new Aurora Serverless MySQL database within the AWS RDS console.
  2. Create a new database named demo, and within it create a new table named course.
  3. Enable the Web Service Data API on the new Aurora Serverless MySQL database.
  4. Use the AWS CLI to invoke the aws rds-data command to read and write into the course table.

Ok, let's begin. Starting off in the AWS RDS console - I’ll create a new Amazon Aurora MySQL Serverless database.

Under the Database features I’ll select the “Serverless” option - this is what makes the cluster serverless. I’ll set the DB cluster identifier to be “cloudacademy-serverless”. I’ll configure the credentials to be admin with a password of cloudacademy.

For capacity settings - I’ll simply go with 2Gb for minimum capacity and 16Gb for maximum capacity. I’ll also enable the “Force Scaling” and “Pause Compute Capacity” settings to ensure cost savings when activity is low.

I’ll then deploy it into an existing Multi AZ VPC. For security groups - I’ll simply allocate an existing one which allows inbound TCP connections to the default MySQL port 3306. Connections will be made from an existing bastion host which has the standard MySQL client already installed on it.

I’ll also enable the “Data API” which will activate a SQL HTTP endpoint.

Ok with all that in place, I can now go ahead and click on the “Create Database” button at the bottom. Provisioning is fairly quick and takes just a matter of minutes to complete.

While the data provisioning is taking place, I’ll head over into the Secrets Manager service and set up a new secret which will be used later on by the AWS CLI to invoke SQL commands using the SQL HTTP endpoint.

I’ll start by clicking on the “Store a new Secret” button. For the secret type I’ll go with the selected default which is “Credentials for RDS database”. I then need to enter in the username and password Mysql database credentials - which for the serverless database I just launched were admin and cloudacademy respectively. I then need to select the cloudacademy-serverless database and then click the Next button. I then need to allocate this secret a name and optionally a description. In this case I’ll call the secret “demo/cloudacademy-serverless”.

I’ll skip assigning any tags and instead just click the Next button. I’ll accept the automatic rotation section defaults - which are to disable automatic rotation - and again just click on the Next button. The review section looks good - I can now click the Store secret button to create and store the secret. Ok, that has worked. Finally, I need to click on the new secret like so and then copy down the secret ARN highlighted here - this will be used later on to set up and authenticate to the Web Service Data API via the AWS CLI in the terminal.

Ok, let’s jump back into the RDS console and confirm that our Serverless database is ready - which it is. Next I’ll need to discover and copy the allocated host name.

I’ll now jump into my local terminal and connect to the bastion host using SSH.

Once connected I’ll use the MySQL client utility to connect to the serverless database using the hostname just copied. Once authenticated into the serverless database - I’ll simply create a new database named demo and then create a new course table within it.

Ok, I’ll now jump into a new terminal session and this time use the AWS CLI to execute a SQL insert statement to populate sample data into the course table. Here I’ll execute the following command:

aws rds-data execute-statement \

I’ll execute it within the us-west-2 region and set the secret-arn to be the arn copied when we setup the RDS secret within the secrets manager service. The resource arn is copied from the serverless database configuration section within RDS. The database is set to demo, and sql will be set to a simple insert SQL statement that will populate a new course record in our course table.

--region us-west-2 \

--secret-arn "" \--

--resource-arn "" \

--database demo \

--sql "show tables" \

--output json

Ok - executing this statement has now successfully created a new database record within the demo course table. Let's rerun this command a few more times to insert more data.

Finally - I’ll now run a select statement against the table to return all data in the course table.

In summary, this demonstration highlighted the following:

  1. How to provision a new Aurora Serverless MySQL database.
  2. How to enable the Web Service Data API.
  3. How to connect to an Aurora Serverless database using the AWS CLI, authenticating with a secret stored in the Secrets Manager service.
  4. How to execute SQL statements using the AWS CLI.

If you’ve followed along, please don’t forget to terminate your database cluster to avoid ongoing charges.

About the Author
Students
229133
Labs
1
Courses
216
Learning Paths
172

Stuart has been working within the IT industry for two decades covering a huge range of topic areas and technologies, from data center and network infrastructure design, to cloud architecture and implementation.

To date, Stuart has created 150+ courses relating to Cloud reaching over 180,000 students, mostly within the AWS category and with a heavy focus on security and compliance.

Stuart is a member of the AWS Community Builders Program for his contributions towards AWS.

He is AWS certified and accredited in addition to being a published author covering topics across the AWS landscape.

In January 2016 Stuart was awarded ‘Expert of the Year Award 2015’ from Experts Exchange for his knowledge share within cloud services to the community.

Stuart enjoys writing about cloud technologies and you will find many of his articles within our blog pages.