Elastic Beanstalk has built in support for RDS. But, I want to use Postgresql with Elastic Beanstalk. Which will be the best approach for doing this?
-
Have you checked the Elastic Beanstalk documentation or talked to the folks at Amazon? [From what I can glean from a 30 second google search](http://aws.amazon.com/elasticbeanstalk/faqs/#db-solutions) you can use whatever DB you want, so this is really a programming question at best, and a Tech Support question at worst - I'm not sure how Server Fault can help you here... – voretaq7 Dec 09 '12 at 02:17
-
1Elastic Beanstalk documentation does say that you can use any DB that you want but doesn't provide any documentation on how to configure it. – rohitmishra Dec 09 '12 at 09:15
-
configure the database, or configure EBS? The former we can help you with (though the Postgres docs are probably better than we are) - the latter I'm not sure is really "system administration" -- I can reopen this but you may not get great answers... – voretaq7 Dec 10 '12 at 02:58
-
I was looking for some pointers on how to add an EC2 instance to Beanstalk which will run POstgres. I understand that this may not be appropriate for this forum. Thanks anyways for your comments. – rohitmishra Dec 11 '12 at 10:38
-
Check @n__o's answer, point #3 ... it's the way to do it. – King'ori Maina Aug 05 '14 at 07:34
2 Answers
The easiest and cleanest way I found, assuming you're using Elastic Beanstalk CLI eb
:
Create an instance (follow the steps):
eb init
This will create an instance with MySQL.
Once it's created, stop it.
eb stop
This will stop your instance and delete the MySQL database that was created by the initial setup.
Edit your instance configuration file in
.elasticbeanstalk
directory at the root of your project, replace DBEngine entry in the[aws:rds:dbinstance]
section by postgres.vi .elasticbeanstalk/optionsettings.<my-app>-env [aws:rds:dbinstance] DBDeletionPolicy=Delete DBEngine=postgres DBInstanceClass=db.t1.micro DBSnapshotIdentifier= DBUser=<dbrootuser>
Restart the instance:
eb start Starting application ".<my-app>". Waiting for environment "<my-app>-env" to launch. 2014-07-17 17:53:15 INFO createEnvironment is starting. 2014-07-17 17:53:21 INFO Using elasticbeanstalk-us-east-1-xxxxxxx as Amazon S3 storage bucket for environment data. 2014-07-17 17:53:52 INFO Created EIP: nn.nnn.nnn.nnn 2014-07-17 17:53:58 INFO Created security group named: awseb-e-xxx 2014-07-17 17:54:10 INFO Creating RDS database named: <db name>. This may take a few minutes. 2014-07-17 18:06:09 INFO Created RDS database named: <db name> 2014-07-17 18:07:07 INFO Waiting for EC2 instances to launch. This may take a few minutes.
Check the status. Once it gets green, you'll now have a postgres database.
eb status --verbose URL : <my-app>-env-xxxxx.elasticbeanstalk.com Status : Ready Health : Green RDS Database: YYYYDatabase | <db name>.zzzzzz.us-east-1.rds.amazonaws.com:5432 Database Engine: postgres 9.3.3 Allocated Storage: 10 Instance Class: db.t1.micro Multi AZ: False Master Username: <dbrootuser> Creation Time: 2014-07-17 18:02:28 DB Instance Status: available
- 151
- 2
- 6
You can set your custom postgres database running anywhere and make your rails application to use it from your database.yml file settings.
For e.g.
You can get a hosted postgres instance on Heroku Postgres - it gives very nicely formatted configuration details for ActiveRecord. You just have to get them in your database.yml file.