5

UPDATE WITH SOLUTIONS: Instead of zipping the directory, I selected all the files and folder within the directory and compressed those. Then I changed the permissions of the zipped folder to 777. Also, in the efs-mount.config file, I changed the commands to:

1chown:
    command: "chown webapp:webapp /drupalfiles"
  2create: 
    command: "sudo -u webapp mkdir -p sites/default/files" 
  3link: 
    command: "sudo -u webapp ln -s /drupalfiles sites/default/files"



Original Question:
I am fairly new to both AWS and Drupal.

I am trying to install Drupal 8 on AWS Elastic Beanstalk following this documentation:

https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/php-hadrupal-tutorial.html#php-hadrupal-tutorial-launch

When I get to "Launch an Elastic Beanstalk Environment", I continually get this error, and I can never get to the Drupal 8 install screen.

Command failed on instance. Return code: 1 Output: ln: failed to create symbolic link 'sites/default/files': No such file or directory. container_command 2link in elastic-beanstalk/.ebextensions/efs-mount.config failed. For more detail, check /var/log/eb-activity.log using console or EB CLI.

I have made sure that this folder and all recursive folders permissions are set to read and write.

Environment Dashboard: enter image description here

Activity Log:

[2018-02-19T19:15:07.237Z] INFO  [31021] - [Application restart/AddonsBefore] : Starting activity...
[2018-02-19T19:15:07.237Z] INFO  [31021] - [Application restart/AddonsBefore/ConfigCWLAgent] : Starting activity...
[2018-02-19T19:15:07.237Z] INFO  [31021] - [Application restart/AddonsBefore/ConfigCWLAgent/10-config.sh] : Starting activity...
[2018-02-19T19:15:07.495Z] INFO  [31021] - [Application restart/AddonsBefore/ConfigCWLAgent/10-config.sh] : Completed activity. Result:
Log streaming option setting is not specified, ignore cloudwatch logs setup.

Disabled log streaming.
[2018-02-19T19:15:07.495Z] INFO  [31021] - [Application restart/AddonsBefore/ConfigCWLAgent] : Completed activity. Result:
Successfully execute hooks in directory /opt/elasticbeanstalk/addons/logstreaming/hooks/config.
[2018-02-19T19:15:07.495Z] INFO  [31021] - [Application restart/AddonsBefore] : Completed activity.
[2018-02-19T19:15:07.496Z] INFO  [31021] - [Application restart/RestartAppServerStage0] : Starting activity...
[2018-02-19T19:15:07.496Z] INFO  [31021] - [Application restart/RestartAppServerStage0/RestartAppServerPreHook] : Starting activity...
[2018-02-19T19:15:07.496Z] INFO  [31021] - [Application restart/RestartAppServerStage0/RestartAppServerPreHook/10_configure_php.sh] :     Starting activity...
[2018-02-19T19:15:08.567Z] INFO  [31021] - [Application restart/RestartAppServerStage0/RestartAppServerPreHook/10_configure_php.sh] : Completed activity. Result:
 Using configuration value for DocumentRoot: 
[2018-02-19T19:15:08.567Z] INFO  [31021] - [Application restart/RestartAppServerStage0/RestartAppServerPreHook] : Completed activity. Result:
 Successfully execute hooks in directory /opt/elasticbeanstalk/hooks/restartappserver/pre.
[2018-02-19T19:15:08.567Z] INFO  [31021] - [Application restart/RestartAppServerStage0] : Completed activity. Result:
Application restart - Command CMD-RestartAppServer stage 0 completed
[2018-02-19T19:15:08.567Z] INFO  [31021] - [Application restart/RestartAppServerStage1] : Starting activity...
[2018-02-19T19:15:08.568Z] INFO  [31021] - [Application restart/RestartAppServerStage1/RestartAppServerEnactHook] : Starting activity...
[2018-02-19T19:15:08.568Z] INFO  [31021] - [Application restart/RestartAppServerStage1/RestartAppServerEnactHook/01_restart.sh] :     Starting activity...
[2018-02-19T19:15:08.680Z] INFO  [31021] - [Application restart/RestartAppServerStage1/RestartAppServerEnactHook/01_restart.sh] : Completed activity. Result:
  Equivalent Upstart operations: start httpd, stop httpd, restart httpd, status httpd
  Stopping httpd
  httpd stop/waiting
  Starting httpd
  httpd start/running, process 31087
  [OK]
