AWS

How to Setup RDS and connect with EC2 in AWS

Disclosure: This post may contain affiliate links, which means we may receive a commission if you click a link and purchase something that we recommended.

Pinterest LinkedIn Tumblr

How to Setup RDS and connect with EC2 in AWS. In this guide you will learn how to create an RDS (Relational Database Service) in AWS and configure it to allow connections from your AWS Instance.

With this method you can have a split website setup by having your programming files on EC2 instance and database on RDS.

Prerequisites

Important: Make sure you have your RDS and EC2 Instance in the same region. Otherwise you will get latency issues.

Create RDS Database in AWS

Go to your AWS console and navigate to Services >> Database >> RDS.

In the dashboard click Create Database.

Create RDS Database in AWS

Now you can define all your details…

Select your database engine.

Select Database Engine

Now select template, if you need to get benefited from free tier you can choose Free tier.

Select Template

Enter a name to identify your RDS instance.

In the Configuration settings enter the master username and password. You can login using this username and password to manage the instance.

Configure Master settings

Leave everything to default and scroll down to Additional configuration and open that tab.

RDS Additional Configuration

Here you can create your first database by entering your database name in the Initial database name.

Proceed to configure the automatic backups and retention period as you wish.

Create RDS Instance

Click Create database to create your RDS Instance.

Now your RDS Database Instance will get created.

RDS Database Instance

Now you have created your first RDS Instance.

Configure RDS to allow connections from EC2 Instance

Go to your RDS instance and click the security group in the Connectivity & Security tab.

Edit Security Group for RDS

This will take you to the configure the security group assigned to your RDS instance.

Click the Inbound tab, then click the Edit button to change the rules for your security group.

Authorize access to RDS

Change the Type property to MYSQL/Aurora, which will update the Protocol and Port Range to the proper values.

In the value group enter the security group that is used for your EC2 instance.

Click Save.

This rule will allow MySQL access to any EC2 instance with that security group configured.

Become a Certified AWS Professional with this easy to learn course now.

Conclusion

Now you have learned how to setup RDS database instance and allow connections from EC2 instance in AWS.

Thanks for your time. If you face any problem or any feedback, please leave a comment below.

4 Comments

  1. But, if the Database is Postgres, why we have to select the rule for MySQL ?
    The ports are different. Also, it is not clear that the inbound rule is inside the Security Group, please specify it a little bit better, otherwise we find ourselves looking for a “Inbound” tab inside the RDS configurations, but it’s not.
    Thanks for the effort.

  2. THANKS A LOT!!!! It worked perfectly for me ! Why this isnt easy to find in amazons own docs?….

  3. Its worked for me. Same problem I also faced i.e Amazon doc did’t helped much.

Write A Comment

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.