setInstanceHealth method
Sets the health status of the specified instance.
For more information, see Health checks for Auto Scaling instances in the Amazon EC2 Auto Scaling User Guide.
May throw ResourceContentionFault.
Parameter healthStatus
:
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.
Parameter instanceId
:
The ID of the instance.
Parameter 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 CreateAutoScalingGroup in the Amazon EC2 Auto Scaling API Reference.
Implementation
Future<void> setInstanceHealth({
required String healthStatus,
required String instanceId,
bool? shouldRespectGracePeriod,
}) async {
ArgumentError.checkNotNull(healthStatus, 'healthStatus');
_s.validateStringLength(
'healthStatus',
healthStatus,
1,
32,
isRequired: true,
);
ArgumentError.checkNotNull(instanceId, 'instanceId');
_s.validateStringLength(
'instanceId',
instanceId,
1,
19,
isRequired: true,
);
final $request = <String, dynamic>{};
$request['HealthStatus'] = healthStatus;
$request['InstanceId'] = instanceId;
shouldRespectGracePeriod
?.also((arg) => $request['ShouldRespectGracePeriod'] = arg);
await _protocol.send(
$request,
action: 'SetInstanceHealth',
version: '2011-01-01',
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
shape: shapes['SetInstanceHealthQuery'],
shapes: shapes,
);
}