VM::EC...T::tag(3pm)

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

✨ 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