Net::Amazon::EC2(3pm)
๐ Net::Amazon::EC2(3pm) ๐
okay bestie, welcome to Net::Amazon::EC2 from the User Contributed Perl Documentation collection. This is the Perl interface to Amazon's Elastic Compute Cloud (EC2), and we're about to make it make sense. ๐ฆ
โจ NAME โจ
Net::Amazon::EC2 โ Perl interface to the Amazon Elastic Compute Cloud (EC2) environment. ๐
โญ VERSION โญ
EC2 Query API version: '2014-06-15'
๐ SYNOPSIS ๐
use Net::Amazon::EC2;
my $ec2 = Net::Amazon::EC2->new(
AWSAccessKeyId => 'PUBLIC_KEY_HERE',
SecretAccessKey => 'SECRET_KEY_HERE',
signature_version => 4,
);
# Start 1 new instance from AMI: ami-XXXXXXXX
my $instance = $ec2->run_instances(ImageId => 'ami-XXXXXXXX', MinCount => 1, MaxCount => 1);
my $running_instances = $ec2->describe_instances;
foreach my $reservation (@$running_instances) {
foreach my $instance ($reservation->instances_set) {
print $instance->instance_id . "\n";
}
}
my $instance_id = $instance->instances_set->[0]->instance_id;
print "$instance_id\n";
# Terminate instance
my $result = $ec2->terminate_instances(InstanceId => $instance_id);
If an error occurs while communicating with EC2, these methods will throw a Net::Amazon::EC2::Errors exception. ๐ญ
๐ธ DESCRIPTION ๐ธ
This module is a Perl interface to Amazon's Elastic Compute Cloud. It uses the Query API to communicate with Amazon's Web Services framework. fr fr, that's the whole plot. โจ
๐ CLASS METHODS ๐
new(%params)
This is the constructor, bestie โ it returns you a Net::Amazon::EC2 object to work with. It takes these parameters:
AWSAccessKeyIdโ required, unless an IAM role is present. Your AWS access key. For info on IAM roles, seehttp://docs.aws.amazon.com/AWSEC2/latest/UserGuide/UsingIAM.html#UsingIAMrolesWithAmazonEC2Instances.SecretAccessKeyโ required, unless an IAM role is present. Your secret key. WARNING! don't give this out or someone will be able to use your account and incur charges on your behalf. ๐จSecurityTokenโ optional. When using temporary credentials from STS, the Security Token must be passed in along with the temporaryAWSAccessKeyIdandSecretAccessKey. The most common case is when using IAM credentials with the addition of MFA (multi-factor authentication). Seehttp://docs.aws.amazon.com/STS/latest/UsingSTS/Welcome.html.regionโ optional. The region to run the API requests through. Defaults tous-east-1.sslโ optional. If set to a true value, thebase_urlwill usehttps://instead ofhttp://. Settingbase_urlexplicitly will override this. Defaults to true as of 0.22.debugโ optional. A flag to turn on debugging. Among other useful things, it will make the failing api calls print a stack trace. It is turned off by default.return_errorsโ optional. Previously,Net::Amazon::EC2would return aNet::Amazon::EC2::Errorsobject when it encountered an error condition. As of 0.19, this object is thrown as an exception usingcroakorconfessdepending on if thedebugflag is set. If you want/need the old behavior, set this attribute to a true value.
๐ฆ OBJECT METHODS ๐ฆ
allocate_address()
Acquires an elastic IP address which can be associated with an EC2-classic instance to create a movable static IP. Takes no arguments. Returns the IP address obtained. ๐
allocate_vpc_address()
Acquires an elastic IP address which can be associated with a VPC instance to create a movable static IP. Takes no arguments. Returns the allocationId of the allocated address.
associate_address(%params)
Associates an elastic IP address with an instance. It takes the following arguments:
InstanceIdโ required. The instance id you wish to associate the IP address with.PublicIpโ optional. The IP address. Used for allocating addresses to EC2-classic instances.AllocationIdโ optional. The allocation ID. Used for allocating address to VPC instances.
Returns true if the association succeeded. โจ
attach_volume(%params)
Attach a volume to an instance. ๐ง
VolumeIdโ required. The volume id you wish to attach.InstanceIdโ required. The instance id you wish to attach the volume to.Deviceโ required. The device id you want the volume attached as.
Returns a Net::Amazon::EC2::Attachment object containing the resulting volume status.
authorize_security_group_ingress(%params)
This method adds permissions to a security group. It takes the following parameters:
GroupNameโ required. The name of the group to add security rules to.SourceSecurityGroupNameโ required when authorizing a user and group together. Name of the group to add access for.SourceSecurityGroupOwnerIdโ required when authorizing a user and group together. Owner of the group to add access for.IpProtocolโ required when adding access for a CIDR. IP Protocol of the rule you are adding access for (TCP, UDP, or ICMP).FromPortโ required when adding access for a CIDR. Beginning of port range to add access for.ToPortโ required when adding access for a CIDR. End of port range to add access for.CidrIpโ required when adding access for a CIDR. The CIDR IP space we are adding access for.
Adding a rule can be done in two ways: adding a source group name + source group owner id, or, CIDR IP range. Both methods allow IP protocol, from port and to port specifications.
Returns 1 if rule is added successfully.
bundle_instance(%params)
Bundles the Windows instance. This procedure is not applicable for Linux and UNIX instances.
NOTE NOTE NOTE This is not well tested as I don't run windows instances. ๐ญ
InstanceIdโ required. The ID of the instance to bundle.Storage.S3.Bucketโ required. The bucket in which to store the AMI. You can specify a bucket that you already own or a new bucket that Amazon EC2 creates on your behalf. If you specify a bucket that belongs to someone else, Amazon EC2 returns an error.Storage.S3.Prefixโ required. Specifies the beginning of the file name of the AMI.Storage.S3.AWSAccessKeyIdโ required. The Access Key ID of the owner of the Amazon S3 bucket.Storage.S3.UploadPolicyโ required. An Amazon S3 upload policy that gives Amazon EC2 permission to upload items into Amazon S3 on the user's behalf.Storage.S3.UploadPolicySignatureโ required. The signature of the Base64 encoded JSON document.
JSON Parameters: (all are required)
expirationโ The expiration of the policy. Amazon recommends 12 hours or longer.conditionsโ A list of restrictions on what can be uploaded to Amazon S3. Must contain thebucketand ACL conditions in this table.bucketโ The bucket to store the AMI.aclโ This must be set toec2-bundle-read.
Returns a Net::Amazon::EC2::BundleInstanceResponse object.
cancel_bundle_task(%params)
Cancels the bundle task. This procedure is not applicable for Linux and UNIX instances.
BundleIdโ required. The ID of the bundle task to cancel.
Returns a Net::Amazon::EC2::BundleInstanceResponse object.
confirm_product_instance(%params)
Checks to see if the product code passed in is attached to the instance id, taking the following parameter:
ProductCodeโ required. The Product Code to check.InstanceIdโ required. The Instance Id to check.
Returns a Net::Amazon::EC2::ConfirmProductInstanceResponse object.
create_image(%params)
Creates an AMI that uses an Amazon EBS root device from a "running" or "stopped" instance.
AMIs that use an Amazon EBS root device boot faster than AMIs that use instance stores. They can be up to 1 TiB in size, use storage that persists on instance failure, and can be stopped and started.
InstanceIdโ required. The ID of the instance.Nameโ required. The name of the AMI that was provided during image creation.
Note that the image name has the following constraints:
3-128 alphanumeric characters, parenthesis, commas, slashes, dashes, or underscores.
Descriptionโ optional. The description of the AMI that was provided during image creation.NoRebootโ optional. By default this property is set tofalse, which means Amazon EC2 attempts to cleanly shut down the instance before image creation and reboots the instance afterwards. When set totrue, Amazon EC2 does not shut down the instance before creating the image. When this option is used, file system integrity on the created image cannot be guaranteed. โ ๏ธBlockDeviceMappingโ optional. Array ref of the device names exposed to the instance.
You can specify device names as '<device>=<block_device>' similar to ec2-create-image command. (http://docs.aws.amazon.com/AWSEC2/latest/CommandLineReference/ApiReference-cmd-CreateImage.html)
BlockDeviceMapping => [
'/dev/sda=:256:true:standard',
'/dev/sdb=none',
'/dev/sdc=ephemeral0',
'/dev/sdd=ephemeral1',
],
Returns the ID of the AMI created.
create_key_pair(%params)
Creates a new 2048 bit key pair, taking the following parameter:
KeyNameโ required. A name for this key. Should be unique.
Returns a Net::Amazon::EC2::KeyPair object.
create_security_group(%params)
This method creates a new security group. It takes the following parameters:
GroupNameโ required. The name of the new group to create.GroupDescriptionโ required. A short description of the new group.
Returns 1 if the group creation succeeds.
create_snapshot(%params)
Create a snapshot of a volume. It takes the following arguments:
VolumeIdโ required. The volume id of the volume you want to take a snapshot of.Descriptionโ optional. Description of the Amazon EBS snapshot.
Returns a Net::Amazon::EC2::Snapshot object of the newly created snapshot.
create_tags(%params)
Creates tags. ๐ท๏ธ
ResourceIdโ required. The ID of the resource to create tags. Can be a scalar or arrayref.Tagsโ required. Hashref where keys and values will be set on all resources given in the first element.
Returns true if the tag creation succeeded.
create_volume(%params)
Creates a volume.
Sizeโ required. The size in GiB ( 1024^3 ) of the volume you want to create.SnapshotIdโ optional. The optional snapshot id to create the volume from. The volume must be equal or larger than the snapshot it was created from.AvailabilityZoneโ required. The availability zone to create the volume in.VolumeTypeโ optional. The volume type:'standard','gp2', or'io1'. Defaults to'standard'.
Iops (required if VolumeType is 'io1')
The number of I/O operations per second (IOPS) that the volume supports. It's capped at 30 times the volume size, with an absolute max of 4000. And bestie, those numbers are very likely to change in the future, so don't hardcode them in your soul.
Required when the volume type is io1; not used otherwise. Like, if you're not on io1, this field is just sitting there uninvited. ๐
Encrypted (optional)
Encrypt the volume. EBS encrypted volumes get encrypted on the host using AWS managed keys. Only some instance types support encrypted volumes. And at the time of writing โ this is a real caveat, pay attention โ encrypted volumes are not supported for boot volumes. ๐ญ
Returns a Net::Amazon::EC2::Volume object containing the resulting volume status.
delete_key_pair(%params)
Deletes a keypair. Slay, goodbye keypair. Takes this one parameter:
KeyName(required) โ the name of the key you're yeeting.
Returns 1 if the key was successfully deleted. ๐
delete_security_group(%params)
Deletes a security group. Takes this parameter:
GroupName(required) โ the name of the security group you want gone.
Returns 1 if the delete succeeded.
delete_snapshot(%params)
Deletes the snapshots you pass in. Arguments:
SnapshotId(required) โ pass in a snapshot id and the corresponding snapshot gets deleted. Periodt.
Returns true if the deleting succeeded.
delete_volume(%params)
Delete a volume. Simple as that.
VolumeId(required) โ the volume id you wish to delete.
Returns true if the deleting succeeded.
delete_tags(%params)
Delete tags. Untagging is self-care. ๐
ResourceId(required) โ the ID of the resource to delete tags from.Tag.Key(required) โ key for a tag, may pass in a scalar or arrayref.Tag.Value(required) โ value for a tag, may pass in a scalar or arrayref.
Returns true if the releasing succeeded.
deregister_image(%params)
This one deregisters an AMI. Takes this parameter:
ImageId(required) โ the image id of the AMI you want to deregister.
Returns 1 if the deregistering succeeded. ๐
describe_addresses(%params)
Describes the elastic addresses currently allocated, plus any instances associated with them. Arguments:
PublicIp(optional) โ the IP address to describe. Can be either a scalar or an array ref.
Returns an array ref of Net::Amazon::EC2::DescribeAddress objects.
describe_availability_zones(%params)
Describes the availability zones you currently have to choose from. Arguments:
ZoneName(optional) โ the zone name to describe. Can be either a scalar or an array ref.
Returns an array ref of Net::Amazon::EC2::AvailabilityZone objects.
describe_bundle_tasks(%params)
Describes current bundling tasks. Heads up: this procedure is not applicable for Linux and UNIX instances. ๐ซ
BundleId(optional) โ the optional ID of the bundle task to describe.
Returns an array ref of Net::Amazon::EC2::BundleInstanceResponse objects.
describe_image_attributes(%params)
Pulls a list of attributes for the image id you specify.
ImageId(required) โ a scalar containing the image you want the list of attributes for.Attribute(required) โ a scalar containing the attribute to describe.
Valid attributes are:
launchPermissionโ the AMIs launch permissions.ImageIdโ ID of the AMI for which an attribute will be described.productCodesโ the product code attached to the AMI.kernelโ describes the ID of the kernel associated with the AMI.ramdiskโ describes the ID of RAM disk associated with the AMI.blockDeviceMappingโ defines native device names to use when exposing virtual devices.platformโ describes the operating system platform.
Returns a Net::Amazon::EC2::DescribeImageAttribute object.
โ ๏ธ NOTE: There is currently a bug in Amazon's SOAP and Query API โ when you try to describe the attributeskernel,ramdisk,blockDeviceMapping, orplatform, AWS returns an invalid response. No response yet from Amazon on an ETA for getting that bug fixed. So likeโฆ not our fault, not our problem, but definitely our problem. ๐
describe_images(%params)
Pulls a list of the AMIs that can be run. You can narrow that list down by passing in some of these parameters:
ImageId(optional) โ either a scalar or an array ref; passing it means just these AMIs get 'described'.Owner(optional) โ either a scalar or an array ref; passing it means AMIs owned by theOwner(s) you provide get 'described'. Pass either account ids, or'amazon'for all amazon-owned AMIs, or'self'for your own AMIs.ExecutableBy(optional) โ either a scalar or an array ref; passing it means AMIs executable by the account id(s) specified get 'described'. Or'self'for your own AMIs.
Returns an array ref of Net::Amazon::EC2::DescribeImagesResponse objects.
describe_instances(%params)
Pulls a list of the instances which are running, or which were just running. Narrow it down with these:
InstanceId(optional) โ either a scalar or an array ref; passing it means just these instances get 'described'.Filter(optional) โ the filters so only matching instances get 'described'. A filter tuple is an arrayref consisting of one key and one or more values. This option takes one filter tuple, or an arrayref of multiple filter tuples.
Returns an array ref of Net::Amazon::EC2::ReservationInfo objects.
describe_instance_status(%params)
Pulls a list of instances based on some status filter. Modify the list with these:
InstanceId(optional) โ either a scalar or an array ref; passing it means just these instances get 'described'.Filter(optional) โ the filters so only matching instances get 'described'. A filter tuple is an arrayref consisting of one key and one or more values. This option takes one filter tuple, or an arrayref of multiple filter tuples.
Returns an array ref of Net::Amazon::EC2::InstanceStatuses objects.
_create_describe_instance_status(%instanceElement)
Returns a blessed object. Used internally for wrapping describe_instance_status nextToken calls โ so like, that leading underscore? Yeah, that's the "do not touch, this is backstage" underscore. ๐
InstanceStatusElement(required) โ the instance status element we want to build out and return.
Returns a Net::Amazon::EC2::InstanceStatuses object.
describe_instance_attribute(%params)
Returns info about an attribute of an instance. Only one attribute can be specified per call โ no bundling, bestie, one at a time. โจ
InstanceId(required) โ the instance id whose attributes we want to describe.Attribute(required) โ the attribute we want to describe. Valid values are:instanceTypekernelramdiskuserDatadisableApiTerminationebsOptimizedinstanceInitiatedShutdownBehaviorrootDeviceNamesourceDestCheckblockDeviceMapping
Returns a Net::Amazon::EC2::DescribeInstanceAttributeResponse object.
describe_key_pairs(%params)
Describes the keypairs available on this account. Takes this parameter:
KeyName(optional) โ the name of the key to be described. Can be either a scalar or an array ref.
Returns an array ref of Net::Amazon::EC2::DescribeKeyPairsResponse objects.
describe_regions(%params)
Describes the EC2 regions that are currently available to launch instances in for this account. ๐
RegionName(optional) โ the name of the region(s) to be described. Can be either a scalar or an array ref.
Returns an array ref of Net::Amazon::EC2::Region objects.
describe_reserved_instances(%params)
Describes the Reserved Instances that you purchased. Look at you, planning ahead. ๐
ReservedInstancesId(optional) โ the reserved instance id(s) to be described. Can be either a scalar or an array ref.
Returns an array ref of Net::Amazon::EC2::ReservedInstance objects.
describe_reserved_instances_offerings(%params)
Describes the Reserved Instance offerings that are available for purchase. With Amazon EC2 Reserved Instances, you purchase the right to launch Amazon EC2 instances for a period of time โ and the whole point is you do it without getting insufficient capacity errors, plus you pay a lower usage rate for the actual time used. It's giving "pay now, vibe later". ๐ธ
ReservedInstancesOfferingId(optional) โ ID of the Reserved Instances to describe.InstanceType(optional) โ the instance type. The default ism1.small. Amazon frequently updates their instance types. Seehttp://aws.amazon.com/ec2/instance-typesAvailabilityZone(optional) โ the Availability Zone in which the Reserved Instance can be used.ProductDescription(optional) โ the Reserved Instance description.
Returns an array ref of Net::Amazon::EC2::ReservedInstanceOffering objects.
describe_security_groups(%params)
Describes the security groups available to this account. Takes these parameters:
GroupName(optional) โ the name of the security group(s) to be described. Can be either a scalar or an array ref.GroupId(optional) โ the id of the security group(s) to be described. Can be either a scalar or an array ref.
Returns an array ref of Net::Amazon::EC2::SecurityGroup objects.
describe_snapshot_attribute(%params)
Describes the snapshot attributes related to the snapshot in question. Arguments:
SnapshotId(optional) โ either a scalar or an array ref of snapshot id's. If this isn't passed in, it will describe the attributes of all the current snapshots.Attribute(required) โ the attribute to describe. Currently the only valid attribute iscreateVolumePermission.
Returns a Net::Amazon::EC2::SnapshotAttribute object.
describe_snapshots(%params)
Describes the snapshots available to the user. Arguments:
SnapshotId(optional) โ either a scalar or an array ref of snapshot id's. If this isn't passed in, it will describe all the current snapshots.Owner(optional) โ the owner of the snapshot.RestorableBy(optional) โ a user who can create volumes from the snapshot.Filter(optional) โ the filters so only matching snapshots get 'described'. A filter tuple is an arrayref consisting of one key and one or more values. This option takes one filter tuple, or an arrayref of multiple filter tuples.
Returns an array ref of Net::Amazon::EC2::Snapshot objects.
describe_volumes(%params)
Describes the volumes currently created. It takes the following arguments:
VolumeId(optional) โ drop in either a single scalar or an array ref of volume ids. Skip it entirely and it'll just describe every volume you've got rn. ๐
Returns an array ref of Net::Amazon::EC2::Volume objects.
๐ describe_subnets(%params) ๐
This one spills the tea on the subnets chilling in this account. Params it wants:
SubnetId(optional) โ the id of the subnet you wanna describe. Scalar or array ref, dealer's choice. โจFilter.Name(optional) โ the name of theFilter.Nameto be described. Can be a scalar or an array ref. Peep http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeSubnets.html for the filters that actually exist, iykyk.Filter.Value(optional) โ the name of theFilter.Valueto be described. Scalar or array ref, either one. ๐ฆ
Returns an array ref of Net::Amazon::EC2::DescribeSubnetResponse objects.
๐ describe_tags(%params) ๐
Describes the tags available on this account. Just one param bestie:
Filter.Name(optional) โ the name of theFilter.Nameto be described. Scalar or array ref, you pick.Filter.Value(optional) โ the name of theFilter.Valueto be described. Scalar or array ref, no cap.
Returns an array ref of Net::Amazon::EC2::DescribeTags objects.
๐
detach_volume(%params) ๐
Detach a volume from an instance. It's giving "we're breaking up." ๐ญ
VolumeId(required) โ the volume id you wish to detach.InstanceId(optional) โ the instance id you wish to detach from.Device(optional) โ the device the volume was attached as.Force(optional) โ a boolean for if to forcibly detach the volume from the instance.
โ ๏ธ WARNING: This can lead to data loss or a corrupted file system. Use this option only as a last resort to detach a volume from a failed instance. The instance will not have an opportunity to flush file system caches nor file system meta data. โ ๏ธ
Returns a Net::Amazon::EC2::Attachment object containing the resulting volume status.
๐ธ disassociate_address(%params) ๐ธ
Disassociates an elastic IP address with an instance. It takes the following arguments:
PublicIp(conditional) โ the IP address to disassociate, mandatory to remove an IP from a EC2-classic instance.AssociationId(conditional) โ the Association ID of an IP address, mandatory to remove an IP from a VPC instance.
Returns true if the disassociation succeeded. ๐ซถ
โญ get_console_output(%params) โญ
Gets the output from the virtual console for an instance. Params:
InstanceId(required) โ a scalar containing a instance id.
Returns a Net::Amazon::EC2::ConsoleOutput object or "undef" if there is no new output. (This can happen in cases where the console output has not changed since the last call.) ๐
๐ get_password_data(%params) ๐
Retrieves the encrypted administrator password for the instances running Windows. Heads up: this procedure is not applicable for Linux and UNIX instances. ๐
InstanceId(required) โ the Instance Id for which to retrieve the password.
Returns a Net::Amazon::EC2::InstancePassword object.
โจ modify_image_attribute(%params) โจ
Modifies attributes of an machine image. Main character energy fr.
ImageId(required) โ the AMI to modify the attributes of.Attribute(required) โ the attribute you wish to modify. Right now the attributes you can modify arelaunchPermissionandproductCodes.OperationType(required forlaunchPermission) โ the operation you wish to perform on the attribute. Right now just'add'and'remove'are supported.UserId(required forlaunchPermission) โ user Id's you wish to add/remove from the attribute.UserGroup(required forlaunchPermission) โ groups you wish to add/remove from the attribute. Currently there is only one User Group available:'all'for all Amazon EC2 customers.ProductCode(required forproductCodes) โ attaches a product code to the AMI. Currently only one product code can be assigned to the AMI. Once this is set it cannot be changed or reset. ๐
Returns 1 if the modification succeeds.
๐ modify_instance_attribute(%params) ๐
Modify an attribute of an instance. So specific, love that for us.
InstanceId(required) โ the instance id we want to modify the attributes of.Attribute(required) โ the attribute we want to modify. Valid values are:instanceTypekernelramdiskuserDatadisableApiTerminationinstanceInitiatedShutdownBehaviorrootDeviceNameblockDeviceMapping
Value(required) โ the value to set the attribute to.
You may also pass a hashref with one or more keys and values. This hashref will be flattened and passed to AWS.
For example:
$ec2->modify_instance_attribute(
'InstanceId' => $id,
'Attribute' => 'blockDeviceMapping',
'Value' => {
'BlockDeviceMapping.1.DeviceName' => '/dev/sdf1',
'BlockDeviceMapping.1.Ebs.DeleteOnTermination' => 'true',
}
);
Returns 1 if the modification succeeds.
๐ง modify_snapshot_attribute(%params) ๐ง
Modifies attributes of a snapshot. Snapshot glow-up โจ
SnapshotId(required) โ the snapshot id to modify the attributes of.UserId(optional) โ user Id you wish to add/remove create volume permissions for.UserGroup(optional) โ user Id you wish to add/remove create volume permissions for. To make the snapshot createable by all set theUserGroupto"all".Attribute(required) โ the attribute you wish to modify. Right now the only attribute you can modify is"CreateVolumePermission".OperationType(required) โ the operation you wish to perform on the attribute. Right now just'add'and'remove'are supported.
Returns 1 if the modification succeeds.
๐ฅ monitor_instances(%params) ๐ฅ
Enables monitoring for a running instance. For more information, refer to the Amazon CloudWatch Developer Guide. ๐
InstanceId(required) โ the instance id(s) to monitor. Can be a scalar or an array ref.
Returns an array ref of Net::Amazon::EC2::MonitoredInstance objects.
๐ purchase_reserved_instances_offering(%params) ๐
Purchases a Reserved Instance for use with your account. With Amazon EC2 Reserved Instances, you purchase the right to launch Amazon EC2 instances for a period of time (without getting insufficient capacity errors) and pay a lower usage rate for the actual time used. It's literally the subscription plan of AWS. ๐ธ
ReservedInstancesOfferingId(required) โ ID of the Reserved Instances to describe. Can be either a scalar or an array ref.InstanceCount(optional) โ the number of Reserved Instances to purchase (default is1). Can be either a scalar or an array ref.
๐ข NOTE NOTE NOTE, the array ref needs to line up with the InstanceCount if you want to pass that in, so that the right number of instances are started of the right instance offering. Don't play yourself bestie. ๐ญ
Returns 1 if the reservations succeeded.
๐ reboot_instances(%params) ๐
Reboots an instance. Have you tried turning it off and on again ๐
InstanceId(required) โ instance Id of the instance you wish to reboot. Can be either a scalar or array ref of instances to reboot.
Returns 1 if the reboot succeeded.
๐ฆ register_image(%params) ๐ฆ
Registers an AMI on the EC2. Params:
ImageLocation(optional) โ the location of the AMI manifest on S3.Name(required) โ the name of the AMI that was provided during image creation.Description(optional) โ the description of the AMI.Architecture(optional) โ the architecture of the image. Eitheri386orx86_64.KernelId(optional) โ the ID of the kernel to select.RamdiskId(optional) โ the ID of the RAM disk to select. Some kernels require additional drivers at launch.RootDeviceName(optional) โ the root device name (e.g.,/dev/sda1).BlockDeviceMapping(optional) โ this needs to be a data structure like this:
[
{
deviceName => "/dev/sdh", (optional)
virtualName => "ephemerel0", (optional)
noDevice => "/dev/sdl", (optional),
ebs => {
snapshotId => "snap-0000", (optional)
volumeSize => "20", (optional)
deleteOnTermination => "false", (optional)
},
},
...
]
Returns the image id of the new image on EC2. ๐
โญ release_address(%params) โญ
Releases an allocated IP address. It takes the following arguments:
PublicIp(required) โ the IP address to release.
Returns true if the releasing succeeded. Bye bye IP ๐ซถ
๐ reset_image_attribute(%params) ๐
Resets an attribute for an AMI to its default state (NOTE: product codes cannot be reset). Params:
ImageId(required) โ the image id of the AMI you wish to reset the attributes on.Attribute(required) โ the attribute you want to reset.
Returns 1 if the attribute reset succeeds.
โจ reset_instance_attribute(%params) โจ
Reset an attribute of an instance. Only one attribute can be specified per call, so don't get greedy. ๐
InstanceId(required) โ the instance id we want to reset the attributes of.Attribute(required) โ the attribute we want to reset. Valid values are:kernelramdisk
Returns 1 if the reset succeeds.
๐ธ reset_snapshot_attribute(%params) ๐ธ
Resets an attribute for an snapshot to its default state. It takes the following parameters:
SnapshotId(required) โ the snapshot id of the snapshot you wish to reset the attributes on.Attribute(required) โ the attribute you want to reset (currently"CreateVolumePermission"is the only valid attribute).
Returns 1 if the attribute reset succeeds.
๐ฅ revoke_security_group_ingress(%params) ๐ฅ
Revokes permissions to a security group. It takes the following parameters:
GroupName(required) โ the name of the group to revoke security rules from.SourceSecurityGroupName(required when revoking a user and group together) โ name of the group to revoke access from.SourceSecurityGroupOwnerId(required when revoking a user and group together) โ owner of the group to revoke access from.IpProtocol(required when revoking access from a CIDR) โ the IP protocol of the rule you're revoking access from. It's giving TCP, UDP, or ICMP ๐FromPort(required when revoking access from a CIDR) โ where the port range starts for the access you're revoking. ๐ToPort(required when revoking access from a CIDR) โ where the port range ends for the access you're revoking. โจCidrIp(required when revoking access from a CIDR) โ the CIDR IP space you're revoking access from. ๐ธ
Revoking a rule can be done in two ways: revoking a source group name + source group owner id, or, by Protocol + start port + end port + CIDR IP. The two are mutually exclusive. ๐
Returns 1 if rule is revoked successfully. โ
๐ run_instances(%params) ๐
okay so this method starts instance(s) of AMIs on EC2. The params tell it which AMI to spin up and how many / what properties they have:
ImageId(required) โ the image id you want to start an instance of. ๐ผ๏ธMinCount(required) โ the minimum number of instances to start. ๐ขMaxCount(required) โ the maximum number of instances to start. ๐ขKeyName(optional) โ the keypair name to associate this instance with. If omitted, it'll use your default keypair. ๐SecurityGroup(optional) โ a scalar or array ref. Will associate this instance with the group names passed in. If omitted, it'll be associated with the default security group. ๐ก๏ธSecurityGroupId(optional) โ a scalar or array ref. Will associate this instance with the group ids passed in. If omitted, it'll be associated with the default security group. ๐ก๏ธAdditionalInfo(optional) โ specifies additional information to make available to the instance(s). ๐UserData(optional) โ optional data to pass into the instance being started. Needs to be base64 encoded. ๐InstanceType(optional) โ specifies the type of instance to start. Seehttp://aws.amazon.com/ec2/instance-typesfor the full vibe. The options are:m1.small(default) โ 1 EC2 Compute Unit (1 virtual core with 1 EC2 Compute Unit). 32-bit or 64-bit, 1.7GB RAM, 160GB disk ๐m1.mediumMedium Instance โ 2 EC2 Compute Units (1 virtual core with 2 EC2 Compute Unit), 32-bit or 64-bit, 3.75GB RAM, 410GB disk ๐m1.large: Standard Large Instance โ 4 EC2 Compute Units (2 virtual cores with 2 EC2 Compute Units each). 64-bit, 7.5GB RAM, 850GB disk โจm1.xlarge: Standard Extra Large Instance โ 8 EC2 Compute Units (4 virtual cores with 2 EC2 Compute Units each). 64-bit, 15GB RAM, 1690GB disk ๐ซt1.microMicro Instance โ Up to 2 EC2 Compute Units (for short periodic bursts), 32-bit or 64-bit, 613MB RAM, EBS storage only ๐c1.medium: High-CPU Medium Instance โ 5 EC2 Compute Units (2 virtual cores with 2.5 EC2 Compute Units each). 32-bit or 64-bit, 1.7GB RAM, 350GB disk ๐ฅc1.xlarge: High-CPU Extra Large Instance โ 20 EC2 Compute Units (8 virtual cores with 2.5 EC2 Compute Units each). 64-bit, 7GB RAM, 1690GB disk ๐ฅm2.2xlargeHigh-Memory Double Extra Large Instance โ 13 EC2 Compute Units (4 virtual cores with 3.25 EC2 Compute Units each). 64-bit, 34.2GB RAM, 850GB disk ๐งm2.4xlargeHigh-Memory Quadruple Extra Large Instance โ 26 EC2 Compute Units (8 virtual cores with 3.25 EC2 Compute Units each). 64-bit, 68.4GB RAM, 1690GB disk ๐งcc1.4xlargeCluster Compute Quadruple Extra Large Instance โ 33.5 EC2 Compute Units (2 x Intel Xeon X5570, quad-core "Nehalem" architecture), 64-bit, 23GB RAM, 1690GB disk, 10Gbit Ethernet ๐ฅ๏ธcc1.8xlargeCluster Compute Eight Extra Large Instance โ 88 EC2 Compute Units (2 x Intel Xeon E5-2670, eight-core "Sandy Bridge" architecture), 64-bit, 60.5GB RAM, 3370GB disk, 10Gbit Ethernet ๐ฅ๏ธcg1.4xlargeCluster GPU Quadruple Extra Large Instance โ 33.5 EC2 Compute Units (2 x Intel Xeon X5570, quad-core "Nehalem" architecture), 64-bit, 22GB RAM 1690GB disk, 10Gbit Ethernet, 2 x NVIDIA Tesla "Fermi" M2050 GPUs ๐ฎhi1.4xlargeHigh I/O Quadruple Extra Large Instance โ 35 EC2 Compute Units (16 virtual cores), 60.5GB RAM, 64-bit, 2 x 1024GB SSD disk, 10Gbit Ethernet โก
Placement.AvailabilityZone(optional) โ the availability zone you want to run the instance in. ๐KernelId(optional) โ the id of the kernel you want to launch the instance with. ๐งRamdiskId(optional) โ the id of the ramdisk you want to launch the instance with. ๐พBlockDeviceMapping.VirtualName(optional) โ this is the virtual name for a blocked device to be attached, may pass in a scalar or arrayref. ๐BlockDeviceMapping.DeviceName(optional) โ this is the device name for a block device to be attached, may pass in a scalar or arrayref. ๐ฝBlockDeviceMapping.Ebs.VolumeSize(optional) โ specifies the size of the root block device as an integer (GB). If used, required thatBlockDeviceMapping.DeviceNamealso be specified. One may pass in a scalar or arrayref. This parameter will override the disk size settings implied by theInstanceType, if used. ๐
Additional volume related parameters include:
BlockDeviceMapping.Ebs.SnapshotIdโ May pass in a scalar or arrayref. ๐ธBlockDeviceMapping.Ebs.VolumeTypeโ May pass in a scalar or arrayref. ๐๏ธBlockDeviceMapping.Ebs.DeleteOnTerminationโ May pass in a scalar or arrayref. ๐๏ธ
Encoding(optional) โ the encoding. ๐คVersion(optional) โ the version. ๐ขMonitoring.Enabled(optional) โ enables monitoring for this instance. ๐SubnetId(optional) โ specifies the subnet ID within which to launch the instance(s) for Amazon Virtual Private Cloud. ๐ClientToken(optional) โ specifies the idempotent instance id. ๐๏ธEbsOptimized(optional) โ whether the instance is optimized for EBS I/O. โกPrivateIpAddress(optional) โ specifies the private IP address to use when launching an Amazon VPC instance. ๐IamInstanceProfile.Name(optional) โ specifies the IAM profile to associate with the launched instance(s). This is the name of the role. ๐คIamInstanceProfile.Arn(optional) โ specifies the IAM profile to associate with the launched instance(s). This is the ARN of the profile. ๐
Returns a Net::Amazon::EC2::ReservationInfo object. ๐ฆ
๐ข start_instances(%params) ๐ข
Starts an instance that uses an Amazon EBS volume as its root device. ๐ฝ
InstanceId(required) โ Either a scalar or an array ref can be passed in (containing instance ids to be started). ๐
Returns an array ref of Net::Amazon::EC2::InstanceStateChange objects. ๐
โน๏ธ stop_instances(%params) โน๏ธ
Stops an instance that uses an Amazon EBS volume as its root device. ๐ฝ
InstanceId(required) โ Either a scalar or an array ref can be passed in (containing instance ids to be stopped). ๐Force(optional) โ If set to true, forces the instance to stop. The instance will not have an opportunity to flush file system caches nor file system meta data. If you use this option, you must perform file system check and repair procedures. This option is not recommended for Windows instances. ๐จ
The default is false. โ
Returns an array ref of Net::Amazon::EC2::InstanceStateChange objects. ๐
๐ terminate_instances(%params) ๐
This method shuts down instance(s) passed into it. It takes the following parameter:
InstanceId(required) โ Either a scalar or an array ref can be passed in (containing instance ids). ๐
Returns an array ref of Net::Amazon::EC2::InstanceStateChange objects. ๐
๐ unmonitor_instances(%params) ๐
Disables monitoring for a running instance. For more information, refer to the Amazon CloudWatch Developer Guide. ๐
InstanceId(required) โ The instance id(s) to monitor. Can be a scalar or an array ref. ๐
Returns an array ref of Net::Amazon::EC2::MonitoredInstance objects. ๐
โจ TESTING โจ
Set AWS_ACCESS_KEY_ID and SECRET_ACCESS_KEY environment variables to run the live tests. ๐ Note: because the live tests start an instance (and kill it) in both the tests and backwards compat tests there will be 2 hours of machine instance usage charges (since there are 2 instances started) which as of February 1st, 2010 costs a total of $0.17 USD ๐ธ
Important note about the windows-only methods. These have not been well tested as I do not run windows-based instances, so exercise caution in using these. โ ๏ธ
๐ BUGS ๐
Please report any bugs or feature requests to bug-net-amazon-ec2 at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net-Amazon-EC2. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. ๐ซถ
๐ AUTHOR ๐
Jeff Kim cpan@chosec.com ๐
๐ CONTRIBUTORS ๐
John McCullough and others as listed in the Changelog ๐
๐ ๏ธ MAINTAINER ๐ ๏ธ
The current maintainer is Mark Allen "<mallen@cpan.org>" ๐
ยฉ๏ธ COPYRIGHT ยฉ๏ธ
Copyright (c) 2006-2010 Jeff Kim. ๐
Copyright (c) 2012 Mark Allen. ๐
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. ๐ช
๐ SEE ALSO ๐
Amazon EC2 API: http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ โ๏ธ
This page was served fresh by perl v5.36.0 on 2022-12-06, and it's Net::Amazon::EC2(3pm). Stay slaying, bestie ๐โจ
๐ฆ where this page comes from
- debian bookworm: libnet-amazon-ec2-perl 0.36-2 ยท Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libnet-amazon-ec2-perl 0.36-2 ยท Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libnet-amazon-ec2-perl 0.36-2 ยท Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libnet-amazon-ec2-perl 0.36-2 ยท Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libnet-amazon-ec2-perl 0.36-2 ยท Artistic-1.0-Perl 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