Sha256: b4d54401086b3cfe3351f902a1d803b7e80c71014d0db66cd620fa147619414f

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.launch_configs
        @launch_configs ||= LaunchConfigs.new
      end

      ##
      # ASG LaunchConfiguration Resources
      ##
      class LaunchConfigs < Model::Cleaner::Base
        PROPERTIES = %w(launch_configuration_arn key_name security_groups
                        user_data instance_type spot_price iam_instance_profile
                        ebs_optimized associate_public_ip_address placement_tenancy)

        def fetch
          @resources = {}.tap do |i|
            Util.asg.describe_launch_configurations.each do |page|
              page.launch_configurations.each do |l|
                properties = { 'creation_date' => l.created_time.to_datetime }
                PROPERTIES.each { |pp| properties[pp] = l[pp.to_sym] }

                i[l.launch_configuration_name] = {
                  :id => l.launch_configuration_name,
                  :properties => properties,
                  :image => l.image_id
                }
              end
            end
          end
        end

        def images
          resources.values.map { |l| l[:image] }
        end

        def in_use
          select(Cleaner.scaling_groups.launch_configs)
        end
      end
    end
  end
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
builderator-1.1.6 lib/builderator/model/cleaner/launch_configs.rb
builderator-1.1.5 lib/builderator/model/cleaner/launch_configs.rb
builderator-1.1.4 lib/builderator/model/cleaner/launch_configs.rb
builderator-1.1.3 lib/builderator/model/cleaner/launch_configs.rb
builderator-1.1.2 lib/builderator/model/cleaner/launch_configs.rb
builderator-1.1.1 lib/builderator/model/cleaner/launch_configs.rb
builderator-1.1.0 lib/builderator/model/cleaner/launch_configs.rb
builderator-1.0.4 lib/builderator/model/cleaner/launch_configs.rb
builderator-1.0.3 lib/builderator/model/cleaner/launch_configs.rb
builderator-1.0.2 lib/builderator/model/cleaner/launch_configs.rb
builderator-1.0.1 lib/builderator/model/cleaner/launch_configs.rb
builderator-1.0.0.pre.rc.12 lib/builderator/model/cleaner/launch_configs.rb
builderator-1.0.0.pre.rc.11 lib/builderator/model/cleaner/launch_configs.rb
builderator-1.0.0.pre.rc.10 lib/builderator/model/cleaner/launch_configs.rb
builderator-1.0.0.pre.rc.9 lib/builderator/model/cleaner/launch_configs.rb
builderator-1.0.0.pre.rc.8 lib/builderator/model/cleaner/launch_configs.rb
builderator-1.0.0.pre.rc.7 lib/builderator/model/cleaner/launch_configs.rb
builderator-1.0.0.pre.rc.6 lib/builderator/model/cleaner/launch_configs.rb
builderator-1.0.0.pre.rc.5 lib/builderator/model/cleaner/launch_configs.rb
builderator-1.0.0.pre.rc.4 lib/builderator/model/cleaner/launch_configs.rb