Class: AWS::EC2::Image
- Inherits:
-
Resource
- Object
- Resource
- AWS::EC2::Image
- Includes:
- HasPermissions, TaggedItem
- Defined in:
- lib/aws/ec2/image.rb
Overview
Represents an Amazon Machine Image (AMI).
Instance Attribute Summary collapse
-
#architecture ⇒ Symbol
readonly
The architecture of the image (e.g.
:i386
). -
#block_device_mappings ⇒ Hash
readonly
A hash of block device mappings for the image.
-
#description ⇒ String
A description of the image.
-
#hypervisor ⇒ Symbol
readonly
The image’s hypervisor type.
-
#id ⇒ Object
readonly
The ID of the AMI.
-
#kernel_id ⇒ String
readonly
The kernel ID associated with the image, if any.
-
#location ⇒ String
readonly
The location of the AMI.
-
#name ⇒ String
readonly
The name of the AMI that was provided during image creation.
-
#owner_alias ⇒ String
readonly
The AWS account alias (e.g., “amazon”) or AWS account ID that owns the AMI.
-
#owner_id ⇒ String
readonly
AWS account ID of the image owner.
-
#platform ⇒ String
readonly
Value is
windows
for Windows AMIs; otherwise blank. -
#ramdisk_id ⇒ String
readonly
The RAM disk ID associated with the image, if any.
-
#root_device_name ⇒ String
readonly
The root device name (e.g., “/dev/sda1”, or “xvda”).
-
#root_device_type ⇒ Symbol
readonly
The root device type used by the AMI.
-
#state ⇒ Symbol
readonly
Current state of the AMI.
-
#state_reason ⇒ Object
readonly
The reason for the image’s most recent state change.
-
#type ⇒ Symbol
readonly
The type of image.
-
#virtualization_type ⇒ Symbol
readonly
The type of virtualization of the AMI.
Instance Method Summary collapse
-
#deregister ⇒ Object
(also: #delete)
Deregisters this AMI.
-
#exists? ⇒ Boolean
the DescribeImages action).
-
#kernel ⇒ Image
The kernel associated with the image, if any.
-
#ramdisk ⇒ Image
The RAM disk associated with the image, if any.
-
#run_instance(opts = {}) ⇒ Instance
Runs a single instance of this image.
-
#run_instances(count, opts = {}) ⇒ Array
Runs multiple instances of this image.
Methods included from HasPermissions
#permissions, #private?, #public=, #public?
Methods included from TaggedItem
Instance Attribute Details
#architecture ⇒ Symbol (readonly)
The architecture of the image (e.g. :i386
).
108 109 110 |
# File 'lib/aws/ec2/image.rb', line 108 def architecture @architecture end |
#block_device_mappings ⇒ Hash (readonly)
A hash of block device mappings for the image. In each entry, the key is the device name (e.g. “/dev/sda1”) and the value is an object with the following methods that return information about the block device:
- snapshot_id
-
The ID of the snapshot that will be used to create this device (may be nil).
- volume_size
-
The size of the volume, in GiBs.
- delete_on_termination
-
True if the Amazon EBS volume is deleted on instance termination.
108 109 110 |
# File 'lib/aws/ec2/image.rb', line 108 def block_device_mappings @block_device_mappings end |
#description ⇒ String
A description of the image.
108 109 110 |
# File 'lib/aws/ec2/image.rb', line 108 def description @description end |
#hypervisor ⇒ Symbol (readonly)
The image’s hypervisor type. Possible values:
-
:ovm
-
:xen
108 109 110 |
# File 'lib/aws/ec2/image.rb', line 108 def hypervisor @hypervisor end |
#id ⇒ Object (readonly)
The ID of the AMI.
115 116 117 |
# File 'lib/aws/ec2/image.rb', line 115 def id @id end |
#kernel_id ⇒ String (readonly)
The kernel ID associated with the image, if any. Only applicable for machine images.
108 109 110 |
# File 'lib/aws/ec2/image.rb', line 108 def kernel_id @kernel_id end |
#location ⇒ String (readonly)
The location of the AMI.
108 109 110 |
# File 'lib/aws/ec2/image.rb', line 108 def location @location end |
#name ⇒ String (readonly)
The name of the AMI that was provided during image creation.
108 109 110 |
# File 'lib/aws/ec2/image.rb', line 108 def name @name end |
#owner_alias ⇒ String (readonly)
The AWS account alias (e.g., “amazon”) or AWS account ID that owns the AMI.
108 109 110 |
# File 'lib/aws/ec2/image.rb', line 108 def owner_alias @owner_alias end |
#owner_id ⇒ String (readonly)
AWS account ID of the image owner.
108 109 110 |
# File 'lib/aws/ec2/image.rb', line 108 def owner_id @owner_id end |
#platform ⇒ String (readonly)
Value is windows
for Windows AMIs; otherwise blank.
108 109 110 |
# File 'lib/aws/ec2/image.rb', line 108 def platform @platform end |
#ramdisk_id ⇒ String (readonly)
The RAM disk ID associated with the image, if any. Only applicable for machine images.
108 109 110 |
# File 'lib/aws/ec2/image.rb', line 108 def ramdisk_id @ramdisk_id end |
#root_device_name ⇒ String (readonly)
The root device name (e.g., “/dev/sda1”, or “xvda”).
108 109 110 |
# File 'lib/aws/ec2/image.rb', line 108 def root_device_name @root_device_name end |
#root_device_type ⇒ Symbol (readonly)
The root device type used by the AMI. Possible values:
-
:ebs
-
:instance_store
108 109 110 |
# File 'lib/aws/ec2/image.rb', line 108 def root_device_type @root_device_type end |
#state ⇒ Symbol (readonly)
Current state of the AMI. If the state is :available
, the image is successfully registered and available for launching. Valid values:
-
:available
-
:pending
-
:failed
108 109 110 |
# File 'lib/aws/ec2/image.rb', line 108 def state @state end |
#state_reason ⇒ Object (readonly)
The reason for the image’s most recent state change. The return value is an object with the following methods:
- code
-
Reason code for the state change.
- message
-
A textual description of the state change.
108 109 110 |
# File 'lib/aws/ec2/image.rb', line 108 def state_reason @state_reason end |
#type ⇒ Symbol (readonly)
The type of image. Valid values:
-
:machine
-
:kernel
-
:ramdisk
108 109 110 |
# File 'lib/aws/ec2/image.rb', line 108 def type @type end |
#virtualization_type ⇒ Symbol (readonly)
The type of virtualization of the AMI. Possible values:
-
:paravirtual
-
:hvm
108 109 110 |
# File 'lib/aws/ec2/image.rb', line 108 def virtualization_type @virtualization_type end |
Instance Method Details
#deregister ⇒ Object Also known as: delete
Deregisters this AMI. Once deregistered, the AMI cannot be used to launch new instances.
125 126 127 |
# File 'lib/aws/ec2/image.rb', line 125 def deregister client.deregister_image(:image_id => id) end |
#exists? ⇒ Boolean
the DescribeImages action).
164 165 166 167 168 169 |
# File 'lib/aws/ec2/image.rb', line 164 def exists? resp = client.describe_images(:filters => [{ :name => "image-id", :values => [id] }]) and !resp.images_set.empty? end |
#kernel ⇒ Image
Returns The kernel associated with the image, if any. Only applicable for machine images.
198 199 200 201 202 |
# File 'lib/aws/ec2/image.rb', line 198 def kernel if id = kernel_id Image.new(id, :config => config) end end |
#ramdisk ⇒ Image
Returns The RAM disk associated with the image, if any. Only applicable for machine images.
208 209 210 211 212 |
# File 'lib/aws/ec2/image.rb', line 208 def ramdisk if id = ramdisk_id Image.new(id, :config => config) end end |
#run_instance(opts = {}) ⇒ Instance
Runs a single instance of this image.
137 138 139 140 |
# File 'lib/aws/ec2/image.rb', line 137 def run_instance(opts = {}) InstanceCollection.new(:config => config). create(opts.merge(:image => self)) end |
#run_instances(count, opts = {}) ⇒ Array
Runs multiple instances of this image.
156 157 158 159 160 |
# File 'lib/aws/ec2/image.rb', line 156 def run_instances(count, opts = {}) InstanceCollection.new(:config => config). create(opts.merge(:image => self, :count => count)) end |