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

Cancel Spot Instance Requests

Each Spot Instance request can be in one of the following states:

  • Open—The request is not fulfilled.

  • Active—The request is currently active (fulfilled).

  • Closed—The request either completed or was not fulfilled within the period specified.

    Depending on conditions, an instance might still be running.

  • Cancelled—The request is canceled because one of two events took place: You canceled the request, or the bid request went past its expiration date.

    In addition, when your Spot Instance request is canceled, either because the bid request went beyond its expiration date or you manually canceled it, the Spot Instances that were launched previously through the now-canceled request don't automatically get terminated. The only time that the Spot Instance service terminates a running instance is when the Spot Price equals or exceeds your price. Also, you can always terminate your instances manually.

    [Note]Note

    The Valid Until option that you specify when you submit a Spot Instance request applies only to the request; this deadline doesn't apply to Spot Instances that are launched by the request.

After placing a request, you can check its state and the state of your other requests.

[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 cancel Spot Instance requests

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

    The console displays a list of Spot Instances requests.

  2. Select the spot instances you want to cancel and click the Cancel Request button.

Command Line Tools

To cancel Spot Instance requests

  1. Enter the following command:

    PROMPT> ec2-describe-spot-instance-requests

    Amazon EC2 returns output similar to the following:

    SPOTINSTANCEREQUEST   sir-09fb0a04   0.04   one-time   Linux/UNIX   closed   
    2010-04-06T10:03:09+0200   ami-b232d0db   m1.small   gsg-keypair   default    monitoring-disabled
  2. To cancel the request, enter the following:

    PROMPT> ec2-cancel-spot-instance-requests sir-09fb0a04

    Amazon EC2 returns output similar to the following:

    SPOTINSTANCEREQUEST     sir-09fb0a04    cancelled
[Tip]Tip

You can filter the list of Spot Instance requests to return only certain types of interest to you. For more information about how to filter the results, go to ec2-describe-spot-instance-requests in the Amazon Elastic Compute Cloud Command Line Reference.

API

To cancel Spot Instance requests

  1. Construct the following Query request.

    https://ec2.amazonaws.com/
    ?Action=DescribeSpotInstanceRequests
    &...auth parameters...

    Following is an example response.

    <DescribeSpotInstanceRequestsResponse xmlns="http://ec2.amazonaws.com/doc/2012-04-01/">
      <spotInstanceRequestSet>
          <item>
             <spotInstanceRequestId>sir-8675309a</spotInstanceRequestId>
             <spotPrice>0.32</spotPrice>
             <type>one-time</type>
             <state>open</state>
             <fault/>
             <validFrom/>
             <validUntil/>
             <launchGroup/>
             <availabilityZoneGroup>MyAzGroup</availabilityZoneGroup>
             <launchSpecification>
                <imageId> i-43a4412a</imageId>
                <keyName>MyKeypair</keyName>
                <groupSet>websrv</groupSet>
                <instanceType>m1.small</instanceType>
             </launchSpecification>
             <instanceId>i-123345678</instanceId>
             <createTime>2009-10-19T00:00:00+0000</createTime>
           <productDescription>Linux/UNIX</productDescription>
           <launchedAvailabilityZone>us-east-1c</launchedAvailabilityZone>
          </item>
       </spotInstanceRequestSet>
    </DescribeSpotInstanceRequestsResponse>
  2. Construct a Query request to cancel the Spot Instance requests.

    https://ec2.amazonaws.com/
    ?Action=CancelSpotInstanceRequests
    &SpotInstanceRequestId.1=sir-8675309a
    &...auth parameters...

    Following is an example response.

    <CancelSpotInstanceRequestsResponse xmlns="http://ec2.amazonaws.com/doc/2012-04-01/">
      <spotInstanceRequestId>sir-8675309a</spotInstanceRequestId>
    </CancelSpotInstanceRequestsResponse>
[Tip]Tip

You can filter the list of Spot Instance requests to return only certain types of interest to you. For more information about how to filter the results, go to DescribeSpotInstanceRequests in the Amazon Elastic Compute Cloud API Reference.

What do you want to do next?