Amazon EC2 实例拓扑示例 - Amazon Elastic Compute Cloud
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

Amazon EC2 实例拓扑示例

您可以使用 describe-instance-topology CLI 命令来描述您的 EC2 实例的实例拓扑。

当您使用不带参数或筛选条件的 describe-instance-topology 命令时,响应将包括与指定区域中该命令支持的实例类型相匹配的所有实例。您可以通过包含 --region 参数或通过设置默认区域来指定区域。有关设置默认区域的更多信息,请参阅 指定资源的区域

您可以包含参数以返回与指定实例 ID 或置放群组名称相匹配的实例。您还可以包含筛选条件以返回与指定实例类型或实例系列匹配的实例,或者返回指定可用区或本地区域中的实例。您可以包含单个参数或筛选条件,也可以包含参数和筛选条件的组合。

输出是分页的,默认情况下每页最多 20 个实例。您可以使用 --max-results 参数为每页指定最多 100 个实例。

有关更多信息,请参阅 Amazon CLI 命令参考 中的 describe-instance-topology

所需的权限

描述实例拓扑需要以下权限:

  • ec2:DescribeInstanceTopology

示例 1 – 无参数或筛选条件

描述所有实例的实例拓扑

使用 describe-instance-topology CLI 命令而不指定任何参数或筛选条件。

aws ec2 describe-instance-topology --region us-west-2

响应仅返回与此 API 支持的实例类型相匹配的实例。这些实例可以位于不同的可用区、本地区域(ZoneId)和置放群组(GroupName)中。如果实例未在任何置放群组中,则 GroupName 字段不会显示在输出结果中。在以下示例输出中,置放群组中只有一个实例。

示例输出

{ "Instances": [ { "InstanceId": "i-1111111111example", "InstanceType": "p4d.24xlarge", "GroupName": "my-ml-cpg", "NetworkNodes": [ "nn-1111111111example", "nn-2222222222example", "nn-3333333333example" ], "ZoneId": "usw2-az2", "AvailabilityZone": "us-west-2a" }, { "InstanceId": "i-2222222222example", "InstanceType": "p4d.24xlarge", "NetworkNodes": [ "nn-1111111111example", "nn-2222222222example", "nn-3333333333example" ], "ZoneId": "usw2-az2", "AvailabilityZone": "us-west-2a" }, { "InstanceId": "i-3333333333example", "InstanceType": "trn1.32xlarge", "NetworkNodes": [ "nn-1212121212example", "nn-1211122211example", "nn-1311133311example" ], "ZoneId": "usw2-az4", "AvailabilityZone": "us-west-2d" }, { "InstanceId": "i-444444444example", "InstanceType": "trn1.2xlarge", "NetworkNodes": [ "nn-1111111111example", "nn-5434334334example", "nn-1235301234example" ], "ZoneId": "usw2-az2", "AvailabilityZone": "us-west-2a" } ], "NextToken": "SomeEncryptedToken" }

示例 2 – 实例类型筛选条件

您可以按指定的实例类型(精确匹配)进行筛选,也可以按实例系列进行筛选(使用通配符)。您也可以将指定的实例类型筛选条件和实例系列筛选条件组合使用。

示例 2a – 指定实例类型的精确匹配筛选条件

描述与指定实例类型匹配的所有实例的实例拓扑

describe-instance-topology CLI 命令与 instance-type 筛选条件一起使用。在此示例中,对 trn1n.32xlarge 实例的输出进行了筛选。响应将仅返回与指定实例类型匹配的实例。

aws ec2 describe-instance-topology \ --region us-west-2 \ --filters Name=instance-type,Values=trn1n.32xlarge

示例输出

{ "Instances": [ { "InstanceId": "i-2222222222example", "InstanceType": "trn1n.32xlarge", "NetworkNodes": [ "nn-1111111111example", "nn-2222222222example", "nn-3333333333example" ], "ZoneId": "usw2-az2", "AvailabilityZone": "us-west-2a" } ], "NextToken": "SomeEncryptedToken" }

示例 2b – 实例系列的通配符筛选条件

描述与实例系列匹配的所有实例的实例拓扑

describe-instance-topology CLI 命令与 instance-type 筛选条件一起使用。在此示例中,对 trn1* 实例的输出进行了筛选。响应将仅返回与指定实例系列匹配的实例。

aws ec2 describe-instance-topology \ --region us-west-2 \ --filters Name=instance-type,Values=trn1*

示例输出

