Class: Aws::EC2::Volume

Inherits:
Object
  • Object
show all
Defined in:
gems/aws-sdk-ec2/lib/aws-sdk-ec2/volume.rb

Defined Under Namespace

Classes: Collection

Read-Only Attributes collapse

Actions collapse

Associations collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Volume.

Overloads:

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

    Parameters:

    • id (String)

    Options Hash (options):

  • #initialize(options = {}) ⇒ Volume

    Options Hash (options):

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


22
23
24
25
26
27
28
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/volume.rb', line 22

def initialize(*args)
  options = Hash === args.last ? args.pop.dup : {}
  @id = extract_id(args, options)
  @data = options.delete(:data)
  @client = options.delete(:client) || Client.new(options)
  @waiter_block_warned = false
end

Instance Method Details

#attach_to_instance(options = {}) ⇒ Types::VolumeAttachment

Examples:

Request syntax with placeholder values


volume.attach_to_instance({
  device: "String", # required
  instance_id: "InstanceId", # required
  dry_run: false,
})

Parameters:

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

    ({})

Options Hash (options):

  • :device (required, String)

    The device name (for example, /dev/sdh or xvdh).

  • :instance_id (required, String)

    The ID of the instance.

  • :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:



335
336
337
338
339
340
341
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/volume.rb', line 335

def attach_to_instance(options = {})
  options = options.merge(volume_id: @id)
  resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
    @client.attach_volume(options)
  end
  resp.data
end

#attachmentsArray<Types::VolumeAttachment>

This parameter is not returned by CreateVolume.

Information about the volume attachments.

Returns:



162
163
164
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/volume.rb', line 162

def attachments
  data[:attachments]
end

#availability_zoneString

The Availability Zone for the volume.

Returns:

  • (String)


140
141
142
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/volume.rb', line 140

def availability_zone
  data[:availability_zone]
end

#availability_zone_idString

The ID of the Availability Zone for the volume.

Returns:

  • (String)


40
41
42
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/volume.rb', line 40

def availability_zone_id
  data[:availability_zone_id]
end

#clientClient

Returns:



182
183
184
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/volume.rb', line 182

def client
  @client
end

#create_snapshot(options = {}) ⇒ Snapshot

Examples:

Request syntax with placeholder values


snapshot = volume.create_snapshot({
  description: "String",
  outpost_arn: "String",
  tag_specifications: [
    {
      resource_type: "capacity-reservation", # accepts capacity-reservation, client-vpn-endpoint, customer-gateway, carrier-gateway, coip-pool, declarative-policies-report, dedicated-host, dhcp-options, egress-only-internet-gateway, elastic-ip, elastic-gpu, export-image-task, export-instance-task, fleet, fpga-image, host-reservation, image, image-usage-report, import-image-task, import-snapshot-task, instance, instance-event-window, internet-gateway, ipam, ipam-pool, ipam-scope, ipv4pool-ec2, ipv6pool-ec2, key-pair, launch-template, local-gateway, local-gateway-route-table, local-gateway-virtual-interface, local-gateway-virtual-interface-group, local-gateway-route-table-vpc-association, local-gateway-route-table-virtual-interface-group-association, natgateway, network-acl, network-interface, network-insights-analysis, network-insights-path, network-insights-access-scope, network-insights-access-scope-analysis, outpost-lag, placement-group, prefix-list, replace-root-volume-task, reserved-instances, route-table, security-group, security-group-rule, service-link-virtual-interface, snapshot, spot-fleet-request, spot-instances-request, subnet, subnet-cidr-reservation, traffic-mirror-filter, traffic-mirror-session, traffic-mirror-target, transit-gateway, transit-gateway-attachment, transit-gateway-connect-peer, transit-gateway-multicast-domain, transit-gateway-policy-table, transit-gateway-metering-policy, transit-gateway-route-table, transit-gateway-route-table-announcement, volume, vpc, vpc-endpoint, vpc-endpoint-connection, vpc-endpoint-service, vpc-endpoint-service-permission, vpc-peering-connection, vpn-connection, vpn-gateway, vpc-flow-log, capacity-reservation-fleet, traffic-mirror-filter-rule, vpc-endpoint-connection-device-type, verified-access-instance, verified-access-group, verified-access-endpoint, verified-access-policy, verified-access-trust-provider, vpn-connection-device-type, vpc-block-public-access-exclusion, vpc-encryption-control, route-server, route-server-endpoint, route-server-peer, ipam-resource-discovery, ipam-resource-discovery-association, instance-connect-endpoint, verified-access-endpoint-target, ipam-external-resource-verification-token, capacity-block, mac-modification-task, ipam-prefix-list-resolver, ipam-policy, ipam-prefix-list-resolver-target, capacity-manager-data-export, vpn-concentrator
      tags: [
        {
          key: "String",
          value: "String",
        },
      ],
    },
  ],
  location: "regional", # accepts regional, local
  dry_run: false,
})

