Context
I am using Elastic Beanstalk to deploy a very simple test application. I have several packages I want to install using apt. I have included a 01_installations.sh
script with the installations in the .platform/hooks/prebuild
directory. When I zip my application and deploy to Elastic Beanstalk, the logs confirm that the prebuild script runs, but it does not have permissions.
2020/08/12 21:03:46.674234 [INFO] Executing instruction: RunAppDeployPreBuildHooks
2020/08/12 21:03:46.674256 [INFO] Executing platform hooks in .platform/hooks/prebuild/
2020/08/12 21:03:46.674296 [INFO] Following platform hooks will be executed in order: [01_installations.sh]
2020/08/12 21:03:46.674302 [INFO] Running platform hook: .platform/hooks/prebuild/01_installations.sh
2020/08/12 21:03:46.674482 [ERROR] An error occurred during execution of command [app-deploy] - [RunAppDeployPreBuildHooks]. Stop running the command. Error: Command .platform/hooks/prebuild/01_installations.sh failed with error fork/exec .platform/hooks/prebuild/01_installations.sh: permission denied
Question
My understanding is that permissions were denied because I did not add chmod +x
to make the .sh file executable. As the AWS documentation on platform hooks states: "Use chmod +x to set execute permission on your hook files." (https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/platforms-linux-extend.html). My question is: how do I do this?
I simply have the .sh file in a directory. I do not call it from anywhere else. Is there a simple step I'm missing? The AWS documentation makes it seem like it should be straightforward.
Previous Attempts
Things I have tried:
.config
file in the .ebextensions
directory with the below command which should execute the .sh file with chmod +x permissions..config
was processed at all.container_commands:
01_chmod1:
command: "chmod +x .platform/hooks/prebuild/01_installations.sh"
[RunAppDeployPreBuildHooks]. Stop running the command. Error: Command .platform/hooks/prebuild/chmod +x 01_installations.sh failed with error fork/exec .platform/hooks/prebuild/chmod +x 01_installations.sh: permission denied
I have reviewed the ideas here, but none of them actually include complete enough examples to follow:
Normally you set the permissions on your local workstation, when before you zip your deployment package.
However, if you want to do this on EB instance, then you can't use container_commands
for that. The reason is that container_commands
execute after prebuild
. Instead you should try using commands
:
The prebuild files run after running commands found in the commands section of any configuration file and before running Buildfile commands.