Sha256: 4215e4f00d2ae7327eceb97956ec3dbd2111b2798ff4e68504c3dad93763aa5f
Contents?: true
Size: 990 Bytes
Versions: 5
Compression:
Stored size: 990 Bytes
Contents
module Awsrm class Ec2 < Awsrm::Resource FILTER_MAP = { id: 'instance-id', instance_id: 'instance-id', name: 'tag:Name', vpc_id: 'vpc-id', vpc: ->(value) { { name: 'vpc-id', values: [Awsrm::Vpc.one(name: value).id] } }, elb: ->(value) do { name: 'instance-id', values: Awsrm::Elb.one(name: value).instances.map { |i| i.instance_id } } end, alb_target_group: ->(value) do { name: 'instance-id', values: Awsrm::AlbTargetGroup.one(name: value).instance_ids } end }.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
5 entries across 5 versions & 1 rubygems