[2018-02-19T19:15:08.680Z] INFO  [31021] - [Application restart/RestartAppServerStage1/RestartAppServerEnactHook] : Completed activity. Result:
  Successfully execute hooks in directory /opt/elasticbeanstalk/hooks/restartappserver/enact.
[2018-02-19T19:15:08.680Z] INFO  [31021] - [Application restart/RestartAppServerStage1/RestartAppServerPostHook] : Starting activity...
[2018-02-19T19:15:08.681Z] INFO  [31021] - [Application restart/RestartAppServerStage1/RestartAppServerPostHook] : Completed activity. Result:
 Successfully execute hooks in directory /opt/elasticbeanstalk/hooks/restartappserver/post.
[2018-02-19T19:15:08.681Z] INFO  [31021] - [Application restart/RestartAppServerStage1] : Completed activity. Result:
 Application restart - Command CMD-RestartAppServer stage 1 completed
[2018-02-19T19:15:08.681Z] INFO  [31021] - [Application restart/AddonsAfter] : Starting activity...
[2018-02-19T19:15:08.681Z] INFO  [31021] - [Application restart/AddonsAfter/ConfigLogRotation] : Starting activity...
[2018-02-19T19:15:08.682Z] INFO  [31021] - [Application restart/AddonsAfter/ConfigLogRotation/10-config.sh] : Starting activity...
[2018-02-19T19:15:09.048Z] INFO  [31021] - [Application restart/AddonsAfter/ConfigLogRotation/10-config.sh] : Completed activity. Result:
 Disabled forced hourly log rotation.
[2018-02-19T19:15:09.048Z] INFO  [31021] - [Application restart/AddonsAfter/ConfigLogRotation] : Completed activity. Result:
 Successfully execute hooks in directory /opt/elasticbeanstalk/addons/logpublish/hooks/config.
[2018-02-19T19:15:09.048Z] INFO  [31021] - [Application restart/AddonsAfter] : Completed activity.
[2018-02-19T19:15:09.048Z] INFO  [31021] - [Application restart] : Completed activity. Result:
 Application restart - Command CMD-RestartAppServer succeeded
[2018-02-19T19:34:27.980Z] INFO  [31597] - [Configuration update drupal-8.4.4@3] : Starting activity...
[2018-02-19T19:34:27.981Z] INFO  [31597] - [Configuration update drupal-8.4.4@3/AddonsBefore] : Starting activity...
[2018-02-19T19:34:27.981Z] INFO  [31597] - [Configuration update drupal-8.4.4@3/AddonsBefore/ConfigCWLAgent] : Starting activity...
[2018-02-19T19:34:27.981Z] INFO  [31597] - [Configuration update drupal-8.4.4@3/AddonsBefore/ConfigCWLAgent/10-config.sh] : Starting activity...
[2018-02-19T19:34:28.241Z] INFO  [31597] - [Configuration update drupal-8.4.4@3/AddonsBefore/ConfigCWLAgent/10-config.sh] : Completed activity. Result:
  Log streaming option setting is not specified, ignore cloudwatch logs setup.

  Disabled log streaming.
[2018-02-19T19:34:28.241Z] INFO  [31597] - [Configuration update drupal-8.4.4@3/AddonsBefore/ConfigCWLAgent] : Completed activity. Result:
  Successfully execute hooks in directory /opt/elasticbeanstalk/addons/logstreaming/hooks/config.
