VM::EC2::Image(3pm)
π VM::EC2::Image π
okay bestie, welcome to the VM::EC2::Image(3pm) page from the User Contributed Perl Documentation. this is where AMIs get their whole main-character moment. β¨
β¨ NAME β¨
VM::EC2::Image β Object describing an Amazon Machine Image (AMI)
πΈ SYNOPSIS πΈ
use VM::EC2;
$ec2 = VM::EC2->new(...);
$image = $ec2->describe_images(-image_id=>'ami-12345');
$state = $image->imageState;
$owner = $image->imageOwnerId;
$rootdev = $image->rootDeviceName;
@devices = $image->blockDeviceMapping;
$tags = $image->tags;
@instances = $image->run_instances(-min_count=>10);
π¦ DESCRIPTION π¦
This object represents an Amazon Machine Image (AMI), and it's what VM::EC2->describe_images() gives you back. Besides all the cute query methods for the image's attributes, the run_instances() method lets you launch and configure EC2 instances based on the AMI. slay.
π METHODS π
These object methods are supported:
imageIdβ AMI IDimageLocationβ Location of the AMIimageStateβ Current state of the AMI. One of "available", "pending" or "failed". Only "available" AMIs can be launched.imageOwnerIdβ AWS account ID of the image owner.isPublicβ Returns true if this image has public launch permissions. Note that this is a Perl boolean, and not the string "true".productCodesβ A list of product codes associated with the image.architectureβ The architecture of the image.imageTypeβ The image type (machine, kernel or RAM disk).kernelIdβ The kernel associated with the image.ramdiskIdβ The RAM disk associated with the image.platformβ "Windows" for Windows AMIs, otherwise undef.sriovNetSupportβ Specifies whether enhanced networking is enabled. "simple" if enabled.stateReasonβ Explanation of a "failed"imageState. This is aVM::EC2::Instance::State::Reasonobject.imageOwnerAlias-The AWS account alias (e.g. "self") or AWS account ID that owns the AMI.nameβ Name of the AMI provided during image creation.descriptionβ Description of the AMI provided during image creation.rootDeviceTypeβ The root device type. One of "ebs" or "instance-store".rootDeviceNameβ Name of the root device, e.g. "/dev/sda1"blockDeviceMappingβ List of block devices attached to this image. Each element is aVM::EC2::BlockDevice.virtualizationTypeβ One of "paravirtual" or "hvm".hypervisorβ One of "ovm" or "xen"
In addition, the object supports the tags() method described in VM::EC2::Generic:
print "ready for production\n" if $image->tags->{Released};
π @instances = $image->run_instances(%args) π
The run_instance() method will launch one or more instances based on this AMI. It takes all the arguments recognized by VM::EC2->run_instances(), except for the -image_id argument. The method returns a list of VM::EC2::Instance objects, which you may monitor periodically until they are up and running.
All arguments are optional. See run_instances() in VM::EC2 for more information.
-min_countβ Minimum number of instances to launch [1]-max_countβ Maximum number of instances to launch [1]-key_nameβ Name of the keypair to use-security_group_idβ Security group ID to use for this instance. Use an arrayref for multiple group IDs-security_groupβ Security group name to use for this instance. Use an arrayref for multiple values.-user_dataβ User data to pass to the instances. Do NOT base64 encode this. It will be done for you.-instance_typeβ Type of the instance to use. See below for a list.-placement_zoneβ The availability zone you want to launch the instance into. Call$ec2->regionsfor a list.-placement_groupβ An existing placement group to launch the instance into. Applicable to cluster instances only.-placement_tenancyβ Specify 'dedicated' to launch the instance on a dedicated server. Only applicable for VPC instances.-kernel_idβ ID of the kernel to use for the instances, overriding the kernel specified in the image.-ramdisk_idβ ID of the ramdisk to use for the instances, overriding the ramdisk specified in the image.-block_devicesβ Specify block devices to map onto the instances, overriding the values specified in the image. This can be a scalar string or an arrayref for multiple mappings: Example:['/dev/sdb=ephemeral0','/dev/sdc=snap-12345:80:false']-monitoringβ Pass a true value to enable detailed monitoring.-subnet_idβ ID of the subnet to launch the instance into. Only applicable for VPC instances.-termination_protectionβ Pass true to lock the instance so that it cannot be terminated using the API. Usemodify_instance()to unset this if youu wish to terminate the instance later.-disable_api_terminationβ Same as above.-shutdown_behaviorβ Pass "stop" (the default) to stop the instance and save its disk state when "shutdown" is called from within the instance. Stopped instances can be restarted later. Pass "terminate" to instead terminate the instance and discard its state completely.-instance_initiated_shutdown_behaviorβ Same as above.-private_ip_addressβ Assign the instance to a specific IP address from a VPC subnet (VPC only).-client_tokenβ Unique identifier that you can provide to ensure idempotency of the request. You can use$ec2->token()to generate a suitable identifier. Seehttp://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/Run_Instance_Idempotency.html
Note that after launching an instance, you may need to wait a few seconds before adding tags to it or performing other operations.
See VM::EC2 for details.
π $boolean = $image->make_public($public) π
Change the isPublic flag. Provide a true value to make the image public, a false one to make it private.
π $state = $image->current_status π
Refreshes the object and then calls imageState() to return one of "pending", "available" or "failed." You can use this to monitor an image_creation process in progress.
π @user_ids = $image->launchPermissions π
Returns a list of user IDs with launch permission for this image. Note that the AWS API calls this "launchPermission", but this module makes it plural to emphasize that the result is a list.
π @user_ids = $image->authorized_users π
The same as launchPermissions.
π $boolean = $image->add_authorized_users($id1,$id2,...) / $boolean = $image->remove_authorized_users($id1,$id2,...) π
These methods add and remove user accounts which have launch permissions for the image. The result code indicates whether the list of user IDs were successfully added or removed.
π $boolean = $image->add_authorized_users($id1,$id2,...) / $boolean = $image->remove_authorized_users($id1,$id2,...) / $boolean = $image->reset_authorized_users π
These methods add and remove user accounts which have launch permissions for the image. The result code indicates whether the list of user IDs were successfully added or removed.
reset_authorized_users() resets the list users authored to launch instances from this image to empty, effectively granting launch privileges to the owner only.
See also authorized_users().
π $copy = $image->copy(-region => $region, -name => $name, -description => $desc) π
Copies the image to another region.
Required arguments:
-regionβ The region to copy to
Optional arguments:
-nameβ The name of the image.-descriptionβ The description of the image.-client_tokenβ Unique identifier to ensure idempotency of the request
π $image->refresh π
This method will refresh the object from AWS, updating all values to their current ones. You can call it after tagging or otherwise changing image attributes.
π STRING OVERLOADING π
When used in a string context, this object will interpolate the imageId.
π SEE ALSO π
VM::EC2VM::EC2::GenericVM::EC2::BlockDeviceVM::EC2::StateReasonVM::EC2::InstanceVM::EC2::Tag
π 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 tea, bestie π«Ά this page is from perl v5.38.2, dated 2024-08-10, for VM::EC2::Image(3pm). go launch something iconic π
β¨
π¦ 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