Class: Aws::EC2::Volume
- Inherits:
-
Object
- Object
- Aws::EC2::Volume
- Extended by:
- Deprecations
- Defined in:
- lib/aws-sdk-ec2/volume.rb
Defined Under Namespace
Classes: Collection
Read-Only Attributes collapse
-
#attachments ⇒ Array<Types::VolumeAttachment>
Information about the volume attachments.
-
#availability_zone ⇒ String
The Availability Zone for the volume.
-
#create_time ⇒ Time
The time stamp when volume creation was initiated.
-
#encrypted ⇒ Boolean
Indicates whether the volume will be encrypted.
- #id ⇒ String (also: #volume_id)
-
#iops ⇒ Integer
The number of I/O operations per second (IOPS) that the volume supports.
-
#kms_key_id ⇒ String
The full ARN of the AWS Key Management Service (AWS KMS) customer master key (CMK) that was used to protect the volume encryption key for the volume.
-
#size ⇒ Integer
The size of the volume, in GiBs.
-
#snapshot_id ⇒ String
The snapshot from which the volume was created, if applicable.
-
#state ⇒ String
The volume state.
-
#tags ⇒ Array<Types::Tag>
Any tags assigned to the volume.
-
#volume_type ⇒ String
The volume type.
Actions collapse
- #attach_to_instance(options = {}) ⇒ Types::VolumeAttachment
- #create_snapshot(options = {}) ⇒ Snapshot
- #create_tags(options = {}) ⇒ Tag::Collection
- #delete(options = {}) ⇒ EmptyStructure
- #describe_attribute(options = {}) ⇒ Types::DescribeVolumeAttributeResult
- #describe_status(options = {}) ⇒ Types::DescribeVolumeStatusResult
- #detach_from_instance(options = {}) ⇒ Types::VolumeAttachment
- #enable_io(options = {}) ⇒ EmptyStructure
- #modify_attribute(options = {}) ⇒ EmptyStructure
Associations collapse
- #identifiers ⇒ Object deprecated private Deprecated.
- #snapshots(options = {}) ⇒ Snapshot::Collection
Instance Method Summary collapse
- #client ⇒ Client
-
#data ⇒ Types::Volume
Returns the data for this Volume.
-
#data_loaded? ⇒ Boolean
Returns ‘true` if this resource is loaded.
-
#initialize(*args) ⇒ Volume
constructor
A new instance of Volume.
- #load ⇒ self (also: #reload)
Constructor Details
#initialize(id, options = {}) ⇒ Volume #initialize(options = {}) ⇒ Volume
Returns a new instance of Volume.
19 20 21 22 23 24 |
# File 'lib/aws-sdk-ec2/volume.rb', line 19 def initialize(*args) = Hash === args.last ? args.pop.dup : {} @id = extract_id(args, ) @data = .delete(:data) @client = .delete(:client) || Client.new() end |
Instance Method Details
#attach_to_instance(options = {}) ⇒ Types::VolumeAttachment
178 179 180 181 182 |
# File 'lib/aws-sdk-ec2/volume.rb', line 178 def attach_to_instance( = {}) = .merge(volume_id: @id) resp = @client.attach_volume() resp.data end |
#attachments ⇒ Array<Types::VolumeAttachment>
Information about the volume attachments.
36 37 38 |
# File 'lib/aws-sdk-ec2/volume.rb', line 36 def data. end |
#availability_zone ⇒ String
The Availability Zone for the volume.
42 43 44 |
# File 'lib/aws-sdk-ec2/volume.rb', line 42 def availability_zone data.availability_zone end |
#create_snapshot(options = {}) ⇒ Snapshot
199 200 201 202 203 204 205 206 207 |
# File 'lib/aws-sdk-ec2/volume.rb', line 199 def create_snapshot( = {}) = .merge(volume_id: @id) resp = @client.create_snapshot() Snapshot.new( id: resp.data.snapshot_id, data: resp.data, client: @client ) end |
#create_tags(options = {}) ⇒ Tag::Collection
231 232 233 234 235 236 237 238 239 240 241 242 243 244 |
# File 'lib/aws-sdk-ec2/volume.rb', line 231 def ( = {}) batch = [] = Aws::Util.deep_merge(, resources: [@id]) resp = @client.() [: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_time ⇒ Time
The time stamp when volume creation was initiated.
48 49 50 |
# File 'lib/aws-sdk-ec2/volume.rb', line 48 def create_time data.create_time end |
#data ⇒ Types::Volume
Returns the data for this Aws::EC2::Volume. Calls Client#describe_volumes if #data_loaded? is ‘false`.
145 146 147 148 |
# File 'lib/aws-sdk-ec2/volume.rb', line 145 def data load unless @data @data end |
#data_loaded? ⇒ Boolean
153 154 155 |
# File 'lib/aws-sdk-ec2/volume.rb', line 153 def data_loaded? !!@data end |
#delete(options = {}) ⇒ EmptyStructure
258 259 260 261 262 |
# File 'lib/aws-sdk-ec2/volume.rb', line 258 def delete( = {}) = .merge(volume_id: @id) resp = @client.delete_volume() resp.data end |
#describe_attribute(options = {}) ⇒ Types::DescribeVolumeAttributeResult
279 280 281 282 283 |
# File 'lib/aws-sdk-ec2/volume.rb', line 279 def describe_attribute( = {}) = .merge(volume_id: @id) resp = @client.describe_volume_attribute() resp.data end |
#describe_status(options = {}) ⇒ Types::DescribeVolumeStatusResult
355 356 357 358 359 |
# File 'lib/aws-sdk-ec2/volume.rb', line 355 def describe_status( = {}) = Aws::Util.deep_merge(, volume_ids: [@id]) resp = @client.describe_volume_status() resp.data end |
#detach_from_instance(options = {}) ⇒ Types::VolumeAttachment
389 390 391 392 393 |
# File 'lib/aws-sdk-ec2/volume.rb', line 389 def detach_from_instance( = {}) = .merge(volume_id: @id) resp = @client.detach_volume() resp.data end |
#enable_io(options = {}) ⇒ EmptyStructure
407 408 409 410 411 |
# File 'lib/aws-sdk-ec2/volume.rb', line 407 def enable_io( = {}) = .merge(volume_id: @id) resp = @client.enable_volume_io() resp.data end |
#encrypted ⇒ Boolean
Indicates whether the volume will be encrypted.
54 55 56 |
# File 'lib/aws-sdk-ec2/volume.rb', line 54 def encrypted data.encrypted end |
#id ⇒ String Also known as: volume_id
29 30 31 |
# File 'lib/aws-sdk-ec2/volume.rb', line 29 def id @id end |
#identifiers ⇒ Object
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.
536 537 538 |
# File 'lib/aws-sdk-ec2/volume.rb', line 536 def identifiers { id: @id } end |
#iops ⇒ Integer
The number of I/O operations per second (IOPS) that the volume supports. For Provisioned IOPS SSD volumes, this represents the number of IOPS that are provisioned for the volume. For General Purpose SSD volumes, this represents the baseline performance of the volume and the rate at which the volume accumulates I/O credits for bursting. For more information on General Purpose SSD baseline performance, I/O credits, and bursting, see [Amazon EBS Volume Types] in the *Amazon Elastic Compute Cloud User Guide*.
Constraint: Range is 100-20000 IOPS for io1 volumes and 100-10000 IOPS for ‘gp2` volumes.
Condition: This parameter is required for requests to create ‘io1` volumes; it is not used in requests to create `gp2`, `st1`, `sc1`, or `standard` volumes.
[1]: docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSVolumeTypes.html
104 105 106 |
# File 'lib/aws-sdk-ec2/volume.rb', line 104 def iops data.iops end |
#kms_key_id ⇒ String
The full ARN of the AWS Key Management Service (AWS KMS) customer master key (CMK) that was used to protect the volume encryption key for the volume.
62 63 64 |
# File 'lib/aws-sdk-ec2/volume.rb', line 62 def kms_key_id data.kms_key_id end |
#load ⇒ self 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
135 136 137 138 139 |
# File 'lib/aws-sdk-ec2/volume.rb', line 135 def load resp = @client.describe_volumes(volume_ids: [@id]) @data = resp.volumes[0] self end |
#modify_attribute(options = {}) ⇒ EmptyStructure
431 432 433 434 435 |
# File 'lib/aws-sdk-ec2/volume.rb', line 431 def modify_attribute( = {}) = .merge(volume_id: @id) resp = @client.modify_volume_attribute() resp.data end |
#size ⇒ Integer
The size of the volume, in GiBs.
68 69 70 |
# File 'lib/aws-sdk-ec2/volume.rb', line 68 def size data.size end |
#snapshot_id ⇒ String
The snapshot from which the volume was created, if applicable.
74 75 76 |
# File 'lib/aws-sdk-ec2/volume.rb', line 74 def snapshot_id data.snapshot_id end |
#snapshots(options = {}) ⇒ Snapshot::Collection
512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 |
# File 'lib/aws-sdk-ec2/volume.rb', line 512 def snapshots( = {}) batches = Enumerator.new do |y| = Aws::Util.deep_merge(, filters: [{ name: "volume-id", values: [@id] }]) resp = @client.describe_snapshots() 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 |
#state ⇒ String
The volume state.
80 81 82 |
# File 'lib/aws-sdk-ec2/volume.rb', line 80 def state data.state end |
#tags ⇒ Array<Types::Tag>
Any tags assigned to the volume.
110 111 112 |
# File 'lib/aws-sdk-ec2/volume.rb', line 110 def data. end |
#volume_type ⇒ String
The volume type. This can be ‘gp2` for General Purpose SSD, `io1` for Provisioned IOPS SSD, `st1` for Throughput Optimized HDD, `sc1` for Cold HDD, or `standard` for Magnetic volumes.
118 119 120 |
# File 'lib/aws-sdk-ec2/volume.rb', line 118 def volume_type data.volume_type end |