amazon-web-servicesdockeramazon-ecsamazon-amiopendj

Seamless switching of an application from one AMI to another AMI


I am having my OpenDJ LDAP setup running on ubuntu 16.04 base AMI. I now want to replace the base AMI with new patched AMI without impacting my working OpenDJ setup. I need to do this everytime a new AMI is released. One way I can think of is to spin a new EC2 instance with new AMI, export the data from existing LDAP and import it into new EC2 instance. But I am wondering if there is better and smarter way to do this automatically. How do I switch an application from one AMI/EC2 instance to another AMI/EC2 instance without redoing the configuration or breaking its functioning?


Solution

    1. Create an EFS file system to be designated for back-end database files (eg /opt/ds)
    2. Install DS/OpenDJ so that the instance files are separate to the install files. (See quote from this link below)
    3. For each new instance launch the AMI with the updated software as needed.
    4. In the user data script for the instance, you attach the instance data folder from Step 1.

    The purpose of this article is to provide information on installing DS/OpenDJ so that the instance files (user data) are separate to the install files (binaries). This setup allows you to separate all your backend database files and configuration in a separate file system to your binaries

    The approach will isolate application data from software binaries, and allow you to easily switch AMIs