Parameters:

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

    ({})

Options Hash (options):

  • :description (String)

    A description for the snapshot.

  • :outpost_arn (String)

    Only supported for volumes on Outposts. If the source volume is not on an Outpost, omit this parameter.

    • To create the snapshot on the same Outpost as the source volume, specify the ARN of that Outpost. The snapshot must be created on the same Outpost as the volume.

    • To create the snapshot in the parent Region of the Outpost, omit this parameter.

    For more information, see Create local snapshots from volumes on an Outpost in the Amazon EBS User Guide.

  • :tag_specifications (Array<Types::TagSpecification>)

    The tags to apply to the snapshot during creation.

  • :location (String)

    Only supported for volumes in Local Zones. If the source volume is not in a Local Zone, omit this parameter.

    • To create a local snapshot in the same Local Zone as the source volume, specify local.

    • To create a regional snapshot in the parent Region of the Local Zone, specify regional or omit this parameter.

    Default value: regional

  • :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:



405
406
407
408
409
410
411
412
413
414
415
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/volume.rb', line 405

def create_snapshot(options = {})
  options = options.merge(volume_id: @id)
  resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
    @client.create_snapshot(options)
  end
  Snapshot.new(
    id: resp.data.snapshot_id,
    data: resp.data,
    client: @client
  )
end

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

Examples:

Request syntax with placeholder values


tag = volume.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:



439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/volume.rb', line 439

def create_tags(options = {})
  batch = []
  options = Aws::Util.deep_merge(options, resources: [@id])
  resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
    @client.create_tags(options)
  end
  options[:tags].each do |t|
    batch << Tag.new(
      resource_id: @id,
      key: t[:key],
      value: t[:value],
      client: @client
    )
  end
  Tag::Collection.new([batch], size: batch.size)
end

#create_timeTime

The time stamp when volume creation was initiated.

Returns:

  • (Time)


152
153
154
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/volume.rb', line 152

def create_time
  data[:create_time]
end

#dataTypes::Volume

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

Returns:



204
205
206
207
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/volume.rb', line 204

def data
  load unless @data
  @data
end

#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.



212
213
214
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/volume.rb', line 212

def data_loaded?
  !!@data
end

#delete(options = {}) ⇒ EmptyStructure

Examples:

Request syntax with placeholder values


volume.delete({
  dry_run: false,
})

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.

Returns:

  • (EmptyStructure)


515
516
517
518
519
520
521
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/volume.rb', line 515

def delete(options = {})
  options = options.merge(volume_id: @id)
  resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
    @client.delete_volume(options)
  end
  resp.data
end

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

Examples:

Request syntax with placeholder values


tag = volume.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:



486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/volume.rb', line 486

def delete_tags(options = {})
  batch = []
  options = Aws::Util.deep_merge(options, resources: [@id])
  resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
    @client.delete_tags(options)
  end
  options[:tags].each do |t|
    batch << Tag.new(
      resource_id: @id,
      key: t[:key],
      value: t[:value],
      client: @client
    )
  end
  Tag::Collection.new([batch], size: batch.size)
end

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

Examples:

Request syntax with placeholder values


volume.describe_attribute({
  attribute: "autoEnableIO", # required, accepts autoEnableIO, productCodes
  dry_run: false,
})

Parameters:

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

    ({})

Options Hash (options):

  • :attribute (required, String)

    The attribute of the volume. This parameter is required.

  • :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:



538
539
540
541
542
543
544
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/volume.rb', line 538

def describe_attribute(options = {})
  options = options.merge(volume_id: @id)
  resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
    @client.describe_volume_attribute(options)
  end
  resp.data
end

#describe_status(options = {}) ⇒ Types::DescribeVolumeStatusResult

Examples:

Request syntax with placeholder values


volume.describe_status({
  max_results: 1,
  next_token: "String",
  dry_run: false,
  filters: [
    {
      name: "String",
      values: ["String"],
    },
  ],
})

Parameters:

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

    ({})

Options Hash (options):

  • :max_results (Integer)

    The maximum number of items to return for this request. To get the next page of items, make another request with the token returned in the output. For more information, see Pagination.

  • :next_token (String)

    The token returned from a previous paginated request. Pagination continues from the end of the items returned by the previous request.

  • :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.

  • :filters (Array<Types::Filter>)

    The filters.

    • action.code - The action code for the event (for example, enable-volume-io).

    • action.description - A description of the action.

    • action.event-id - The event ID associated with the action.

    • availability-zone - The Availability Zone of the instance.

    • event.description - A description of the event.

    • event.event-id - The event ID.

    • event.event-type - The event type (for io-enabled: passed | failed; for io-performance: io-performance:degraded | io-performance:severely-degraded | io-performance:stalled).

    • event.not-after - The latest end time for the event.

    • event.not-before - The earliest start time for the event.

    • volume-status.details-name - The cause for volume-status.status (io-enabled | io-performance).

    • volume-status.details-status - The status of volume-status.details-name (for io-enabled: passed | failed; for io-performance: normal | degraded | severely-degraded | stalled).

    • volume-status.status - The status of the volume (ok | impaired | warning | insufficient-data).

