Sha256: d1b342655869a2a662cb2f15830a1703a8cba7e5a7665ac288110680f328a811

Contents?: true

Size: 1.3 KB

Versions: 8

Compression:

Stored size: 1.3 KB

Contents

module Awspec::Type
  class EcsCluster < Base
    def initialize(name)
      super
      @display_name = name
    end

    def resource_via_client
      @resource_via_client ||= find_ecs_cluster(@display_name)
    end

    def id
      @id ||= resource_via_client.cluster_name if resource_via_client
    end

    STATES = %w(ACTIVE INACTIVE)

    STATES.each do |state|
      define_method state.downcase + '?' do
        resource_via_client.status == state
      end
    end

    def has_container_instance?(uuid)
      uuid = arn_or_uuid.split('/').last
      find_ecs_container_instance(id, uuid)
    end

    # deprecated method
    def container_instance_arns
      puts ''
      warn Color.on_red(Color.white("!!! `#{__method__}` is deprecated. awspec don't provide complex result !!!"))
      @container_instance_arns ||= select_ecs_container_instance_arn_by_cluster_name(id)
    end

    # deprecated method
    def container_instances
      puts ''
      warn Color.on_red(Color.white("!!! `#{__method__}` is deprecated. awspec don't provide complex result !!!"))
      return @container_instances if @container_instances
      arns = container_instance_arns
      @container_instances ||=
        arns.empty? ? [] : find_ecs_container_instances(id, arns).map! { |ci| EcsContainerInstance.new(id, ci) }
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
awspec-0.69.1 lib/awspec/type/ecs_cluster.rb
awspec-0.69.0 lib/awspec/type/ecs_cluster.rb
awspec-0.68.0 lib/awspec/type/ecs_cluster.rb
awspec-0.67.1 lib/awspec/type/ecs_cluster.rb
awspec-0.67.0 lib/awspec/type/ecs_cluster.rb
awspec-0.66.2 lib/awspec/type/ecs_cluster.rb
awspec-0.66.1 lib/awspec/type/ecs_cluster.rb
awspec-0.66.0 lib/awspec/type/ecs_cluster.rb