Skip to content

Instantly share code, notes, and snippets.

@dakatsuka
Created August 5, 2015 15:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dakatsuka/9f0bbcb876b873540db5 to your computer and use it in GitHub Desktop.
Save dakatsuka/9f0bbcb876b873540db5 to your computer and use it in GitHub Desktop.
require 'aws-sdk'
require 'aws-sdk-resources'
ec2 = Aws::EC2::Resource.new
instances = ec2.instances.select {|i|
i.tags.select {|t| t.key == "env" && t.value == "staging"}.present? && i.tags.select {|t| t.key == "role" && t.value == "app" }.present?
}.map(&:private_ip_address)
role :app, instances
role :web, instances
role :db, [instances.sample]
gem 'aws-sdk', '~> 1'
gem 'aws-sdk-resources', '~> 2'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment