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

*******************
set_instance_health
*******************



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

  

  Sets the health status of the specified instance.

   

  For more information, see `Set up a custom health check for your Auto Scaling group <https://docs.aws.amazon.com/autoscaling/ec2/userguide/set-up-a-custom-health-check.html>`__ in the *Amazon EC2 Auto Scaling User Guide*.

  

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


  **Request Syntax**
  ::

    response = client.set_instance_health(
        InstanceId='string',
        HealthStatus='string',
        ShouldRespectGracePeriod=True|False
    )
    
  :type InstanceId: string
  :param InstanceId: **[REQUIRED]** 

    The ID of the instance.

    

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

    The health status of the instance. Set to ``Healthy`` to have the instance remain in service. Set to ``Unhealthy`` to have the instance be out of service. Amazon EC2 Auto Scaling terminates and replaces the unhealthy instance.

    

  
  :type ShouldRespectGracePeriod: boolean
  :param ShouldRespectGracePeriod: 

    If the Auto Scaling group of the specified instance has a ``HealthCheckGracePeriod`` specified for the group, by default, this call respects the grace period. Set this to ``False``, to have the call not respect the grace period associated with the group.

     

    For more information about the health check grace period, see `Set the health check grace period for an Auto Scaling group <https://docs.aws.amazon.com/autoscaling/ec2/userguide/health-check-grace-period.html>`__ in the *Amazon EC2 Auto Scaling User Guide*.

    

  
  
  :returns: None
  **Exceptions**
  
  *   :py:class:`AutoScaling.Client.exceptions.ResourceContentionFault`

  

  **Examples**

  This example sets the health status of the specified instance to Unhealthy.
  ::

    response = client.set_instance_health(
        HealthStatus='Unhealthy',
        InstanceId='i-93633f9b',
    )
    
    print(response)

  
  Expected Output:
  ::

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

  