使用Docker配置Bitbucket管道以连接到AWS [英] Configuring bitbucket pipelines with Docker to connect to AWS

查看:204
本文介绍了使用Docker配置Bitbucket管道以连接到AWS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正尝试在此处设置Bitbucket管道以部署到ECS:

I am trying to set up Bitbucket pipelines to deploy to ECS as here: https://confluence.atlassian.com/bitbucket/deploy-to-amazon-ecs-892623902.html

这些说明说明了如何推送到Docker集线器,但我想将映像推送到Amazon的映像存储库.我已经在我的Bitbucket参数列表中设置了AWS_SECRET_ACCESS_KEY和AWS_ACCESS_KEY_ID,并且我可以在本地运行这些命令而没有任何问题(在〜/.aws/credentials中定义的键).但是,我不断收到错误没有基本身份验证凭据".我想知道它是否无法以某种方式识别变量.此处的文档: http://docs. aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html 说:

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: http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html say that:

AWS CLI使用供应商链在许多不同的地方查找AWS凭证,包括系统或用户环境变量以及本地AWS配置文件.所以我不确定为什么它不起作用.我的bitbucket管道配置是这样的(我没有添加任何不必要的内容):

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):

      - 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

是否可以指定aws ecr get-login使用的凭据?我什至尝试过,但是不起作用:

Is there a way of specifying the credentials for aws ecr get-login to use? I even tried this, but it doesn't work:

      - mkdir -p ~/.aws
      - echo -e "[default]\n" > ~/.aws/credentials
      - echo -e "aws_access_key_id = $AWS_ACCESS_KEY_ID\n" >> ~/.aws/credentials
      - echo -e "aws_secret_access_key = $AWS_SECRET_ACCESS_KEY\n" >> ~/.aws/credentials

谢谢

推荐答案

我遇到了同样的问题.该错误主要是由于awscli的旧版本引起的. 您需要使用awscli较新的docker映像. 对于我的项目,我使用 linkmobility/maven-awscli

i had the same issue. the error is mainly due to an old version of awscli. you need to use a docker image with a more recent awscli. for my project i use linkmobility/maven-awscli

  1. 您需要在Bitbucket中设置环境变量

  1. You need to set the Environnment variables in Bitbucket

管道的小改动

图片:Docker-Image-With-awscli

image: Docker-Image-With-awscli

  • eval $(aws ecr get-login --no-include-email --region $ {AWS_DEFAULT_REGION})

这篇关于使用Docker配置Bitbucket管道以连接到AWS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