amazon web services - Auto Scaling Group launch config changes -
i wonder if there simple way or best practices on how ensure instances within autoscaling group have been launched current launch-configuration of autoscaling group.
to give example, imagine auto-scaling group called www-asg
4 desired instances running webservers behind elb. want change ami or userdata used start instances of auto-scaling group. create new launch configuration www-cfg-v2
, update www-asg
use that.
# create new launch config as-create-launch-config www-cfg-v2 \ --image-id 'ami-xxxxxxxx' --instance-type m1.small \ --group web,asg-www --user-data "..." # update asg use new config as-update-auto-scaling-group www-asg --launch-configuration www-cfg-v2
by 4 running instances still use old launch configuration. wonder if there simple way of replacing running instances new instances enforce new configuration, but ensure minimum of instances kept running.
my current way of achieving follows..
- save list of current running instances given autoscaling group
- temporarily increase number of desired instances +1
- wait new instance available
terminate 1 instance list via
as-terminate-instance-in-auto-scaling-group i-xxxx \ --no-decrement-desired-capacity --force
wait replacement instance available
- if more 1 instance left repeat 4.
terminate last instance list via
as-terminate-instance-in-auto-scaling-group i-xxxx \ --decrement-desired-capacity --force
done, instances should run same launch config
i have automated procedure feel there must better way of achieving same goal. knows better more efficient way?
mathias
also posted question in official aws ec2 forum.
this isn't lot different, could:
- create new lc
- create new asg using new lc
- scale down old asg
- delete old asg , lc
i deployments way, , it's in experience roll 1 asg another, rather having jump , forth. noted, it's not huge difference.
it might worth looking at: https://github.com/netflix/asgard , netflix oss tool managing autoscaling groups. ended not using it, it's pretty interesting nonetheless.
Comments
Post a Comment