CodeBuild session-role-name is incompatible with sts:AssumeRole

0

What I'm trying to do is the following:

  1. CodeBuild assumes a role
  2. This assumed role then assumes a role in a different account
  3. The last role retrieves an SSM parameter in a different account

To retrieve an SSM parameter with a regular account is possible: set sts:AssumeRole to Allow for the given account, e.g. for principal:
arn:aws:sts::xxxxxxxxxxxx:assumed-role/power-user/role-session-name

However, when CodeBuild assumes the role in step 1, there is no control over the role-session-name, which will differ between each run of CodeBuild. It will look something like this:
arn:aws:sts::xxxxxxxxxxxx:assumed-role/codebuild-role/AWSCodeBuild-12345678-1234-4321-1234-01234567890a
This is unfortunate, as sts:AssumeRole does not allow for wildcards in the principals specified.

Adding codebuild.amazonaws.com as a Service-type principal does not work either, as it is not the CodeBuild service itself assuming the final role, but the role it has assumed in step 1.

Is there a way to either change the role-session-name, or assume the role in a different way?

heemsk
질문됨 3년 전727회 조회
1개 답변
1

The solution here was to allow CodeBuild to assume the role:
arn:aws:sts::xxxxxxxxxxxx:root
As described here: https://dannys.cloud/create-reusable-assume-role-script-cross-account-aws

heemsk
답변함 3년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