I'm trying to setup two Rails applications. I want both of them to use one MySQL database. My setup is like this:
With Elastic Beanstalk I've setup two Rails applications with two diffrent enviroments. One of those applications I setup with a MySQL database. So now I have two EC2 instances - one for each rails app and one RDS MySQL instance.
I setup Security Groups in both EC2 instances to be able to connect to MYSQL via port 3306
.
I've setup the DB Security Group to authorized both EC2 instances and also I setup the CIDR/IP with the Private IP of the second EC2 Instance (the one without the MySQL database set while configuring Beanstallk Application)
In both Rails applications I setup the database.yml like:
production:
adapter: mysql2
encoding: utf8
database: <%= ENV['RDS_DB_NAME'] %>
username: <%= ENV['RDS_USERNAME'] %>
password: <%= ENV['RDS_PASSWORD'] %>
host: <%= ENV['RDS_HOSTNAME'] %>
port: <%= ENV['RDS_PORT'] %>
I assigned the ENV values for the production on the second instance (that one without the MySQL DB) with ENV values from the first EC2 instance.
What am I missing here?
I also added my computers IP address to the DB Securty Group and I'm able to connect to the MySQL DB with the credentials I use as ENV varaibles.