Amazon Elastic Compute Cloud
User Guide (API Version 2013-02-01)
« PreviousNext »
View the PDF for this guide.Go to the AWS Discussion Forum for this product.Go to the Kindle Store to download this guide in Kindle format.Did this page help you?  Yes | No |  Tell us about it...

Creating a Spot Instance Request

After deciding on your bid price, you are ready to request a Spot Instance. Using the AWS Management Console, the API, or the CLI, you can specify how many Spot Instances you’d like, what instance type to use, and the bid price you are willing to pay.

If you request multiple Spot Instances at once, Amazon EC2 creates separate Spot Instance Requests with unique IDs (e.g., sir-1a2b3c4d) so that you can track the status of each request separately. For information about tracking Spot requests, see Tracking Spot Requests with Bid Status Codes.

In this section, we discuss how to create requests for Amazon EC2 Spot Instances using the AWS Management Console, the API, or the CLI. For more information about requesting Spot Instances, see the following:

Note

Make sure you have set up the prerequisites for working with Amazon EC2. If you haven't, see Prerequisites for Using Spot Instances.

AWS Management Console

To create a Spot Instance request

  1. From the Amazon EC2 console, click Spot Requests in the navigation pane.

  2. Click the Request Spot Instances button.

    The Request Instances Wizard starts.

  3. In the Request Instances Wizard, choose an AMI, and click Select.

  4. On the INSTANCE DETAILS page, specify the number and type of instances you want. Then in the Request Spot Instances section, choose and specify the options you want to configure your Spot Instance settings, and click Continue.

    Note

    Amazon EC2 supports the following platforms: EC2-Classic and EC2-VPC. Your AWS account is capable of launching instances either into both platforms or only into EC2-VPC, on a region-by-region basis. If your account is capable of launching instances into both platforms, you will see the EC2-Classic and EC2-VPC tabs. If your account can launch instances only into EC2-VPC, you will not see any tab. Instead, you will see a Subnet drop-down box that lets you select where to launch your Spot Instance. For information, see Supported Platforms.

    OptionDescription

    Current Price

    Displays the price for the Availability Zone you specified, or the lowest price across all Availability Zones if you do not specify an Availability Zone.

    Max Price

    Specifies the maximum price you are willing to pay per instance hour.

    Request Valid From and Request Valid Until

    Defines the validity period of a Spot request. The validity period, beginning with Request Valid From through Request Valid Until, specifies the length of time that your request will remain valid. By default, a Spot request will be considered for fulfillment from the time it is created until it is either fulfilled or canceled by you. However, you can constrain the validity period using these options.

    Note

    The end time you specify doesn't apply to the Spot Instances launched by this request. This end time only applies to the Spot Instance request.

    Persistent Request?

    Determines whether your request is one-time or persistent. By default, it is one-time. A one-time request can only be fulfilled once. A persistent request is considered for fulfillment whenever there is no Spot Instance running for the same request.

    Launch Group

    Groups a set of requests together in the same launch group. All requests in a launch group have their instances started and terminated together. For more information about using Launch Group in your Spot request, see Launching Spot Instances in Launch Groups and Availability Zones.

    Availability Zone Group

    Groups a set of requests together in the same Availability Zone. All requests that share an Availability Zone group will launch Spot Instances in the same Availability Zone. For more information about using Availability Zone Group in your Spot request, see Launching Spot Instances in Launch Groups and Availability Zones.

  5. Continue with the wizard as you normally would when launching instances.

    If your request specified multiple instances, Amazon EC2 creates a separate Spot Instance request for each instance. The requests are displayed on the Spot Requests page.

Command Line Tools

To create a Spot price request

  • Enter the following command:

    PROMPT> ec2-request-spot-instances
    --price price
    --user-data data
    --instance-count count
    --type one-time | persistent
    [--valid-from timestamp]
    [--valid-until timestamp]
    [--launch-group launchgroup]
    (run-instances-arguments)
    

    For example:

    PROMPT> ec2-request-spot-instances --price 0.32 ami-1234abcd --key MyKeypair --group websrv --instance-type m1.small --instance-count 10 --type one-time

    Amazon EC2 returns output similar to the following:

    SPOTINSTANCEREQUEST     sir-09fb0a04    0.32    one-time        Linux/UNIX     open     2010-04-06T10:03:09+0200   ami-1234abc     m1.small        MyKeypair     websrv      monitoring-disabled
    ...

    If your request specified multiple instances, Amazon EC2 creates a separate Spot Instance request for each instance; each instance has a different ID (e.g., sir-09fb0a04).

API

To create a Spot price request

  • Construct a Query request similar to the following.

    https://ec2.amazonaws.com/
    ?Action=RequestSpotInstances
    &SpotPrice.1=0.50
    &InstanceCount.1=10
    &Type.1=one-time
    &AvailabilityZoneGroup.1=MyAzGroup
    &LaunchSpecification.ImageId.1=ami-43a4412a
    &LaunchSpecification.KeyName.1=MyKeypair
    &LaunchSpecification.GroupSet.1=websrv
    &LaunchSpecification.InstanceType.1=m1.small
    &...auth parameters...

    Following is an example response.

    <RequestSpotInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2013-02-01/">
       <spotInstanceRequestSet>
          <item>
             <spotInstanceRequestId>sir-876aff12</spotInstanceRequestId>
             <spotPrice>0.32</spotPrice>
             <type>one-time</type>
             <state>open</state>
             <fault/>
             <validFrom/>
             <validUntil/>
             <launchGroup/>
             <availabilityZoneGroup>MyAzGroup</availabilityZoneGroup>
             <launchSpecification>
                <imageId>ami-43a4412a</imageId>
                <keyName>MyKeypair</keyName>
                <groupSet>
                   <item>
                      <groupId>websrv</groupId>
                   </item>
                </groupSet>
                <instanceType>m1.small</instanceType>
                ...
             </launchSpecification>
             <instanceId/>
             <createTime>2009-10-19T00:00:00+0000</createTime>
             <productDescription>Linux/UNIX</productDescription>
             <tagSet/>
          </item>
          ...
       </spotInstanceRequestSet>
    </RequestSpotInstancesResponse>

    If your request specified multiple instances, Amazon EC2 creates a separate Spot Instance request for each instance; each instance has a different ID (e.g., sir-876aff12).

What do you want to do next?