Day 44: Relational Database Service in AWS (Jan 09, 2024)

Day 44: Relational Database Service in AWS (Jan 09, 2024)

Relational Database Service

Amazon Relational Database Service (Amazon RDS) is a web service that makes it easier to set up, operate, and scale a relational database in the AWS Cloud. It provides cost-efficient, resizable capacity for an industry-standard relational database and manages common database administration tasks.”

RDS offers six database engines:

  • MySQL: A widely-used open-source relational database management system known for its stability, ease of use, and compatibility.

  • MariaDB: A community-developed, open-source fork of MySQL, offering similar features and compatibility.

  • PostgreSQL: An open-source object-relational database management system known for its robustness, extensibility, and support for advanced features.

  • Oracle: A commercial relational database management system that provides enterprise-level features and capabilities.

  • SQL Server: A commercial relational database management system developed by Microsoft, offering scalability, security, and integration with Microsoft products.

  • Amazon Aurora: A MySQL and PostgreSQL-compatible database engine developed by AWS. It offers high performance, scalability, and durability. It is up to five times faster than MySQL.

Task-01:

  • Create a Free tier RDS instance of MySQL

  • Follow to create RDS on AWS..

  • login on your AWS account > GO to search bar and search RDS.

  • Go to your AWS console > Search RDS > Choose to Create database > Select Standard Create > Under “Engine options”, choose “MySQL”

Select template > Free Tier.

Under Settings, I am providing the following details:

DB instance identifier: database-44

Credentials Settings:

Master username: admin

And provide the password of your choice according to the constraints mentioned.

Configure other settings like storage, backups, VPC, and security groups according to your requirements. Review the configuration and click “Create Database”.

Create an EC2 instance

I am creating an instance named instance-44rds.

I am configuring the security group to allow inbound traffic on the MySQL port (default is 3306)

Create an IAM role with RDS access. Assign the role to EC2 so that your EC2 Instance can connect with RDS.

Go to IAM Dashboard > Click on Roles > Create Role > Select the EC2 service for the trusted entity > In permission policies, attach the permission AmazonRDSFullAccess > Name the role as “rds-data” > Create Role.

The role is created.

Let’s connect to the EC2 instance using SSH.

And then install the MySQL client in the instance:

sudo apt-get update
sudo apt-get install mysql-client
mysql --version

To connect to the RDS instance using the MySQL client and the endpoint address, username, and password, we use the following command:

mysql -h <RDS_ENDPOINT> -P <RDS_PORT> -u <MASTER_USERNAME> -p
#The below details we copied when we created the RDS instance:
#<RDS_ENDPOINT> with the endpoint of your RDS instance
#<RDS_PORT> with the port number (default is 3306)
#<MASTER_USERNAME> with the master username
# '-h' is used to specify the endpoint of MySQL server to which we want to connect (basically the host)
mysql -h database-example-rd-1.cg9zuoghw8tf.ap-south-1rds.amazonaws.com -P 3306 -u admin -p

After running this command, you will be prompted for the password. Give the password you created while creating RDS:

Now you can verify the CRUD operations confirming the MYSQL is working properly.

And Yay! We have created a Free tier RDS instance of MySQL, an EC2 instance, assigned an IAM role with RDS access to the EC2 instance, and connected to the RDS instance from the EC2 instance using a MySQL client.

In this blog, I have discussed Relational Database Services in AWS. If you have any questions or want to share your experiences, please comment below. Don’t forget to read my blogs and connect with me on LinkedIn and let’s have a conversation.

If you have questions or experiences to share, please feel free to comment below. You can also connect with me on LinkedIn; my name there is Akash Singh. I'm open to suggestions and corrections to improve my blog.