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...

Finding Running Spot Instances

Your Spot request will launch a Spot Instance when the Spot price is below your bid price. A Spot Instance will run until either its maximum bid price is no longer higher than the Spot price or you terminate the Spot Instance yourself. (If your bid price is exactly equal to the Spot price, there is a chance your Spot Instance will remain running.) When your Spot request is fulfilled and has running instances, your Spot request will be active (as opposed to open, closed, or canceled). In this section, we describe how to find running Spot Instances associated with your active Spot requests.

Note

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

AWS Management Console

To find running Spot Instances

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

    The console displays a list of running instances.

  2. To identify which of the instances were launched as a result of Spot requests, match the Instance IDs in the Instances page— where the Lifecycle column lists the instance as spot—with Instance IDs in the Spot Requests page. (You might need to turn on the display of the column by clicking Show/Hide in the top right corner.)

Command Line Tools

To find running Spot Instances

  1. Use ec2-describe-spot-instance-requests. If your Spot Instance request has been fulfilled (an instance has been launched), the instance ID appears in the response.

    PROMPT> ec2-describe-spot-instance-requests
    SPOTINSTANCEREQUEST     sir-e1471206    0.09    one-time        Linux/UNIX      active  2010-09-13T16:50:44-0800
    i-992cf7dd      ami-813968c4    m1.small        MyKey   default                         monitoring-disabled
  2. Alternatively, you can use ec2-describe-instances with the following filter: --filter instance-lifecycle=spot. If you're using the command line tools on a Windows system, you might need to use quotation marks (--filter "instance-lifecycle=spot"). For more information about filters, see Listing and Filtering Your Resources.

    PROMPT>  ec2-describe-instances --filter instance-lifecycle=spot

    Amazon EC2 returns output similar to the following:

    RESERVATION     r-b58651f1      111122223333    default
    INSTANCE        i-992cf7dd      ami-813968c4    ec2-184-72-8-111.us-west-1.compute.amazonaws.com    ip-10-166-105-139.us-west-1.compute.internal
      running    MyKey   0               m1.small        2010-09-13T23:54:40+0000        us-west-1a      aki-a13667e4    ari-a33667e6            
      monitoring-disabled   184.72.8.111    10.166.105.139                  ebs     spot    sir-e1471206                paravirtual

API

To find running Spot Instances

  1. Construct a DescribeInstances Query request and use a filter to look for instances where instance-lifecycle=spot. For more information about filters, see Listing and Filtering Your Resources.

    https://ec2.amazonaws.com/
    ?Action=DescribeInstances
    &Filter.1.Name=instance-lifecycle
    &Filter.1.Value.1=spot
    &...auth parameters...

    Following is an example response. It includes an instanceLifecycle element with spot as the value.

    <DescribeInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2013-02-01/">
      ...
       <instancesSet>
       <item>
         <instanceId>i-992cf7dd</instanceId>
         <imageId>ami-813968c4</imageId>
         <instanceState>
           <code>16</code>
           <name>running</name>
         </instanceState>
         <privateDnsName>ip-10-166-105-139.us-west-1.compute.internal</privateDnsName>
         <dnsName>ec2-184-72-8-111.us-west-1.compute.amazonaws.com</dnsName>
         <reason/>
         <keyName>MyKey</keyName>
         <amiLaunchIndex>0</amiLaunchIndex>
         <productCodes/>
         <instanceType>m1.small</instanceType>
         <launchTime>2010-09-13T23:54:40.000Z</launchTime>
         <placement>
           <availabilityZone>us-west-1a</availabilityZone>
           <groupName/>
         </placement>
         <kernelId>aki-a13667e4</kernelId>
         <ramdiskId>ari-a33667e6</ramdiskId>
         <monitoring>
           <state>disabled</state>
         </monitoring>
         <privateIpAddress>10.166.105.139</privateIpAddress>
         <ipAddress>184.72.8.111</ipAddress>
         <architecture>i386</architecture>
         <rootDeviceType>ebs</rootDeviceType>
         <rootDeviceName>/dev/sda1</rootDeviceName>
         <blockDeviceMapping>
           <item>
             <deviceName>/dev/sda1</deviceName>
             <ebs>
               <volumeId>vol-61088f0a</volumeId>
               <status>attached</status>
               <attachTime>2010-09-13T23:54:42.000Z</attachTime>
               <deleteOnTermination>true</deleteOnTermination>
             </ebs>
           </item>
         </blockDeviceMapping>
         <instanceLifecycle>spot</instanceLifecycle>
         <spotInstanceRequestId>sir-e1471206</spotInstanceRequestId>
         <virtualizationType>paravirtual</virtualizationType>
       </item>
     </instancesSet>
    </DescribeInstancesResponse>
  2. Alternatively, you can use DescribeSpotInstanceRequests. If your Spot Instance request has been fulfilled (an instance has been launched), the instance ID appears in the response. Following is an excerpt from a response.

    ...
    <spotInstanceRequestSet>
       <item>
          <spotInstanceRequestId>sir-e1471206</spotInstanceRequestId>
          <spotPrice>0.09</spotPrice>
          <type>one-time</type>
          <state>active</state>
          <launchSpecification>
             <imageId>ami-813968c4</imageId>
             <keyName>MyKey</keyName>
             <groupSet>
                <item>
                   <groupId>default</groupId>
                </item>
             </groupSet>
             <instanceType>m1.small</instanceType>
             <blockDeviceMapping/>
             <monitoring>
                <enabled>false</enabled>
             </monitoring>
          </launchSpecification>
          <instanceId>i-992cf7dd</instanceId>
          <createTime>2010-09-13T23:50:44.000Z</createTime>
          <productDescription>Linux/UNIX</productDescription>
          <launchedAvailabilityZone>us-east-1c</launchedAvailabilityZone>
       </item>
    <spotInstanceRequestSet/>
    ...

What do you want to do next?