Elastic Beanstalk: what's the best way to create folders & set permissions after deploy?

Viewed 6316

I'm running a Rails 4.2 app on Elastic Beanstalk, and need to set log permissions and create the /tmp/uploads folder (plus permissions) after deploy.

I was running two ebextensions scripts to do this, but on some occasions they would fail because the folder /var/app/current/ didn't yet exist.

I'm presuming this is because the permissions and/or folders should be created on /app/ondeck/ first so that EB can copy the contents over to /var/app/current/, but I'm interested to see if there's a recommended and more foolproof approach to doing this?

For reference, my two ebextension scripts were:

commands: 
    01_set_log_permissions:
        command: "chmod 755 /var/app/current/log/*"

and

commands: 
    01_create_uploads_folder: 
        command: "mkdir -p /var/app/current/tmp/uploads/"
    02_set_folder_permission: 
        command: "chmod 755 /var/app/current/tmp/uploads/"

Thanks, Dan

3 Answers

I've used the below stpes:

  • Create a folder .ebextensions
  • Creta a file .config
  • Move .config to .ebextensions
  • Edit the file .config, it must have the below sintaxe
    commands:
        command1:
             command: mkdir /opt/jenkins
       command2:
             command: chmod 644 /opt/jenkins

https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html#linux-commands

* Pay Attention *

You cannot run again command1 "mkdir /opt/jenkins", you will have a error, so you must do a test before.

Related