:doc:`AutoScaling <../../autoscaling>` / Client / set_instance_protection

***********************
set_instance_protection
***********************



.. py:method:: AutoScaling.Client.set_instance_protection(**kwargs)

  

  Updates the instance protection settings of the specified instances. This operation cannot be called on instances in a warm pool.

   

  For more information, see `Use instance scale-in protection <https://docs.aws.amazon.com/autoscaling/ec2/userguide/ec2-auto-scaling-instance-protection.html>`__ in the *Amazon EC2 Auto Scaling User Guide*.

   

  If you exceed your maximum limit of instance IDs, which is 50 per Auto Scaling group, the call fails.

  

  See also: `AWS API Documentation <https://docs.aws.amazon.com/goto/WebAPI/autoscaling-2011-01-01/SetInstanceProtection>`_  


  **Request Syntax**
  ::

    response = client.set_instance_protection(
        InstanceIds=[
            'string',
        ],
        AutoScalingGroupName='string',
        ProtectedFromScaleIn=True|False
    )
    
  :type InstanceIds: list
  :param InstanceIds: **[REQUIRED]** 

    One or more instance IDs. You can specify up to 50 instances.

    

  
    - *(string) --* 

    

  :type AutoScalingGroupName: string
  :param AutoScalingGroupName: **[REQUIRED]** 

    The name of the Auto Scaling group.

    

  
  :type ProtectedFromScaleIn: boolean
  :param ProtectedFromScaleIn: **[REQUIRED]** 

    Indicates whether the instance is protected from termination by Amazon EC2 Auto Scaling when scaling in.

    

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

    
    ::

      {}
      
    **Response Structure**

    

    - *(dict) --* 
  
  **Exceptions**
  
  *   :py:class:`AutoScaling.Client.exceptions.LimitExceededFault`

  
  *   :py:class:`AutoScaling.Client.exceptions.ResourceContentionFault`

  

  **Examples**

  This example enables instance protection for the specified instance.
  ::

    response = client.set_instance_protection(
        AutoScalingGroupName='my-auto-scaling-group',
        InstanceIds=[
            'i-93633f9b',
        ],
        ProtectedFromScaleIn=True,
    )
    
    print(response)

  
  Expected Output:
  ::

    {
        'ResponseMetadata': {
            '...': '...',
        },
    }

  

  This example disables instance protection for the specified instance.
  ::

    response = client.set_instance_protection(
        AutoScalingGroupName='my-auto-scaling-group',
        InstanceIds=[
            'i-93633f9b',
        ],
        ProtectedFromScaleIn=False,
    )
    
    print(response)

  
  Expected Output:
  ::

    {
        'ResponseMetadata': {
            '...': '...',
        },
    }

  