# Day 44: Relational Database Service in AWS

Welcome to another exciting day of exploring AWS services. Today, we'll delve into the process of seamlessly integrating an RDS instance with an EC2 instance in AWS.

In this blog post, we'll walk through each step, from creating a Free Tier RDS instance of MySQL to connecting an EC2 instance using a MySQL client. Let's get started

Task-01: Integrating RDS and EC2 Instances

**Step 1: Create a Free Tier RDS Instance of MySQL**

To begin, let's set up an RDS instance of MySQL using the AWS Management Console. Here's how you can do it:

1. Log in to the AWS Management Console.
    
2. Navigate to the RDS service.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686611817429/85b9cd56-2980-48de-b63b-f7fdcdf84049.png align="center")
    
3. Click on "Create database" to start the instance creation wizard.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686611852592/b10dbb5e-88a3-46d3-b39e-1e2e7b647193.png align="center")
    
4. Choose "MySQL" as the database engine and select the version that suits your requirements. we will be using PostgreSQL
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686612167598/051ea09c-d4a5-4b4f-ab2d-3db58a951d6d.png align="center")
    
5. Configure the instance details, including instance specifications, storage options, and database settings.
    
6. Set up the master username and password for your MySQL database.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686612282202/a7f094a4-b274-4c22-b2b8-1e35ee69b9e5.png align="center")
    
7. Configure the networking options and security groups.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686612321465/8e646f49-0944-4cfd-a217-b0d6f1faa47e.png align="center")
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686612363986/ca2d4977-13cb-4ea1-8c70-5635cb832fc8.png align="center")
    
8. Review your settings and Create the RDS instance.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686612527379/f22b4d14-c61d-4ff4-b26a-30d0634ebfbe.png align="center")
    
    **Step 2: Create an EC2 Instance**
    
    I hope till now you have mastered in creating instance of EC2
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686612785766/6f034403-1c27-4215-9084-dc03aecb11a3.png align="center")
    
    **Step 3: Create an IAM Role with RDS Access**
    
    1\. Navigate to the IAM service in the AWS Management Console.  
    2.Click on "Roles" and then "Create role".
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686613006021/0423c28b-32af-45bc-b4c3-174ff2c90afd.png align="center")
    
    1. Choose the EC2 service as the trusted entity.
        
        ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686613178733/0dd642e9-09cb-4b7f-b5ad-3f1c6824d23a.png align="center")
        
    2. Attach the appropriate policies that grant RDS access to the role.
        
        ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686613268792/dfe4a330-00a2-4e70-9574-38413e6ed26d.png align="center")
        
    3. Review your settings and create the IAM role.
        
        ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686613336089/3edf9d29-7e40-45c4-8d01-cf43ef132eab.png align="center")
        

**Step 4: Assign the IAM Role to the EC2 Instance**

1. Go to the EC2 dashboard in the AWS Management Console.
    
2. Select the EC2 instance you created in Step 2.
    
3. Click on "Actions" and then "Security".
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686613515846/3058a947-d8c5-4f9b-a001-dac433065840.png align="center")
    
4. Choose "Modify IAM role" and select the IAM role created in Step 3.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686613608399/0194dc51-4531-43f0-8e91-9beae60a7ce2.png align="center")
    
5. update IAM role
    

Step 5: Connect the EC2 Instance to the RDS Database Using a MySQL Client

1. Retrieve the credentials for your RDS instance from the RDS dashboard.
    
2. SSH into your EC2 instance using a terminal or SSH client.
    
3. Install a MySQL client on your EC2 instance.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686614038559/c38d43cb-7492-4357-b9fb-787bc6ad4c99.png align="center")
    
4. Use the MySQL client and the RDS credentials to connect to the RDS instance.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686615508138/f0c92953-fe2d-47f7-a908-439a74c97d98.png align="center")
    

That's it! You have successfully connected your RDS and EC2 instances. Now you can leverage the power of this integration for your applications and databases.

If you have any queries/suggestions please write a comment below. See you another day with another challenge.
