AWS CodeBuild failed CLIENT_ERROR: authorization failed for primary source and source version
Asked Answered
T

4

32

I have already authenticated the GitHub account.

My AWS CodePipeline is failing with this error:

CLIENT_ERROR: authorization failed for primary source and source version

enter image description here

Ting answered 11/10, 2020 at 2:42 Comment(3)
There seem to something wrong with the setup of your source action. But there are no details how it was setup, so its difficult to speculate.Fruitcake
Please mention if you're Github connector or webhook integration ?Zoosporangium
I have same issues. I connected with github using github2 provider. What is problem?Crabby
K
33

CodeBuild role needs permission to access and use CodePipeline connection:

Kamat answered 5/11, 2020 at 12:1 Comment(1)
That link is for CodeStar; I don't see anything in the question about codestar.Zareba
J
10

Disconnecting and re-authenticating to GutHub in CodeBuild of the job fixed this error for me.

Make sure that you still have access to the access token used to connect to GitHub before disconnecting from it!

Access tokens can be set up/found here on your GitHub profile.

  1. Select Source

    Select Source

  2. Edit Source (disconnect and reconnect)

    Edit Source

3.Enter access token and Save.

Jaquiss answered 2/9, 2021 at 14:8 Comment(0)
M
2

I know it is too late to answer but just log my case.

In the CodePipeline, it is using a CodeBuild Project.
CodeBuild Project has different IAM Role with the CodePipeline itself.

And the CodeBuild Project gets the source from S3 bucket which was pulled by CodePipeline in the previous stage.
(It depends on your settings)

So the CodeBuild Role need both of the CodeStar and S3 permission.
(If the source is coming from GitHub)

To know clear root cause, you can refer to the CloudTrail > Event History. It shows which event and sources occurred issues.

In my case, 'AWSCodeStarFullAccess' didn't solve the issues, because that managed policy doesn't have 'codestar-connections:*' permission.

I added to more policies for the CodeBuild Role and it worked.

  1. Search the CodeBuild source directory in the S3 and allow it.
  2. Add policy to allow 'codestar-connections:*'

Might you can configure them better.

Mesopotamia answered 18/5, 2023 at 6:22 Comment(0)
P
0

I had the same problem, and it was solved by adding CodeCommit permissions to the CodeBuild roles.

Periodical answered 1/9, 2023 at 23:20 Comment(1)
This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. To get notified when this question gets new answers, you can follow this question. Once you have enough reputation, you can also add a bounty to draw more attention to this question. - From ReviewLahr

© 2022 - 2024 — McMap. All rights reserved.