[2018-02-19T19:34:28.241Z] INFO  [31597] - [Configuration update drupal-8.4.4@3/AddonsBefore] : Completed activity.
[2018-02-19T19:34:28.242Z] INFO  [31597] - [Configuration update drupal-8.4.4@3/ConfigDeployStage0] : Starting activity...
[2018-02-19T19:34:28.242Z] INFO  [31597] - [Configuration update drupal-8.4.4@3/ConfigDeployStage0/ConfigDeployPreHook] : Starting activity...
[2018-02-19T19:34:28.244Z] INFO  [31597] - [Configuration update drupal-8.4.4@3/ConfigDeployStage0/ConfigDeployPreHook/10_setup_envvars.sh] : Starting activity...
[2018-02-19T19:34:28.709Z] INFO  [31597] - [Configuration update drupal-8.4.4@3/ConfigDeployStage0/ConfigDeployPreHook/10_setup_envvars.sh] : Completed activity.
[2018-02-19T19:34:28.710Z] INFO  [31597] - [Configuration update drupal-8.4.4@3/ConfigDeployStage0/ConfigDeployPreHook/20_configure_php.sh] : Starting activity...
[2018-02-19T19:34:29.736Z] INFO  [31597] - [Configuration update drupal-8.4.4@3/ConfigDeployStage0/ConfigDeployPreHook/20_configure_php.sh] : Completed activity. Result:
 Using configuration value for DocumentRoot: 
[2018-02-19T19:34:29.736Z] INFO  [31597] - [Configuration update drupal-8.4.4@3/ConfigDeployStage0/ConfigDeployPreHook] : Completed activity. Result:
 Successfully execute hooks in directory /opt/elasticbeanstalk/hooks/configdeploy/pre.
[2018-02-19T19:34:29.736Z] INFO  [31597] - [Configuration update drupal-8.4.4@3/ConfigDeployStage0] : Completed activity. Result:
 Configuration update - Command CMD-ConfigDeploy stage 0 completed
[2018-02-19T19:34:29.736Z] INFO  [31597] - [Configuration update drupal-8.4.4@3/ConfigDeployStage1] : Starting activity...
[2018-02-19T19:34:29.737Z] INFO  [31597] - [Configuration update drupal-8.4.4@3/ConfigDeployStage1/ConfigDeployEnactHook] : Starting activity...
[2018-02-19T19:34:29.738Z] INFO  [31597] - [Configuration update drupal-8.4.4@3/ConfigDeployStage1/ConfigDeployEnactHook/99_reload_app_server.sh] : 
 Starting activity...
[2018-02-19T19:34:29.851Z] INFO  [31597] - [Configuration update drupal-8.4.4@3/ConfigDeployStage1/ConfigDeployEnactHook/99_reload_app_server.sh] : Completed activity. Result:
  Equivalent Upstart operations: start httpd, stop httpd, restart httpd, status httpd
  Stopping httpd
  httpd stop/waiting
  Starting httpd
  httpd start/running, process 31677
  [OK]
[2018-02-19T19:34:29.851Z] INFO  [31597] - [Configuration update drupal-8.4.4@3/ConfigDeployStage1/ConfigDeployEnactHook] : Completed activity. Result:
  Successfully execute hooks in directory /opt/elasticbeanstalk/hooks/configdeploy/enact.
[2018-02-19T19:34:29.851Z] INFO  [31597] - [Configuration update drupal-8.4.4@3/ConfigDeployStage1/ConfigDeployPostHook] : Starting activity...
[2018-02-19T19:34:29.852Z] INFO  [31597] - [Configuration update drupal-8.4.4@3/ConfigDeployStage1/ConfigDeployPostHook] : Completed activity. Result:
 Successfully execute hooks in directory /opt/elasticbeanstalk/hooks/configdeploy/post.
[2018-02-19T19:34:29.852Z] INFO  [31597] - [Configuration update drupal-8.4.4@3/ConfigDeployStage1] : Completed activity. Result:
 Application restart - Command CMD-ConfigDeploy stage 1 completed
