Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access RDS database created through Elastic Beanstalk

I created a Elastic Beanstalk environment which created a EC2 instance and a RDS database.

It created security groups and everything. Also I know the configuration:

DB endpoint: xxxxx Port: 3306 Master username: uuuuu

But I cannot connect to it using mysql neither from inside ec2 or outside it.

I get a connection refused error.

Any help?

like image 695
Tony Avatar asked Oct 08 '13 17:10

Tony


People also ask

How do I allow Elastic Beanstalk to access RDS?

In the navigation pane, choose Configuration. In the Instances configuration category, choose Edit. Under EC2 security groups, choose the security group to attach to the instances, in addition to the instance security group that Elastic Beanstalk creates. Choose Apply.

How do I access an RDS database?

Sign in to the AWS Management Console and open the Amazon RDS console at https://console.aws.amazon.com/rds/ . In the navigation pane, choose Databases to display a list of your DB instances. Choose the name of the DB instance to display its details. On the Connectivity & security tab, copy the endpoint.

Does Elastic Beanstalk use RDS?

You can use Elastic Beanstalk with Amazon Relational Database Service (Amazon RDS) to set up, operate, and scale a relational database.

How does Elastic Beanstalk connect to database?

You can add a DB instance to your environment by using the Elastic Beanstalk console. Open the Elastic Beanstalk console , and in the Regions list, select your AWS Region. In the navigation pane, choose Environments, and then choose the name of your environment from the list.


2 Answers

If you are still having this problem, check out your security groups. I was lost in a similar problem and solved it by allowing connections from the security group that the ec2 instance was running in to the security group the RDS database was running in.

So, if your EC2 instance is in the security group sg-randomec2name and your rds instance is in the security group sg-randomrdsname, edit the inbound rules for sg-randomrdsname to allow connections from sg-randomec2name.

like image 167
Vignir Hafsteinsson Avatar answered Oct 05 '22 22:10

Vignir Hafsteinsson


For future viewers, there's now a pretty nice tutorial on how to connect an existing ElasticBeanstalk instance with an existing RDS database (MySQL, etc).

Ideally, you should NOT make the database while setting up the ElasticBeanstalk environment, as this binds the two together and there is currently no way to unbind them without terminating the environment.

like image 20
Abhishek Divekar Avatar answered Oct 05 '22 23:10

Abhishek Divekar