Sha256: aa844177e00c9e171574317c0f238b4d2980ee47b47411cd3bb73dcd35915c42
Contents?: true
Size: 1.07 KB
Versions: 1
Compression:
Stored size: 1.07 KB
Contents
module Stackster class InstanceReader def initialize(args) @config = args[:config] end def list_stack_instances(stack_name) @asg_id = auto_scaling_group_id(stack_name) asg_instances = auto_scaling.list_instances if @asg_id return [] unless asg_instances ec2.describe_instance asg_instances end private def ec2 @ec2 ||= AWS::EC2.new :config => @config end def auto_scaling @auto_scaling ||= AWS::AutoScalingGroups.new :config => @config, :asg_id => @asg_id end def cloud_formation @cloud_formation ||= AWS::CloudFormation.new :config => @config end def auto_scaling_group_id(stack_name) cf_stack_resources = cloud_formation.stack_resources stack_name parse_cf_stack_resources cf_stack_resources end def parse_cf_stack_resources(cf_stack_resources) cf_stack_resources.each do |resource| if resource['ResourceType'] == 'AWS::AutoScaling::AutoScalingGroup' return resource['PhysicalResourceId'] end end false end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
stackster-0.4.3 | lib/stackster/instance/instance_reader.rb |