Verwendung von DescribeHosts mit einer CLI - AWS-SDK-Codebeispiele

Weitere AWS-SDK-Beispiele sind im GitHub-Repository Beispiele für AWS Doc SDKs verfügbar.

Verwendung von DescribeHosts mit einer CLI

Die folgenden Code-Beispiele zeigen, wie DescribeHosts verwendet wird.

CLI
AWS CLI

So zeigen Sie die Details zu Dedicated Hosts an

Im folgenden describe-hosts-Beispiel werden Details zu den available Dedicated Hosts in Ihrem AWS-Konto angezeigt.

aws ec2 describe-hosts --filter "Name=state,Values=available"

Ausgabe:

{ "Hosts": [ { "HostId": "h-07879acf49EXAMPLE", "Tags": [ { "Value": "production", "Key": "purpose" } ], "HostProperties": { "Cores": 48, "TotalVCpus": 96, "InstanceType": "m5.large", "Sockets": 2 }, "Instances": [], "State": "available", "AvailabilityZone": "eu-west-1a", "AvailableCapacity": { "AvailableInstanceCapacity": [ { "AvailableCapacity": 48, "InstanceType": "m5.large", "TotalCapacity": 48 } ], "AvailableVCpus": 96 }, "HostRecovery": "on", "AllocationTime": "2019-08-19T08:57:44.000Z", "AutoPlacement": "off" } ] }

Weitere Informationen dazu finden Sie unter Anzeigen von Dedicated Hosts im Amazon Elastic Compute Cloud – Benutzerhandbuch zu Linux-Instances.

  • Weitere API-Informationen finden Sie unter DescribeHosts in der AWS CLI-Befehlsreferenz.

PowerShell
Tools für PowerShell V4

Beispiel 1: Dieses Beispiel gibt die EC2-Hostdetails zurück.

Get-EC2Host

Ausgabe:

AllocationTime : 3/23/2019 4:55:22 PM AutoPlacement : off AvailabilityZone : eu-west-1b AvailableCapacity : Amazon.EC2.Model.AvailableCapacity ClientToken : HostId : h-01e23f4cd567890f1 HostProperties : Amazon.EC2.Model.HostProperties HostReservationId : Instances : {} ReleaseTime : 1/1/0001 12:00:00 AM State : available Tags : {}

Beispiel 2: In diesem Beispiel wird die AvailableInstanceCapacity für den Host h-01e23f4cd567899f1 abgefragt.

Get-EC2Host -HostId h-01e23f4cd567899f1 | Select-Object -ExpandProperty AvailableCapacity | Select-Object -expand AvailableInstanceCapacity

Ausgabe:

AvailableCapacity InstanceType TotalCapacity ----------------- ------------ ------------- 11 m4.xlarge 11
  • Weitere API-Informationen finden Sie unter DescribeHosts in der AWS -Tools für PowerShell-Cmdlet-Referenz (V4).

Tools für PowerShell V5

Beispiel 1: Dieses Beispiel gibt die EC2-Hostdetails zurück.

Get-EC2Host

Ausgabe:

AllocationTime : 3/23/2019 4:55:22 PM AutoPlacement : off AvailabilityZone : eu-west-1b AvailableCapacity : Amazon.EC2.Model.AvailableCapacity ClientToken : HostId : h-01e23f4cd567890f1 HostProperties : Amazon.EC2.Model.HostProperties HostReservationId : Instances : {} ReleaseTime : 1/1/0001 12:00:00 AM State : available Tags : {}

Beispiel 2: In diesem Beispiel wird die AvailableInstanceCapacity für den Host h-01e23f4cd567899f1 abgefragt.

Get-EC2Host -HostId h-01e23f4cd567899f1 | Select-Object -ExpandProperty AvailableCapacity | Select-Object -expand AvailableInstanceCapacity

Ausgabe:

AvailableCapacity InstanceType TotalCapacity ----------------- ------------ ------------- 11 m4.xlarge 11
  • Weitere API-Informationen finden Sie unter DescribeHosts in der AWS -Tools für PowerShell-Cmdlet-Referenz (V5).