class AWS::EC2::ImageCollection


ec2.images.create(:instance_id => “i-123”, :name => “my-image”)
You can also use it to create new images. For example:
tagged_amis.map(&:id) # => [“ami-123”, …]
tagged_amis = all_images.tagged(‘mytag’)
my_images = all_images.with_owner(‘self’)
amazon_owned_images = all_images.with_owner(‘amazon’)
all_images = ec2.images
ec2 = EC2.new
interested in:
find out which images exist with the characteristics you are
Represents a collection of EC2 images. You can use this to

def [] image_id

Returns:
  • (Image) - image_id The ID of the image.
def [] image_id
  super
end

def create options = {}

Returns:
  • (Image) -

Options Hash: (**options)
  • :block_device_mappings (Hash) -- This must be a
  • :root_device_name (String) -- The root device
  • :ramdisk (Image) -- The ramdisk image to use.
  • :ramdisk_id (String) -- The ID of the RAM disk
  • :kernel (Image) -- The kernel image to use.
  • :kernel_id (String) -- The ID of the kernel to
  • :architecture (String) -- The architecture of
  • :image_location (String) -- Full path to your
  • :no_reboot (Boolean) -- By default this
  • :description (String) -- A description of the
  • :instance_id (String) -- The ID of a running

Parameters:
  • options (Hash) -- Options for creating the image.
def create options = {}
  resp = case
  when options[:instance_id]
    client.create_image(options)
  when options[:image_location] || options[:root_device_name]
    if kernel = options.delete(:kernel)
      options[:kernel_id] = kernel.id
    end
    if ramdisk = options.delete(:ramdisk)
      options[:ramdisk_id] = ramdisk.id
    end
    options[:block_device_mappings] =
      translate_block_device_mappings(options[:block_device_mappings]) if
      options[:block_device_mappings]
    client.register_image(options)
  else
    raise(ArgumentError,
          "expected instance_id, image_location, " +
          "or root_device_name")
  end
  Image.new(resp.image_id, :config => config)
end

def each &block

Returns:
  • (nil) -

Other tags:
    Yield: - Each image in the collection.
def each &block
  opts = {}
  opts[:owners] = @owners.map { |id| id.to_s } unless @owners.empty?
  opts[:executable_users] = @executable_users.map { |id| id.to_s } unless
    @executable_users.empty?
  response = filtered_request(:describe_images, opts)
  response.images_set.each do |i|
    image = Image.new_from(:describe_images, i, i.image_id, :config => config)
    yield(image)
  end
  nil
end

def executable_by(*users)

Parameters:
  • users (Array of Strings) -- The AWS account IDs by which

Returns:
  • (ImageCollection) - A new collection that only includes
def executable_by(*users)
  collection_with(:executable_users => @executable_users + users)
end

def initialize(options = {})

Other tags:
    Api: - private
def initialize(options = {})
  @owners = options[:owners] || []
  @executable_users = options[:executable_users] || []
  super(options)
end

def member_class

def member_class
  Image
end

def preserved_options

def preserved_options
  super.merge(:owners => @owners, :executable_users => @executable_users)
end

def with_owner(*owners)

Parameters:
  • owners (Array of Strings) -- The AWS account IDs by

Returns:
  • (ImageCollection) - A new collection that only includes
def with_owner(*owners)
  collection_with(:owners => @owners + owners)
end