:doc:`EC2 <../../ec2>` / Client / cancel_spot_instance_requests

*****************************
cancel_spot_instance_requests
*****************************



.. py:method:: EC2.Client.cancel_spot_instance_requests(**kwargs)

  

  Cancels one or more Spot Instance requests.

   

  .. warning::

     

    Canceling a Spot Instance request does not terminate running Spot Instances associated with the request.

    

  

  See also: `AWS API Documentation <https://docs.aws.amazon.com/goto/WebAPI/ec2-2016-11-15/CancelSpotInstanceRequests>`_  


  **Request Syntax**
  ::

    response = client.cancel_spot_instance_requests(
        DryRun=True|False,
        SpotInstanceRequestIds=[
            'string',
        ]
    )
    
  :type DryRun: boolean
  :param DryRun: 

    Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is ``DryRunOperation``. Otherwise, it is ``UnauthorizedOperation``.

    

  
  :type SpotInstanceRequestIds: list
  :param SpotInstanceRequestIds: **[REQUIRED]** 

    The IDs of the Spot Instance requests.

    

  
    - *(string) --* 

    

  
  :rtype: dict
  :returns: 
    
    **Response Syntax**

    
    ::

      {
          'CancelledSpotInstanceRequests': [
              {
                  'SpotInstanceRequestId': 'string',
                  'State': 'active'|'open'|'closed'|'cancelled'|'completed'
              },
          ]
      }
      
    **Response Structure**

    

    - *(dict) --* 

      Contains the output of CancelSpotInstanceRequests.

      
      

      - **CancelledSpotInstanceRequests** *(list) --* 

        The Spot Instance requests.

        
        

        - *(dict) --* 

          Describes a request to cancel a Spot Instance.

          
          

          - **SpotInstanceRequestId** *(string) --* 

            The ID of the Spot Instance request.

            
          

          - **State** *(string) --* 

            The state of the Spot Instance request.

            
      
    
  

  **Examples**

  This example cancels a Spot Instance request.
  ::

    response = client.cancel_spot_instance_requests(
        SpotInstanceRequestIds=[
            'sir-08b93456',
        ],
    )
    
    print(response)

  
  Expected Output:
  ::

    {
        'CancelledSpotInstanceRequests': [
            {
                'SpotInstanceRequestId': 'sir-08b93456',
                'State': 'cancelled',
            },
        ],
        'ResponseMetadata': {
            '...': '...',
        },
    }

  