Sha256: 70a18bda734f99a1543de119742eb783fd7a188885c8928f1f36ab13789382de

Contents?: true

Size: 630 Bytes

Versions: 3

Compression:

Stored size: 630 Bytes

Contents

module Awsrm
  class Ec2 < Awsrm::Resource
    FILTER_MAP = {
      name: 'tag:Name',
      vpc_id: 'vpc-id',
      vpc: ->(value) { { name: 'vpc-id', values: [Awsrm::Vpc.one(name: value).id] } }
    }.freeze

    class << self
      def all(params)
        res = ec2_client.describe_instances(
          filters: filters(params)
        )
        res.reservations.map do |reservation|
          reservation.instances.map do |instance|
            Ec2Reader.new(instance)
          end
        end.flatten
      end
    end
  end

  class Ec2Reader < Awsrm::ResourceReader
    def id
      @resource.instance_id
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
awsrm-0.2.0 lib/awsrm/resources/ec2.rb
awsrm-0.1.1 lib/awsrm/resources/ec2.rb
awsrm-0.1.0 lib/awsrm/resources/ec2.rb