VM::EC...Mapping(3pm)

πŸ“¦
version 1.28 Β· 7 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

🌸 VM::EC2::BlockDevice::Mapping β€” the 3pm manual page 🌸

okay bestie, pull up a chair, because today we're talking about VM::EC2::BlockDevice::Mapping β€” a Perl module straight outta the User Contributed Perl Documentation collection. yes, the docs are written by the community, and yes, they still ate. πŸ’…


✨ NAME ✨

VM::EC2::BlockDevice::Mapping β€” the object that describes an EC2 block device attached to an instance. it's literally the little guy that knows which volume is glued to which instance, no cap. πŸ¦‹


πŸŽ€ SYNOPSIS πŸŽ€

here's the vibe, in code:

use VM::EC2;

$ec2        = VM::EC2->new(...);
$instance   = $ec2->describe_instances(-instance_id=>'i-123456');
my @devices   = $instance->blockDeviceMapping;
for my $dev (@devices) {
  $dev       = $dev->deviceName;
  $volume_id = $dev->volumeId;
  $status    = $dev->status;
  $atime     = $dev->attachmentTime;
  $delete    = $dev->deleteOnTermination;
  $volume    = $dev->volume;
}

look at that loop go. she's looping, she's grabbing device names, volume ids, statuses, attach times, delete flags, and the volume itself. main character energy fr fr. πŸ‘‘


πŸ’– DESCRIPTION πŸ’–

So like, this object represents an Amazon block device associated with an instance. It gets returned by Instance->blockDeviceMapping(). That's the whole origin story. 🌈

also!! if you wanna know about the methods that EVERY VM::EC2 object shares, go peek at VM::EC2::Generic. it's the shared lore. πŸ’œ


🫢 METHODS 🫢

these object methods are supported:

  • deviceName β€” the name of the device, such as /dev/sda1. πŸ“
  • instance β€” the Instance object associated with this volume.
  • ebs β€” a VM::EC2::BlockDevice::Mapping::EBS object describing the characteristics of the attached EBS volume. she's the detail girlie of the group. ✨

πŸŽ€ the pass-through methods (a.k.a. for your convenience) πŸŽ€

bestie, because the module loves you, a bunch of the ebs() object's methods get passed straight through:

  • volumeId β€” ID of the volume. πŸ†”
  • status β€” one of "attaching", "attached", "detaching", "detached". four states, four moods, we stan a full lifecycle. πŸ’…
  • attachTime β€” the time this volume was attached. ⏰
  • deleteOnTermination β€” whether the volume will be deleted when its attached instance is deleted. heads up tho: note that this will return perl true/false vales, rather than the strings "true" "false". (yes the original says "vales," and I am not gonna gaslight you by silently fixing it β€” we love a documented typo, it's iconic) 😭

πŸ¦‹ the deleteOnTermination() situation πŸ¦‹

okay so this method can be used to retrieve or modify this flag. she's flexible like that.

# get current deleteOnTermination flag
my $current_flag = $dev->deleteOnTermination;

# if flag is true, then set it to false
if ($current_flag) { $dev->deleteOnTermination(0) }

read it, then change it. read it, then change it. slay. πŸ”₯


🌸 in addition, the following convenience function is provided: 🌸

πŸ’– $volume = $dev->volume πŸ’–

This returns a VM::EC2::Volume object, from which more information about the volume β€” such as its size β€” can be derived. it's giving "ask the volume directly, she'll tell you everything." πŸŽ€


🌈 STRING OVERLOADING 🌈

when used in a string context, this object will be interpolated as the deviceName. so if you just shove her into a string, you get the device name. periodt. ✨


πŸ‘‘ SEE ALSO πŸ‘‘

go read these next, bestie, they're all connected:

  • VM::EC2
  • VM::EC2::Generic
  • VM::EC2::BlockDevice
  • VM::EC2::BlockDevice::Attachment
  • VM::EC2::BlockDevice::Mapping::EBS
  • VM::EC2::Volume

πŸ’œ πŸ¦‹ πŸ’–


πŸ’Œ AUTHOR πŸ’Œ

Lincoln Stein <lincoln.stein@gmail.com>. the legend himself. πŸ‘‘

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


and that's the whole page, babe β€” documented under perl v5.38.2, dated 2024-08-10, filed away as VM::EC2::BlockDevice::Mapping in the 3pm section. go forth and map those block devices. mwah. πŸ’…πŸ’–βœ¨

πŸ“¦ where this page comes from