2

In short - OS Amazon Linux or Ubuntu. One EC2 instance (or OpsWorks instance?) is running. Once a day start second instance, update it with latest security updates, install my app. Shutdown first instance. Repeat every day...

AWS documentation states:

By default, AWS OpsWorks automatically installs the latest updates during setup... We recommend that you... Create and start new instances to replace your current online instances. Then delete the current instances. The new instances will have the latest set of security patches installed during setup.

How to automate this process?

I know, I can start one micro instance to manage this process via CLI, but I would prefer to use some AWS built-in tool, so I can get notifications on failure, to add some redundancy (if CLI instance fails), everything continues to work on new CLI / AWS API versions etc.

Am I missing some elegant approach?

Update: Ability to use existing Elastic IP is preferred.

5

Use EC2 instances behind an ELB.

Upon launch, your nodes should download and install the latest security updates and do whatever other configuration is necessary to get your application running.

As for cycling out your instances, once a day:

  1. Create a second EC2 node
  2. Wait for it to configure itself and become available
  3. Add the second node to the ELB
  4. Remove the old node from the ELB
  5. Shoot the old node in the head

All of the above can be trivially automated using various AWS APIs, perhaps even as a Lambda job.

  • Is there any advantage by using Load Balancer? I can just switch Elastic IP address between new and old instance. – Maris B. Jul 1 '16 at 15:48
  • 2
    Yes, moving an EIP will drop any queries that are in progress. Using an ELB will handle this gracefully. Another benefit of ELB is that you can get a free SSL cert for your domain. – EEAA Jul 1 '16 at 16:01
  • Also, as I have just read, ELB does not support Elastic or Static IP – Maris B. Jul 1 '16 at 16:39
  • That does not matter, and is not needed. You create a CNAME or Alias record that points to your ELB endpoint. – EEAA Jul 1 '16 at 16:41
  • Yes, I know. Static/Elastic IP was preferred, but that's another story. – Maris B. Jul 1 '16 at 16:44

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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