Sha256: 22bf0f22c934b745838e8ab806499058b94904da7ee43d185c240fefe1c1c893
Contents?: true
Size: 845 Bytes
Versions: 2
Compression:
Stored size: 845 Bytes
Contents
require 'aws-sdk-v1' module Capistrano module Ec2RoleTag class AwsEc2Loader def initialize(options = {}) if options[:region].nil? @ec2 = AWS::EC2::Client.new(region: 'us-west-2') else @ec2 = AWS::EC2::Client.new(region: options[:region]) end end def fetch(options = {}) apps = @ec2.describe_instances( {filters: [ {name: "tag:Stage", values: [options[:stage].to_s]}, {name: "tag:Role", values: [options[:role].to_s]}, {name: "instance-state-name", values: ["running"]} ]}) return [] if apps.reservation_set.empty? return [] if apps.reservation_set[0].instances_set.empty? return apps.reservation_set[0].instances_set.map{|instance| instance.private_dns_name } end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
capistrano-ec2_role_tag-0.0.4 | lib/capistrano/ec2_role_tag/aws_ec2_loader.rb |
capistrano-ec2_role_tag-0.0.2 | lib/capistrano/ec2_role_tag/aws_ec2_loader.rb |