Reputation: 171
I would like to start a new instance inside an Auto-Scaling group so the new instance will be 100% identical to other instances in this group. In other words I want to do the same thing AWS does when scaling rules are triggered.
What API method I need to call to achieve this?
Upvotes: 1
Views: 164
Reputation: 26003
You can achieve this with the DescribeAutoScalingGroups API and the SetDesiredCapacity API.
Pseudocode:
DesiredCapacity = CurrentDesiredCapacity + 1
SetDesiredCapacity allows you to change the "desired capacity" of an AutoScaling group. If you increase the current desired capacity by 1, the AutoScaling Group will launch a new instance based on the AMI associated with your launch configuration. This is what scaling policies do within the bounds of your min/max capacity.
SetDesiredCapacity API Example: (from docs)
https://autoscaling.amazonaws.com/?Action=SetDesiredCapacity
&AutoScalingGroupName=my-asg
&HonorCooldown=false
&DesiredCapacity=2
&Version=2011-01-01
&AUTHPARAMS
set-desired-capacity CLI Example: (from docs)
aws autoscaling set-desired-capacity --auto-scaling-group-name my-auto-scaling-group --desired-capacity 2 --no-honor-cooldown
Reference:
Upvotes: 2