Accend Networks San Francisco Bay Area Full Service IT Consulting Company

How to Set Up and Connect Amazon RDS with EC2: A Practical Guide

Amazon RDS configuration settings

What is Amazon RDS?

Amazon Web Services (AWS) provides various tools to simplify the management of web applications, including Amazon RDS (Relational Database Service) and EC2 instances. Amazon RDS is a fully managed service that allows users to set up, operate, and scale relational databases in the cloud. At the same time, EC2 (Elastic Compute Cloud) provides secure and scalable computing power. Connecting these two services is essential for applications requiring database backends for dynamic data storage.

In this hands-on guide, we’ll walk you through connecting an EC2 instance with Amazon RDS, covering essential configurations, security, and best practices.

For this project, I have an EC2 Instance already launched and running. To launch an EC2 instance, you can follow these steps.

Go to the EC2 Dashboard: Open the EC2 dashboard and select “Launch instance.”

Choose an Amazon Machine Image (AMI): Select an OS that suits your application environment, such as Amazon Linux or Ubuntu.

Select an Instance Type: Choose a size based on your application needs, considering the expected database connection load.

Configure Network and Security Settings:

Ensure the instance is in the same VPC as the RDS instance to avoid connectivity issues.

Assign a Security Group to the EC2 instance that allows outbound traffic on the port your RDS instance uses, port 3306.

Launch the Instance: Once configured, launch the instance and connect to it using SSH.

Let’s configure the IAM Role:

Go to the I AM console and search for I AM then select I AM under services.

Amazon RDS configuration settings

In the I AM dashboard, select roles then click on the create role button.

Amazon RDS configuration settings
Amazon RDS configuration settings

Under trusted entity select AWS service then use case select EC2, then scroll sown and click on the next button.

Amazon RDS configuration settings
Amazon RDS configuration settings

For permission select RDS full access, then click next.

Amazon RDS configuration settings

Name your role then click on the Create role.

Amazon RDS configuration settings
Amazon RDS configuration settings

Come back to your EC2 instance and then attach that role.

Since RDS listens on port 3306, we will open port 3306 in the security groups of our EC2 instance. Move to the security tab of your EC2 instance then click on the security group wizard.

Amazon RDS configuration settings

Move to the inbound rules tab then click on edit inbound rules.

Amazon RDS configuration settings

Click add rule.

Amazon RDS configuration settings

Select MYSQL/Aurora then for destination select 0.0.0.0/0 then click on save.

Amazon RDS configuration settings

Set Up Amazon RDS

Navigate to the RDS console.

Amazon RDS configuration settings

Click on DB instances then click on the Create database.

Amazon RDS configuration settings

Choose standard create as the creation method.

Amazon RDS configuration settings

Choose MySQL as the DB engine type.

Amazon RDS configuration settings

Move with the default Engine version then for templates select the free tier.

Amazon RDS configuration settings

Under credentials settings choose the master username for your DB, then select self-managed. You can generate your password or choose an autogenerated password.

Amazon RDS configuration settings

Under burstable classes, choose on dB t3. Micro then leaves storage as default.

Amazon RDS configuration settings

For connectivity select connect to an EC2 compute resource. Under EC2 instance select the drop-down button then select the EC2 instances you created.

Amazon RDS configuration settings

Under the VPC security firewall choose existing.

Amazon RDS configuration settings

For database authentication, choose a password.

Amazon RDS configuration settings

Scroll down and click on Create Database.

Amazon RDS configuration settings

Database creation has been initiated.

Amazon RDS configuration settings
Amazon RDS configuration settings

Click on the created database and copy the Database endpoint to your clipboard. Since we will need this for connecting to the database.

Amazon RDS configuration settings

Now SSH into your EC2 instance.

Amazon RDS configuration settings

Run this code to install the MySQL client.

sudo apt update

sudo apt install mysql-client -y

Amazon RDS configuration settings

