AWS Auto-Scaling – Host Multiple Websites with EFS

amazon-web-servicesApache2aws-ec2Ubuntu

I hope this is a simple question.
Currently I have an Apache2 webserver on Ubuntu with multiple websites.
The basic structure of the Apache is

/etc
  /apache2
     /sites-available  --> the .conf files for the websites
     /sites-enabled    --> the enabled .conf file links for the websites
/var
  /www
    /html
      /sites-admin     --> the location of the websites code

My task is to create an auto-scaling group that will be adjusting with the load.
My thought is to mount an EFS drive under /var/www/html/efs_mount and store the websites code there

However, this creates two issues:

  1. this approach does not accommodate adding websites as i will have to update AMI and launch template, as well as instance refresh every time I add a website
  2. when adding the website configuration to /etc/apache2/sites-available, in order to enable it we run a2ensite webiste.conf. as in the issue #1 this requires an update to the AMI and launch template, as well as instance refresh

Is there a way to work around this issue?
I know there's an option to use code deploy with the in-place or replace approach. Are there any other options?

Thanks
Igal

Best Answer

This was resolved by mounting EFS under /mnt/efs/fs1, setting the Apache root directory to /mnt/efs/fs1/www/html, and configuring bitbucket pipelines to trigger AWS CodeDeploy to deploy to the root directory and, as part of the script, run sudo systemctl reload apache2

Related Topic