Connecting from Amazon AWS EC2 to RDS

While preparing to deploy a Java-based application on Amazon, I encountered a strange error — the EC2 instance was not able to access the RDS instance.

I looked into various forums, and many indicated that the only option is to allow this is by adding the public IP of the EC2 instance as an “authorized IP” (CIDR/IP) in RDS instance’s security groups. I wanted to avoid that, as this did not seem right.

Tried out various combinations, and finally, (with some background from one of the posts), things got working:

I got a whiff of what could be wrong here. Turns out, EC2 instance’s security groups have to be added in the ‘default’ security group in the RDS instance, for it to allow traffic from EC2. We need to select the ‘Connection Type’ as ‘EC2 Security Group’ which would populate the active EC2 instance security in the ‘details’ cell — which then then be authorized.

amazonawsOnce the above is done, use the public IP of RDS instance to connect. For instance, for MySQL, I used the following string:

mysql -u admin -p -h xxxxx.yyyyy.rds.amazonaws.com

and Voila! I got through!

DB course

Over the past few weeks I’ve been taking a database course, and I must say, it’s well-worth the time (whatever meager amount) I’m able to invest.

Thanks to Sri, and his persistence on us taking it.

I have taken a so-called DBMS course in academics twice, but never have I had the perspective as this course has given me. Thank you Prof.¬†Jennifer Widom and the team of Stanford University who’ve taken efforts to come up with such a course and have had a vision of the larger good.

I would highly recommend it to all the software engineers, especially those from India.

Here’s the link¬†for the ongoing class.