0
votes

I am trying to leverage the power of elastic beanstalk with a fresh wordpress install. To keep it stateless I am trying to use EFS to persist wp-content files between ec2 instances, but for some reason I can't get my EFS setup to persist my wp-content folder.

The following is my efs.config file.

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/wp-content
      chown webapp:webapp /mnt/efs/wp-content
      mkdir -p /mnt/efs/wp-content/themes
      chown webapp:webapp /mnt/efs/wp-content/themes
      mkdir -p /mnt/efs/wp-content/plugins
      chown webapp:webapp /mnt/efs/wp-content/plugins
      mkdir -p /mnt/efs/wp-content/uploads
      chown webapp:webapp /mnt/efs/wp-content/uploads
commands:
  01_mount:
    command: "/tmp/mount-efs.sh"
container_commands:
  01-rm-wp-content-uploads:
    command: rm -rf /var/app/ondeck/wp-content
  02-symlink-uploads:
    command: ln -snf /mnt/efs/wp-content /var/app/ondeck/wp-content

It seems like it's mounting and deleting the files? Each time when a new instance is auto created I was able to ssh into the instance and see the new instance mount a wp-content folder but without my existing files?

Thanks in Advance! Also, would I be able to see what files are in EFS directly in the AWS console? Thanks.

1

1 Answers

0
votes

You need setup to mount your efs folder automatically when your instance reboots.

Follow the steps which mention in this article.

http://docs.aws.amazon.com/efs/latest/ug/mount-fs-auto-mount-onreboot.html