VM::EC...T::tag(3pm)
β¨ VM::EC2::REST::tag β¨
okay so bestie, welcome to VM::EC2::REST::tag β the page where we talk about tagging your AWS resources. it's giving organization. it's giving "everything in its right place." let's go π
π NAME π
VM::EC2::REST::tag β create, delete and fetch resource tags. periodt. π
πΈ SYNOPSIS πΈ
use VM::EC2 ':standard';
π¦ METHODS π¦
these methods let you create, delete and fetch resource tags, bestie. and ngl, you'll probably rarely need to call them directly, because every single object that VM::EC2 hands you already comes with a super cute tag interface built in:
$object = $ec2->describe_volumes(-volume_id=>'vol-12345'); # e.g.
$tags = $object->tags();
$name = $tags->{Name};
$object->add_tags(Role => 'Web Server', Status=>'development);
$object->delete_tags(Name=>undef);
if you want the full rundown on that uniform object tagging interface, go read VM::EC2::Generic. it's the whole lore β¨
so when are these methods the move? honestly, when you're creating and deleting tags for multiple resources at the same time. that's their main character moment. π
Implemented:
- CreateTags
- DeleteTags
- DescribeTags
Unimplemented:
- (none)
π₯ @t = $ec2->describe_tags(-filter=>\%filters);
returns a whole series of VM::EC2::Tag objects, each one describing an AMI. you get exactly one optional -filter argument, no more, no less. π
the filters you can use are: key, resource-id, resource-type and value. for the deep lore, go read the docs at http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeTags.html π«Ά
π $bool = $ec2->create_tags(-resource_id=>\@ids,-tag=>{key1=>value1...})
tags whatever resource -resource_id points at, using the tag(s) inside the hashref you pass to -tag. want to tag just one resource? pass a scalar resourceId to -resource_id. want to tag a whole squad? pass an anonymous array instead. it returns a true value if the tagging went off without a hitch. β¨
oh and heads up: add_tags() is just an alias for create_tags(). same energy, different name. π«
ngl you might find it way more convenient to tag an object you already pulled with any of the describe() methods, using its built-in add_tags() method:
@snap = $ec2->describe_snapshots(-filter=>{status=>'completed'});
foreach (@snap) {$_->add_tags(ReadyToUse => 'true')}
but if you've got a lot of snapshots to tag all at once, this way is faster:
@snap = $ec2->describe_snapshots(-filter=>{status=>'completed'});
$ec2->add_tags(-resource_id=>\@snap,-tag=>{ReadyToUse=>'true'});
π also bestie, plot twist: you can tag volumes, snapshots and images that are owned by other people. but only you will ever be able to see those tags. it's giving secret diary. π
π $bool = $ec2->delete_tags(-resource_id=>$id1,-tag=>{key1=>value1...})
deletes the tags you name from the resource you name. want to hit several resources at once? pass an arrayref, slay. π
but okay, the tag syntax here is a little tricky, so listen up. π§
use a value of undef to delete the tag unconditionally, no questions asked:
-tag => { Role => undef } # deletes any Role tag
any scalar value means the tag only gets deleted if its current value exactly matches what you specified:
-tag => { Role => 'Server' } # only delete the Role tag
# if it currently has the value "Server"
and an empty string value ('') will only delete the tag if its value is an empty string β which is probably not what you want. lowkey a trap. π
you can also pass an array reference of tag names to delete each of those tag names unconditionally (same thing as passing a value of undef):
$ec2->delete_tags(['Name','Role','Description']);
and again, it might be way comfier to delete tags straight off your objects using their delete_tags() method:
@snap = $ec2->describe_snapshots(-filter=>{status=>'completed'});
foreach (@snap) {$_->delete_tags(Role => undef)}
π @arguments = $ec2->tagcreate_parm(\%args)
π @arguments = $ec2->tagdelete_parm(\%args)
π SEE ALSO π
VM::EC2 β the mothership, go check it out π
π 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. πβ¨
and that's the whole page, bestie!! π«Ά this was VM::EC2::REST::tag, pulled from perl v5.38.2 and dated 2024-08-10 β so if you're reading this on some other version or date, just know the vibes were immaculate back then. mwah, go tag something. π
ππ
π¦ 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