Now that the client software is installed, you can connect to your RDS instance.

mysql -h [RDS_ENDPOINT] -P [PORT] -u [USERNAME] -p
show databases;

Amazon RDS configuration settings

Able to connect, thumps up.

Amazon RDS configuration settings
Amazon RDS configuration settings

Best Practices

Use IAM Authentication: For added security, enable IAM database authentication and manage access via AWS Identity and Access Management.

Enable Encryption: Encrypt the database at rest and enable SSL for in-transit data encryption.

Implement Monitoring and Logging: Use Amazon CloudWatch to monitor the database performance, and set up alerts for any unusual activity.

Maintain Security Groups: Review and tighten Security Group rules regularly to prevent unauthorized access.

Automate Backups: Configure automated backups for data recovery in case of data loss.

Conclusion

Connecting Amazon RDS with an EC2 instance involves careful configuration of network settings, security groups, and database settings. By following these steps, you’ll establish a secure and reliable connection between your EC2 instance and Amazon RDS, supporting scalable and highly available database access for your applications.

Thanks for reading and stay tuned for more. Make sure you clean up.

If you have any questions concerning this article or have an AWS project that requires our assistance, please reach out to us by leaving a comment below or email us at sales@accendnetworks.com.


Thank you!

Written By :

Victor Onyango, AWS Certified Solutions Architect – Associate, AWS Certified Security

0 0 votes
Article Rating
Subscribe
Notify of
guest

13 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
365jlvip
365jlvip
1 day ago

Interesting points about responsible gaming & platform legitimacy – crucial in this space! Seeing platforms like 365jl vip vip prioritize verification builds trust, especially with evolving online regulations. A curated experience can make a difference.

jilibibi
jilibibi
10 days ago

That level design was chef’s kiss! Seriously immersive. Thinking about trying new platforms though – heard good things about the ease of use with a jilibibi download, especially for quick access to games! Great article, thanks!

canli maç izle matbet
canli maç izle matbet
12 days ago

Canli maç izle matbet sounds like exactly what I need after a long day. A cold one and some live sports is the perfect combo, hoping the stream is stable. Time to chill at canli maç izle matbet.

agents 747.com
agents 747.com
12 days ago

Looking for the best agents on 747.com? These guys are the real deal. Quick responses, helpful tips, and no messing around. Thumbs up! agents 747.com

nesine.com para yatırma
nesine.com para yatırma
12 days ago

Nesine.com para yatırma is quite simple! I did it myself the other day without any problems. Look here nesine.com para yatırma !

cf789casino
cf789casino
1 month ago

cf789casino is where it’s at! The selection of games is huge, and I’ve had some pretty sweet wins. Easy to navigate and a good vibe overall. Ready to roll the dice? Head over to cf789casino

888jogosbet
888jogosbet
1 month ago

888jogosbet é confiável. Boas opções de apostas em diversos esportes. Plataforma fácil de usar, recomendo 888jogosbet.

100jilislot
100jilislot
2 months ago

I love slots. Is this 100jilislot a great place to play slot games? Hope I get some good wins here! 100jilislot

gameqq88
gameqq88
2 months ago

Alright, GameQQ88, lemme tell ya. Games are solid, graphics are slick, and the vibe is cool. Ain’t gonna lie, I’ve spent a chunk of time here. See for yourself: gameqq88

Prime Biome Reviews
Prime Biome Reviews
10 months ago

Your blog is a true hidden gem on the internet. Your thoughtful analysis and engaging writing style set you apart from the crowd. Keep up the excellent work!

platea
platea
1 year ago

2rQlrVeQFDf

overfavor
overfavor
1 year ago

MEcViQTQw82

temp mail
temp mail
1 year ago

“Simply extraordinary! ✨ Your in-depth analysis and crystal-clear explanations make this a must-read. The amount of valuable information you’ve packed in here is amazing.”