amazon-web-servicesamazon-efsautomount

Mounting EFS using .ebextensions file


I am deploying a PHP app using AWS Elastic Beanstalk. I would like to use EFS I've already built. I'm using a .ebextension folder using following link as guide:

https://github.com/awsdocs/elastic-beanstalk-samples/blob/master/configuration-files/aws-provided/instance-configuration/storage-efs-mountfilesystem.config

I have configured the storage-efs-mountfilesystem.config file in .ebextension folder file:

option_settings:
  aws:elasticbeanstalk:application:environment:
    FILE_SYSTEM_ID: fs-12345678
    MOUNT_DIRECTORY: '/efs'

When I look in my ec2 instance spun up from elastic beanstalk, I do not see the EFS mounted. I am trying to figure out what might be the issue here? Wouldn't it be better to have EFS details in a file in .ebextension folder so it can be persistently mounted when software is deployed regularly?


Solution

  • Based on the additional information from comments.

    The issue is due to:

    /opt/elasticbeanstalk/bin/get-config: No such file or directory
    

    This file exists only for EB environments running Amazon Linux 1, not for Amazon Linux 2. Since PHP 7.4 running on 64bit Amazon Linux 2/3.0. is used, the storage-efs-mountfilesystem.config fails, as it requires Amazon Linux 1.

    In this situation there are generally two options to rectify the issue:

    1. Use Amazon Linux 1.
    2. Or adapt storage-efs-mountfilesystem.config to work with Amazon Linux 2.

    It should be noted that there are many differences between Amazon Linux 1 and 2. General steps to migrate from the older to newer version are below: