SetInstanceHealthCommand

Sets the health status of the specified instance.

For more information, see Set up a custom health check for your Auto Scaling group  in the Amazon EC2 Auto Scaling User Guide.

Example Syntax

Use a bare-bones client and the command you need to make an API call.

import { AutoScalingClient, SetInstanceHealthCommand } from "@aws-sdk/client-auto-scaling"; // ES Modules import
// const { AutoScalingClient, SetInstanceHealthCommand } = require("@aws-sdk/client-auto-scaling"); // CommonJS import
const client = new AutoScalingClient(config);
const input = { // SetInstanceHealthQuery
  InstanceId: "STRING_VALUE", // required
  HealthStatus: "STRING_VALUE", // required
  ShouldRespectGracePeriod: true || false,
};
const command = new SetInstanceHealthCommand(input);
const response = await client.send(command);
// {};

Example Usage

 Loading code editor

SetInstanceHealthCommand Input

See SetInstanceHealthCommandInput for more details

Parameter
Type
Description
HealthStatus
Required
string | undefined

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.

InstanceId
Required
string | undefined

The ID of the instance.

ShouldRespectGracePeriod
boolean | undefined

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  in the Amazon EC2 Auto Scaling User Guide.

SetInstanceHealthCommand Output

Parameter
Type
Description
$metadata
Required
ResponseMetadata
Metadata pertaining to this request.

Throws

Name
Fault
Details
ResourceContentionFault
server

You already have a pending update to an Amazon EC2 Auto Scaling resource (for example, an Auto Scaling group, instance, or load balancer).

AutoScalingServiceException
Base exception class for all service exceptions from AutoScaling service.