CLI로 EnterStandby 사용 - AWS SDK 코드 예제

AWS SDK 예제 GitHub 리포지토리에 더 많은 AWS문서 SDK 예제가 있습니다.

CLI로 EnterStandby 사용

다음 코드 예시는 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 instance lifecycle 섹션을 참조하세요.

  • API 세부 정보는 AWS CLI 명령 참조의 EnterStandby를 참조하세요.

PowerShell
Tools for PowerShell V4

예제 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 참조(V4)EnterStandby를 참조하세요.

Tools for PowerShell V5

예제 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 참조(V5)EnterStandby를 참조하세요.