Search code examples
amazon-web-servicesamazon-ec2aws-code-deploy

scripts/install_dependencies run as user ubuntu failed with exit code 1


I am trying to Deploy an application from GitHub.I have created a repository in Github with appspec.yml. The following is the code of my appspec.yml:

version: 0.0
os: linux
files:
  - source: /index.html
    destination: /var/www/html/
hooks:
  BeforeInstall:
    - location: scripts/install_dependencies
      timeout: 300
      runas: ubuntu
    - location: scripts/start_server
      timeout: 300
      runas: ubuntu
  ApplicationStop:
    - location: scripts/stop_server
      timeout: 300
      runas: ubuntu

I am getting an error while deploying the application

Script at specified location: scripts/install_dependencies run as user ubuntu failed with exit code 1


Solution

  • The install_dependencies script exits with code 1, because Apache installation for permission before installing Apache.

    To get around this problem use the -y flag with the install command inside your install_dependencies.sh file

    #!/bin/bash
    sudo apt-get install -y apache2