[2018-02-19T19:34:29.852Z] INFO  [31597] - [Configuration update drupal-8.4.4@3/AddonsAfter] : Starting activity...
[2018-02-19T19:34:29.852Z] INFO  [31597] - [Configuration update drupal-8.4.4@3/AddonsAfter/ConfigLogRotation] : Starting activity...
[2018-02-19T19:34:29.853Z] INFO  [31597] - [Configuration update drupal-8.4.4@3/AddonsAfter/ConfigLogRotation/10-config.sh] : Starting activity...
[2018-02-19T19:34:30.244Z] INFO  [31597] - [Configuration update drupal-8.4.4@3/AddonsAfter/ConfigLogRotation/10-config.sh] : Completed activity. Result:
  Disabled forced hourly log rotation.
[2018-02-19T19:34:30.244Z] INFO  [31597] - [Configuration update drupal-8.4.4@3/AddonsAfter/ConfigLogRotation] : Completed activity. Result:
 Successfully execute hooks in directory /opt/elasticbeanstalk/addons/logpublish/hooks/config.
[2018-02-19T19:34:30.244Z] INFO  [31597] - [Configuration update drupal-8.4.4@3/AddonsAfter] : Completed activity.
[2018-02-19T19:34:30.244Z] INFO  [31597] - [Configuration update drupal-8.4.4@3] : Completed activity. Result:
 Configuration update - Command CMD-ConfigDeploy succeeded
[2018-02-19T19:44:06.592Z] INFO  [32014] - [CMD-TailLogs] : Starting activity...
[2018-02-19T19:44:06.592Z] INFO  [32014] - [CMD-TailLogs/AddonsBefore] : Starting activity...
[2018-02-19T19:44:06.592Z] INFO  [32014] - [CMD-TailLogs/AddonsBefore] : Completed activity.
[2018-02-19T19:44:06.592Z] INFO  [32014] - [CMD-TailLogs/TailLogs] : Starting activity...
[2018-02-19T19:44:06.593Z] INFO  [32014] - [CMD-TailLogs/TailLogs/TailLogs] : Starting activity...

efs-mount.config file:

          ##############################################
#### Do not modify values below this line ####
##############################################
container_commands:
  1chown:
command: "chown webapp:webapp /drupalfiles"
  2link:
command: "sudo -u webapp ln -s /drupalfiles sites/default/files"

option_settings:
aws:elasticbeanstalk:application:environment:
EFS_VOLUME_ID: '`{"Ref" : "FileSystem"}`'
EFS_MOUNT_DIR: '/drupalfiles'
EFS_REGION: '`{"Ref": "AWS::Region"}`'

packages:
  yum:
nfs-utils: []
jq: []

commands:
  01_mount:
 command: "/tmp/mount-efs.sh"

files:
 "/tmp/mount-efs.sh":
  mode: "000755"
  content : |
    #!/bin/bash

    EFS_REGION=$(/opt/elasticbeanstalk/bin/get-config environment | jq -r '.EFS_REGION')
    EFS_MOUNT_DIR=$(/opt/elasticbeanstalk/bin/get-config environment | jq -r '.EFS_MOUNT_DIR')
    EFS_VOLUME_ID=$(/opt/elasticbeanstalk/bin/get-config environment | jq -r '.EFS_VOLUME_ID')

    echo "Mounting EFS filesystem ${EFS_DNS_NAME} to directory ${EFS_MOUNT_DIR} ..."

    echo 'Stopping NFS ID Mapper...'
    service rpcidmapd status &> /dev/null
    if [ $? -ne 0 ] ; then
        echo 'rpc.idmapd is already stopped!'
    else
        service rpcidmapd stop
        if [ $? -ne 0 ] ; then
            echo 'ERROR: Failed to stop NFS ID Mapper!'
            exit 1
        fi
    fi

    echo 'Checking if EFS mount directory exists...'
    if [ ! -d ${EFS_MOUNT_DIR} ]; then
        echo "Creating directory ${EFS_MOUNT_DIR} ..."
        mkdir -p ${EFS_MOUNT_DIR}
        if [ $? -ne 0 ]; then
            echo 'ERROR: Directory creation failed!'
            exit 1
        fi
        chmod 777 ${EFS_MOUNT_DIR}
        if [ $? -ne 0 ]; then
            echo 'ERROR: Permission update failed!'
            exit 1
        fi
    else
        echo "Directory ${EFS_MOUNT_DIR} already exists!"
    fi

    mountpoint -q ${EFS_MOUNT_DIR}
    if [ $? -ne 0 ]; then
        AZ=$(curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone)
        echo "mount -t nfs4 -o nfsvers=4.1 ${AZ}.${EFS_VOLUME_ID}.efs.${EFS_REGION}.amazonaws.com:/ ${EFS_MOUNT_DIR}"
        mount -t nfs4 -o nfsvers=4.1 ${AZ}.${EFS_VOLUME_ID}.efs.${EFS_REGION}.amazonaws.com:/ ${EFS_MOUNT_DIR}
        if [ $? -ne 0 ] ; then
            echo 'ERROR: Mount command failed!'
            exit 1
        fi
    else
        echo "Directory ${EFS_MOUNT_DIR} is already a valid mountpoint!"
    fi

    echo 'EFS mount complete.'