Returns:



611
612
613
614
615
616
617
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/volume.rb', line 611

def describe_status(options = {})
  options = Aws::Util.deep_merge(options, volume_ids: [@id])
  resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
    @client.describe_volume_status(options)
  end
  resp.data
end

#detach_from_instance(options = {}) ⇒ Types::VolumeAttachment

Examples:

Request syntax with placeholder values


volume.detach_from_instance({
  device: "String",
  force: false,
  instance_id: "InstanceIdForResolver",
  dry_run: false,
})

Parameters:

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

    ({})

Options Hash (options):

  • :device (String)

    The device name.

  • :force (Boolean)

    Forces detachment if the previous detachment attempt did not occur cleanly (for example, logging into an instance, unmounting the volume, and detaching normally). This option can lead to data loss or a corrupted file system. Use this option only as a last resort to detach a volume from a failed instance. The instance won't have an opportunity to flush file system caches or file system metadata. If you use this option, you must perform file system check and repair procedures.

  • :instance_id (String)

    The ID of the instance. If you are detaching a Multi-Attach enabled volume, you must specify an instance ID.

  • :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:



648
649
650
651
652
653
654
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/volume.rb', line 648

def detach_from_instance(options = {})
  options = options.merge(volume_id: @id)
  resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
    @client.detach_volume(options)
  end
  resp.data
end

#enable_io(options = {}) ⇒ EmptyStructure

Examples:

Request syntax with placeholder values


volume.enable_io({
  dry_run: false,
})

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.

Returns:

  • (EmptyStructure)


668
669
670
671
672
673
674
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/volume.rb', line 668

def enable_io(options = {})
  options = options.merge(volume_id: @id)
  resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
    @client.enable_volume_io(options)
  end
  resp.data
end

#encryptedBoolean

Indicates whether the volume is encrypted.

Returns:

  • (Boolean)


168
169
170
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/volume.rb', line 168

def encrypted
  data[:encrypted]
end

#fast_restoredBoolean

This parameter is not returned by CreateVolume.

Indicates whether the volume was created using fast snapshot restore.

Returns:

  • (Boolean)


85
86
87
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/volume.rb', line 85

def fast_restored
  data[:fast_restored]
end

#idString Also known as: volume_id

Returns:

  • (String)


33
34
35
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/volume.rb', line 33

def id
  @id
end

#iopsInteger

The number of I/O operations per second (IOPS). For gp3, io1, and io2 volumes, this represents the number of IOPS that are provisioned for the volume. For gp2 volumes, this represents the baseline performance of the volume and the rate at which the volume accumulates I/O credits for bursting.

Returns:

  • (Integer)


63
64
65
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/volume.rb', line 63

def iops
  data[:iops]
end

#kms_key_idString

The Amazon Resource Name (ARN) of the KMS key that was used to protect the volume encryption key for the volume.

Returns:

  • (String)


175
176
177
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/volume.rb', line 175

def kms_key_id
  data[:kms_key_id]
end

#loadself Also known as: reload

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

volume.reload.data

Returns:

  • (self)


192
193
194
195
196
197
198
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/volume.rb', line 192

def load
  resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
    @client.describe_volumes(volume_ids: [@id])
  end
  @data = resp.volumes[0]
  self
end

#modify_attribute(options = {}) ⇒ EmptyStructure

Examples:

Request syntax with placeholder values


volume.modify_attribute({
  auto_enable_io: {
    value: false,
  },
  dry_run: false,
})

Parameters:

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

    ({})

Options Hash (options):

  • :auto_enable_io (Types::AttributeBooleanValue)

    Indicates whether the volume should be auto-enabled for I/O operations.

  • :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)


694
695
696
697
698
699
700
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/volume.rb', line 694

def modify_attribute(options = {})
  options = options.merge(volume_id: @id)
  resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
    @client.modify_volume_attribute(options)
  end
  resp.data
end

#multi_attach_enabledBoolean

Indicates whether Amazon EBS Multi-Attach is enabled.

Returns:

  • (Boolean)


91
92
93
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/volume.rb', line 91

def multi_attach_enabled
  data[:multi_attach_enabled]
end

#operatorTypes::OperatorResponse

The service provider that manages the volume.



113
114
115
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/volume.rb', line 113

def operator
  data[:operator]
end

#outpost_arnString

