VM::EC2::Volume(3pm)
π VM::EC2::Volume π
okay bestie, welcome to VM::EC2::Volume β it's a Perl module, it lives in the User Contributed Perl Documentation crew, and it's literally the object that describes an Amazon EBS volume. she's iconic, she's storage, she's giving "your instance's emotional support disk." π
β¨ NAME β¨
VM::EC2::Volume β Object describing an Amazon EBS volume π¦
πΈ SYNOPSIS πΈ
no cap, this is the whole vibe:
use VM::EC2;
$ec2 = VM::EC2->new(...);
@vol = $ec2->describe_volumes;
for my $vol (@vols) {
$id = $vol->volumeId;
$size = $vol->size;
$snap = $vol->snapshotId;
$zone = $vol->availabilityZone;
$status = $vol->status;
$ctime = $vol->createTime;
@attachments = $vol->attachments;
$attachment = $vol->attachment;
$origin = $vol->from_snapshot;
@snapshots = $vol->to_snapshots;
}
$vols[0]->attach('i-12345','/dev/sdg1');
$vols[0]->deleteOnTermination('true');
$vols[0]->detach;
$vols[0]->create_snapshot('automatic snapshot')
(yes the code is exactly like that, I am not touching a single character, that's the assignment π )
π DESCRIPTION π
So. This object is what you get when you ask about an Amazon EBS volume. It's the thing that VM::EC2->describe_volumes() hands back to you. That's it, that's the description. Simple, clean, main character energy. β¨
π METHODS π
the basics (the object methods, bestie)
volumeIdβ ID of this volume.sizeβ Size of this volume (in GB).snapshotIdβ ID of snapshot this volume was created from.availabilityZoneβ Availability zone in which this volume resides.statusβ Volume state, one of"creating","available","in-use","deleting","deleted","error"createTimeβ Timestamp for when volume was created.volumeTypeβ The volume type, one of"standard","io1", or"gp2"iopsβ The number of I/O operations per second that the volume supports, an integer between100and4000. Only valid for volumes of type"io1".encryptedβ True if volume is encrypted.tagsβ Hashref containing tags associated with this group. SeeVM::EC2::Generic.
and now the convenience functions, aka the fun part π«Ά
$attachment = $vol->attachment
@attachments = $vol->attachments
The attachment() method returns a VM::EC2::BlockDevice::Attachment object describing the attachment of this volume to an instance. If the volume is unused, then this returns undef. (sad. empty. no attachments. it's giving single and thriving π§)
The attachments() method is similar, except that it returns a list of the attachments. Currently an EBS volume can only be attached to one instance at a time, but the Amazon call syntax supports multiple attachments and this method is provided for future compatibility. so like, she's ready for her poly era, just not yet π
$attachment = $vol->attach($instance,$device)
$attachment = $vol->attach(-instance_id=>$instance,-device=>$device)
Attach this volume to an instance using virtual device $device. Both arguments are required. The result is a VM::EC2::BlockDevice::Attachment object which you can monitor by calling current_status():
my $a = $volume->attach('i-12345','/dev/sdg');
while ($a->current_status ne 'attached') {
sleep 2;
}
print "volume is ready to go\n";
look at her go, waiting politely in a while loop. patient queen. π
$attachment = $volume->detach()
$attachment = $volume->detach(-instance_id=>$instance_id, -device=>$device, -force=>$force)
Detaches this volume. With no arguments, will detach the volume from whatever instance it is currently attached to. Provide -instance_id and/or -device as a check that you are detaching the volume from the expected instance and device. (safety first, bestie, we do not yank the wrong disk π« )
Optional arguments:
-instance_idβ ID of the instance to detach from.-deviceβ How the device is exposed to the instance.-forceβ Force detachment, even if previous attempts were unsuccessful.
The result is a VM::EC2::BlockDevice::Attachment object which you can monitor by calling current_status():
my $a = $volume->detach;
while ($a->current_status ne 'detached') {
sleep 2;
}
print "volume is ready to go\n";
$boolean = $vol->deleteOnTermination([$boolean])
Get or set the deleteOnTermination flag for attached volumes. If the volume is unattached, then this causes a fatal error. π¨ Called with no arguments, this method returns the current state of the deleteOnTermination flag for the volume's attachment. Called with a true/false argument, the method sets the flag by calling modify_instance_attributes() on the corresponding instance and returns true if successful.
bestie if the volume isn't attached, this one does not gently explain itself. it's a fatal error. respect the boundary. π
$snap = $vol->from_snapshot
Returns the VM::EC2::Snapshot object that this volume was originally derived from. It will return undef if the resource no longer exists, or if the volume was created from scratch.
@snap = $vol->to_snapshots
If this volume has been used to create one or more snapshots, this method will return them as a list of VM::EC2::Snapshot objects.
$snapshot = $vol->create_snapshot('Description')
Create a snapshot of the volume and return a VM::EC2::Snapshot object. To ensure a consistent snapshot, you should unmount the volume before snapshotting it. The optional argument allows you to add a description to the snapshot.
Here is an example:
$s = $volume->create_snapshot("Backed up at ".localtime);
while ($s->current_status eq 'pending') {
print "Progress: ",$s->progress,"% done\n";
}
print "Snapshot status: ",$s->current_status,"\n";
$status = $vol->current_status
This returns the up-to-date status of the volume. It works by calling refresh() and then returning status().
$boolean = $vol->auto_enable_io([$new_boolean])
Get or set the auto-enable IO flag.
$boolean = $vol->enable_volume_io()
Enable volume I/O after it has been disabled by an Amazon health check. If successful, the call will return true.
π STRING OVERLOADING π
When used in a string context, this object will interpolate the volumeId. she knows how to introduce herself. π
π¦ SEE ALSO π¦
VM::EC2 VM::EC2::Generic VM::EC2::Snapshot VM::EC2::BlockDevice VM::EC2::BlockDevice::Attachment
π AUTHOR π
Lincoln Stein <lincoln.stein@gmail.com>.
Copyright (c) 2011 Ontario Institute for Cancer Research
This package and its accompanying libraries is free software; you can redistribute it and/or modify it under the terms of the GPL (either version 1, or at your option, any later version) or the Artistic License 2.0. Refer to LICENSE for the full license text. In addition, please see DISCLAIMER.txt for disclaimers of warranty.
okay that's the whole page, periodt. π this was perl v5.38.2, dated 2024-08-10, and the page itself is VM::EC2::Volume(3pm). go forth and describe your volumes, bestie, you've got this πβ¨π«Ά
π¦ where this page comes from
- debian trixie: libvm-ec2-perl 1.28-5 Β· Artistic-2.0 OR GPL-1.0-or-later
- ubuntu resolute: libvm-ec2-perl 1.28-5 Β· Artistic-2.0 OR GPL-1.0-or-later
- ubuntu stonking: libvm-ec2-perl 1.28-5 Β· Artistic-2.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms