Class: Capistrano::Ec2RoleTag::AwsEc2Loader
- Inherits:
-
Object
- Object
- Capistrano::Ec2RoleTag::AwsEc2Loader
- Defined in:
- lib/capistrano/ec2_role_tag/aws_ec2_loader.rb
Instance Method Summary collapse
- #fetch(options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ AwsEc2Loader
constructor
A new instance of AwsEc2Loader.
Constructor Details
#initialize(options = {}) ⇒ AwsEc2Loader
Returns a new instance of AwsEc2Loader.
6 7 8 9 10 11 12 |
# File 'lib/capistrano/ec2_role_tag/aws_ec2_loader.rb', line 6 def initialize( = {}) if [:region].nil? @ec2 = Aws::EC2::Client.new(region: 'us-west-2') else @ec2 = Aws::EC2::Client.new(region: [:region]) end end |
Instance Method Details
#fetch(options = {}) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/capistrano/ec2_role_tag/aws_ec2_loader.rb', line 13 def fetch( = {}) apps = @ec2.describe_instances( {filters: [ {name: "tag:Stage", values: [[:stage].to_s]}, {name: "tag:Role", values: [[:role].to_s]}, {name: "instance-state-name", values: ["running"]} ]}) return [] if apps.reservations.empty? return [] if apps.reservations[0].instances.empty? return apps.reservations[0].instances.map{|instance| instance.private_dns_name } end |