{ "Instances": [ { "InstanceId": "i-2222222222example", "InstanceType": "trn1n.32xlarge", "NetworkNodes": [ "nn-1111111111example", "nn-2222222222example", "nn-3333333333example" ], "ZoneId": "usw2-az2", "AvailabilityZone": "us-west-2a" }, { "InstanceId": "i-3333333333example", "InstanceType": "trn1.32xlarge", "NetworkNodes": [ "nn-1212121212example", "nn-1211122211example", "nn-1311133311example" ], "ZoneId": "usw2-az4", "AvailabilityZone": "us-west-2d" }, { "InstanceId": "i-444444444example", "InstanceType": "trn1.2xlarge", "NetworkNodes": [ "nn-1111111111example", "nn-5434334334example", "nn-1235301234example" ], "ZoneId": "usw2-az2", "AvailabilityZone": "us-west-2a" } ], "NextToken": "SomeEncryptedToken" }

示例 2c – 组合的实例系列和精确匹配筛选条件

描述与实例系列或指定实例类型匹配的所有实例的实例拓扑

describe-instance-topology CLI 命令与 instance-type 筛选条件一起使用。在此示例中,对 pd4d*trn1n.32xlarge 实例的输出进行了筛选。响应将返回与任何指定筛选条件匹配的实例。

aws ec2 describe-instance-topology \ --region us-west-2 \ --filters "Name=instance-type,Values=p4d*,trn1n.32xlarge"

示例输出

{ "Instances": [ { "InstanceId": "i-1111111111example", "InstanceType": "p4d.24xlarge", "GroupName": "ML-group", "NetworkNodes": [ "nn-1111111111example", "nn-2222222222example", "nn-3333333333example" ], "ZoneId": "usw2-az2", "AvailabilityZone": "us-west-2a" }, { "InstanceId": "i-2222222222example", "InstanceType": "trn1n.32xlarge", "NetworkNodes": [ "nn-1111111111example", "nn-2222222222example", "nn-4343434343example" ], "ZoneId": "usw2-az2", "AvailabilityZone": "us-west-2a" } ], "NextToken": "SomeEncryptedToken" }

示例 3 – 区域 ID 筛选条件

您可以使用 zone-id 筛选条件按可用区或本地区域进行筛选。您也可以将可用区筛选条件和本地区域筛选条件组合使用。

示例 3a – 可用区筛选条件

描述与指定可用区匹配的所有实例的实例拓扑

describe-instance-topology CLI 命令与 zone-id 筛选条件一起使用。在此示例中,使用可用区 ID use1-az1 对输出进行了筛选。响应将仅返回与指定可用区匹配的实例。

aws ec2 describe-instance-topology \ --region us-east-1 \ --filters Name=zone-id,Values=use1-az1

示例输出

{ "Instances": [ { "InstanceId": "i-2222222222example", "InstanceType": "trn1n.32xlarge", "NetworkNodes": [ "nn-1111111111example", "nn-2222222222example", "nn-3214313214example" ], "ZoneId": "use1-az1", "AvailabilityZone": "us-east-1a" } ], "NextToken": "SomeEncryptedToken" }

示例 3b – 本地区域筛选条件

描述与指定本地区域匹配的所有实例的实例拓扑

describe-instance-topology CLI 命令与 zone-id 筛选条件一起使用。在此示例中,使用本地区 ID use1-atl2-az1 对输出进行了筛选。响应将仅返回与指定本地区域匹配的实例。

aws ec2 describe-instance-topology \ --region us-east-1 \ --filters Name=zone-id,Values=use1-atl2-az1

示例输出

{ "Instances": [ { "InstanceId": "i-1111111111example", "InstanceType": "p4d.24xlarge", "GroupName": "ML-group", "NetworkNodes": [ "nn-1111111111example", "nn-2222222222example", "nn-3333333333example" ], "ZoneId": "use1-atl2-az1", "AvailabilityZone": "us-east-1-atl-2a" } ], "NextToken": "SomeEncryptedToken" }

示例 3c – 组合的可用区和本地区域筛选条件

描述与指定可用区或本地区域匹配的所有实例的实例拓扑

describe-instance-topology CLI 命令与 zone-id 筛选条件一起使用。在此示例中,使用可用区 ID use1-az1 和本地区 ID use1-atl2-az1 对输出进行了筛选。响应将返回与任何指定筛选条件匹配的实例。

aws ec2 describe-instance-topology \ --region us-east-1 \ --filters Name=zone-id,Values=use1-az1,use1-atl2-az1

