Skip to content

update_instance_custom_health_status async

update_instance_custom_health_status(
    service_id: Arn,
    instance_id: ResourceId,
    status: CustomHealthStatus,
    *,
    config_overrides: Optional[AsyncServiceDiscoveryClientConfig] = None,
) -> None

Submits a request to change the health status of a custom health check to healthy or unhealthy.

You can use UpdateInstanceCustomHealthStatus to change the status only for custom health checks, which you define using HealthCheckCustomConfig when you create a service. You can't use it to change the status for Route 53 health checks, which you define using HealthCheckConfig.

For more information, see HealthCheckCustomConfig.

Parameters:

  • service_id (Arn) –

    The ID or Amazon Resource Name (ARN) of the service that includes the configuration for the custom health check that you want to change the status for. For services created in a shared namespace, specify the service ARN. For more information about shared namespaces, see Cross-account Cloud Map namespace sharing in the Cloud Map Developer Guide.

  • instance_id (ResourceId) –

    The ID of the instance that you want to change the health status for.

  • status (CustomHealthStatus) –

    The new status of the instance, HEALTHY or UNHEALTHY.

Raises:

  • CustomHealthNotFound –

    The health check for the instance that's specified by ServiceId and InstanceId isn't a custom health check.

  • InstanceNotFound –

    No instance exists with the specified ID, or the instance was recently registered, and information about the instance hasn't propagated yet.

  • InvalidInput –

    One or more specified values aren't valid. For example, a required value might be missing, a numeric value might be outside the allowed range, or a string value might exceed length constraints.

  • ServiceNotFound –

    No service exists with the specified ID.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Examples:

Update instance custom health status using service ARN Updates instance custom health status using a service ARN instead of service ID, useful when working with shared namespaces.

>>> await client.update_instance_custom_health_status(instance_id='i-abcd1234xmpl5678', service_id='arn:aws:servicediscovery:us-west-2:123456789012:service/srv-abcd1234xmpl5678', status='HEALTHY')
UpdateInstanceCustomHealthStatus Example
This example submits a request to change the health status of an instance associated with a service with a custom health check to HEALTHY.
>>> await client.update_instance_custom_health_status(instance_id='i-abcd1234', service_id='srv-e4anhexample0004', status='HEALTHY')
Source code in docs_src/capo_servicediscovery/_services/async_service_discovery.py
async def update_instance_custom_health_status(
    self,
    service_id: "capo_servicediscovery.types.arn.Arn",
    instance_id: "capo_servicediscovery.types.resource_id.ResourceId",
    status: "capo_servicediscovery.types.custom_health_status.CustomHealthStatus",
    *,
    config_overrides: Optional[AsyncServiceDiscoveryClientConfig] = None,
) -> None:
    """<p>Submits a request to change the health status of a custom health check to healthy or unhealthy.</p> <p>You can use <code>UpdateInstanceCustomHealthStatus</code> to change the status only for custom health checks, which you define using <code>HealthCheckCustomConfig</code> when you create a service. You can't use it to change the status for Route 53 health checks, which you define using <code>HealthCheckConfig</code>.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/cloud-map/latest/api/API_HealthCheckCustomConfig.html">HealthCheckCustomConfig</a>.</p>

    Args:
        service_id: <p>The ID or Amazon Resource Name (ARN) of the service that includes the configuration for the custom health check that you want to change the status for. For services created in a shared namespace, specify the service ARN. For more information about shared namespaces, see <a href="https://docs.aws.amazon.com/cloud-map/latest/dg/sharing-namespaces.html">Cross-account Cloud Map namespace sharing</a> in the <i>Cloud Map Developer Guide</i>.</p>
        instance_id: <p>The ID of the instance that you want to change the health status for.</p>
        status: <p>The new status of the instance, <code>HEALTHY</code> or <code>UNHEALTHY</code>.</p>

    Raises:
        capo_servicediscovery.errors.custom_health_not_found.CustomHealthNotFound: <p>The health check for the instance that's specified by <code>ServiceId</code> and <code>InstanceId</code> isn't a custom health check. </p>
        capo_servicediscovery.errors.instance_not_found.InstanceNotFound: <p>No instance exists with the specified ID, or the instance was recently registered, and information about the instance hasn't propagated yet.</p>
        capo_servicediscovery.errors.invalid_input.InvalidInput: <p>One or more specified values aren't valid. For example, a required value might be missing, a numeric value might be outside the allowed range, or a string value might exceed length constraints.</p>
        capo_servicediscovery.errors.service_not_found.ServiceNotFound: <p>No service exists with the specified ID.</p>
        capo_servicediscovery.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        Update instance custom health status using service ARN
        Updates instance custom health status using a service ARN instead of service ID, useful when working with shared namespaces.

        >>> await client.update_instance_custom_health_status(instance_id='i-abcd1234xmpl5678', service_id='arn:aws:servicediscovery:us-west-2:123456789012:service/srv-abcd1234xmpl5678', status='HEALTHY')
        UpdateInstanceCustomHealthStatus Example
        This example submits a request to change the health status of an instance associated with a service with a custom health check to HEALTHY.

        >>> await client.update_instance_custom_health_status(instance_id='i-abcd1234', service_id='srv-e4anhexample0004', status='HEALTHY')
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_servicediscovery.types.update_instance_custom_health_status_request.UpdateInstanceCustomHealthStatusRequest]",
    ) -> AsyncOperationResponse[None]:
        import capo_servicediscovery._operations.route53_auto_naming_v20170314.update_instance_custom_health_status

        (
            output,
            http_response,
        ) = await capo_servicediscovery._operations.route53_auto_naming_v20170314.update_instance_custom_health_status.async_update_instance_custom_health_status(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("UpdateInstanceCustomHealthStatus")
    )
    input_: capo_servicediscovery.types.update_instance_custom_health_status_request.UpdateInstanceCustomHealthStatusRequest = {
        "service_id": service_id,
        "instance_id": instance_id,
        "status": status,
    }

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output