VM::EC...stance(3pm)
β¨ NAME β¨
VM::EC2::REST::spot_instance β okay so this is the one that lets you request spot instances and manipulate spot datafeed subscriptions π―πΈ
β¨ SYNOPSIS β¨
use VM::EC2 ':misc';
β¨ METHODS β¨
These methods are your whole little toolkit for requesting spot instances and wrangling spot datafeed subscriptions. bestie, they're so useful π
Implemented:
CancelSpotInstanceRequests
CreateSpotDatafeedSubscription
DeleteSpotDatafeedSubscription
DescribeSpotDatafeedSubscription
DescribeSpotInstanceRequests
DescribeSpotPriceHistory
RequestSpotInstances
Unimplemented:
(none)
Like, literally nothing is unimplemented. we ate that. π
$subscription = $ec2->create_spot_datafeed_subscription($bucket,$prefix) πͺ£β¨
This makes you a spot datafeed subscription. You hand it the name of an S3 bucket that's associated with your account, plus a prefix that gets appended to the files the datafeed writes. Spot instance usage logs get written into that bucket you asked for, prefixed with whatever prefix you wanted. cute, right?
If you don't specify a prefix, it defaults to "SPOT_DATAFEED_" β no cap.
On success, you get a VM::EC2::Spot::DatafeedSubscription object back π
Heads up bestie: only one datafeed is allowed per account. that's the rule, periodt.
$boolean = $ec2->delete_spot_datafeed_subscription() π
This deletes the current account's spot datafeed subscription, if there is one. It takes no arguments β it just does the thing.
On success, it returns true. slay.
$subscription = $ec2->describe_spot_datafeed_subscription() π
This describes the current account's spot datafeed subscription, if there is one. Takes no arguments, super low effort.
On success, you get a VM::EC2::Spot::DatafeedSubscription object back π«Ά
@spot_price_history = $ec2->describe_spot_price_history(@filters) ππΈ
This method applies whatever filters you give it to spot instances, and returns a list of instances, timestamps, and their price at the indicated time. Each spot price history point is represented as a VM::EC2::Spot::PriceHistory object. it's giving data β¨
Option arguments are:
-start_timeβ Start date and time of the desired history data, in the formyyyy-mm-ddThh:mm:ss(GMT). The PerlDateTimemodule provides a convenient way to create times in this format.-end_timeβ End date and time of the desired history data.-instance_typeβ The instance type, e.g."m1.small", can be a scalar value or an arrayref.-product_descriptionβ The product description. One of"Linux/UNIX","SUSE Linux"or"Windows". Can be a scalar value or an arrayref.-availability_zoneβ A single availability zone, such as"us-east-1a".-max_resultsβ Maximum number of rows to return in a single call.-next_tokenβ Specifies the next set of results to return; used internally.-filterβ Hashref containing additional filters to apply,
The following filters are recognized: "instance-type", "product-description", "spot-price", "timestamp", "availability-zone". The '*' and '?' wildcards can be used in filter values, but numeric comparison operations are not supported by the Amazon API. Note that wildcards are not generally allowed in the standard options. Hence if you wish to get spot price history in all availability zones in us-east, this will work:
$ec2->describe_spot_price_history(-filter=>{'availability-zone'=>'us-east*'})
but this will return an invalid parameter error:
$ec2->describe_spot_price_history(-availability_zone=>'us-east*')
If you specify -max_results, then the list of history objects returned may not represent the complete result set. In this case, the method more_spot_prices() will return true. You can then call describe_spot_price_history() repeatedly with no arguments in order to retrieve the remainder of the results. When there are no more results, more_spot_prices() will return false. it's giving pagination π
my @results = $ec2->describe_spot_price_history(-max_results => 20,
-instance_type => 'm1.small',
-availability_zone => 'us-east*',
-product_description=>'Linux/UNIX');
print_history(\@results);
while ($ec2->more_spot_prices) {
@results = $ec2->describe_spot_price_history
print_history(\@results);
}
@requests = $ec2->request_spot_instances(%args) ππ₯
This method will request one or more spot instances to be launched when the current spot instance run-hour price drops below a preset value and terminated when the spot instance run-hour price exceeds the value. it's a whole little deal-with-the-market situation, main character energy tbh
On success, will return a series of VM::EC2::Spot::InstanceRequest objects, one for each instance specified in -instance_count.
Required arguments:
-spot_priceβ The desired spot price, in USD.-image_idβ ID of an AMI to launch-instance_typeβ Type of the instance(s) to launch, such as"m1.small"
Optional arguments:
-instance_countβ Maximum number of instances to launch (default 1)-typeβ Spot instance request type; one of"one-time"or"persistent"-valid_fromβ Date/time the request becomes effective, in formatyyyy-mm-ddThh:mm:ss. Default is immediately.-valid_untilβ Date/time the request expires, in formatyyyy-mm-ddThh:mm:ss. Default is to remain in effect indefinitely.-launch_groupβ Name of the launch group. Instances in the same launch group are started and terminated together. Default is to launch instances independently.-availability_zone_groupβ If specified, all instances that are given the same zone group name will be launched into the same availability zone. This is independent of the-availability_zoneargument, which specifies a particular availability zone.-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.-availability_zoneβ The availability zone you want to launch the instance into. Call$ec2->regionsfor a list.-zoneβ Short version of-availability_aone.-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. Seerun_instances()for the syntax of this argument.-block_device_mappingβ Alias for-block_devices.-network_interfacesβ Same as the-network_interfacesoption inrun_instances().-monitoringβ Pass a true value to enable detailed monitoring.-subnetβ The ID of the Amazon VPC subnet in which to launch the spot instance (VPC only).-subnet_idβ deprecated-addressing_typeβ Deprecated and undocumented, but present in the current EC2 API documentation.-iam_arnβ The Amazon resource name (ARN) of the IAM Instance Profile (IIP) to associate with the instances.-iam_nameβ The name of the IAM instance profile (IIP) to associate with the instances.-ebs_optimizedβ If true, request an EBS-optimized instance (certain instance types only).
@requests = $ec2->cancel_spot_instance_requests(@request_ids) π
βοΈ
This method cancels the pending requests. It does not terminate any instances that are already running as a result of the requests. It returns a list of VM::EC2::Spot::InstanceRequest objects, whose fields will be unpopulated except for spotInstanceRequestId and state. so like, mostly empty little objects, but they did their job π
@requests = $ec2->describe_spot_instance_requests(@spot_instance_request_ids) π
@requests = $ec2->describe_spot_instance_requests(\%filters) π
@requests = $ec2->describe_spot_instance_requests(-spot_instance_request_id=>\@ids,-filter=>\%filters) π
This method will return information about current spot instance requests as a list of VM::EC2::Spot::InstanceRequest objects. bestie, three whole ways to call it, pick your fave π
Optional arguments:
-spot_instance_request_idβ Scalar or arrayref of request Ids.-filterβ Tags and other filters to apply.
There are many filters available, described fully at http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-ItemType-SpotInstanceRequestSetItemType.html:
availability-zone-groupcreate-timefault-codefault-messageinstance-idlaunch-grouplaunch.block-device-mapping.delete-on-terminationlaunch.block-device-mapping.device-namelaunch.block-device-mapping.snapshot-idlaunch.block-device-mapping.volume-sizelaunch.block-device-mapping.volume-typelaunch.group-idlaunch.image-idlaunch.instance-typelaunch.kernel-idlaunch.key-namelaunch.monitoring-enabledlaunch.ramdisk-idlaunch.network-interface.network-interface-idlaunch.network-interface.device-indexlaunch.network-interface.subnet-idlaunch.network-interface.descriptionlaunch.network-interface.private-ip-addresslaunch.network-interface.delete-on-terminationlaunch.network-interface.group-idlaunch.network-interface.group-namelaunch.network-interface.addresses.primaryproduct-descriptionspot-instance-request-idspot-pricestatestatus-codestatus-messagetag-keytag-valuetag:<key>typelaunched-availability-zonevalid-fromvalid-until
β¨ SEE ALSO β¨
VM::EC2
okay that's part 1, keep scrolling bestie, there's more π
π AUTHOR π
Bestie, this whole masterpiece was written by Lincoln Stein <lincoln.stein@gmail.com>. π Like, actual icon behavior. Put some respect on the name.
Copyright (c) 2011 Ontario Institute for Cancer Research β yep, that's the whole vibe, the legal stuff matters, don't skip it. π
π THE LEGAL TEA π
okay so here's the important part and I need you to actually read it, not just scroll past like it's a terms-of-service popup:
- 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
LICENSEfor the full license text. fr fr, go read it. - In addition, please see
DISCLAIMER.txtfor disclaimers of warranty. π«Ά (yes bestie, the warranty disclaimers are in their own little file, go peek)
no cap: pick your license, read theLICENSEfile, and checkDISCLAIMER.txtbefore you go doing anything wild. that's the whole assignment. π
and that's a wrap on this page, bestie!! ππ this doc came from perl v5.38.2, dated 2024-08-10, and it's living its best life as VM::EC...stance(3pm). go forth and request those spot instances, you absolute main character. πβ¨πΈ
π¦ 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