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
812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 | |