Skip to content

get_instance

get_instance(
    service_id: Arn,
    instance_id: ResourceId,
    *,
    config_overrides: Optional[ServiceDiscoveryClientConfig] = None,
) -> GetInstanceResponse

Gets information about a specified instance.

Parameters:

  • service_id (Arn) –

    The ID or Amazon Resource Name (ARN) of the service that the instance is associated with. 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 get information about.

Raises:

  • 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:

GetInstance example This example gets information about a specified instance.

>>> client.get_instance(instance_id='i-abcd1234', service_id='srv-e4anhexample0004')
Get instance details using service ARN for shared namespace
This example gets information about an instance using a service ARN instead of service ID. This is useful for listing instances associated with shared namespaces.
>>> client.get_instance(instance_id='i-abcd1234', service_id='arn:aws:servicediscovery:us-west-2:123456789012:service/srv-e4anhexample0004')
Source code in docs_src/capo_servicediscovery/_services/service_discovery.py
def get_instance(
    self,
    service_id: "capo_servicediscovery.types.arn.Arn",
    instance_id: "capo_servicediscovery.types.resource_id.ResourceId",
    *,
    config_overrides: Optional[ServiceDiscoveryClientConfig] = None,
) -> "capo_servicediscovery.types.get_instance_response.GetInstanceResponse":
    """<p>Gets information about a specified instance.</p>

    Args:
        service_id: <p>The ID or Amazon Resource Name (ARN) of the service that the instance is associated with. 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 get information about.</p>

    Raises:
        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:
        GetInstance example
        This example gets information about a specified instance.

        >>> client.get_instance(instance_id='i-abcd1234', service_id='srv-e4anhexample0004')
        Get instance details using service ARN for shared namespace
        This example gets information about an instance using a service ARN instead of service ID. This is useful for listing instances associated with shared namespaces.

        >>> client.get_instance(instance_id='i-abcd1234', service_id='arn:aws:servicediscovery:us-west-2:123456789012:service/srv-e4anhexample0004')
    """

    def _handler(
        req: "OperationRequest[capo_servicediscovery.types.get_instance_request.GetInstanceRequest]",
    ) -> OperationResponse[
        "capo_servicediscovery.types.get_instance_response.GetInstanceResponse"
    ]:
        import capo_servicediscovery._operations.route53_auto_naming_v20170314.get_instance

        output, http_response = (
            capo_servicediscovery._operations.route53_auto_naming_v20170314.get_instance.get_instance(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("GetInstance")
    )
    input_: capo_servicediscovery.types.get_instance_request.GetInstanceRequest = {
        "service_id": service_id,
        "instance_id": instance_id,
    }

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output