Module: Awspec::Helper::Finder::Ami

Included in:
Awspec::Helper::Finder
Defined in:
lib/awspec/helper/finder/ami.rb

Instance Method Summary collapse

Instance Method Details

#find_ami(image_id) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/awspec/helper/finder/ami.rb', line 6

def find_ami(image_id)
  res = ec2_client.describe_images({
                                     filters: [{ name: 'image-id', values: [image_id] }]
                                   })
  resource = res.images.single_resource(image_id)
  return resource if resource

  res = ec2_client.describe_images({
                                     filters: [{ name: 'name', values: [image_id] }]
                                   })
  resource = res.images.single_resource(image_id)
  return resource if resource

  res = ec2_client.describe_images({
                                     filters: [{ name: 'tag:Name', values: [image_id] }]
                                   })
  res.images.single_resource(image_id)
end