How to setup RDS proxy for streamlined database connectivity | easydeploy.io (2024)

Contents hide

1 Introduction

2 Prerequisites

3 Create security group

4 Create database

5 Connect database to EC2 instance

6 Create secret

7 Create policy and role

8 Create RDS Proxy

9 Check connection

10 Conclusion

In this article, we are going to cover – How to setup RDS proxy for streamlined database connectivity

RDS proxy – Amazon RDS Proxy is a fully managed database proxy for Amazon Relational Database Service (RDS) that improves application scalability, resiliency, and security. It enables applications to pool and share database connections, reducing the overhead of opening and closing connections frequently.RDS Proxy helps handle spikes in traffic by efficiently managing connections, thus improving database performance and availability. It also enhances security by centralizing database credentials and managing IAM authentication.

AWS Account: Ensure you have an active AWS account with full access.
RDS Database: You should have an existing Amazon RDS database instance (MySQL)
IAM Roles and Policies: Appropriate IAM roles and policies to allow RDS Proxy to access your RDS instances.
VPC: The RDS instance should be in an Amazon VPC.
Security Groups: Ensure security groups are set up to allow communication between your application and the RDS Proxy.

Navigate to EC2 service, select >> security groups, and click >> create security group.

How to setup RDS proxy for streamlined database connectivity | easydeploy.io (1)

Give a >> security group name, give a >> description, select >> your vpc (iam choosing my existing vpc).

How to setup RDS proxy for streamlined database connectivity | easydeploy.io (2)

In inbound rules, choose >> mysql/Aurora in type, and source select >> anywhere ipv4.

In outbound rules, choose >> all traffic in type, and source select >> anywhere ipv4.

Click >> create security group.

How to setup RDS proxy for streamlined database connectivity | easydeploy.io (3)

Now our security group is created, click >> Edit inbound rules.

How to setup RDS proxy for streamlined database connectivity | easydeploy.io (4)

Click >> add rule, select >> all traffic in type, and select >> created security group, click >> save rules

How to setup RDS proxy for streamlined database connectivity | easydeploy.io (5)

Now we successfully created a security group.

Navigate to RDS service, select >> databases, and click >> create database.

Select >> standard create.

Choose >> your engine type (I am choosing Mysql).

In templates >> choose free tier.

Give a name for the db instance and select >> selfmanaged.

Type >> username and type >> password to access the database.

How to setup RDS proxy for streamlined database connectivity | easydeploy.io (6)

Select >> your vpc (iam choosing my existing vpc).

How to setup RDS proxy for streamlined database connectivity | easydeploy.io (7)

In public access, select >> no.

In vpc security group , select >> choose existing and select >> your security group that we created in the first step

How to setup RDS proxy for streamlined database connectivity | easydeploy.io (8)

Now click >> create database and it takes time to create a database.

Now the database is created successfully.

How to setup RDS proxy for streamlined database connectivity | easydeploy.io (9)

Now click and go inside your database.

Swipe down.

In compute resources, click >> set up EC2 connection

How to setup RDS proxy for streamlined database connectivity | easydeploy.io (10)

Select >> your ec2 instance and click >> continue

How to setup RDS proxy for streamlined database connectivity | easydeploy.io (11)

Click >> set up, Now our database is successfully connected with EC2 instance.

Navigate to the Secrets Manager section of your AWS Management Console and choose >> Store a new secret.

How to setup RDS proxy for streamlined database connectivity | easydeploy.io (12)

In the Select secret type, choose >> Credentials for RDS database. Then, type >> user name and password that you used when creating your database.

Select >> your database, and click >> next.

How to setup RDS proxy for streamlined database connectivity | easydeploy.io (13)

Give a >> name to the secret and click >> next, and click again >> next

How to setup RDS proxy for streamlined database connectivity | easydeploy.io (14)

Now the secret was created.

How to setup RDS proxy for streamlined database connectivity | easydeploy.io (15)

Click >> your secret, and copy your secret ARN.

How to setup RDS proxy for streamlined database connectivity | easydeploy.io (16)

Navigate to IAM service, click >> policies and click >> create policy.

In service, select >> RDS, select >> RDS-add role to database.

