AWS

How to Setup RDS and connect with EC2 in AWS

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.

Choose Best Hosting for your Business

PlatformReviewsPricing
Siteground★★★★★$3.95
Kinsta – Google Cloud★★★★★$30

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.

Cloudbooklet builds a large collection of Linux based guides and tutorials on Cloud platforms like Google Cloud, AWS, Azure, DigitalOcean and more

1 Comment

  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.

Write A Comment

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

If you find this helpful? Support me!
Buy me a coffee Donation Please buy me a coffee