Skip to content

feat(codepipeline-actions): add serviceRoleOverride to CodeBuildAction - #38630

Open
sanyamk23 wants to merge 1 commit into
aws:mainfrom
sanyamk23:feat/codebuild-service-role-override
Open

feat(codepipeline-actions): add serviceRoleOverride to CodeBuildAction#38630
sanyamk23 wants to merge 1 commit into
aws:mainfrom
sanyamk23:feat/codebuild-service-role-override

Conversation

@sanyamk23

Copy link
Copy Markdown

Issue # (if applicable)

Closes #38611 (partial — the explicit override half; the auto-created scoped role behind a feature flag is left for a follow-up)

Reason for this change

CodePipeline added a ServiceRoleArnOverride field to the CodeBuild action configuration, but the CDK L2 CodeBuildAction has no way to set it. This PR exposes it as an optional prop.

Description of changes

  • Add optional serviceRoleOverride?: iam.IRole to CodeBuildActionProps.
  • When set, bound() emits ServiceRoleArnOverride in the action configuration and grants the pipeline role iam:PassRole on the provided role.
  • When unset, nothing changes — the CodeBuild project's service role is used as before.

Service role selection after this change:

  1. Explicit serviceRoleOverride → that role
  2. Otherwise → the CodeBuild project's default service role (unchanged)

Describe any new or updated permissions

The pipeline's role receives iam:PassRole scoped to the ARN of the role passed in serviceRoleOverride, only when the prop is provided.

Any new (or removed) dependencies

None.

Tests added

  • sets the ServiceRoleArnOverride configuration and grants PassRole: asserts the action configuration renders ServiceRoleArnOverride and the pipeline policy contains the scoped iam:PassRole statement.
  • does not set ServiceRoleArnOverride by default: asserts the key is absent when the prop is not provided.

All 9 tests in test/codebuild/codebuild-action.test.ts pass; package builds clean with jsii + eslint.

Checklist

Add an optional serviceRoleOverride prop to CodeBuildActionProps that maps
to CodePipeline's ServiceRoleArnOverride action configuration, allowing the
service role used when the action runs to be overridden per-action. The
pipeline role is granted iam:PassRole on the provided role.

Closes aws#38611 (partial: explicit override; auto-created scoped role behind
a feature flag left for a follow-up)
@sanyamk23
sanyamk23 deployed to automation August 21, 2026 19:16 — with GitHub Actions Active
@sanyamk23
sanyamk23 deployed to automation August 21, 2026 19:16 — with GitHub Actions Active
@github-actions github-actions Bot added feature-request A feature should be added or improved. p2 labels Aug 21, 2026
@aws-cdk-automation
aws-cdk-automation requested a review from a team August 21, 2026 19:16
@github-actions github-actions Bot added the beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK label Aug 21, 2026
@sanyamk23
sanyamk23 deployed to automation August 21, 2026 19:16 — with GitHub Actions Active

@aws-cdk-automation aws-cdk-automation left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pull request linter fails with the following errors:

❌ Features must contain a change to a README file.
❌ Features must contain a change to an integration test file and the resulting snapshot.

If you believe this pull request should receive an exemption, please comment and provide a justification. A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed, add Clarification Request to a comment.

@aws-cdk-automation aws-cdk-automation added the pr/needs-further-review PR requires additional review from our team specialists due to the scope or complexity of changes. label Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK feature-request A feature should be added or improved. p2 pr/needs-further-review PR requires additional review from our team specialists due to the scope or complexity of changes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(codepipeline-actions): cdk support for service role override field in codebuild actions

2 participants