示例输出

{ "Instances": [ { "InstanceId": "i-1111111111example", "InstanceType": "p4d.24xlarge", "GroupName": "ML-group", "NetworkNodes": [ "nn-1111111111example", "nn-2222222222example", "nn-3333333333example" ], "ZoneId": "use1-atl2-az1", "AvailabilityZone": "us-east-1-atl-2a" }, { "InstanceId": "i-2222222222example", "InstanceType": "trn1n.32xlarge", "NetworkNodes": [ "nn-1111111111example", "nn-2222222222example", "nn-3214313214example" ], "ZoneId": "use1-az1", "AvailabilityZone": "us-east-1a" } ], "NextToken": "SomeEncryptedToken" }

示例 4 – 组合的实例类型和区域 ID 筛选条件

您可以将所有筛选条件组合在单个命令中。

描述与指定实例类型、实例系列、可用区或本地区域匹配的所有实例的实例拓扑

describe-instance-topology CLI 命令与 instance-typezone-id 筛选条件一起使用。在此示例中,对 p4d* 实例系列、trn1n.32xlarge 实例类型、use1-az1 可用区 ID 和 use1-atl2-az1 本地区 ID 的输出进行了筛选。响应将返回与 us-east-1a us-east-1-atl-2a 区域中的 p4d* trn1n.32xlarge 实例匹配的实例。

aws ec2 describe-instance-topology \ --region us-east-1 \ --filters "Name=instance-type,Values=p4d*,trn1n.32xlarge" "Name=zone-id,Values=use1-az1,use1-atl2-az1"

示例输出

{ "Instances": [ { "InstanceId": "i-1111111111example", "InstanceType": "p4d.24xlarge", "GroupName": "ML-group", "NetworkNodes": [ "nn-1111111111example", "nn-2222222222example", "nn-3333333333example" ], "ZoneId": "use1-atl2-az1", "AvailabilityZone": "us-east-1-atl-2a" }, { "InstanceId": "i-2222222222example", "InstanceType": "trn1n.32xlarge", "NetworkNodes": [ "nn-1111111111example", "nn-2222222222example", "nn-3214313214example" ], "ZoneId": "use1-az1", "AvailabilityZone": "us-east-1a" } ], "NextToken": "SomeEncryptedToken" }

示例 5 – 置放群组名称参数

描述指定置放群组中所有实例的实例拓扑

describe-instance-topology CLI 命令与 group-names 参数一起使用。在以下示例中,实例可以位于 ML-groupHPC-group 置放群组中。响应将返回位于任一置放群组中的实例。

aws ec2 describe-instance-topology \ --region us-west-2 \ --group-names ML-group HPC-group

示例输出

{ "Instances": [ { "InstanceId": "i-1111111111example", "InstanceType": "p4d.24xlarge", "GroupName": "ML-group", "NetworkNodes": [ "nn-1111111111example", "nn-2222222222example", "nn-3333333333example" ], "ZoneId": "usw2-az2", "AvailabilityZone": "us-west-2a" }, { "InstanceId": "i-2222222222example", "InstanceType": "trn1n.32xlarge", "GroupName": "HPC-group", "NetworkNodes": [ "nn-1111111111example", "nn-2222222222example", "nn-3214313214example" ], "ZoneId": "usw2-az2", "AvailabilityZone": "us-west-2a" } ], "NextToken": "SomeEncryptedToken" }

示例 6 – 实例 ID

描述指定实例的实例拓扑

describe-instance-topology CLI 命令与 --instance-ids 参数一起使用。响应将返回与指定实例 ID 匹配的实例。

aws ec2 describe-instance-topology \ --region us-west-2 \ --instance-ids i-1111111111example i-2222222222example

示例输出

{ "Instances": [ { "InstanceId": "i-1111111111example", "InstanceType": "p4d.24xlarge", "GroupName": "ML-group", "NetworkNodes": [ "nn-1111111111example", "nn-2222222222example", "nn-3333333333example" ], "ZoneId": "usw2-az2", "AvailabilityZone": "us-west-2a" }, { "InstanceId": "i-2222222222example", "InstanceType": "trn1n.32xlarge", "GroupName": "HPC-group", "NetworkNodes": [ "nn-1111111111example", "nn-2222222222example", "nn-3214313214example" ], "ZoneId": "usw2-az2", "AvailabilityZone": "us-west-2a" } ], "NextToken": "SomeEncryptedToken" }