PropK
PropK

Reputation: 687

Specific Auto-Scaling group Cloudformation AWS

I have an auto scaling group in AWS so i can change stack size of instances created by CF. However when i want to reduce the stack it will terminate random instances in the stack.

I need to know if its possible to reduce stack size in CF but leave specific instances in the stack running using the scaling group?

      "WebServerScaleUpPolicy" : {
  "Type" : "AWS::AutoScaling::ScalingPolicy",
  "Properties" : {
    "AdjustmentType" : "ChangeInCapacity",
    "AutoScalingGroupName" : { "Ref" : "AutoScalingServerGroup" },
    "Cooldown" : "60",
    "ScalingAdjustment" : "1"
  }
},
"WebServerScaleDownPolicy" : {
  "Type" : "AWS::AutoScaling::ScalingPolicy",
  "Properties" : {
    "AdjustmentType" : "ChangeInCapacity",
    "AutoScalingGroupName" : { "Ref" : "AutoScalingServerGroup" },
    "Cooldown" : "60",
    "ScalingAdjustment" : "-1"
  }
}

Any Help Appreciated.

Upvotes: 0

Views: 241

Answers (2)

Laurent Jalbert Simard
Laurent Jalbert Simard

Reputation: 6329

Look into Amazon EC2 Auto Scaling Lifecycle Hooks. As you'll see below, instance can be notified of the Scale In event and either prepare for termination or straight up cancel the scaling event.

enter image description here

Upvotes: 3

mcfinnigan
mcfinnigan

Reputation: 11638

Look into instance scale-in protection, as detailed in this AWS blog post.

I don't use CloudFormation so I'm not sure of the level of support it has for Autoscaling customisation, but this post has a workaround that may work for you.

Upvotes: 2

Related Questions