amazon-web-servicesamazon-elastic-beanstalkconfigamazon-efsebextensions

EFS symlink fails while deploying


So I use AWS Elastic Beanstalk to serve my PHP application. I want to mount EFS to have permanent storage for the images uploaded via my application. I have created .ebextensions folder and created one file called mount.config with the below code

packages:
  yum:
    nfs-utils: []
    jq: []
files:
  "/tmp/mount-efs.sh" :
    mode: "000755"
    content: |
      #!/usr/bin/env bash
      mkdir -p /mnt/efs
      EFS_NAME=$(/opt/elasticbeanstalk/bin/get-config environment | jq -r '.EFS_NAME')
      mount -t nfs4 -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2 $EFS_NAME:/ /mnt/efs || true
      mkdir -p /mnt/efs/questions
      chown webapp:webapp /mnt/efs/questions
commands:
  01_mount:
    command: "/tmp/mount-efs.sh"
container_commands:
  01-symlink-uploads:
    command: ln -s /mnt/efs/questions /var/app/ondeck/images/

Everything is working fine until the last line where it fails to create a symlink.

What I have tried so far:

In the logs I see

ln: failed to create symbolic link '/var/app/current/images/questions': No such file or directory

Any suggestion what could be the reason?


Solution

  • Ok, I fixed it by replacing ondeck with staging

    And adding this line under container_commands:

      01-change-permission:
        command: chmod -R 777 /var/app/staging/images