Skip to content
Xiao Li edited this page Aug 18, 2015 · 4 revisions

EbDeployer ships with a Rails 3+ generator since version 0.4.5.

Install

Add eb_deployer to your Gemfile

gem 'eb_deployer'

Setup AWS credentials:

$ export AWS_ACCESS_KEY_ID=xxx
$ export AWS_SECRET_ACCESS_KEY=xxx

Initial configurations and rake tasks

Run Rails generator to generate configurations and rake file:

rails generate eb_deployer:install

It will setup AWS Elastic Beanstalk blue-green deployment configuration with a Postgres RDS instance as your Rails' backend database. The followings are details:

  • Add file "lib/tasks/eb_deployer.rake", please run "rake -T eb" for tasks description. These tasks are simple and designed for you to customize.
  • Add file "config/eb_deployer.yml", it includes basic blue-green configurations with a Postgres RDS instance resource.
  • Add file "config/rds.json", it is a CloudFormation template file which provisions the Postgres RDS instance. A separated CloudFormation stack maintains all resources that are shared between different Elastic Beanstalk environments in blue-green deployment. Notice: each eb_deployer environment will create one.
  • Add "gem 'pg'" to your Gemfile, as this initial configuration is hooking up with a Postgres RDS instance, we need postgres driver.
  • Add file ".ebextenstions/01_postgres_packages.config", which installs Postgres dev packages on EC2 instances, so that we can build gem "pg" on your EC2 machine after deployed.
  • Add a new production database configuration into "config/database.yml" file. Your original production configuration will be commented out.

Deploy

Add all files that need to be deployed into your Git repository, because we will simply use "git ls-files" to find all files need to be packaged.

Deploy a dev environment for testing your application deployment:

rake eb:deploy

Then, when you're ready to deploy a production environment:

EB_DEPLOYER_ENV=production rake eb:deploy

You can run the following command to see full document of these tasks

rake -D eb

Alternatives

A rails specific alternative to this process is the AlienFast elastic-beanstalk gem which is a DRY configuration based approach that utilizes eb_deployer.

Clone this wiki locally