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

***********************************************
modify_instance_capacity_reservation_attributes
***********************************************



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

  

  Modifies the Capacity Reservation settings for a stopped instance. Use this action to configure an instance to target a specific Capacity Reservation, run in any ``open`` Capacity Reservation with matching attributes, run in On-Demand Instance capacity, or only run in a Capacity Reservation.

  

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


  **Request Syntax**
  ::

    response = client.modify_instance_capacity_reservation_attributes(
        InstanceId='string',
        CapacityReservationSpecification={
            'CapacityReservationPreference': 'capacity-reservations-only'|'open'|'none',
            'CapacityReservationTarget': {
                'CapacityReservationId': 'string',
                'CapacityReservationResourceGroupArn': 'string'
            }
        },
        DryRun=True|False
    )
    
  :type InstanceId: string
  :param InstanceId: **[REQUIRED]** 

    The ID of the instance to be modified.

    

  
  :type CapacityReservationSpecification: dict
  :param CapacityReservationSpecification: **[REQUIRED]** 

    Information about the Capacity Reservation targeting option.

    

  
    - **CapacityReservationPreference** *(string) --* 

      Indicates the instance's Capacity Reservation preferences. Possible preferences include:

       

      
      * ``capacity-reservations-only`` - The instance will only run in a Capacity Reservation or Capacity Reservation group. If capacity isn't available, the instance will fail to launch.
       
      * ``open`` - The instance can run in any ``open`` Capacity Reservation that has matching attributes (instance type, platform, Availability Zone, and tenancy). If capacity isn't available, the instance runs as an On-Demand Instance.
       
      * ``none`` - The instance doesn't run in a Capacity Reservation even if one is available. The instance runs as an On-Demand Instance.
      

      

    
    - **CapacityReservationTarget** *(dict) --* 

      Information about the target Capacity Reservation or Capacity Reservation group.

      

    
      - **CapacityReservationId** *(string) --* 

        The ID of the Capacity Reservation in which to run the instance.

        

      
      - **CapacityReservationResourceGroupArn** *(string) --* 

        The ARN of the Capacity Reservation resource group in which to run the instance.

        

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

    

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

    
    ::

      {
          'Return': True|False
      }
      
    **Response Structure**

    

    - *(dict) --* 
      

      - **Return** *(boolean) --* 

        Returns ``true`` if the request succeeds; otherwise, it returns an error.

        
  