title: AWS CodeDeploy is failing on EC2 instances everytime
body: <p><a href="https://i.stack.imgur.com/rNZxF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rNZxF.png" alt="enter image description here"></a></p>
  
  <p>i have configured a cicd pipeline on aws using jenkins. I have written a very small application that only serves a static index.html file.It is working all the way but breaking at the very last step of codedeploy.
  the problem is , when i am trigerring codedeploy from jenkins using aws codedeploy project, it is failing the deployment on the ec2 instances.
  Jenkins log is not throwing enough information to debug it. 
  Some points that i should make aware of -</p>
  
  <ol>
  <li>i am using deployment configuration deployment one at a time instances</li>
  <li>i havenot installed aws codedeploy agent on the ec2 instances</li>
  <li>where can i get detailed log on where it is failing? cloudwatch is not logging the codedeploy log in this case.</li>
  </ol>
  
  <p>Error logs-</p>
  
  <pre><code>HttpMethod: GET
  URL: https://aws-devops-jenkins-docker.s3.amazonaws.com/aws_docker_codebuild_jenkins
  Sending request to url: https://aws-devops-jenkins-docker.s3.amazonaws.com/aws_docker_codebuild_jenkins
  Response Code: HTTP/1.1 200 OK
  Success code from [100‥399]
  Saving response body to /var/lib/jenkins/workspace/aws_docker_demo/aws-codebuild-artifact.zip
  Zipping files into /tmp/#61-6687599754523764921.zip
  Uploading zip to s3://aws-devops-jenkins-docker/#61-6687599754523764921.zip
  Registering revision for application 'aws_docker_codedeploy_jenkins'
  Creating deployment with revision at {RevisionType: S3,S3Location: {Bucket: aws-devops-jenkins-docker,Key: #61-6687599754523764921.zip,BundleType: zip,ETag: 86c6ace4adeaa41f5206ca96c6ff6637},}
  Monitoring deployment with ID d-V1R54BRY1...
  Deployment status: Created; instances: null
  Deployment status: Created; instances: null
  Deployment status: InProgress; instances: {Pending: 2,InProgress: 0,Succeeded: 0,Failed: 0,Skipped: 0,Ready: 0}
  Deployment status: InProgress; instances: {Pending: 2,InProgress: 0,Succeeded: 0,Failed: 0,Skipped: 0,Ready: 0}
  Deployment status: InProgress; instances: {Pending: 2,InProgress: 0,Succeeded: 0,Failed: 0,Skipped: 0,Ready: 0}
  Deployment status: InProgress; instances: {Pending: 2,InProgress: 0,Succeeded: 0,Failed: 0,Skipped: 0,Ready: 0}
  Deployment status: InProgress; instances: {Pending: 1,InProgress: 1,Succeeded: 0,Failed: 0,Skipped: 0,Ready: 0}
  Deployment status: InProgress; instances: {Pending: 1,InProgress: 1,Succeeded: 0,Failed: 0,Skipped: 0,Ready: 0}
  Deployment status: InProgress; instances: {Pending: 1,InProgress: 1,Succeeded: 0,Failed: 0,Skipped: 0,Ready: 0}
  Deployment status: InProgress; instances: {Pending: 1,InProgress: 1,Succeeded: 0,Failed: 0,Skipped: 0,Ready: 0}
  Deployment status: InProgress; instances: {Pending: 1,InProgress: 1,Succeeded: 0,Failed: 0,Skipped: 0,Ready: 0}
  Deployment status: InProgress; instances: {Pending: 1,InProgress: 1,Succeeded: 0,Failed: 0,Skipped: 0,Ready: 0}
  Deployment status: InProgress; instances: {Pending: 1,InProgress: 1,Succeeded: 0,Failed: 0,Skipped: 0,Ready: 0}
  Deployment status: InProgress; instances: {Pending: 1,InProgress: 1,Succeeded: 0,Failed: 0,Skipped: 0,Ready: 0}
  Deployment status: InProgress; instances: {Pending: 1,InProgress: 1,Succeeded: 0,Failed: 0,Skipped: 0,Ready: 0}
  Deployment status: InProgress; instances: {Pending: 1,InProgress: 1,Succeeded: 0,Failed: 0,Skipped: 0,Ready: 0}
  Deployment status: InProgress; instances: {Pending: 1,InProgress: 1,Succeeded: 0,Failed: 0,Skipped: 0,Ready: 0}
  Deployment status: InProgress; instances: {Pending: 1,InProgress: 1,Succeeded: 0,Failed: 0,Skipped: 0,Ready: 0}
  Deployment status: InProgress; instances: {Pending: 1,InProgress: 1,Succeeded: 0,Failed: 0,Skipped: 0,Ready: 0}
  Deployment status: InProgress; instances: {Pending: 1,InProgress: 1,Succeeded: 0,Failed: 0,Skipped: 0,Ready: 0}
  Deployment status: InProgress; instances: {Pending: 1,InProgress: 1,Succeeded: 0,Failed: 0,Skipped: 0,Ready: 0}
  Deployment status: InProgress; instances: {Pending: 1,InProgress: 1,Succeeded: 0,Failed: 0,Skipped: 0,Ready: 0}
  Deployment status: Failed; instances: {Pending: 0,InProgress: 0,Succeeded: 0,Failed: 1,Skipped: 1,Ready: 0}
  Deployment did not succeed. Final status: Failed
  ERROR: Step ‘Deploy an application to AWS CodeDeploy’ failed: null
  Finished: FAILURE
  </code></pre>
  
  <p><strong>Buildspec.yml</strong></p>
  
  <pre><code>version: 0.2
  
  phases:
    install:
      runtime-versions:
        nodejs: 10
      commands:
        - echo "installing nodejs"
    pre_build:
      commands:
        - printenv
        - echo "we are in the pre build phase"
    build:
      commands:
        - echo "we are in the build block"
        - echo "running test ...."
        - grep -Fq "cloud" index.html
    post_build:
      commands:
        - echo "we are in the post build phase"
  
  artifacts:
    files:
      - '**/*'
    name: aws_devops_poc_mywebb_artifacts
  </code></pre>
  
  <p><strong>appspec.yml</strong></p>
  
  <pre><code>version: 0.0
  os: linux
  files:
    - source: /index.html
      destination: /var/www/html/ 
  Hooks:
    ApplicationStop:
      - location: scripts/stop_server.sh
        timeout: 300
        runas: root
  
    AfterInstall:
      - location: scripts/after_install.sh
        timeout: 300
        runas: root
  
    BeforeInstall:
      - location: scripts/install_dependencies.sh
        timeout: 300
        runas: root
    ApplicationStart:
      - scripts/start_server.sh
        timeout: 300
        runas: root
  
    ValidateService:
      - location: scripts/validate_service.sh
        timeout: 300
  </code></pre>
  
  <p><strong>stop_server</strong> and <strong>start_server</strong> scripts are only to start stop httpd service.</p>
  
  <p><strong>validate_service</strong> script only checks if the html contains the 'world' word.</p>
  
  <p><strong>install_dependencies</strong> script only install httpd service</p>
  
  <p>I am very new to aws devops. Any help is highly appreciated.</p>