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

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

Verwendung von EnterStandby mit einer CLI

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

CLI
AWS CLI

So verschieben Sie Instances in den Standby-Modus

In diesem Beispiel wird die angegebene Instance in den Standby-Modus versetzt. Das ist nützlich, um eine Instance zu aktualisieren oder Fehler zu beheben, die sich derzeit im Service befindet.

aws autoscaling enter-standby \ --instance-ids i-061c63c5eb45f0416 \ --auto-scaling-group-name my-asg \ --should-decrement-desired-capacity

Ausgabe:

{ "Activities": [ { "ActivityId": "ffa056b4-6ed3-41ba-ae7c-249dfae6eba1", "AutoScalingGroupName": "my-asg", "Description": "Moving EC2 instance to Standby: i-061c63c5eb45f0416", "Cause": "At 2020-10-31T20:31:00Z instance i-061c63c5eb45f0416 was moved to standby in response to a user request, shrinking the capacity from 1 to 0.", "StartTime": "2020-10-31T20:31:00.949Z", "StatusCode": "InProgress", "Progress": 50, "Details": "{\"Subnet ID\":\"subnet-6194ea3b\",\"Availability Zone\":\"us-west-2c\"}" } ] }

Weitere Informationen finden Sie unter Lebenszyklus-Hooks für Amazon EC2 Auto Scaling im Benutzerhandbuch zu Amazon EC2 Auto Scaling.

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

PowerShell
Tools für PowerShell V4

Beispiel 1: In diesem Beispiel wird die angegebene Instance in den Standby-Modus versetzt und die gewünschte Kapazität verringert, sodass Auto Scaling keine Ersatz-Instance startet.

Enter-ASStandby -InstanceId i-93633f9b -AutoScalingGroupName my-asg -ShouldDecrementDesiredCapacity $true

Ausgabe:

ActivityId : e36a5a54-ced6-4df8-bd19-708e2a59a649 AutoScalingGroupName : my-asg Cause : At 2015-11-22T15:48:06Z instance i-95b8484f was moved to standby in response to a user request, shrinking the capacity from 2 to 1. Description : Moving EC2 instance to Standby: i-95b8484f Details : {"Availability Zone":"us-west-2b","Subnet ID":"subnet-5264e837"} EndTime : Progress : 50 StartTime : 11/22/2015 7:48:06 AM StatusCode : InProgress StatusMessage :

Beispiel 2: In diesem Beispiel wird die angegebene Instance in den Standby-Modus versetzt, ohne die gewünschte Kapazität zu verringern. Auto Scaling startet eine neue Ersatz-Instance.

Enter-ASStandby -InstanceId i-93633f9b -AutoScalingGroupName my-asg -ShouldDecrementDesiredCapacity $false

Ausgabe:

ActivityId : e36a5a54-ced6-4df8-bd19-708e2a59a649 AutoScalingGroupName : my-asg Cause : At 2015-11-22T15:48:06Z instance i-95b8484f was moved to standby in response to a user request. Description : Moving EC2 instance to Standby: i-95b8484f Details : {"Availability Zone":"us-west-2b","Subnet ID":"subnet-5264e837"} EndTime : Progress : 50 StartTime : 11/22/2015 7:48:06 AM StatusCode : InProgress StatusMessage :
  • Weitere API-Informationen finden Sie unter EnterStandby in der AWS -Tools für PowerShell-Cmdlet-Referenz (V4).

Tools für PowerShell V5

Beispiel 1: In diesem Beispiel wird die angegebene Instance in den Standby-Modus versetzt und die gewünschte Kapazität verringert, sodass Auto Scaling keine Ersatz-Instance startet.

Enter-ASStandby -InstanceId i-93633f9b -AutoScalingGroupName my-asg -ShouldDecrementDesiredCapacity $true

Ausgabe:

ActivityId : e36a5a54-ced6-4df8-bd19-708e2a59a649 AutoScalingGroupName : my-asg Cause : At 2015-11-22T15:48:06Z instance i-95b8484f was moved to standby in response to a user request, shrinking the capacity from 2 to 1. Description : Moving EC2 instance to Standby: i-95b8484f Details : {"Availability Zone":"us-west-2b","Subnet ID":"subnet-5264e837"} EndTime : Progress : 50 StartTime : 11/22/2015 7:48:06 AM StatusCode : InProgress StatusMessage :

Beispiel 2: In diesem Beispiel wird die angegebene Instance in den Standby-Modus versetzt, ohne die gewünschte Kapazität zu verringern. Auto Scaling startet eine neue Ersatz-Instance.

Enter-ASStandby -InstanceId i-93633f9b -AutoScalingGroupName my-asg -ShouldDecrementDesiredCapacity $false

Ausgabe:

ActivityId : e36a5a54-ced6-4df8-bd19-708e2a59a649 AutoScalingGroupName : my-asg Cause : At 2015-11-22T15:48:06Z instance i-95b8484f was moved to standby in response to a user request. Description : Moving EC2 instance to Standby: i-95b8484f Details : {"Availability Zone":"us-west-2b","Subnet ID":"subnet-5264e837"} EndTime : Progress : 50 StartTime : 11/22/2015 7:48:06 AM StatusCode : InProgress StatusMessage :
  • Weitere API-Informationen finden Sie unter EnterStandby in der AWS -Tools für PowerShell-Cmdlet-Referenz (V5).