Amazon Elastic Compute Cloud
User Guide (API Version 2012-04-01)
Print this pageEmail this pageGo to the ForumsView the PDFShare this page on TwitterShare this page on FacebookBookmark this page on DeliciousSubmit this page to RedditSubmit this page to DiggDid this page help you?  Yes  No   Tell us about it...

Find Running Spot Instances

Spot Instances continue running until the Spot Price is greater than your maximum bid price. In addition, when your Spot Instance request is canceled, the Spot Instances that were launched previously through the canceled request don't automatically get terminated. The only time that the Spot Instance service terminates a running instance is when the Spot Price exceeds your price. This section describes how to find running Spot Instances.

[Important]Important

Although Spot Instances can use Amazon EBS-backed AMIs, be aware that the EBS-backed AMIs don't support Stop/Start. In other words, you can't stop and start Spot Instances launched from an AMI with an Amazon EBS root device.

[Note]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. Look for instances in the table where the Lifecycle column contains spot. You might need to turn on the display of the column (click Show/Hide in the top right corner of the page).

Command Line Tools

To find running Spot Instances

  • 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
  • You can alternately 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

    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/2012-04-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. You can alternately 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?