Skip to content

DiscoverInstances

Source: src/AWS/CloudMap/DiscoverInstances.ts

Runtime binding for servicediscovery:DiscoverInstances — the Cloud Map data-plane query that returns a randomized list of registered (by default healthy) instances of a service.

Bind this operation to a Service inside a function runtime to get a callable that automatically injects the namespace and service names.

Discover Healthy Instances

const discover = yield* AWS.CloudMap.DiscoverInstances(service);
const { Instances } = yield* discover({});
for (const instance of Instances ?? []) {
console.log(instance.InstanceId, instance.Attributes?.AWS_INSTANCE_IPV4);
}

Include Unhealthy Instances

const { Instances } = yield* discover({ HealthStatus: "ALL" });