Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
    
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 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 9 '12 at 2:17
    
Elastic Beanstalk documentation does say that you can use any DB that you want but doesn't provide any documentation on how to configure it. –  movingahead Dec 9 '12 at 9: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 2: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. –  movingahead Dec 11 '12 at 10:38
    
Check @n__o's answer, point #3 ... it's the way to do it. –  King'ori Maina Aug 5 at 7:34

2 Answers 2

The easiest and cleanest way I found, assuming you're using Elastic Beanstalk CLI eb:

  1. Create an instance (follow the steps):

    eb init
    

    This will create an instance with MySQL.

  2. 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.

  3. 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>
    
  4. 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.
    
  5. 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
    
share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.