capistrano-ec2tag is a Capistrano plugin designed to simplify the task of deploying to infrastructure hosted on Amazon EC2. It was inspired by the capistrano-ec2group plugin, to which all credit is due.
While the original capistrano-ec2group plugin served me well, I started to run into cases where I wanted more flexibility. More specifically, in order to change security groups, instances have to be restarted.
I created capistrano-ec2tag to bypass this limitation. Now, modifying the list of instances that are deployable is as easy as modifying tags.
Add this line to your application's Gemfile:
gem 'capistrano-ec2tag'
And then execute:
$ bundle
Or install it yourself as:
$ gem install capistrano-ec2tag
Tag your instances, using deploy
as the key. For example:
The tag value can be any string, but I suggest using something like APP-ENVIRONMENT
.
Add this to the top of your deploy.rb
:
require 'capistrano/ec2tag'
Then supply your AWS credentials with the environment variables (default):
# aws
export AWS_ACCESS_KEY_ID='...'
export AWS_SECRET_ACCESS_KEY='...'
Or in your deploy.rb
with capistrano variables:
set :aws_access_key_id, '...'
set :aws_secret_access_key, '...'
# old & busted
server 'web1.example.com', :web
# new hotness
tag 'github-staging', :web
capistrano-ec2tag is copyright 2013 by Douglas Jarquin, released under the MIT License (see LICENSE for details).`