2

Background: I am facing this error AWS codedeploy deployment throwing "[stderr] Could not open input file" while trying to invoke a php file from the sh file at afterInstall step

In the afterInstall step, I am trying to run a php file from the afterInstall.sh file and I am getting this error - unable to open php file.

I am not sure what exactly to do. Thought of trying to manually check if I could run the file as that user.

Community
  • 1
  • 1
Sandeepan Nath
  • 9,966
  • 17
  • 86
  • 144

2 Answers2

3

The CodeDeploy agent default user is root.

The directory listing below shows the ownership of the deployed files in their destination folder, /tmp, after a successful deployment.

ubuntu@ip-10-0-xx-xx:~$ ls -l /tmp
total 36
-rw-r--r-- 1 root root    85 Aug  2 05:04 afterInstall.php
-rw-r--r-- 1 root root    78 Aug  2 05:04 afterInstall.sh
-rw-r--r-- 1 root root  1397 Aug  2 05:04 appspec.yml
-rw------- 1 root root  3189 Aug  2 05:07 codedeploy-agent.update.log
drwx------ 2 root root 16384 Aug  2 03:01 lost+found
-rw-r--r-- 1 root root    63 Aug  2 05:04 out.log
Rodrigo Murillo
  • 13,080
  • 2
  • 29
  • 50
2
  • runas is an optional filed in the AppSpec file. The user to impersonate when running the script. By default, this is the AWS CodeDeploy agent running on the instance(If you don't specify a non-root user, it will be root).

  • To run host agent as a non-root user, the environment variable CODEDEPLOY_USER needs to be set, as the link to the host agent source code show. The env variable can be set to whatever user you want the host agent to run as.

binbinlu
  • 416
  • 2
  • 5