DEV Community

Cover image for Configure Amazon RDS Proxy
Parth Patel
Parth Patel

Posted on

Configure Amazon RDS Proxy

Scenario

Amazon RDS Proxy can help busy online stores manage sudden traffic surges during sales events by pooling and sharing database connections. This ensures a smooth shopping experience even during peak times and helps the store recover quickly from any database failures, minimizing downtime and maintaining customer satisfaction.

This blog will cover everything we need to know about Amazon RDS Proxy and how to configure it!

  • What is Amazon RDS?
  • How does it work?
  • Benefits of configuring Amazon RDS Proxy
  • Hands-on
  • Conclusion

Image description

What is Amazon RDS?

Amazon RDS stands for Amazon Relational Database Service. It is a web service that makes it easier to set up, operate, and scale a relational database in the cloud. Amazon RDS manages routine database tasks such as provisioning, patching, backup, recovery, and scaling, allowing developers to focus on their applications rather than the administrative aspects of managing a database.

How does it work?

Amazon RDS Proxy simplifies connection management for Amazon RDS database instances by pooling and sharing database connections, actively handling network traffic between client applications and databases. It optimizes memory and CPU resources, reduces overhead on database servers, and improves application scalability and resilience to database failures

Benefits of Configuring RDS Proxy?

  1. Improved Database Connection Management
  2. Enhanced Scalability
  3. Better Fault Tolerance
  4. Security
  5. Database Caching

Hands-on

Amazon RDS Database

Open the Amazon RDS service in the AWS console, choose Standard Database, and then pick the engine type that you want to use. Additionally, choose free-tier templates.

Enter your password in the settings section. Next, pick "Amazon VPC with No Public Access" under "Connectivity" and start a new security group.

Image description

Image description

finally, in additional configuration, provide a database name, make all the settings as default and create the database

Image description

AWS Secrets Manager

Enter your credentials (password and username), choose the "Credentials for Amazon RDS database" secret type, and then pick the recently created database and encryption key.

Image description

Click Next after entering your name in the Configure Secret field. once more and developed the secret manager. Please copy the Secret ARN and keep it somewhere secure.

AWS IAM Role and Policy

Make a policy that permits the use of Amazon KMS and AWS Secret Manager. It should also be connected with an IAM role that permits the use of Amazon EC2 and RDS services.

Image description

Note that the policy is below. Setting up AWS KMS has an optional setting.

Image description

{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "GetSecretValue",
"Action": [
"secretsmanager:GetSecretValue"
],
"Effect": "Allow",
"Resource": [
"AWS-Secret-Manager-ARN"
]
},
{
"Sid": "DecryptSecretValue",
"Action": [
"kms:Decrypt"
],
"Effect": "Allow",
"Resource": [
"AWS-KMS-ARN"
],
"Condition": {
"StringEquals": {
"kms:ViaService": "secretsmanager.ap-south-1.amazonaws.com"
}
}
}
]
}

Amazon RDS Proxy

Enter the proxy address and select Database in the target group configuration. Select the newly established Secret Manager role in Connectivty. Then, under Additional Configuration, build a new Security Group and select build Proxy.

Image description

Amazon Security Groups

Note: It is crucial that this step be configured correctly.

Allow inbound traffic from port 3306 for the rds proxy security group, which is for mysql/aurora, with the ec2 instance security group as the source.

Image description

Allow incoming traffic from the rds proxy security group and the ec2 security group for the rds security group. The EC2 security group allows port 3306, which is used for MySQL and Aurora.

Image description

Permit the post-22, or SSH, for the EC2 security group.

Image description

Amazon EC2 Instance

Launch your EC2 instance, install MySQL and execute the command
mysql -h -P 3306 -u admin -p

Image description

The connection to the Amazon RDS database is successful.

Conclusion

Finally, we have completed a hands-on exercise to gain an understanding of the Amazon RDS proxy, including its importance and the reasons to use it.

Top comments (0)