Class: SimpleDeploy::AWS::InstanceReader

Inherits:
Object
  • Object
show all
Includes:
Helpers
Defined in:
lib/simple_deploy/aws/instance_reader.rb

Instance Method Summary collapse

Methods included from Helpers

#connection_args

Constructor Details

#initializeInstanceReader

Returns a new instance of InstanceReader.



7
8
9
10
11
# File 'lib/simple_deploy/aws/instance_reader.rb', line 7

def initialize
  @config      = SimpleDeploy.config
  @asg_connect = Fog::AWS::AutoScaling.new connection_args
  @ec2_connect = Fog::Compute::AWS.new connection_args
end

Instance Method Details

#list_stack_instances(stack_name) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/simple_deploy/aws/instance_reader.rb', line 13

def list_stack_instances(stack_name)

  instances = []

  #Nested stack
  nested_stacks = nested_stacks_names(stack_name)
  instances = nested_stacks.map {|stack| list_stack_instances stack }.flatten if nested_stacks.any?

  #Auto Scaling Group
  asg_ids = auto_scaling_group_id(stack_name)
  asg_instances = asg_ids.map { |asg_id| list_instances asg_id }.flatten

  #EC2 instance
  stack_instances = instance_names(stack_name)

  instances += (describe_instances (asg_instances + stack_instances)) if (asg_instances + stack_instances).any?

  instances
end