How can I mount an Amazon EFS volume to an instance in my Elastic Beanstalk environment?

Last updated: 2019-10-11

How can I mount an Amazon Elastic File System (Amazon EFS) volume to an instance in my AWS Elastic Beanstalk environment?

Short Description

In an Elastic Beanstalk environment, you can use Amazon EFS to create a shared directory that stores files uploaded or modified by users of your application. Your application can treat a mounted Amazon EFS volume like local storage, so you don't have to change your application code to scale up to multiple instances.

To mount an Amazon EFS volume to an Amazon Elastic Compute Cloud (Amazon EC2) instance in your Elastic Beanstalk environment, you must include configuration files in your source code.


1.    Create an Amazon EFS File System, and note the EFS ID.

2.    In the root of your application bundle, create a directory named .ebextensions.

3.    Add a formatted configuration file (YAML or JSON) to your directory.

Note: The configuration file includes a script that adds an entry in the fstab (file system table) system configuration file, and mounts all (-a) file systems listed in the fstab file of type (-t) nfs4. The type is always nfs4 for Amazon EFS. The file systems listed in the fstab file are automatically mounted using the mount -a command during deployment.

4.    Deploy the source code that includes the configuration file from step 3 to your Elastic Beanstalk application.

5.    To confirm that your Amazon EFS volume is mounted to your instance on your specified mount path, run the following command:

dh -H

Did this article help you?

Anything we could improve?

Need more help?