Class: AwsAuditor::Stack
- Inherits:
-
Object
- Object
- AwsAuditor::Stack
- Extended by:
- EC2Wrapper, OpsWorksWrapper
- Defined in:
- lib/aws_auditor/stack.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#instances ⇒ Object
Returns the value of attribute instances.
-
#name ⇒ Object
Returns the value of attribute name.
Attributes included from OpsWorksWrapper
Attributes included from EC2Wrapper
Instance Method Summary collapse
- #all_instances ⇒ Object
- #get_instances ⇒ Object
-
#initialize(aws_stack) ⇒ Stack
constructor
A new instance of Stack.
- #pretty_print ⇒ Object
Constructor Details
#initialize(aws_stack) ⇒ Stack
Returns a new instance of Stack.
7 8 9 10 11 |
# File 'lib/aws_auditor/stack.rb', line 7 def initialize(aws_stack) @id = aws_stack[:stack_id] @name = aws_stack[:name] @instances = get_instances.compact end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
6 7 8 |
# File 'lib/aws_auditor/stack.rb', line 6 def id @id end |
#instances ⇒ Object
Returns the value of attribute instances.
6 7 8 |
# File 'lib/aws_auditor/stack.rb', line 6 def instances @instances end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/aws_auditor/stack.rb', line 6 def name @name end |
Instance Method Details
#all_instances ⇒ Object
31 32 33 |
# File 'lib/aws_auditor/stack.rb', line 31 def all_instances @all_instances ||= Instance.instance_hash end |
#get_instances ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/aws_auditor/stack.rb', line 13 def get_instances instances = self.class.opsworks.describe_instances({stack_id: id})[:instances] instances.map do |instance| next unless instance[:status].to_s == 'online' all_instances[instance[:ec2_instance_id]].to_s end end |
#pretty_print ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/aws_auditor/stack.rb', line 21 def pretty_print puts "----------------------------------" puts "#{@name}" puts "----------------------------------" instances.each do |instance| puts instance.to_s end puts "\n" end |