How to setup RDS proxy for streamlined database connectivity | easydeploy.io (17)

Click >> JSON, Replace the current script with the new one. This is my repository, and you can find the new script at https://github.com/easydeploy-cloud/RDS_proxy-RDS_database_connection.

Paste your >> secret ARN here, and click >> next.

How to setup RDS proxy for streamlined database connectivity | easydeploy.io (18)

Give a >> policy name, click >> create policy.

How to setup RDS proxy for streamlined database connectivity | easydeploy.io (19)

Now we successfully created a policy, we want to attach the policy to a new role

Click >> roles, and click >> create role.

Select >> AWS service in trusted entity type, click >> choose a service, and select >> RDS, now click >> next.

How to setup RDS proxy for streamlined database connectivity | easydeploy.io (20)

Select your >> created policy, and click >> next.

How to setup RDS proxy for streamlined database connectivity | easydeploy.io (21)

Give a >> role name, and click >> create role.

How to setup RDS proxy for streamlined database connectivity | easydeploy.io (22)

Navigate to the RDS service, choose >> Proxies, then Create proxy.

How to setup RDS proxy for streamlined database connectivity | easydeploy.io (23)

Choose >> Engine type, give a >> name to proxy, and leave other default option.

How to setup RDS proxy for streamlined database connectivity | easydeploy.io (24)

In database, select >> your database.

How to setup RDS proxy for streamlined database connectivity | easydeploy.io (25)

In authentication section, select >> your created IAM role.

In secrets manager, select >> your created secrets.

How to setup RDS proxy for streamlined database connectivity | easydeploy.io (26)

Select >> choose existing, select >> your created security group.

How to setup RDS proxy for streamlined database connectivity | easydeploy.io (27)

Click >> create proxy.

The proxy is creating it takes time to process.

How to setup RDS proxy for streamlined database connectivity | easydeploy.io (28)

Click >> databases, and click >> your created database, copy your database endpoint

How to setup RDS proxy for streamlined database connectivity | easydeploy.io (29)

Navigate to your EC2 instance CLI, and test the connectivity to the RDS DB instance using the following command:

mysql -h <RDS DB endpoint> -P 3306 -u <username> -p

When prompted, type >> your password and press Enter.

How to setup RDS proxy for streamlined database connectivity | easydeploy.io (30)

Now we successfully connected to the RDS DB instance.

How to setup RDS proxy for streamlined database connectivity | easydeploy.io (31)

Now go back to RDS service, select >> proxies, click >> your created proxy.

Copy the endpoint.

How to setup RDS proxy for streamlined database connectivity | easydeploy.io (32)

Go back to EC2 instance CLI, use the following command to connect to the RDS instance through the RDS Proxy endpoint:

mysql -h <proxy endpoint> -P 3306 -u <username> -p

When prompted, type >> your password and press Enter.

Now we successfully connected to the RDS DB instance via the RDS Proxy endpoint.

How to setup RDS proxy for streamlined database connectivity | easydeploy.io (33)

Setting up an RDS Proxy streamlines database connectivity by managing connections more efficiently, improving performance, scalability, and security. It reduces connection overhead, ensuring consistent and reliable database access, especially under high load.

The setup process is straightforward, involving proxy creation, credential configuration, and application integration. Overall, using RDS Proxy optimizes resource utilization and enhances application responsiveness, making it a valuable tool for maintaining high availability and seamless database interactions.

How to setup RDS proxy for streamlined database connectivity | easydeploy.io (2024)

References

Top Articles
Latest Posts
Article information

Author: Roderick King

Last Updated:

Views: 6438

Rating: 4 / 5 (51 voted)

Reviews: 82% of readers found this page helpful

Author information

Name: Roderick King

Birthday: 1997-10-09

Address: 3782 Madge Knoll, East Dudley, MA 63913

Phone: +2521695290067

Job: Customer Sales Coordinator

Hobby: Gunsmithing, Embroidery, Parkour, Kitesurfing, Rock climbing, Sand art, Beekeeping

Introduction: My name is Roderick King, I am a cute, splendid, excited, perfect, gentle, funny, vivacious person who loves writing and wants to share my knowledge and understanding with you.