问题
Could you suggest in which ways I can deploy code changes from SVN to all ec2 instances running behind Amazon load balancer in auto-scaling group? I also need to update code to latest version when a new ec2 instance launching automatically in auto-scaling group.
I suppose to use 'user-data' to run 'svn up' on new machines. And probably I could use cron to run 'svn up' periodically on all machines. Could you suggest better solutions?
回答1:
In my opinion, you shouldn't be updating code on the running instances, better to create an master AMI that has all the updated stack/code ready to go and then methodically terminate the running instances and let the auto scaling code to care of deploying new instances as needed, which will in effect deploy your new code.
You can use AWS Cloudformation for this task: http://aws.amazon.com/about-aws/whats-new/2013/02/20/announcing-new-aws-cloudformation-deployment-enhancements/
or ElasticBeanStalk:
http://aws.amazon.com/about-aws/whats-new/2013/11/11/aws-elastic-beanstalk-announces-rolling-updates/
Try googling "AWS Rolling Updates" for even more helpful links.
来源:https://stackoverflow.com/questions/21023388/how-to-deploy-and-update-app-on-multiply-ec2-instances-in-amazon-auto-scaling-gr