選取您的 Cookie 偏好設定

我們使用提供自身網站和服務所需的基本 Cookie 和類似工具。我們使用效能 Cookie 收集匿名統計資料,以便了解客戶如何使用我們的網站並進行改進。基本 Cookie 無法停用,但可以按一下「自訂」或「拒絕」以拒絕效能 Cookie。

如果您同意,AWS 與經核准的第三方也會使用 Cookie 提供實用的網站功能、記住您的偏好設定,並顯示相關內容,包括相關廣告。若要接受或拒絕所有非必要 Cookie,請按一下「接受」或「拒絕」。若要進行更詳細的選擇,請按一下「自訂」。

搭配使用 EnterStandby 與 CLI - AWS SDK 程式碼範例

文件 AWS 開發套件範例 GitHub 儲存庫中有更多可用的 AWS SDK 範例

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

文件 AWS 開發套件範例 GitHub 儲存庫中有更多可用的 AWS SDK 範例

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

搭配使用 EnterStandby 與 CLI

下列程式碼範例示範如何使用 EnterStandby

CLI
AWS CLI

將執行個體移至待命模式

此範例會讓指定的執行個體進入待命模式。這對於更新或故障診斷目前正在使用的執行個體非常有用。

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

輸出:

{ "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\"}" } ] }

如需詳細資訊,請參閱《Amazon EC2 Auto Scaling 使用者指南》中的 Amazon EC2 Auto Scaling 執行個體生命週期Amazon EC2 Auto Scaling

  • 如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 EnterStandby

PowerShell
Tools for PowerShell

範例 1:此範例會讓指定的執行個體進入待命模式,並減少所需的容量,讓 Auto Scaling 不會啟動替換執行個體。

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

輸出:

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 :

範例 2:此範例會讓指定的執行個體進入待命模式,而不會減少所需的容量。Auto Scaling 會啟動替換執行個體。

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

輸出:

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 :
  • 如需 API 詳細資訊,請參閱 AWS Tools for PowerShell Cmdlet 參考中的 EnterStandby

AWS CLI

將執行個體移至待命模式

此範例會讓指定的執行個體進入待命模式。這對於更新或故障診斷目前正在使用的執行個體非常有用。

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

輸出:

{ "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\"}" } ] }

如需詳細資訊,請參閱《Amazon EC2 Auto Scaling 使用者指南》中的 Amazon EC2 Auto Scaling 執行個體生命週期Amazon EC2 Auto Scaling

  • 如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 EnterStandby

隱私權網站條款Cookie 偏好設定
© 2025, Amazon Web Services, Inc.或其附屬公司。保留所有權利。