AWS CodeBuild 中的 GetAuthorizationToken 权限错误
GetAuthorizationToken permission error in AWS CodeBuild
我正在尝试使用 AWS CodeBuild 设置我的 Node 项目。
version: 0.2
phases:
pre_build:
commands:
- $(aws ecr get-login)
- TAG="$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | head -c 8)"
build:
commands:
- docker build -t "${REPOSITORY}:${TAG}" .
post_build:
commands:
- docker push "${REPOSITORY}:${TAG}"
当我触发构建时,命令 $(aws ecr get-login)
失败:
An error occurred (AccessDeniedException) when calling the
GetAuthorizationToken operation: User is not authorized to perform: ecr:GetAuthorizationToken on resource: *
[Container] 2018/10/26 10:04:12 Command did not exit successfully
$(aws ecr get-login) exit status 255
在 IAM 控制台中,用户附加了这些策略:
- AmazonEC2ContainerRegistryFullAccess
- AmazonEC2ContainerRegistryPowerUser
并且都包含 ecr:GetAuthorizationToken
权限。
我错过了什么?
已解决。我需要将 ecr:GetAuthorizationToken
权限授予角色,而不是用户。
我正在尝试使用 AWS CodeBuild 设置我的 Node 项目。
version: 0.2
phases:
pre_build:
commands:
- $(aws ecr get-login)
- TAG="$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | head -c 8)"
build:
commands:
- docker build -t "${REPOSITORY}:${TAG}" .
post_build:
commands:
- docker push "${REPOSITORY}:${TAG}"
当我触发构建时,命令 $(aws ecr get-login)
失败:
An error occurred (AccessDeniedException) when calling the GetAuthorizationToken operation: User is not authorized to perform: ecr:GetAuthorizationToken on resource: * [Container] 2018/10/26 10:04:12 Command did not exit successfully $(aws ecr get-login) exit status 255
在 IAM 控制台中,用户附加了这些策略:
- AmazonEC2ContainerRegistryFullAccess
- AmazonEC2ContainerRegistryPowerUser
并且都包含 ecr:GetAuthorizationToken
权限。
我错过了什么?
已解决。我需要将 ecr:GetAuthorizationToken
权限授予角色,而不是用户。