Create a MariaDB Database with AWS RDS

Now that the permissions are sorted, let’s create the MariaDB RDS instance.

We’re using RDS instead of Amazon Aurora because RDS offers a MariaDB-compatible database, and RDS is included in the free tier, while Amazon Aurora is not. If it wasn’t for those two considerations, Amazon Aurora would be a great choice as well. Let’s go over the steps to perform to get our MariaDB RDS instance running:

  1. Create a database subnet group that includes our subnet-private-a and subnet-private-b.
  2. Create a security group to grant all our instances in our private VPC access to the database.
  3. Create the MariaDB RDS instance.

Step 1: Create a database subnet group

RDS databases behave slightly differently compared to EC2 instances. Instead of being launched into a specific subnet, RDS databases use either of the subnet in the database subnet group. If we’re creating a Multi-AZ deployment, it uses at least two different subnets to be present in two different availability zones.

For now, we will create a Single-AZ RDS database, but the same logic regarding database subnet groups applies—we need to specify at least two subnets for the database subnet group, and the RDS database picks a subnet out of the database subnet group to be launched in.

To create a database subnet group, we can use the rds create-db-subnet-group CLI command. Because we’re dealing with RDS databases, the CLI command is now rds instead of ec2. The subcommand is create-db-subnet-group.

The command to create the database subnet group looks like this:

Get hands-on with 1400+ tech skills courses.