Unable to create pipeline because of service role

Viewed 5454

Even though I have created just a role specific to codepipeline and code build I am getting this error. Whatever I do I am unable to get rid of it. Anyone know how to resolve this?

Could not update the service role policy. The following message contains details on the exception: The policy is attached to 0 entities but it must be attached to a single role

3 Answers

This is happening because the the checkbox for "Allow AWS CodeBuild to modify this service role so it can be used with this build project" is selected from the edit page, and the generated policy is not attached to the role that is selected in the "Service role" field.

When you check the box for "Allow AWS CodeBuild to modify this service role so it can be used with this build project", CodeBuild creates a policy of format "CodeBuildBasePolicy-project-name-region". If this policy is created already(previous builds), it must be attached to the service role that CodeBuild is using so that CodeBuild will be able to modify it accordingly.

In my case I had previous policy that was already unused. When I deleted it, the problem was solved.

Follow these steps:

  1. open IAM
  2. policies
  3. add "Edited time" column and sort desc
  4. there will be visible unused policies causing problem
  5. delete them

I just had the same problem and shared my solution in this other answer. I hope it helps!

Related