Day 44: Relational Database Service in AWS.

Day 44: Relational Database Service in AWS.

Today I have covered,

  • What is AWS Relational Database Service or RDS?

  • Why should we use RDS?

  • How to Connect RDS to an EC2 Instance?

What is AWS Relational Database Service or RDS?

  • AWS RDS (Amazon Relational Database Service) is a cloud-based service provided by Amazon Web Services which simplifies the process of setting up, operating, and scaling relational databases. It is designed to make it easier for developers to manage databases without the need to worry about the underlying infrastructure.

  • In simple terms, AWS RDS allows you to create and manage databases in the cloud without having to set up and maintain your own database servers. It supports popular relational database engines like MySQL,PostgreSQL, Oracle, SQL Server, and MariaDB.

  • With AWS RDS, you can perform tasks such as creating a new database instance, scaling your database to handle increased traffic, and automating backups. It handles many administrative tasks for you, such as software patching, database backups, and system maintenance, so you can focus more on building your applications.

  • AWS RDS offers features like automated backups, which can be scheduled to occur at regular intervals, and you can restore your database to any point in time within the backup retention period. It also provides high availability and fault tolerance by automatically replicating your database across multiple availability zones, ensuring that your data is safe and accessible even if one zone fails.

  • Furthermore, AWS RDS allows you to easily scale your database resources up or down based on your application's needs. This means you can increase the processing power, memory, or storage capacity of your database instance as your application demands grow, without significant downtime or manual intervention.

product-page-diagram_Amazon-RDS-Custom_HIW-V2 2a0401dfa56ea4cb6494ac52c6ad6dd1c62f5d44

Why use AWS RDS?

  • AWS RDS is a fully managed service that simplifies the process of setting up, operating, and scaling relational databases. It eliminates the need to provision and manage your own database servers, install and configure database software, and perform ongoing maintenance tasks such as software patching, database backups, and system maintenance.


Task-01:

Before Creating RDS Instance let's create an EC2 Instance which we will use to connect to our RDS Instance.

Step-01: Go to AWS Console >> Services >> EC2.

Screenshot from 2023-07-17 11-56-04

Step-02: Click on Launch Instance.

Screenshot from 2023-07-17 11-56-37

Step-03: Give a Name to your Instance and Select Ubuntu and it Version.

Screenshot from 2023-07-17 11-58-14

Step-04: Select t2.micro as your Instance Type and also key pair.

Screenshot from 2023-07-17 11-58-33

Step-05: Click on Review and Launch and check dashboard for your instance.

Screenshot from 2023-07-17 12-03-45


Create a Free tier RDS instance of MySQL.

  • Step-01: Go to AWS Console >> Services >> RDS.

Screenshot from 2023-07-15 21-16-14

  • Step-02: Click on Create database.

imageedit_2_4092586013

  • Step-03: Select MySQL as the Database creation method.

Screenshot from 2023-07-15 21-18-32

  • Step-04: Select Engine Version and then Select Free tier in Templates.

Screenshot from 2023-07-15 23-11-13

  • Step-05: Now we will set the DB instance identifier and Master username and Master password and make sure a

imageedit_7_6313015612

  • Step-06: Instance Configuration >> Burstable classes >> db.t3.micro.

Screenshot from 2023-07-15 23-13-50

  • Step-07: Connectivity with your EC2 instancewhich we created previously for RDS connection.

Screenshot from 2023-07-17 09-16-40

  • Step-08: Add the VPC security group (launch-wizard-23) which we will configure in the EC2 instance of the Security group >> Edit inbound rules.

Screenshot from 2023-07-17 09-18-59

  • Step-09: Thus we have created a RDS instance.

Screenshot from 2023-07-17 09-31-06


Assign the role to EC2 so that your EC2 Instance can connect with RDS Instance.

  • Step-01: Go to AWS Console >> Services >> IAM >> Roles >> Create Role and also select EC2 as the service.

Screenshot from 2023-07-17 09-56-25

  • Step-02: Add the AmazonRDSFullAccess policy to the role.

Screenshot from 2023-07-17 09-56-54

  • Step-03: Give a name to the role and create the role and review it.

Screenshot from 2023-07-17 09-58-06

  • Step-04: Now check whether the role is created or not.

imageedit_4_5255382338

  • Step-05: Now go to EC2 and select them Instance and click on Actions >> Instance Settings >> Modify IAM Role.

Screenshot from 2023-07-17 12-48-50

  • Step-06: Select the role which we created previously and click on Save.

Screenshot from 2023-07-17 09-59-46


Once the RDS instance is up and running, get the credentials and connect your EC2 instance using a MySQL client.

  • Step-01: Go to AWS Console >> Services >> RDS >> Databases >> Connectivity & security >> Endpoint.

imageedit_8_6018864739

  • Step-02: Now Open the EC2 instance and install the MySQL client.
sudo apt-get install mysql-client

Screenshot from 2023-07-17 10-16-04

mysql --version

Screenshot from 2023-07-17 10-18-08

  • Step-03: Now Let's configure the Security group of the EC2 instance to allow the inbound traffic from the RDS instance.

imageedit_13_6694516260

  • Here we have configured the port MySQL (3306) and source as the security group of the RDS instance.

imageedit_10_2759972710

  • Step-04: Now connect the RDS instance with the EC2 instance using the MySQL client.
mysql -h <endpoint-name> -P <port-name> -u <username> -p
  • At last, verify your password and we are connected to MySQL.

Screenshot from 2023-07-17 10-25-26

Thus we have connected our Relational Database (MySql) to an EC2 instance using IAM roles.


Happy Learning :)

Did you find this article valuable?

Support DevOps by becoming a sponsor. Any amount is appreciated!