title: Configuring bitbucket pipelines with Docker to connect to AWS
body: <p>I am trying to set up Bitbucket pipelines to deploy to ECS as here: <a href="https://confluence.atlassian.com/bitbucket/deploy-to-amazon-ecs-892623902.html" rel="noreferrer">https://confluence.atlassian.com/bitbucket/deploy-to-amazon-ecs-892623902.html</a></p>
  
  <p>These instructions say how to push to Docker hub, but I want to push the image to Amazon's image repo. I have set AWS_SECRET_ACCESS_KEY and AWS_ACCESS_KEY_ID in my Bitbucket parameters list and I can run these command locally with no problems (the keys defined in ~/.aws/credentials). However, I keep getting the error 'no basic auth credentials'. I am wondering if it is not recognising the variables somehow. The docs here: <a href="http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html" rel="noreferrer">http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html</a> say that:</p>
  
  <p>The AWS CLI uses a provider chain to look for AWS credentials in a number of different places, including system or user environment variables and local AWS configuration files. So I am not sure why it isn't working. My bitbucket pipelines configuration is as so (I have not included anything unnecessary):</p>
  
  <pre><code>      - export IMAGE_NAME=$AWS_REPO_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/my/repo-name:$BITBUCKET_COMMIT
        # build the Docker image (this will use the Dockerfile in the root of the repo)
        - docker build -t $IMAGE_NAME .
        # authenticate with the AWS repo (this gets and runs the docker login command)
        - eval $(aws ecr get-login --region $AWS_DEFAULT_REGION)
        # push the new Docker image to the repo
        - docker push $IMAGE_NAME
  </code></pre>
  
  <p>Is there a way of specifying the credentials for aws ecr get-login to use? I even tried this, but it doesn't work:</p>
  
  <pre><code>      - mkdir -p ~/.aws
        - echo -e "[default]\n" &gt; ~/.aws/credentials
        - echo -e "aws_access_key_id = $AWS_ACCESS_KEY_ID\n" &gt;&gt; ~/.aws/credentials
        - echo -e "aws_secret_access_key = $AWS_SECRET_ACCESS_KEY\n" &gt;&gt; ~/.aws/credentials
  </code></pre>
  
  <p>Thanks</p>