Created: 2012-03-22 12:56
Updated: 2014-10-03 05:55

This script helps you to deploy web application to EC2 instances.

This script will

  1. Check instances which have specific name.If the instances are stopped, wake them up.
  2. Deploy application using capistrano.
  3. After deployment, automatically create snapshot.

You can do rollback.(Using capistrano)

  1. Check instances which have specific name.If the instances are stopped, wake them up.
  2. Rollback.(capistrano)
  3. After rollback, this script will delete latest snapshot.

※Creating/Delete snapshot function is arrangement of



  1. Open ec2helper/
    Edit access_key, and secret_key in dictionary "AWS_DATA".
    Set key of "REGION" you want to connect to. (If you want to connect to TOKYO region, set "t")
    You can set multiple AWS account.
  2. open
    Edit「Edit ===」area.
# Account you want to connect.(key of AWS_DATA)
conf.aws_account = 'default'
# Instance name of production environment(p), development enviroment(d). 
conf.instances = {
    'p' : ['production_server1', 'production_server2'],
    'd' : ['dev_server'],

# Path of directory exec cap command.
conf.cap_path = '/path/to/cap/directory'

# First argument of cap command.
# Example:if the cap command is "cap production deploy", set "production".
conf.cap_deploy_to = {
    'p' : 'production',
    'd' : 'dev',

# Uncomment if you want to create snapshot after deployment.
#conf.create_snapshot = True

# Description of snapshot.Uncoment if you create snapshot.
#conf.snap_description = 'snapshot test'

# If you want to create snapshot in develop enviroment, uncomment this.
#conf.create_snap_only_production = False
  1. Edit deploy.rb(Capistrano's script).Change "role" to receive host name dynamically.
role :app do

How to use

$ python [enviroment] [deploy command]

・p production enviroment ・d develop enviroment

Deploy command:

Deploy to dev enviroment.
$ python d deploy

Deploy to production enviroment.
$ python p deploy

Rollback in dev enviroment.
$ python d deploy:rollback

Cleanup in dev enviroment.
$ python d deploy:cleanup

You can create snapshot using ec2helper/
$ python [snapshot description] -v volume-name(vol-xxxxx)

You can change region using -r option.
$ python [snapshot description] -v volume-name(vol-xxxxx) -r s
※Create snapshot of vol-xxxx in singapore region

Cookies help us deliver our services. By using our services, you agree to our use of cookies Learn more