Class: Aws::EC2::Image

Inherits:
Object
  • Object
show all
Extended by:
Deprecations
Defined in:
sig/image.rbs,
lib/aws-sdk-ec2/image.rb

Overview

Defined Under Namespace

Classes: Collection

Read-Only Attributes collapse

Actions collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, options = {}) ⇒ Image #initialize(options = {}) ⇒ Image

Returns a new instance of Image.

Overloads:

  • #initialize(id, options = {}) ⇒ Image

    Parameters:

    • id (String)

    Options Hash (options):

  • #initialize(options = {}) ⇒ Image

    Options Hash (options):

    • :id (required, String)
    • :client (Client)


13
14
15
# File 'sig/image.rbs', line 13

def initialize: (String id, Hash[Symbol, untyped] options) -> void
| (id: String, ?client: Client) -> void
| (Hash[Symbol, untyped] args) -> void

Instance Method Details

#architectureString

The architecture of the image.

Returns:

  • (String)


118
# File 'sig/image.rbs', line 118

def architecture: () -> ("i386" | "x86_64" | "arm64" | "x86_64_mac" | "arm64_mac")

#block_device_mappingsArray<Types::BlockDeviceMapping>

Any block device mapping entries.

Returns:



28
# File 'sig/image.rbs', line 28

def block_device_mappings: () -> ::Array[Types::BlockDeviceMapping]

#boot_modeString

The boot mode of the image. For more information, see Instance launch behavior with Amazon EC2 boot modes in the Amazon EC2 User Guide.

Returns:

  • (String)


64
# File 'sig/image.rbs', line 64

def boot_mode: () -> ("legacy-bios" | "uefi" | "uefi-preferred")

#clientClient

Returns:



348
# File 'lib/aws-sdk-ec2/image.rb', line 348

def client: () -> Client

#create_tags(options = {}) ⇒ Tag::Collection

Examples:

Request syntax with placeholder values


tag = image.create_tags({
  dry_run: false,
  tags: [ # required
    {
      key: "String",
      value: "String",
    },
  ],
})

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Options Hash (options):

  • :dry_run (Boolean)

    Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.

  • :tags (required, Array<Types::Tag>)

    The tags. The value parameter is required, but if you don't want the tag to have a value, specify the parameter with no value, and we set the value to an empty string.

Returns:



153
# File 'sig/image.rbs', line 153

