title: AWS Codebuild fails while downloading source. Message: Access Denied
body: <p>I created a CodeBuild Project that uses a <a href="https://hub.docker.com/r/brooksn/aws-codebuild-nodejs-8/" rel="noreferrer">docker image for node8</a>. The purpose of this CodeBuild project is to do unit testing. It takes an input artifact from CodeCommit. And in the buildspec.yml it runs a test command.</p>
  <p>This is my (simple) buildspec file:</p>
  <pre><code>version: 0.2
  
  phases:
    install:
      commands:
       - echo &quot;install phase started&quot;
       - npm install
       - echo &quot;install phase ended&quot;
    pre_build: 
      commands:
       - echo &quot;pre_build aka test phase started&quot;
       - echo &quot;mocha unit test&quot;
       - npm test
       - echo &quot;mocha unit test ended&quot;
    build:
      commands:
       - echo &quot;build phase started&quot;
       - echo &quot;build complete&quot;
  </code></pre>
  <p>The build is failing at the DOWNLOAD_SOURCE phase with the following:</p>
  <blockquote>
  <p>PHASE - DOWNLOAD_SOURCE</p>
  <p><strong>Start time</strong> 2 minutes ago</p>
  <p><strong>End time</strong> 2 minutes ago</p>
  <p><strong>Message</strong>  Access Denied</p>
  </blockquote>
  <p>The only logs in the build logs are the following</p>
  <blockquote>
  <p>[Container] 2018/01/12 11:30:22 Waiting for agent ping</p>
  <p>[Container] 2018/01/12 11:30:22 Waiting for DOWNLOAD_SOURCE</p>
  </blockquote>
  <p>Thanks in advance.</p>
  <p>Screenshot of the CodeBuild policies.</p>
  <p><a href="https://i.stack.imgur.com/i1fu6.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/i1fu6.jpg" alt="enter image description here" /></a></p>