June 2012
« May   Jul »

Auto scaling : Updating ScalingGroup with latest AMI ID

You may need to update the AMI frequently when there is new s/w or application revision has published. So this steps should be executed many times whenever there is an update on application.

To override this, I uses a script to syncronize the files in remote ftp/scp location with my server document root which is added as a script on cron job.

Let us make this steps simpler. The major steps involved in this steps are creating new launch config and updating the existing scaling group. Then you may delete the existing LC once all are in place.

Create a new Launch Config which will be using our latest EBS image. Say my new AMI ID is ami-c2a0d3ab

[root@rc-026 ~]# as-create-launch-config BLC_new --image-id ami-c2a0d3ab  --instance-type c1.medium --key botch --group Web-secure
OK-Created launch config

Listing all the launch Config

[root@rc-026 ~]# as-describe-launch-configs
LAUNCH-CONFIG  BLC      ami-e46108d  c1.medium
LAUNCH-CONFIG  BLC_new  ami-c2a0d3ab  c1.medium
[root@rc-026 ~]#

Now we need to terminate all the running instance from Scaling Group.

Terminate all the instances

[root@rc-026 bin]# as-update-auto-scaling-group BSG --min-size 0 --max-size 0

Then we need to update the existing Scaling Group

[root@rc-026 ~]# as-update-auto-scaling-group BSG --launch-configuration BLC_new --availability-zones us-east-1c --min-size 1 --max-size 3
OK-Updated AutoScalingGroup

Note : We do not need to mention the loadbalencer associate with this Scaling Group.

Listing out the existing scaling group

[root@rc-026 ~]#  as-describe-auto-scaling-groups
AUTO-SCALING-GROUP  BSG  BLC_new  us-east-1d  BotcheeLB  1  3  1
INSTANCE  i-72d045b  us-east-1d  InService  Healthy  BLC_new
[root@rc-026 ~]#

Deleting Lauch Config

[root@rc-026 ~]# as-describe-launch-configs
LAUNCH-CONFIG  BLC      ami-e461c08d  c1.medium
LAUNCH-CONFIG  BLC_new  ami-c2a003ab  c1.medium
[root@rc-026 ~]# as-delete-launch-config BLC
Are you sure you want to delete this launch configuration? [Ny]y
OK-Deleted launch configuration
[root@rc-026 ~]#

That’s so simple !! Now the time for sit back and relax 🙂

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>