Which user does AWS ELB run under for a predeploy hook?

Viewed 112

I have a file called .platform/hooks/predeploy/01.download.py. When I sudo into the instance, it looks like the user is ec2-user, so the ~/ folder points to /home/ec2-user. But when my app runs, it seems that ~/ points to /home/webapp. How can I get my predeploy script to know the location of /home/webapp?

1 Answers

Which user does AWS ELB run under for a predeploy hook?

It runs as root and folder ~ points to /root, not /home/ec2-user.

If you want your scripts to run under different user, e.g. ec2-user, you can use the following in your deployment scripts:

runuser -l ec2-user -c '<command>'

or any variation of it or other similar tool as shown, for instance, here,

Related