No commit activity in last 3 years
No release in over 3 years
Get DNS/ip addresses of AWS EC2 instances filtered by custom criteria (tag, name, status etc)
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 1.3
 Project Readme

Introduction

capistrano-ec2filter is a Capistrano plugin designed to simplify the task of deploying to infrastructure hosted on Amazon EC2. It allows to declare capistrano deploy servers filtered with ec2-describe-instances criteria (read more).

Installation

Add this line to your application's Gemfile:

gem 'capistrano-ec2filter'

And then execute:

$ bundle

Or install it yourself as:

$ gem install capistrano-ec2filter

Usage

Add this to the top of your deploy.rb:

require 'capistrano/ec2filter'

Then supply your AWS credentials with the environment variables (default):

# aws
export AWS_ACCESS_KEY_ID='...'
export AWS_SECRET_ACCESS_KEY='...'
# export AWS_EC2_ENDPOINT='...'

Or in your deploy.rb with capistrano variables:

set :aws_access_key_id, "..."
set :aws_secret_access_key, "..."
# set :aws_ec2_endpoint, "ec2.eu-west-1.amazonaws.com"

Define your servers:

ec2_filter("tag:application"=>"SuperApp", "tag:layer"=>"application") do |address|
  server address, :web, :app
end

ec2_filter("tag:application"=>"SuperApp", "tag:layer"=>"workers") do |address, instance|
  server address, :app, :jobs, :min_job_priority: 10
end

ec2_filter("placement-group-name"=>"matrix") do |address, instance|
  server address, :matrix, platform: instance.platform
end

instance - AWS::EC2::Instance from AWS SDK for Ruby

address - dns/ip address of instance = instance.dns_name || instance.ip_address || instance.private_ip_address

By default ec2_filter apply "instance-state-name" => "running" filter. You can overwrite this:

  ec2_filter("instance-state-name" => ["stopped", "stopping"], "tag:layer"=>"application") do |address|
    server address, :app, stopped: true
  end

Supported filters

Full list of supported EC2 filters: click here

Contributing

  1. Fork it ( http://github.com/rogal111/capistrano-ec2filter/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request