This is a strange one, I have an AWS EC2 instance setup where Im attempting to install Wordpress and use an RDS for the database. I can connect to the database from the instance just fine with mysql client and the credentials work along with the RDS endpoint.
I have a security group setup for the RDS that will only accept port 3306 connections from the instance ip and I can telnet to it just fine from the instance but I can't from my local machine so I know that the DB security group is working fine.
The EC2 instance has a security group allowing ports 80,22,443 and 3306 in and everything out so that should be fine too.
However at the WP install step for setting up the database it doesn't accept the credentials every time and returns 'Error establishing a database connection'. I have tried adding the details to wp-config.php but then it complains that it needs wp-config-sample.php to continue the process.
The Wordpress directory and files are all owned by apache in the instance and permissions are 755/644 for dirs & files.