Amazon EC2 實例拓撲示例 - Amazon Elastic Compute Cloud

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

Amazon EC2 實例拓撲示例

您可以使用 describe-instance-topologyCLI 命令描述 EC2 執行個體的執行個體拓撲。

若不搭配參數或篩選條件使用 describe-instance-topology 命令,回應會包含指定區域中符合此命令所支援執行個體類型的所有執行個體。您可以藉由包含 --region 參數或設定預設區域來指定區域。如需設定預設區域的詳細資訊,請參閱:指定資源的區域

您可以加入參數以傳回符合指定執行個體 ID 或放置群組名稱的執行個體。您也可以加入篩選條件,以傳回符合指定執行個體類型或執行個體系列的執行個體,或是指定可用區域或本地區域中的執行個體。您可以包含單一參數或篩選條件,或是參數和篩選條件的組合。

系統會將輸出會分頁,預設每頁最多 20 個執行個體。您可以使用 --max-results 參數指定每頁最多 100 個執行個體。

如需詳細資訊,請參閱 AWS 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:instance-type 篩選條件

您可以依指定的執行個體類型進行篩選 (完全相符),或依執行個體系列進行篩選 (使用萬用字元)。您也可以結合指定的執行個體類型篩選器和執行個體族群篩選。

範例 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:zone-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:結合 instance-type 和 zone-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-group或放HPC-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" }