The Amazon Resource Name (ARN) of the Outpost.

Returns:

  • (String)


46
47
48
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/volume.rb', line 46

def outpost_arn
  data[:outpost_arn]
end

#sizeInteger

The size of the volume, in GiBs.

Returns:

  • (Integer)


128
129
130
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/volume.rb', line 128

def size
  data[:size]
end

#snapshot_idString

The snapshot from which the volume was created, if applicable.

Returns:

  • (String)


134
135
136
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/volume.rb', line 134

def snapshot_id
  data[:snapshot_id]
end

#snapshots(options = {}) ⇒ Snapshot::Collection

Examples:

Request syntax with placeholder values


snapshots = volume.snapshots({
  owner_ids: ["String"],
  restorable_by_user_ids: ["String"],
  snapshot_ids: ["SnapshotId"],
  dry_run: false,
  filters: [
    {
      name: "String",
      values: ["String"],
    },
  ],
})

Parameters:

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

    ({})

Options Hash (options):

  • :owner_ids (Array<String>)

    Scopes the results to snapshots with the specified owners. You can specify a combination of Amazon Web Services account IDs, self, and amazon.

  • :restorable_by_user_ids (Array<String>)

    The IDs of the Amazon Web Services accounts that can create volumes from the snapshot.

  • :snapshot_ids (Array<String>)

    The snapshot IDs.

    Default: Describes the snapshots for which you have create volume permissions.

  • :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.

  • :filters (Array<Types::Filter>)

    The filters.

    • description - A description of the snapshot.

    • encrypted - Indicates whether the snapshot is encrypted (true | false)

    • owner-alias - The owner alias, from an Amazon-maintained list (amazon). This is not the user-configured Amazon Web Services account alias set using the IAM console. We recommend that you use the related parameter instead of this filter.

    • owner-id - The Amazon Web Services account ID of the owner. We recommend that you use the related parameter instead of this filter.

    • progress - The progress of the snapshot, as a percentage (for example, 80%).

    • snapshot-id - The snapshot ID.

    • start-time - The time stamp when the snapshot was initiated.

    • status - The status of the snapshot (pending | completed | error).

    • storage-tier - The storage tier of the snapshot (archive | standard).

    • transfer-type - The type of operation used to create the snapshot (time-based | standard).

    • tag:<key> - The key/value combination of a tag assigned to the resource. Use the tag key in the filter name and the tag value as the filter value. For example, to find all resources that have a tag with the key Owner and the value TeamA, specify tag:Owner for the filter name and TeamA for the filter value.

    • tag-key - The key of a tag assigned to the resource. Use this filter to find all resources assigned a tag with a specific key, regardless of the tag value.

    • volume-id - The ID of the volume the snapshot is for.

    • volume-size - The size of the volume, in GiB.

Returns:



782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/volume.rb', line 782

def snapshots(options = {})
  batches = Enumerator.new do |y|
    options = Aws::Util.deep_merge(options, filters: [{
      name: "volume-id",
      values: [@id]
    }])
    resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
      @client.describe_snapshots(options)
    end
    resp.each_page do |page|
      batch = []
      page.data.snapshots.each do |s|
        batch << Snapshot.new(
          id: s.snapshot_id,
          data: s,
          client: @client
        )
      end
      y.yield(batch)
    end
  end
  Snapshot::Collection.new(batches)
end

#source_volume_idString

The ID of the source volume from which the volume copy was created. Only for volume copies.

Returns:

  • (String)


53
54
55
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/volume.rb', line 53

def source_volume_id
  data[:source_volume_id]
end

#sse_typeString

This parameter is not returned by CreateVolume.

Reserved for future use.

Returns:

  • (String)


107
108
109
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/volume.rb', line 107

def sse_type
  data[:sse_type]
end

#stateString

The volume state.

Returns:

  • (String)


146
147
148
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/volume.rb', line 146

def state
  data[:state]
end

#tagsArray<Types::Tag>

Any tags assigned to the volume.

Returns:



69
70
71
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/volume.rb', line 69

def tags
  data[:tags]
end

#throughputInteger

The throughput that the volume supports, in MiB/s.

Returns:

  • (Integer)


97
98
99
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/volume.rb', line 97

def throughput
  data[:throughput]
end

#volume_initialization_rateInteger

The Amazon EBS Provisioned Rate for Volume Initialization (volume initialization rate) specified for the volume during creation, in MiB/s. If no volume initialization rate was specified, the value is null.

Returns:

  • (Integer)


122
123
124
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/volume.rb', line 122

def volume_initialization_rate
  data[:volume_initialization_rate]
end

#volume_typeString

The volume type.

Returns:

  • (String)


75
76
77
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/volume.rb', line 75

def volume_type
  data[:volume_type]
end

#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



296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/volume.rb', line 296

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