I'm working in a python 2.7 elastic beanstalk environment.

I'm trying to use the sources key in an .ebextensions .config file to copy a tgz archive to a directory in my application root -- /opt/python/current/app/utility. I'm doing this because the files in this folder are too big to include in my github repository.

However, it looks like the sources key is executed before the ondeck symbolic link is created to the current bundle directory so I can't reference /opt/python/ondeck/app when using the sources command because it creates the folder and then beanstalk errors out when trying to create the ondeck symbolic link.

Here are copies of the .ebextensions/utility.config files I have tried:

  /opt/python/ondeck/app/utility: http://[bucket].s3.amazonaws.com/utility.tgz

Above successfully copies to /opt/python/ondec/app/utility but then beanstalk errors out becasue it can't create the symbolic link from /opt/python/bundle/x --> /opt/python/ondeck.

  utility: http://[bucket].s3.amazonaws.com/utility.tgz

Above copies the folder to /utility right off the root in parallel with /etc.


I was able to accomplish this with a different key:

    command: "cd /opt/python/ondeck/app/utility && curl http://[bucket].s3.amazonaws.com/elasticbeanstalk/utility.tgz | tar xz"

This helped somewhat, but in my environment (php) there is no transient ondeck directory and the current directory where my app is eventually deployed is recreated after commands are run.

Therefore, I needed to run a script post deploy. Searching revealed that I can put a script in /opt/elasticbeanstalk/hooks/appdeploy/post/ and it will run after deploy.

So I download/extract my files from S3 to a temporary directory in the simplest way by using sources. Then I create a file that will copy my files over after the deploy and put it in the post deploy hook directory .

  /some/existing/directory: https://s3-us-west-2.amazonaws.com/my-bucket/vendor.zip
    mode: "000755"
    owner: root
    group: root
    content: |
      #!/usr/bin/env bash
      mv /some/existing/directory /var/app/current/where/the/files/belong

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.