Customers running stateful workloads on Amazon Elastic Compute Cloud ( Amazon EC2 ) need to patch operating systems, upgrade OS versions, remediate vulnerabilities quickly, and patch applications in user space. These workloads are connected to resources such as Elastic IP addresses , secondary network interfaces, attached data volumes, AWS Identity and Access Management ( IAM ) instance profiles, and DNS records. For OS upgrades or patches that require downtime, a common approach is to replace the instance with a new one launched from a newer Amazon Machine Image (AMI).
That approach means moving each of these resources to the new instance. With Amazon EC2 Replace Root Volume ( RRV ) using Amazon Elastic Block Store ( Amazon EBS ), you can prepare and validate a replacement root volume in advance. You then swap it onto a running production instance with a single API call. The interruption is limited to the reboot that RRV performs and the time your application takes to restart.
In this post, we show how to use the existing EBS volume option of root volume replacement on a Linux instance to upgrade the operating system generation and apply patches, while the instance keeps its production identity. We also cover instances in Amazon EC2 Auto Scaling groups. It’s a two-phase process: in the preparation phase you build the new root volume, and in the replacement phase you call the root volume replacement API, which swaps the volume and reboots the instance.
Step 1 – Preparation phase : On a separate preparation instance, you create a new volume from a newer OS AMI, patch and configure it in a chroot, and test a copy on a non-production instance. Figure 1: Preparation phase. You build and validate the replacement root volume on a separate instance before touching production. Step 2 – Replacement phase : The create-replace-root-volume-task call starts a task that, during one reboot, detaches the original root volume and attaches the prepared one.
