文件 AWS 開發套件範例 GitHub 儲存庫中有更多可用的 AWS SDK 範例
本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
搭配使用 EnterStandby
與 CLI
下列程式碼範例示範如何使用 EnterStandby
。
- AWS CLI
-
將執行個體移至待命模式
此範例會讓指定的執行個體進入待命模式。這對於更新或故障診斷目前正在使用的執行個體非常有用。
aws autoscaling enter-standby \ --instance-ids
i-061c63c5eb45f0416
\ --auto-scaling-group-namemy-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
。
-