I have an AMI that I use for my rails web servers. This AMI using an EBS Snapshot to launch with the basics all ready for production.

I now need to update some configuration settings on web servers (nginx.conf). I can easily ssh into a box and update the settings but then future launched instances don't have the settings as they use an older snapshot.

How do I go about making it so that new ec2 instances launch with the new settings. I'm guessing I need to update the snapshot? How do I go about updating the snapshot which all the web server ec2 instances use?



One option is the create a new AMI. This is easy these days with a number of tools available like this ruby gem "build-ubuntu-ami". When building the new ami, you can include the new settings.

Another option is that you can use chef/puppet/salt/ansible etc to update all instances with your current ami.

Update: The better option to creating images on all cloud platforms is Packer.

| improve this answer | |
  • Can I do this with the web console? – AnApprentice Nov 26 '12 at 23:32
  • I'm not sure what you mean buyout last sentence. You can't update the AMI of running instances. – EEAA Nov 26 '12 at 23:57
  • Still trying to get steps on how to update the ebs snapshot for an AMI using the AWS Web Console... thx – AnApprentice Nov 27 '12 at 0:15
  • 1
    @AnApprentice What I meant by my comment was, that you don't have to update an existing ami+ebs, even if it were possible. If all you do is run nginx+rails, you can simply create a new ami with your new settings, or use a Cfg management tool to apply the new settings. Since you use rails, I imagined you might be familiar with Ruby and hence suggested a gem. There are multiple options to achieve your end goal, which seems to be updating Nginx for a Rails app. – Not Now Nov 27 '12 at 1:35
  • Thanks, I can easily update Nginx and Rails in the running instance. The trick, where I'm stuck is, after updating how do I then update the AMI's EBS snapshot so future instances have the latest settings? – AnApprentice Nov 27 '12 at 1:39

You can't update a snapshot. You have to update the existing AMI, and take a new snapshot, then register it which will give you a new AMI ID.

I assume your instances are behind an AutoScaler? If so, then you have to update your Launch configuration with your new AMI ID. The easiest way of managing this I find is using Asgard from Netflix

If you are using CloudFormation then you can just update your template and CloudFormation will create the new Launch Configs for you and update the Auto Scaler.

If you just launch your instances manually, then use the new AMI ID when doing so.

| improve this answer | |
  • Martin, thanks. I launch our instances manually. I'm very new to this and could use some more details. Would you mind providing steps on how to update the snapshot? Do I have to start by stopping the current ec2 instances? or do I leave them running and do something with the AMI? Do I then update the ec2 instance w the AMI etc? You can see there are lots of moving parts and I'm not sure the correct ordering. Thanks – AnApprentice Nov 26 '12 at 23:31
  • Do I need to update the existing AMI? Can I take a new snapshot and will the AMI automatically take the latest snapshot? – AnApprentice Nov 27 '12 at 0:16
  • Snapshots are taken when the machine is running. You need to do a bit of housekeeping first, remove logs etc. Here is an example of how to do this philchen.com/2009/05/19/… – Martin Nov 27 '12 at 22:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.