skip to Main Content

I’m new to AWS and a little perplexed as to the situation with var/www/html folder in an EC2 instance in which Apache has been installed.

After setting up an Elastic Beanstalk service and uploading the files, I see that these are stored in the regular var/www/html folder of the instance.

From reading AWS documents, it seems that instances may be deleted and re-provisioned, which is why use of an S3 bucket, EFS or EBS is recommended.

Why, then, is source code stored in the EC2 instance when using an apache server? Won’t these files potentially be deleted with the instance?

3

Answers


  1. Chosen as BEST ANSWER

    Seems that, when the app is first deployed, all files are uploaded to an S3 bucket, from where these are copied into the relevant directory of each new instance. In the event new instances have to be created (such as for auto-scaling) or replaced, these instances also pull the code from the S3 bucket. This is also how the app is re-deployed - the bucket is updated and each instance makes a new copy of the code.

    Apologies if this is stating the obvious to some people, but I had seen a few similar queries.


  2. If you manually uploaded some files and data to /var/www/html then off course they will be wiped out when AWS is going to replace/delete the instance, e.g. due to autoscalling.

    All files that you use on EB should be part of your deployment package, and all files that, e.g. your users upload, should be stored outside of Eb, e.g. on S3.

    Login or Signup to reply.
  3. Even if the instance is terminated for some reason, since the source code is part of your deployment package on Beanstalk it can provision another instance to replace with the exact same application and configurations. Basically you are losing this data, but it doesn’t matter.

    The data loss concern is for anything you do that is not part of the automated provisioning/deployment, ie any manual configuration changes or any data your application may write to ephemeral storage. This is what you would need a more persistent storage option for.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search