Sha256: 23111cd85730bf1d4b18adf02af8db87fe2f0a160d6a4e3dee1f73d267c7ce41

Contents?: true

Size: 1.31 KB

Versions: 42

Compression:

Stored size: 1.31 KB

Contents

require 'aws-sdk'
require_relative '../../util'

module Builderator
  module Model
    # :nodoc:
    module Cleaner
      def self.scaling_groups
        @scaling_groups ||= ScalingGroups.new
      end

      ##
      # AutoScaling Group Resoruces
      ##
      class ScalingGroups < Model::Cleaner::Base
        attr_reader :resources
        PROPERTIES = %w(auto_scaling_group_arn min_size max_size desired_capacity
                        default_cooldown availability_zones load_balancer_names
                        vpc_zone_identifier status termination_policies)

        def fetch
          @resources = {}.tap do |i|
            Util.asg.describe_auto_scaling_groups.each do |page|
              page.auto_scaling_groups.each do |a|
                properties = Util.from_tags(a.tags)
                properties['creation_date'] = a.created_time.to_datetime
                PROPERTIES.each { |pp| properties[pp] = a[pp.to_sym] }

                i[a.launch_configuration_name] = {
                  :id => a.auto_scaling_group_name,
                  :properties => properties,
                  :config => a.launch_configuration_name
                }
              end
            end
          end
        end

        def launch_configs
          resources.values.map { |g| g[:config] }
        end
      end
    end
  end
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
builderator-1.0.0.pre.rc.3 lib/builderator/model/cleaner/scaling_groups.rb
builderator-1.0.0.pre.rc.1 lib/builderator/model/cleaner/scaling_groups.rb