I would like to have a load balancer for my site and have the site up to date. The load balancer will take the AMI I select and spin up more of those instances when processing power hits a certain level. The problem is the AMI may not be up to date so I'll have some instances up to date and others not. When I deploy I can deploy to all the instances under the load balancer without issue, but I would need to know whenever the load balancer spins up a new instance in order to trigger this deployment. Also there would be a block of time when the updates happen greatly decreasing its responsiveness. So I've come up with a plan.
My plan:
After deploy:
identify one of the instances and
get instance id
identify volume of instance id
ec2-create-snapshot vol-yyyyyyyy
get snapshot volume id
ec2reg -s snap-zzzzzzzz -a x86 -d Description -n imagename
get image id
as-delete-launch-config existinglaunchconfig
as-create-launch-config mylaunchconfig --image-id IMAGEID --instance-type m1.small --key mykey --group mysecuritygroup
as-update-auto-scaling-group --launch-configuration mylaunchconfig
Before I go and spend however many hours trying to figure this out and scripting it all, testing, and everything else, my question is: Will this work? Is there a better way? Is there a tutorial or post that anyone knows of that would speed up my efforts on this issue? Thanks.