Jen
  • 156
  • 1
  • 3
  • 17
  • Single instance or load balanced? Also, what does the eb activity log look like? – Sam H. Feb 18 '18 at 00:28
  • Did you set up the RDS instance already? – Sam H. Feb 18 '18 at 02:28
  • Single instance. Yes, the RDS is set up. – Jen Feb 19 '18 at 17:41
  • @SamH. I have added a screenshot of the error when trying to create the instance. – Jen Feb 19 '18 at 17:43
  • In the GUI you can go to logs > request last 100 lines. What does the eb-activity.log portion look like? – Sam H. Feb 19 '18 at 17:52
  • @SamH. I added the log to the OP. – Jen Feb 19 '18 at 18:22
  • 2
    Cna you share the content of your `efs-mount.config` file? – Hackerman Feb 19 '18 at 18:28
  • When you create the zip that you uploaded... what are you zipping? The files, or the directory containing the files? – Sam H. Feb 19 '18 at 19:00
  • 1
    Can you add an extra step in you `config` file, like: `container_commands: 1chown: command: "chown webapp:webapp /drupalfiles" 2create: command: "sudo -u webapp mkdir -p sites/default/files" 3link: command: "sudo -u webapp ln -s /drupalfiles sites/default/files"` – Hackerman Feb 19 '18 at 19:04
  • I'm running zip -r -X Documents/drupal-8.4.4.zip Documents/drupal-beanstalk in terminal. drupal-beanstalk is the directory. – Jen Feb 19 '18 at 19:06
  • @Hackerman I revised the file and it seemed to work, the health is Green. I updated the environment properties but the URL is still not loading the Drupal install page, it times out. – Jen Feb 19 '18 at 19:36
  • Ok, we are in the right path...since we added the new step, a new activity log was generated...can you add the new activity log to the post? – Hackerman Feb 19 '18 at 19:41
  • @Hackerman Yep! Updated OP with new activity log and a new screenshot of the EB dashboard. – Jen Feb 19 '18 at 19:49
  • @Hackerman Don't give up on me now! :| – Jen Feb 19 '18 at 23:09
  • Can you setup up `eb ssh` access in order to take a closer look? – Hackerman Feb 20 '18 at 01:20
  • @hackerman I somehow got the install to start. Thank you for your help! I'm not sure how bounty is awarded. – Jen Feb 20 '18 at 22:29

1 Answers1

0

UPDATE WITH SOLUTIONS:
In the efs-mount.config file, I changed the commands to:

1chown:
    command: "chown webapp:webapp /drupalfiles"
  2create: 
    command: "sudo -u webapp mkdir -p sites/default/files" 
  3link: 
    command: "sudo -u webapp ln -s /drupalfiles sites/default/files"

I changed the permissions of the folder by using the command:

chmod -R 777 /drupal-beanstalk

Instead of zipping the directory itself, I selected all the files and folder within the directory and compressed those. I removed the .MACOSX from the zipped folder by using the command:

zip -d filename.zip __MACOSX/\*

When uploading this folder to AWS Elastic Beanstalk, the app was green health and the URL opened the Drupal install page.

Jen
  • 156
  • 1
  • 3
  • 17