简体   繁体   中英

AWS: how to configure EC2 instances during auto scale

I'm currently preparing to leverage the features of AWS more, still a few questions arose during my research. I'm currently interested in a combination of AWS autoscaling with multiple auto scale groups (one for each service) as well as deployment with AWS code deploy.

I'm wondering what are common practices to configure the EC2 instance which will get spun up when AWS notices that I need a new EC2 instance. I thought about creating a custom AMI where everything is installed that I need for the application to run. Are there other possibilities? How would something like Ansible play into in this setup? Also, what if I need to change the instances like install a security update, what is a common practice to do so without sshing to each server instance and doing it manually.

Thanks

There are basically two choices for configuring an Amazon EC2 instance that is created using Auto Scaling:

  • A fully-configured AMI
  • A User Data script that configures the instance

You could also use a combination of the two -- have most of it configured on an AMI, then do the final configuration via User Data.

Tools like Puppet, Chef and Ansible are also popular. They are triggered via User Data script, that then runs Puppet/Chef/Ansible to install software on the instance.

The benefit of using a fully-configured AMI is that the instance is available more quickly, which is handy in an auto-scaling situation where you need more capacity fast . The downside is that you must create a new AMI whenever the software has been updated. Netflix have automated this process with Aminator , which automatically builds a new AMI when software is updated.

The benefit of using a User Data script is that the configuration is fully flexible and you do not need to maintain a library of AMIs.

尝试在自动缩放配置期间添加引导脚本。

First of all if you were looking for Provisioning Automation of AWS infra, then go through Ansible , CloudFormation and Terraform , choice is yours.

You can prepare GoldenImage with all required packages, tools, security configs installed within it. After that you can create Launch Configuration for Auto Scaling Group , within the launch configuration, you can also provide your custom startup scripts .

Afterworld, if for any ad-hoc task or command execution, ansible is best choice.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM