Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS CodeBuild GetAuthorizationToken failed

I'm trying to build my testing project, but everytime It failed in pre_build. I check the error log and it says:

[Container] 2017/03/26 19:28:21 An error occurred (AccessDeniedException) when calling the GetAuthorizationToken operation: User: arn:aws:sts::074181202020:assumed-role/codebuild-Testing-project-service-role/AWSCodeBuild is not authorized to perform: ecr:GetAuthorizationToken on resource: *

I have tried to attach the following policies:

  • IAMSelfManageServiceSpecificCredentials
  • IAMFullAccess
  • AmazonS3ReadOnlyAccess
  • CodeBuildPolicy-Testing-project-1490555003058
  • IAMReadOnlyAccess
  • AWSCodeBuildAdminAccess
  • IAMUserSSHKeys
  • AWSCodeCommitFullAccess
  • IAMFullAccess
  • AmazonS3FullAccess
  • AdministratorAccess
  • AWSElasticBeanstalkFullAccess
  • AWSCodePipelineFullAccess
  • WSCodeBuildAdminAccess

But it still giving me the same error

Any help would be appreciated! Thanks!

like image 200
Nucleus Avatar asked Mar 26 '17 19:03

Nucleus


People also ask

How do I get an authorization token from AWS codeartifact?

To fetch an authorization token from CodeArtifact, you must call the GetAuthorizationToken API. Using the AWS CLI, you can call GetAuthorizationToken with the login or get-authorization-token command. aws codeartifact login (npm, pip, and twine): This command makes it easy to configure common package managers to use CodeArtifact in a single step.

Why can't I trust my AWS codebuild build project?

The AWS CodeBuild service role associated with the build project does not exist or does not have sufficient permissions to trust CodeBuild. Make sure AWS STS is activated for the AWS region where you are attempting to create or update the build project.

How to solve the getauthorizationtoken error inside ECR?

Actually the getAuthorizationToken error can't be solved inside ECR (As you won't even see ecr:getAuthorizationToken there). You need to go to the IAM panel => Roles => CodeBuild Role => Grant Policy => AmazonEC2ContainerRegistryReadOnly You need to add permissions to the ECR repository policy, not to the CodeBuild service role.

What happened to the AWS Security Token Service (AWS STS)?

The AWS Security Token Service (AWS STS) has been deactivated for the AWS region where you are attempting to create or update the build project. The AWS CodeBuild service role associated with the build project does not exist or does not have sufficient permissions to trust CodeBuild.


1 Answers

Actually the getAuthorizationToken error can't be solved inside ECR (As you won't even see ecr:getAuthorizationToken there).

You need to go to the IAM panel => Roles => CodeBuild Role => Grant Policy => AmazonEC2ContainerRegistryReadOnly

That enables it to get a token

like image 68
Jimmy Avatar answered Sep 27 '22 20:09

Jimmy