我想要构建 Docker 镜像并将其从 Azure DevOps 部署到 AWS ECR。
我遵循了本教程 - https://www.devguides.dev/how-to-build-and-deploy-docker-images-from-azure-devops-to-aws-ecr/
我不断收到以下错误:
调用GetAuthorizationToken操作时发生错误(InvalidSignatureException):我们计算的请求签名与您提供的签名不匹配。检查您的 AWS secret 访问 key 和签名方法。有关详细信息,请参阅服务文档。
我已使用相同的 AWS 访问 key 和 key 在本地手动检查并运行了“aws ecr-get-login-password”命令,它确实返回了临时密码,因此我知道权限和 key 是正确的。
我验证了我设置的变量是否正确,并且通过将它们打印出来供我在 Azure bash shell 中查看来读取它们 - 它们是正确的。
有什么建议吗?
我需要在 Azure 中的其他位置提供 AWS 登录信息吗?
下面是管道构建 yaml:
trigger:
branches:
include:
- build-and-push-azure-to-aws
pool:
vmImage: 'ubuntu-latest'
variables:
- group: dev
- name: DOCKER_REPOSITORY
value: $(AWS_ACCOUNT_ID).dkr.ecr.$(AWS_REGION).amazonaws.com/$(DOCKER_REPOSITORY_NAME)
steps:
- script: |
aws ecr get-login-password --region $(AWS_REGION) | docker login --username AWS --password-stdin $(AWS_ACCOUNT_ID).dkr.ecr.$(AWS_REGION).amazonaws.com
displayName: 'Login to AWS'
env:
AWS_ACCESS_KEY_ID: $(AWS_ACCESS_KEY_ID)
AWS_SECRET_ACCESS_KEY: $(AWS_SECRET_ACCESS_KEY)
- task: Docker@2
displayName: Build docker image
inputs:
repository: $(DOCKER_REPOSITORY)
command: buildAndPush
Dockerfile: Dockerfile
tags: |
latest
这是我得到的错误:
==============================================================================
Task : Command line
Description : Run a command line script using Bash on Linux and macOS and cmd.exe on Windows
Version : 2.164.2
Author : Microsoft Corporation
Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/utility/command-line
==============================================================================
Generating script.
========================== Starting Command Output ===========================
/bin/bash --noprofile --norc /home/vsts/work/_temp/043d91c2-1246-45f3-909b-6594561cfbf1.sh
An error occurred (InvalidSignatureException) when calling the GetAuthorizationToken operation: The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.
最佳答案
如果您想要构建并部署从 Azure DevOps 到 AWS ECR 的 Docker 镜像,您可以使用一组有效的 AWS 凭证创建与 AWS 的服务连接。您可以关注此文档 AWS Toolkit for Azure DevOps获取设置此服务连接的更多详细信息。
然后使用 Amazon ECR Push
任务将 Docker 镜像推送到 AWS 上的 Amazon Elastic Container Registry。
您可以查看下面的博客以获取更多详细信息:
关于azure - 尝试在 Azure DevOps 管道 shell 中运行 "InvalidSignatureException"命令时获取 "aws ecr-get-login-password",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62958269/