Note: Both the EC2 Instance and the Serverless RDS cluster must be in the same AWS Virtual Private Cloud (VPC) for this to work*
For this example, new EC2 instances are deployed in the 'VPC Security' group. AWS Serverless RDS setup the other security group when the database was created. Follow these steps to allow your EC2 instances to connect directly to the Serverless RDS cluster.
Change the following sample ID's to match your AWS setup
VPC Security Group: sg-0c1b4b-example RDS Serverless Security Group: sg-025faf-example
- Select the Database security Group
- Select ‘Inbound’ rules.
- Select ‘Edit rules’
- Select ‘Add Rule’
- Select ‘Mysql/Aurora’ for the type.
- For source, enter the security group id of the VPN group
You will now be able to connect directly to the Serverless database while logged into an EC2 instance inside your VPC.