Changing file permissions on AWS Elastic beanstalk environment

amazon-web-serviceselastic-beanstalk

I have an AWS worker tier environment and I want to change file permissions so i can write logs to file. I have tried doing this in eb extensions .config file but cannot get it to work.

If the command is run (sudo chmod 777 /path/to/file.rb) under the 'commmands:' then its executed before the env is built and does not work.

If its under 'container_commands:' then it also does not work.

I cannot find any guidance on how to do this in the AWS docs (it may of course be there)

Help much appreciated.

Best Answer

If your challenge is that you need to change the permissions after your application has been deployed, then you'll need to use a post-deploy hook. Unfortunately post-deploy hooks are not officially supported by AWS, but they seem to be pretty widely used.

I done similar things using the technique described here: https://forums.aws.amazon.com/thread.jspa?messageID=493887

Your hook might look something like this:

files:
  "/opt/elasticbeanstalk/hooks/appdeploy/post/99_change_permissions.sh":
    mode: "000755"
    owner: root
    group: root
    content: |
      #!/usr/bin/env bash
      chmod 777 /path/to/file.rb
Related Topic