title: AccessDenied for ListObjectsV2 operation for S3 bucket
body: <p>During GitlabCi I got:
  "fatal error: An error occurred (AccessDenied) when calling the ListObjectsV2 operation: Access Denied"</p>
  
  <p>My bucket policy :</p>
  
  <pre><code>{
  "Version": "2008-10-17",
  "Statement": [
      {
          "Sid": "AllowPublicRead",
          "Effect": "Allow",
          "Principal": {
              "AWS": "*"
          },
          "Action": "s3:*",
          "Resource": "arn:aws:s3:::BUCKET-NAME/*"
      }
  ]
  </code></pre>
  
  <p>}</p>
  
  <p>In gitlabCI settings set:</p>
  
  <ul>
  <li>AWS_ACCESS_KEY_ID: YOUR-AWS-ACCESS-KEY-ID</li>
  <li>AWS_SECRET_ACCESS_KEY: YOUR-AWS-SECRET-ACCESS-KEY</li>
  <li>S3_BUCKET_NAME: YOUR-S3-BUCKET-NAME</li>
  <li>DISTRIBUTION_ID: CLOUDFRONT-DISTRIBUTION-ID</li>
  </ul>
  
  <p>My .gitlab-ci.yml</p>
  
  <pre><code>image: docker:latest
  
  stages:
    - build
    - deploy
  
  build:
    stage: build
    image: node:8.11.3
  script:
    - export API_URL="d144iew37xsh40.cloudfront.net"
    - npm install
    - npm run build
    - echo "BUILD SUCCESSFULLY"
  artifacts:
     paths:
      - public/
  expire_in: 20 mins
  environment:
  name: production
  only:
     - master
  deploy:
    stage: deploy
    image: python:3.5
  dependencies:
     - build
  script:
    - export AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID
    - export AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY
    - export S3_BUCKET_NAME=$S3_BUCKET_NAME
    - export DISTRIBUTION_ID=$DISTRIBUTION_ID
    - pip install awscli --upgrade --user
    - export PATH=~/.local/bin:$PATH
    - aws s3 sync --acl public-read --delete public $S3_BUCKET_NAME
    - aws cloudfront create-invalidation --distribution-id 
  $DISTRIBUTION_ID --paths '/*'
    - echo "DEPLOYED SUCCESSFULLY"
  
  environment:
     name: production
  only:
    - master
  </code></pre>