discover_instances
¶
discover_instances(
namespace_name: NamespaceName,
service_name: ServiceName,
*,
config_overrides: Optional[ServiceDiscoveryClientConfig] = None,
max_results: Optional[DiscoverMaxResults] = None,
query_parameters: Optional[Attributes] = None,
optional_parameters: Optional[Attributes] = None,
health_status: Optional[HealthStatusFilter] = None,
owner_account: Optional[AWSAccountId] = None,
) -> DiscoverInstancesResponse
Discovers registered instances for a specified namespace and service. You can use DiscoverInstances to discover instances for any type of namespace. DiscoverInstances returns a randomized list of instances allowing customers to distribute traffic evenly across instances. For public and private DNS namespaces, you can also use DNS queries to discover instances.
Parameters:
-
namespace_name(NamespaceName) –The
HttpNamename of the namespace. TheHttpNameis found in theHttpPropertiesmember of thePropertiesmember of the namespace. In most cases,NameandHttpNamematch. However, if you reuseNamefor namespace creation, a generated hash is added toHttpNameto distinguish the two. -
service_name(ServiceName) –The name of the service that you specified when you registered the instance.
-
max_results(Optional[DiscoverMaxResults], default:None) –The maximum number of instances that you want Cloud Map to return in the response to a
DiscoverInstancesrequest. If you don't specify a value forMaxResults, Cloud Map returns up to 100 instances. -
query_parameters(Optional[Attributes], default:None) –Filters to scope the results based on custom attributes for the instance (for example,
{version=v1, az=1a}). Only instances that match all the specified key-value pairs are returned. -
optional_parameters(Optional[Attributes], default:None) –Opportunistic filters to scope the results based on custom attributes. If there are instances that match both the filters specified in both the
QueryParametersparameter and this parameter, all of these instances are returned. Otherwise, the filters are ignored, and only instances that match the filters that are specified in theQueryParametersparameter are returned. -
health_status(Optional[HealthStatusFilter], default:None) –The health status of the instances that you want to discover. This parameter is ignored for services that don't have a health check configured, and all instances are returned.
- HEALTHY
-
Returns healthy instances.
- UNHEALTHY
-
Returns unhealthy instances.
- ALL
-
Returns all instances.
- HEALTHY_OR_ELSE_ALL
-
Returns healthy instances, unless none are reporting a healthy state. In that case, return all instances. This is also called failing open.
-
owner_account(Optional[AWSAccountId], default:None) –The ID of the Amazon Web Services account that owns the namespace associated with the instance, as specified in the namespace
ResourceOwnerfield. For instances associated with namespaces that are shared with your account, you must specify anOwnerAccount.
Raises:
-
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.
-
NamespaceNotFound–No namespace exists with the specified ID.
-
RequestLimitExceeded–The operation can't be completed because you've reached the quota for the number of requests. For more information, see Cloud Map API request throttling quota in the Cloud Map Developer Guide.
-
ServiceNotFound–No service exists with the specified ID.
-
UnknownServiceError–The service returned an error code this client does not model.
Examples:
Discover instances using owner account Discovers instances in a shared namespace by specifying the OwnerAccount parameter, useful when working with shared namespaces.
>>> client.discover_instances(namespace_name='example-shared-namespace', service_name='shared-namespace-service', owner_account='123456789012')
Example: Discover registered instances
Example: Discover registered instances
>>> client.discover_instances(namespace_name='example.com', service_name='myservice', max_results=10, health_status='ALL')
Source code in docs_src/capo_servicediscovery/_services/service_discovery.py
918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 | |