Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅
中国的 Amazon Web Services 服务入门
(PDF)。
本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
查看您的 Amazon Cloud Map 服务实例
要查看已使用服务注册的服务实例的列表,请执行以下过程。
- Amazon Web Services Management Console
-
- Amazon CLI
-
- Amazon SDK for Python (Boto3)
-
-
如果您尚未安装 Boto3
,则可以在此处找到安装、配置和使用Boto3
的说明。
-
导入 Boto3
并将 servicediscovery
用作您的服务。
import boto3
client = boto3.client('servicediscovery')
-
使用list_instances()
列出服务实例(将红色
值替换为您自己的值)。
response = client.list_instances(
ServiceId='srv-xxxxxxxxx',
)
# If you want to see the response
print(response)
示例响应输出
{
'Instances': [
{
'Attributes': {
'AWS_INSTANCE_IPV4': '172.2.1.3',
'AWS_INSTANCE_PORT': '808',
},
'Id': 'i-xxxxxxxxxxxxxxxxx',
},
],
'ResponseMetadata': {
'...': '...',
},
}