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:
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.
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.'