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
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.
Hint:
You should install mysql client on EC2, and connect the Host and Port of RDS with this client.
Post the screenshots once your EC2 instance can connect a MySQL server, that will be a small win for you.
Watch this video for reference.
Steps:
Log in to the AWS console and create an Instance (ubuntu) and start it.
Navigate to RDS and start creating a free tire RDS for yourself
Click on create database and select Standard create and MySQL
In the Templates session choose it as Free tier
Give it a name in DB instance identifier and Set the "Master username" and "Master password" for the database.
Instance Configuration and Storage
- Connectivity
- Select the VPC and Certificate authority
- Set the Database authentication and leave the rest to defaults
Click on Create database and database is successfully created
Create an IAM role with RDS access. IAM > Roles > Create role
Select the entity type as AWS service and EC2 as a use case and click on Next
- Under Add Permissions provide policy AmazonRDSFULLAccess and click on next
- Give it a role name and click on create role
A new role for RDS is created
- Now we will assign the IAM role to the EC2 instance, go to the instance and click on Actions > Security > Modify IAM roles
Modify the role and update it
- Go to the RDS database, under "Connectivity and Security" and note the endpoint address.
- Click "Configuration" and note the username and password.
SSH into your EC2 instance using a terminal or remote access tool.
Install MySQL client in the Ec2 instance
$ sudo apt install mysql-client-core-8.0
- Connect to the RDS instance using the MySQL client and the endpoint address, username, and password
mysql -h <endpoint address> -P <port.no> -u <username> -p
Now you are connected to RDS database through the Ec2 instance with a IAM role of RDS