0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【AWS】AWS Systems Manager Automationで「SetDesiredCapacity value 0 is below min value 1 for the AutoScalingGroup」エラー

Posted at

概要

AWS Systems Manager AutomationでAutoScalingGroupのキャパシティー(インスタンスの数)を0にしたくて、Runbookを以下のように記載して実行。

description: Set AutoScalingGroup DesiredCapacity to 0
schemaVersion: '0.3'
parameters:
  AutoScalingGroupName:
    type: String
    description: AutoScalingGroup name
    default: Ec2AutoScalingGroup-Sample
  DesiredCapacity:
    type: Integer
    description: Desired capacity
    default: 0
assumeRole: arn:aws:iam::xxxxxxxxxxxx:role/AutomationAssumeRole
mainSteps:
- name: setDesiredCapacity
  action: aws:executeAwsApi
  isEnd: true
  inputs:
    Service: autoscaling
    Api: SetDesiredCapacity
    AutoScalingGroupName: '{{ AutoScalingGroupName }}'
    DesiredCapacity: '{{ DesiredCapacity }}'
    HonorCooldown: false

すると、以下のエラーになりました。

Step fails when it is Execute/Cancelling action. An error occurred (ValidationError) when calling the SetDesiredCapacity operation: New SetDesiredCapacity value 0 is below min value 1 for the AutoScalingGroup.. Please refer to Automation Service Troubleshooting Guide for more diagnosis details.

原因と解決方法

エラーの原因は、AutoScalingGroupのMinSizeが1なのに、DesiredCapacityを0にしようとしたため、でした。

AutoScalingGroupにはMinSize(最小インスタンス数)が設定されているので、そちらをまず0にしないと、希望インスタンス数を0にしてもエラーになってしまうよ、というオチでした...。

以下のように、AutoScalingGroupのDesiredCapacity/MinSize/MaxSizeを直接0にすることで、エラーがなくなり、無事にEC2インスタンスの数を0にすることができました。

description: Set AutoScalingGroup DesiredCapacity/MinSize/MaxSize to 0
schemaVersion: '0.3'
parameters:
  AutoScalingGroupName:
    type: String
    description: AutoScalingGroup name
    default: Ec2AutoScalingGroup-Sample
assumeRole: arn:aws:iam::xxxxxxxxxxxx:role/AutomationAssumeRole
mainSteps:
  - name: setDesiredCapacity
    action: aws:executeAwsApi
    isEnd: true
    inputs:
      Service: autoscaling
      Api: UpdateAutoScalingGroup
      AutoScalingGroupName: "{{ AutoScalingGroupName }}"
      MinSize: 0
      MaxSize: 0
      DesiredCapacity: 0

AutomationAssumeRoleには、autoscaling:UpdateAutoScalingGroupを付与する

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?