I want to access RDS instance from ec2 instance. Both are in different private subnet but in same VPC.
1 Answers
4
votes
Resources within the same VPC (even in different subnets) can certainly access each other.
Check your security groups. The best configuration would be to create two security groups:
- Server-SG: Allow SSH or RDP access (as appropriate) from
0.0.0.0/0
(or less, if possible, for better security). Associate it to the EC2 instance. - Database-SG: Allow access (eg port 3306 if MySQL) with the Source set to Server-SG. Associate it to the RDS instance.
This means that the Database security group will accept incoming connections from any EC2 instance that is associated with Server-SG.
When connecting to the database, use the DNS Name provided in the RDS console.