RDS is the Database service of AWS. It supports a wide variety of Databases. Since we are going Serverless, it makes sense to start a Serverless DB also. We are going to use Aurora Serverless Cluster for this, which can be scaled according to the demand and is compatible with MySQL 5.7.
Create a Serverless Aurora RDS DB Cluster, which starts out with 1 instance and can be scaled upto 64 instances.
Create a Subnet Group to ensure the availability of the DB in both private subnets.
RDS > Subnet groups > Create DB Subnet Group
Name: wp-stack-aurora-subg > Description: Aurora Serverless Subnet group for WP Stack > VPC
Availability Zones: ap-southeast-1a,1b > Subnets: private-1a,1b
Create the Serverless DB cluster
RDS > Databases > Create database > Amazon Aurora > Capacity type: Serverless > Version: MySQL 5.7 (2.07.1)
DB cluster identifier: wp-stack-aurora-serverless-db
Master username: melvincv
(Auto generate a password)
Capacity settings: Min:1 Max:2
Connectivity: Select VPC > Select Subnet Group wp-stack-aurora-subg > VPC security group: wp-stack-db-sg
Additional config > Tick “Data API” > Create
Click “View Credential details” on the top and note down your password. That is the only time that the password will be shown to you!
Endpoint: wp-stack-aurora-serverless-db.cluster-c9*****wroj.ap-southeast-1.rds.amazonaws.com DB Name: wptest Master username: melvincv Password: **********
Create a new database user and grant privileges on the wptest DB. (Or just skip creating the initial database and create one here)
Select wp-stack-aurora-serverless-db > Actions > Query
create database wpstack;
(the above command is not required if you specified an initial DB)
create user 'wpuser'@'%' identified by 'J43*********AOG'; grant all on wpstack. to 'wpuser'@'%'; show grants for wpuser;
(Optional) Login to the DB using mysql client on the bastion host
sudo yum update sudo yum install -y https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm sudo yum install -y mysql-community-client mysql -h wp-stack-db.c9******wroj.ap-southeast-1.rds.amazonaws.com -u melvincv -p