Much of what I write is a compilation of what I found on the Internet, esp. Pēteris Ņikiforovs’s post. I am indebted to him, as I heavily benefitted from his post while trying to get WP working. However, since that article is a bit dated, and cannot be used verbatim — I decided to jot this post down.
It is assumed that one would be having the domain name handy (e.g. myblogsite.com or foobar.io), before proceeding with the installation. In this post, let’s go ahead with foobar.io.
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.
Once 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