0

This is what appspec.yml looks like:

version: 0.0
os: linux
files:
  - source: /
    destination: /home/ec2-user/webocitySalonPOS/
    owner: ec2-user
permissions:
  - object: /home/ec2-user/webocitySalonPOS/
    mode: 755
    acls:
      - "d:u::rwx"
      - "d:g::rwx"
      - "d:o::rwx"
    owner: ec2-user
    type:
      - directory
  - object: /scripts/
    mode: 777
    acls:
      - "d:u::rwx"
      - "d:g::rwx"
      - "d:o::rwx"
    owner: ec2-user
    type:
hooks:
   AfterInstall:
     - location: scripts/autoinstall.sh
       timeout: 1000
       runas: ec2-user
   ApplicationStart:
     - location: scripts/autostart.sh
       timeout: 300
       runas: ec2-user

If I change autoinstall.sh that has npm install in it to be exceuted as root user

 AfterInstall:
         - location: scripts/autoinstall.sh
           timeout: 1000
           runas: root

I get:

Script at specified location: scripts/autoinstall.sh run as user root failed with exit code 1

If I execute it as ec2-user, I get:

script at specified location: scripts/autoinstall.sh run as user ec2-user failed with exit code 243
Log Tail[stderr]npm WARN codedeploy-agent No license field.
[stderr]npm ERR! Linux 4.4.8-20.46.amzn1.x86_64
[stderr]npm ERR! argv "/home/ec2-user/.nvm/versions/node/v6.11.5/bin/node" "/home/ec2-user/.nvm/versions/node/v6.11.5/bin/npm" "install"
[stderr]npm ERR! node v6.11.5
[stderr]npm ERR! npm  v3.10.10
[stderr]npm ERR! path /opt/codedeploy-agent/node_modules
[stderr]npm ERR! code EACCES
[stderr]npm ERR! errno -13
[stderr]npm ERR! syscall mkdir
[stderr]
[stderr]npm ERR! Error: EACCES: permission denied, mkdir '/opt/codedeploy-agent/node_modules'
[stderr]npm ERR!     at Error (native)
[stderr]npm ERR!  { Error: EACCES: permission denied, mkdir '/opt/codedeploy-agent/node_modules'
[stderr]npm ERR!     at Error (native)
[stderr]npm ERR!   errno: -13,
[stderr]npm ERR!   code: 'EACCES',
[stderr]npm ERR!   syscall: 'mkdir',
[stderr]npm ERR!   path: '/opt/codedeploy-agent/node_modules' }
[stderr]npm ERR! 

On deployment, permissions for directory

/home/ec2-user/webocitySalonPOS/

look like this:

ls -ltr webocitySalonPOS

total 48
-rw-r--r--  1 root     root   279 Jan  8 11:09 README.md
-rw-r--r--  1 root     root 13940 Jan  8 11:09 Gruntfile.js
-rw-r--r--  1 root     root  1415 Jan  8 11:09 package.json
-rw-r--r--  1 root     root  1432 Jan  8 11:09 bower.json
-rw-r--r--  1 root     root   645 Jan  8 11:09 appspec.yml
-rw-r--r--  1 root     root    85 Jan  8 11:09 afterinstall.sh
drwxr-xr-x+ 3 ec2-user root  4096 Jan  8 11:09 test
drwxr-xr-x+ 2 ec2-user root  4096 Jan  8 11:09 scripts
drwxr-xr-x+ 6 ec2-user root  4096 Jan  8 11:09 app

How do I fix this?

systemdebt
  • 4,589
  • 10
  • 55
  • 116

0 Answers0