Day 44 of #90DaysOfDevOps
Amazon Relational Database Service (Amazon RDS) is a collection of managed services that makes it simple to set up, operate, and scale databases in the cloud and It consists of sequel databases such as MySQL, Microsoft SQL Server, Oracle, PostgreSQL, MariaDB, Aurora (PostgreSQL Compatible), Aurora (MySQL Compatible).
Task-01
Create a free tier RDS instance of MySQL.
Create an EC2 instance.
Create an IAM role with RDS access.
Assign the role to EC2 so that your EC2 Instance can connect with RDS.
Once the RDS instance is up and running, get the credentials and connect your EC2 instance using a MySQL client.
Solution
Create an EC2 instance
To create an EC2 instance, refer to this blog ๐.
I have created one instance with an Ubuntu image and free tier setup and also assigned port 3306 for MySQL to the security group.
Create a free tier RDS instance of MySQL.
To create a free tier RDS instance of MySQL, search for RDS in AWS and visit the RDS page.
Click on "Create database"
Choose the database creation method: "Standard Create"
In the configuration, choose MySQL.
Next, in the templates, choose "Free tier".
In the settings, give the database name, username and password.
Scroll down to "Connectivity".
Select "Connect to an EC2 compute resource", then select the EC2 instance.
Just below that, choose the "DB subnet group" and "VPC security group (firewall)"
Then "Create Database".
It will take a few minutes to fully create.
Create an IAM role with RDS access
Go to IAM in AWS Management Console, click on "Roles", then "Create Role".
Select "AWS Services" from the trusted entity.
In the use case, select "EC2". Click Next.
Now add permission of "AmazonRDSDataFullAccess" and click next.
Then enter role name, review, and create.
Now, go to EC2, select the instance, click on actions then security and then Modify IAM role.
Choose the role and update.
Once the RDS instance is up and running, get the credentials and connect your EC2 instance using a MySQL client.
Go to RDS, click on the database name.
Next, at the bottom, copy the endpoint and the port.
Then connect the EC2 instance with the SSH.
Now install MySQL client
sudo apt install mysql-client-core-8.0 -y
Connect to RDS MySQL database-2 database by entering the mysql command with endpoint, port, username and -p for entering the password on the next stage.
mysql -h <endpoint address> -P <port number> -u <username> -p
Thank you.