NAME VM::EC2::REST::spot_instance - Request spot instances and manipulate spot data feed subscriptions
SYNOPSIS
use VM::EC2 ':misc';
METHODS
These methods allow you to request spot instances and manipulate spot data feed subscriptions.
Implemented:
CancelSpotInstanceRequests
CreateSpotDatafeedSubscription
DeleteSpotDatafeedSubscription
DescribeSpotDatafeedSubscription
DescribeSpotInstanceRequests
DescribeSpotPriceHistory
RequestSpotInstances
Unimplemented:
(none)
$subscription = $ec2->create_spot_datafeed_subscription($bucket,$prefix)
This method creates a spot datafeed subscription. Provide the method with the name of an S3 bucket associated with your account, and a prefix to be appended to the files written by the datafeed. Spot instance usage logs will be written into the requested bucket, and prefixed with the desired prefix.
If no prefix is specified, it defaults to "SPOT_DATAFEED_";
On success, a VM::EC2::Spot::DatafeedSubscription object is returned;
Only one datafeed is allowed per account;
$boolean = $ec2->delete_spot_datafeed_subscription()
This method delete's the current account's spot datafeed subscription, if any. It takes no arguments.
On success, it returns true.
$subscription = $ec2->describe_spot_datafeed_subscription()
This method describes the current account's spot datafeed subscription, if any. It takes no arguments.
On success, a VM::EC2::Spot::DatafeedSubscription object is returned;
@spot_price_history = $ec2->describe_spot_price_history(@filters)
This method applies the specified filters 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.
Option arguments are:
-start_time Start date and time of the desired historydata, in the form yyyy-mm-ddThh:mm:ss (GMT).The Perl DateTime module provides a convenientway to create times in this format.-end_time End date and time of the desired historydata.-instance_type The instance type, e.g. "m1.small", can bea scalar value or an arrayref.-product_description The product description. One of "Linux/UNIX","SUSE Linux" or "Windows". Can be a scalar valueor an arrayref.-availability_zone A single availability zone, such as "us-east-1a".-max_results Maximum number of rows to return in a singlecall.-next_token Specifies the next set of results to return; usedinternally.-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.
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_historyprint_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.
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 ineffect indefinitely.-launch_group Name of the launch group. Instances in the samelaunch group are started and terminated together.Default is to launch instances independently.-availability_zone_group If specified, all instances that are giventhe same zone group name will be launched into thesame availability zone. This is independent ofthe -availability_zone argument, which specifiesa 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 base64encode this. It will be done for you.-availability_zone The availability zone you want to launch theinstance into. Call $ec2->regions for a list.-zone Short version of -availability_aone.-placement_group An existing placement group to launch theinstance into. Applicable to cluster instancesonly.-placement_tenancy Specify 'dedicated' to launch the instance on adedicated server. Only applicable for VPCinstances.-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.See run_instances() for the syntax of this argument.-block_device_mapping Alias for -block_devices.-network_interfaces Same as the -network_interfaces option in run_instances().-monitoring Pass a true value to enable detailed monitoring.-subnet The ID of the Amazon VPC subnet in which to launch thespot instance (VPC only).-subnet_id deprecated-addressing_type Deprecated and undocumented, but present in thecurrent 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 theinstances.-ebs_optimized If true, request an EBS-optimized instance (certaininstance 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.
@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.
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
AUTHOR
Lincoln Stein <[email protected]>.
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.