def create_tags: (

#creation_dateString

The date and time the image was created.

Returns:

  • (String)


109
# File 'sig/image.rbs', line 109

def creation_date: () -> ::String

#dataTypes::Image

Returns the data for this Aws::EC2::Image. Calls Client#describe_images if #data_loaded? is false.

Returns:



139
# File 'sig/image.rbs', line 139

def data: () -> Types::Image

#data_loaded?Boolean

Returns true if this resource is loaded. Accessing attributes or #data on an unloaded resource will trigger a call to #load.

Returns:

  • (Boolean)

    Returns true if this resource is loaded. Accessing attributes or #data on an unloaded resource will trigger a call to #load.



142
# File 'sig/image.rbs', line 142

def data_loaded?: () -> bool

#delete_tags(options = {}) ⇒ Tag::Collection

Examples:

Request syntax with placeholder values


tag = image.delete_tags({
  dry_run: false,
  tags: [
    {
      key: "String",
      value: "String",
    },
  ],
})

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Options Hash (options):

  • :dry_run (Boolean)

    Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.

  • :tags (Array<Types::Tag>)

    The tags to delete. Specify a tag key and an optional tag value to delete specific tags. If you specify a tag key without a tag value, we delete any tag with this key regardless of its value. If you specify a tag key with an empty string as the tag value, we delete the tag only if its value is an empty string.

    If you omit this parameter, we delete all user-defined tags for the specified resources. We do not delete Amazon Web Services-generated tags (tags that have the aws: prefix).

    Constraints: Up to 1000 tags.

Returns:



165
# File 'sig/image.rbs', line 165

def delete_tags: (

#deprecation_timeString

The date and time to deprecate the AMI, in UTC, in the following format: YYYY-MM-DDTHH:MM:SSZ. If you specified a value for seconds, Amazon EC2 rounds the seconds to the nearest minute.

Returns:

  • (String)


70
# File 'sig/image.rbs', line 70

def deprecation_time: () -> ::String

#deregister(options = {}) ⇒ Types::DeregisterImageResult

Examples:

Request syntax with placeholder values


image.deregister({
  delete_associated_snapshots: false,
  dry_run: false,
})

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Options Hash (options):

  • :delete_associated_snapshots (Boolean)

    Specifies whether to delete the snapshots associated with the AMI during deregistration.

    If a snapshot is associated with multiple AMIs, it is not deleted, regardless of this setting.

    Default: The snapshots are not deleted.

  • :dry_run (Boolean)

    Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.

Returns:



177
# File 'sig/image.rbs', line 177

def deregister: (

#deregistration_protectionString

Indicates whether deregistration protection is enabled for the AMI.

Returns:

  • (String)


79
# File 'sig/image.rbs', line 79

def deregistration_protection: () -> ::String

#describe_attribute(options = {}) ⇒ Types::ImageAttribute

Examples:

Request syntax with placeholder values


image.describe_attribute({
  attribute: "description", # required, accepts description, kernel, ramdisk, launchPermission, productCodes, blockDeviceMapping, sriovNetSupport, bootMode, tpmSupport, uefiData, lastLaunchedTime, imdsSupport, deregistrationProtection
  dry_run: false,
})

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Options Hash (options):

  • :attribute (required, String)

    The AMI attribute.

    Note: The blockDeviceMapping attribute is deprecated. Using this attribute returns the Client.AuthFailure error. To get information about the block device mappings for an AMI, describe the image instead.

  • :dry_run (Boolean)

    Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.

Returns:



184
# File 'sig/image.rbs', line 184

def describe_attribute: (

#descriptionString

The description of the AMI that was provided during image creation.

Returns:

  • (String)


31
# File 'sig/image.rbs', line 31

def description: () -> ::String

#ena_supportBoolean

Specifies whether enhanced networking with ENA is enabled.

Returns:

  • (Boolean)


34
# File 'sig/image.rbs', line 34

def ena_support: () -> bool

#exists?(options = {}) ⇒ Boolean

Returns true if the Image exists.

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Returns:

  • (Boolean)

    Returns true if the Image exists.



145
146
# File 'sig/image.rbs', line 145

def exists?: (?max_attempts: Integer, ?delay: Numeric, ?before_attempt: (^(Integer attempts) -> void), ?before_wait: (^(Integer attempts, untyped response) -> void)) -> bool
| (?Hash[Symbol, untyped]) -> bool

#free_tier_eligibleBoolean

Indicates whether the image is eligible for Amazon Web Services Free Tier.

  • If true, the AMI is eligible for Free Tier and can be used to launch instances under the Free Tier limits.

  • If false, the AMI is not eligible for Free Tier.

Returns:

  • (Boolean)


94
# File 'sig/image.rbs', line 94

def free_tier_eligible: () -> bool

#hypervisorString

The hypervisor type of the image. Only xen is supported. ovm is not supported.

Returns:

  • (String)


37
# File 'sig/image.rbs', line 37

def hypervisor: () -> ("ovm" | "xen")

#idString Also known as: image_id

Returns:

  • (String)


18
# File 'sig/image.rbs', line 18

def id: () -> String

#identifiersObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Deprecated.


780
781
782
# File 'lib/aws-sdk-ec2/image.rb', line 780

def identifiers
  { id: @id }
end

#image_allowedBoolean

If true, the AMI satisfies the criteria for Allowed AMIs and can be discovered and used in the account. If false and Allowed AMIs is set to enabled, the AMI can't be discovered or used in the account. If false and Allowed AMIs is set to audit-mode, the AMI can be discovered and used in the account.

For more information, see Control the discovery and use of AMIs in Amazon EC2 with Allowed AMIs in Amazon EC2 User Guide.

Returns:

  • (Boolean)


85
# File 'sig/image.rbs', line 85

def image_allowed: () -> bool

#image_locationString

The location of the AMI.

Returns:

  • (String)


100
# File 'sig/image.rbs', line 100

def image_location: () -> ::String

#image_owner_aliasString

The owner alias (amazon | aws-backup-vault | aws-marketplace).

Returns:

  • (String)


40
# File 'sig/image.rbs', line 40

def image_owner_alias: () -> ::String

#image_typeString

The type of image.

Returns:

  • (String)


121
# File 'sig/image.rbs', line 121

def image_type: () -> ("machine" | "kernel" | "ramdisk")

#image_watermarksArray<Types::ImageWatermark>

The watermarks attached to the AMI.

Returns:



97
# File 'sig/image.rbs', line 97

def image_watermarks: () -> ::Array[Types::ImageWatermark]

#imds_supportString

If v2.0, it indicates that IMDSv2 is specified in the AMI. Instances launched from this AMI will have HttpTokens automatically set to required so that, by default, the instance requires that IMDSv2 is used when requesting instance metadata. In addition, HttpPutResponseHopLimit is set to 2. For more information, see Configure the AMI in the Amazon EC2 User Guide.

Returns:

  • (String)


73
# File 'sig/image.rbs', line 73

def imds_support: () -> ("v2.0")

#kernel_idString

The kernel associated with the image, if any. Only applicable for machine images.

Returns:

  • (String)


124
# File 'sig/image.rbs', line 124

def kernel_id: () -> ::String

#last_launched_timeString

The date and time, in ISO 8601 date-time format, when the AMI was last used to launch an EC2 instance. When the AMI is used to launch an instance, there is a 24-hour delay before that usage is reported.

lastLaunchedTime data is available starting April 2017.

Returns:

  • (String)


82
# File 'sig/image.rbs', line 82

def last_launched_time: () -> ::String

#loadself Also known as: reload

Loads, or reloads #data for the current Aws::EC2::Image. Returns self making it possible to chain methods.

image.reload.data

Returns:

  • (self)


135
# File 'sig/image.rbs', line 135

def load: () -> self

#modify_attribute(options = {}) ⇒ EmptyStructure

Examples:

Request syntax with placeholder values


image.modify_attribute({
  attribute: "String",
  description: "value", # value <Hash,Array,String,Numeric,Boolean,IO,Set,nil>
  launch_permission: {
    add: [
      {
        organization_arn: "String",
        organizational_unit_arn: "String",
        user_id: "String",
        group: "all", # accepts all
      },
    ],
    remove: [
      {
        organization_arn: "String",
        organizational_unit_arn: "String",
        user_id: "String",
        group: "all", # accepts all
      },
    ],
  },
  operation_type: "add", # accepts add, remove
  product_codes: ["String"],
  user_groups: ["String"],
  user_ids: ["String"],
  value: "String",
  organization_arns: ["String"],
  organizational_unit_arns: ["String"],
  imds_support: "value", # value <Hash,Array,String,Numeric,Boolean,IO,Set,nil>
  dry_run: false,
})

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Options Hash (options):

  • :attribute (String)

    The name of the attribute to modify.

    Valid values: description | imdsSupport | launchPermission

  • :description (Types::AttributeValue)

    A new description for the AMI.

  • :launch_permission (Types::LaunchPermissionModifications)

    A new launch permission for the AMI.

  • :operation_type (String)

    The operation type. This parameter can be used only when the Attribute parameter is launchPermission.

  • :product_codes (Array<String>)

    Not supported.

  • :user_groups (Array<String>)

    The user groups. This parameter can be used only when the Attribute parameter is launchPermission.

  • :user_ids (Array<String>)

    The Amazon Web Services account IDs. This parameter can be used only when the Attribute parameter is launchPermission.

  • :value (String)

    The value of the attribute being modified. This parameter can be used only when the Attribute parameter is description or imdsSupport.

  • :organization_arns (Array<String>)

    The Amazon Resource Name (ARN) of an organization. This parameter can be used only when the Attribute parameter is launchPermission.

  • :organizational_unit_arns (Array<String>)

    The Amazon Resource Name (ARN) of an organizational unit (OU). This parameter can be used only when the Attribute parameter is launchPermission.

  • :imds_support (Types::AttributeValue)

    Set to v2.0 to indicate that IMDSv2 is specified in the AMI. Instances launched from this AMI will have HttpTokens automatically set to required so that, by default, the instance requires that IMDSv2 is used when requesting instance metadata. In addition, HttpPutResponseHopLimit is set to 2. For more information, see Configure the AMI in the Amazon EC2 User Guide.

    Do not use this parameter unless your AMI software supports IMDSv2. After you set the value to v2.0, you can't undo it. The only way to “reset” your AMI is to create a new AMI from the underlying snapshot.

  • :dry_run (Boolean)

    Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.

Returns:

  • (EmptyStructure)


191
# File 'sig/image.rbs', line 191

def modify_attribute: (

#nameString

The name of the AMI that was provided during image creation.

Returns:

  • (String)


43
# File 'sig/image.rbs', line 43

def name: () -> ::String

#owner_idString

The ID of the Amazon Web Services account that owns the image.

Returns:

  • (String)


106
# File 'sig/image.rbs', line 106

def owner_id: () -> ::String

#platformString

This value is set to windows for Windows AMIs; otherwise, it is blank.

Returns:

  • (String)


130
# File 'sig/image.rbs', line 130

def platform: () -> ("Windows")

#platform_detailsString

The platform details associated with the billing code of the AMI. For more information, see Understand AMI billing information in the Amazon EC2 User Guide.

Returns:

  • (String)


22
# File 'sig/image.rbs', line 22

def platform_details: () -> ::String

#product_codesArray<Types::ProductCode>

Any product codes associated with the AMI.

Returns:



115
# File 'sig/image.rbs', line 115

def product_codes: () -> ::Array[Types::ProductCode]

#publicBoolean

Indicates whether the image has public launch permissions. The value is true if this image has public launch permissions or false if it has only implicit and explicit launch permissions.

Returns:

  • (Boolean)


112
# File 'sig/image.rbs', line 112

def public: () -> bool

#ramdisk_idString

The RAM disk associated with the image, if any. Only applicable for machine images.

Returns:

  • (String)


127
# File 'sig/image.rbs', line 127

def ramdisk_id: () -> ::String

#reset_attribute(options = {}) ⇒ EmptyStructure

Examples:

Request syntax with placeholder values


image.reset_attribute({
  attribute: "launchPermission", # required, accepts launchPermission
  dry_run: false,
})

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Options Hash (options):

  • :attribute (required, String)

    The attribute to reset (currently you can only reset the launch permission attribute).

  • :dry_run (Boolean)

    Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.

Returns:

  • (EmptyStructure)


225
# File 'sig/image.rbs', line 225

def reset_attribute: (

#root_device_nameString

The device name of the root device volume (for example, /dev/sda1).

Returns:

  • (String)


46
# File 'sig/image.rbs', line 46

def root_device_name: () -> ::String

#root_device_typeString

The type of root device used by the AMI. The AMI can use an Amazon EBS volume or an instance store volume.

Returns:

  • (String)


49
# File 'sig/image.rbs', line 49

def root_device_type: () -> ("ebs" | "instance-store")

#source_image_idString

The ID of the source AMI from which the AMI was created.

Returns:

  • (String)


88
# File 'sig/image.rbs', line 88

def source_image_id: () -> ::String

#source_image_regionString

The Region of the source AMI.

Returns:

  • (String)


91
# File 'sig/image.rbs', line 91

def source_image_region: () -> ::String

#source_instance_idString

The ID of the instance that the AMI was created from if the AMI was created using CreateImage. This field only appears if the AMI was created using CreateImage.

Returns:

  • (String)


76
# File 'sig/image.rbs', line 76

def source_instance_id: () -> ::String

#sriov_net_supportString

Specifies whether enhanced networking with the Intel 82599 Virtual Function interface is enabled.

Returns:

  • (String)


52
# File 'sig/image.rbs', line 52

def sriov_net_support: () -> ::String

#stateString

The current state of the AMI. If the state is available, the image is successfully registered and can be used to launch an instance.

Returns:

  • (String)


103
# File 'sig/image.rbs', line 103

def state: () -> ("pending" | "available" | "invalid" | "deregistered" | "transient" | "failed" | "error" | "disabled")

#state_reasonTypes::StateReason

The reason for the state change.

Returns:



55
# File 'sig/image.rbs', line 55

def state_reason: () -> Types::StateReason

#tagsArray<Types::Tag>

Any tags assigned to the image.

Returns:



58
# File 'sig/image.rbs', line 58

def tags: () -> ::Array[Types::Tag]

#tpm_supportString

If the image is configured for NitroTPM support, the value is v2.0. For more information, see NitroTPM in the Amazon EC2 User Guide.

Returns:

  • (String)


67
# File 'sig/image.rbs', line 67

def tpm_support: () -> ("v2.0")

#usage_operationString

The operation of the Amazon EC2 instance and the billing code that is associated with the AMI. usageOperation corresponds to the lineitem/Operation column on your Amazon Web Services Cost and Usage Report and in the Amazon Web Services Price List API. You can view these fields on the Instances or AMIs pages in the Amazon EC2 console, or in the responses that are returned by the DescribeImages command in the Amazon EC2 API, or the describe-images command in the CLI.

Returns:

  • (String)


25
# File 'sig/image.rbs', line 25

def usage_operation: () -> ::String

#virtualization_typeString

The type of virtualization of the AMI.

Returns:

  • (String)


61
# File 'sig/image.rbs', line 61

def virtualization_type: () -> ("hvm" | "paravirtual")

#wait_until(options = {}) {|resource| ... } ⇒ Resource

Deprecated.

Use [Aws::EC2::Client] #wait_until instead

Note:

The waiting operation is performed on a copy. The original resource remains unchanged.

Waiter polls an API operation until a resource enters a desired state.

Basic Usage

Waiter will polls until it is successful, it fails by entering a terminal state, or until a maximum number of attempts are made.

# polls in a loop until condition is true
resource.wait_until(options) {|resource| condition}

Example

instance.wait_until(max_attempts:10, delay:5) do |instance|
  instance.state.name == 'running'
end

Configuration

You can configure the maximum number of polling attempts, and the delay (in seconds) between each polling attempt. The waiting condition is set by passing a block to #wait_until:

# poll for ~25 seconds
resource.wait_until(max_attempts:5,delay:5) {|resource|...}

Callbacks

You can be notified before each polling attempt and before each delay. If you throw :success or :failure from these callbacks, it will terminate the waiter.

started_at = Time.now
# poll for 1 hour, instead of a number of attempts
proc = Proc.new do |attempts, response|
  throw :failure if Time.now - started_at > 3600
end

  # disable max attempts
instance.wait_until(before_wait:proc, max_attempts:nil) {...}

Handling Errors

When a waiter is successful, it returns the Resource. When a waiter fails, it raises an error.

begin
  resource.wait_until(...)
rescue Aws::Waiters::Errors::WaiterFailed
  # resource did not enter the desired state in time
end

attempts attempt in seconds invoked before each attempt invoked before each wait

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :max_attempts (Integer) — default: 10

    Maximum number of

  • :delay (Integer) — default: 10

    Delay between each

  • :before_attempt (Proc) — default: nil

    Callback

  • :before_wait (Proc) — default: nil

    Callback

Yield Parameters:

  • resource (Resource)

    to be used in the waiting condition.

Returns:

  • (Resource)

    if the waiter was successful

Raises:

  • (Aws::Waiters::Errors::FailureStateError)

    Raised when the waiter terminates because the waiter has entered a state that it will not transition out of, preventing success.

    yet successful.

  • (Aws::Waiters::Errors::UnexpectedError)

    Raised when an error is encountered while polling for a resource that is not expected.

  • (NotImplementedError)

    Raised when the resource does not



496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
# File 'lib/aws-sdk-ec2/image.rb', line 496

def wait_until(options = {}, &block)
  self_copy = self.dup
  attempts = 0
  options[:max_attempts] = 10 unless options.key?(:max_attempts)
  options[:delay] ||= 10
  options[:poller] = Proc.new do
    attempts += 1
    if block.call(self_copy)
      [:success, self_copy]
    else
      self_copy.reload unless attempts == options[:max_attempts]
      :retry
    end
  end
  Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
    Aws::Waiters::Waiter.new(options).wait({})
  end
end

#wait_until_exists(options = {}, &block) ⇒ Image

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Options Hash (options):

  • :max_attempts (Integer) — default: 40
  • :delay (Float) — default: 15
  • :before_attempt (Proc)
  • :before_wait (Proc)

Returns:



149
150
# File 'sig/image.rbs', line 149

def wait_until_exists: (?max_attempts: Integer, ?delay: Numeric, ?before_attempt: (^(Integer attempts) -> void), ?before_wait: (^(Integer attempts, untyped response) -> void)) ?{ (untyped waiter) -> void } -> Image
| (?Hash[Symbol, untyped]) ?{ (untyped waiter) -> void } -> Image