Code build role is not authorized to perform: sts:AssumeRole on resource

0

I have a code build leading to EKS. When it calls this particular command "CREDENTIALS=$(aws sts assume-role --role-arn arn:aws:iam::3318******:role/EksWorkshopCodeBuildKubectlRole --role-session-name code-build --duration-seconds 900)" I get an error "An error occurred (AccessDenied) when calling the AssumeRole operation: User: arn:aws:sts::331*****:assumed-role/codebuild-kubernetes-eks-service-role/AWSCodeBuild-31746234-c1a9-4fe9-9cbc-b0d54264613e is not authorized to perform: sts:AssumeRole on resource: arn:aws:iam::331879450537:role/EksWorkshopCodeBuildKubectlRole"

My code build trusted relationship looks like { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": "codebuild.amazonaws.com" }, "Action": "sts:AssumeRole", "Condition": {} } ] } I have an STS policy attached to my user, group, codebuils service role and eksworkshopkubectlrole. What could I be doing wrong

2 個答案
0

As per the documentation https://docs.aws.amazon.com/codebuild/latest/userguide/troubleshooting.html#troubleshooting-assume-role, the issue could be either STS is not active for the AWS region or CodeBuild service role associated with the build project does not exist or does not have sufficient permissions to trust CodeBuild.

akjone
已回答 1 年前
0

Would it work if you modify the trusted relationship as follows?

Before

"Principal": { "Service": "codebuild.amazonaws.com" }, 

After

"Principal": { "AWS": "arn:aws:iam::331879450537:role/codebuild-kubernetes-eks-service-role" }, 

I think that the principal that call the AssumeRole operation is not codebuild, but codebuild-kubernetes-eks-service-role. Of course, codebuild-kubernetes-eks-service-role must have permission to call assume role too.

imiky
已回答 1 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南