title: Packer Script exited with non-zero exit status : 127
body: <p>I am trying to provision an AWS AMI but the packer script terminates with the following error.</p>
  
  <pre><code>Build 'amazon-ebs' errored: Script exited with non-zero exit status: 127
     ==&gt; Some builds didn't complete successfully and had errors:
     --&gt; amazon-ebs: Script exited with non-zero exit status: 127
     ==&gt; Builds finished but no artifacts were created.
  </code></pre>
  
  <p>My template for Packer is as follows:</p>
  
  <pre><code>   { 
     "variables": {
      "aws_access_key": "{{env `MY_ACCESS_KEY`}}",
      "aws_secret_key": "{{env `MY_SECRET_KEY`}}"
     },
      "builders": [{
      "type": "amazon-ebs",
      "access_key": "{{user `aws_access_key`}}",
      "secret_key": "{{user `aws_secret_key`}}",
      "region": "us-east-1",
      "source_ami":"ami-8c1be5f6",
      "instance_type": "t2.micro",
      "ssh_username": "ec2-user",
      "ami_name": "packer-example {{timestamp}}"
      }],
      "provisioners":[
      {
        "type": "shell",
        "script": "provision.sh"
      }]}
  </code></pre>
  
  <p>Error log is as follows: <code>PACKER_LOG=1 packer build template.json</code></p>
  
  <pre><code>2017/11/01 01:30:37 [INFO] (telemetry) ending amazon-ebs
  2017/11/01 01:30:37 [INFO] (telemetry) found error: Script exited with non-zero exit status: 127
  2017/11/01 01:30:37 ui error: Build 'amazon-ebs' errored: Script exited with non-zero exit status: 127
  2017/11/01 01:30:37 Builds completed. Waiting on interrupt barrier...
  2017/11/01 01:30:37 machine readable: error-count []string{"1"}
  2017/11/01 01:30:37 ui error: 
  ==&gt; Some builds didn't complete successfully and had errors:
  2017/11/01 01:30:37 machine readable: amazon-ebs,error []string{"Script exited with non-zero exit status: 127"}
  2017/11/01 01:30:37 ui error: --&gt; amazon-ebs: Script exited with non-zero exit status: 127
  2017/11/01 01:30:37 ui: 
  ==&gt; Builds finished but no artifacts were created.
  Build 'amazon-ebs' errored: Script exited with non-zero exit status: 127
  </code></pre>
  
  <p>provision.sh comprises of </p>
  
  <pre><code>   #!/bin/bash
     sudo yum install httpd -y
     sudo yum update -y
     sudo aws s3 cp s3://zbcxlkxcjvlxkj/index1.html /var/www/html/ --region us-east-1
     sudo service httpd start
     sudo chkconfig httpd on
  </code></pre>