Skip to content

feat(pipelines): actions can default to the pipeline service role instead of a newly created role #33991

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 2, 2025

Conversation

hwum
Copy link
Contributor

@hwum hwum commented Apr 1, 2025

Issue # 27065

#27605

Reason for this change

Lots of customer reported they don't want such many new roles generated in cdk level.
Current cdk library will help customer to generate a action role if no role configured.
But in Codepipeline backend logic, the pipeline service role will be used as default action role, which the cdk library doesn't align.

Description of changes

Support this field in L3 construct. L2 construct support has been delivered: d8bbc1c

Describe any new or updated permissions being added

No

Description of how you validated changes

Local deployment/unit test/integ test

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@github-actions github-actions bot added the p2 label Apr 1, 2025
@aws-cdk-automation aws-cdk-automation requested a review from a team April 1, 2025 01:27
@github-actions github-actions bot added the repeat-contributor [Pilot] contributed between 3-5 PRs to the CDK label Apr 1, 2025
Copy link
Collaborator

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

Choose a reason for hiding this comment

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

(This review is outdated)

@hwum hwum changed the title feat(pipelines) add usePipelineRoleForActions field in L3 construct feat(pipelines):add usePipelineRoleForActions field in L3 construct Apr 1, 2025
Copy link

codecov bot commented Apr 1, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.98%. Comparing base (1418277) to head (4695ec1).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #33991   +/-   ##
=======================================
  Coverage   83.98%   83.98%           
=======================================
  Files         120      120           
  Lines        6976     6976           
  Branches     1178     1178           
=======================================
  Hits         5859     5859           
  Misses       1005     1005           
  Partials      112      112           
Flag Coverage Δ
suite.unit 83.98% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
packages/aws-cdk ∅ <ø> (∅)
packages/aws-cdk-lib/core 83.98% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@hwum hwum requested a review from aws-cdk-automation April 1, 2025 01:38
@hwum hwum changed the title feat(pipelines):add usePipelineRoleForActions field in L3 construct feat(codepipeline): add usePipelineRoleForActions field support in L3 construct Apr 1, 2025
@hwum hwum changed the title feat(codepipeline): add usePipelineRoleForActions field support in L3 construct feat(pipelines): add usePipelineRoleForActions field support in L3 construct Apr 1, 2025
@aws-cdk-automation aws-cdk-automation dismissed their stale review April 1, 2025 02:01

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Apr 1, 2025
Copy link
Contributor

@kaizencc kaizencc left a comment

Choose a reason for hiding this comment

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

minor comments, otherwise looks good

@@ -1,3 +1,4 @@
/* eslint-disable no-console */
Copy link
Contributor

Choose a reason for hiding this comment

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

these consoles are all debugs right? at any rate we can't console.log like this :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

lol forgot to delete after debuging

Comment on lines 366 to 370
/**
* Allow no-actionRole-configured actions use pipeline service role
*/
public readonly usePipelineRoleForActions: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/**
* Allow no-actionRole-configured actions use pipeline service role
*/
public readonly usePipelineRoleForActions: boolean;
/**
* Allow no-actionRole-configured actions to use the pipeline service role
* instead of creating a new role for each action
*/
public readonly usePipelineRoleForActions: boolean;

is no-actionRole-configured a thing you are referencing? otherwise not sure why its hyphenated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll revise it

Comment on lines 22 to 24
// input: pipelines.CodePipelineSource.gitHub('cdklabs/construct-hub-probe', 'main', {
// trigger: GitHubTrigger.POLL,
// }),
Copy link
Contributor

Choose a reason for hiding this comment

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

delete?

@@ -976,6 +976,10 @@ Note that if you provide an existing pipeline, you cannot provide values for
`pipelineName`, `crossAccountKeys`, `reuseCrossRegionSupportStacks`, or `role`
because those values are passed in directly to the underlying `codepipeline.Pipeline`.

### Use pipeline service role as default action role in pipeline

If you don't want cdk helps you automatically create roles for each actions(like CodeBuild step ,etc.),you could set `usePipelineServiceRoleForActions` as true to use pipeline service role as default action role in Codepipeline if no action role provided.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
If you don't want cdk helps you automatically create roles for each actions(like CodeBuild step ,etc.),you could set `usePipelineServiceRoleForActions` as true to use pipeline service role as default action role in Codepipeline if no action role provided.
By default CDK automatically creates roles for each action (`CodeBuildStep`, etc).
If you prefer to use the pipeline service role as default instead, set the `usePipelineRoleForActions` property.
This will tell CDK to default to the pipeline service role in AWS CodePipeline if no action role is provided.

@kaizencc kaizencc changed the title feat(pipelines): add usePipelineRoleForActions field support in L3 construct feat(pipelines): actions can default to the pipeline service role instead of a newly created role Apr 1, 2025
@aws-cdk-automation aws-cdk-automation removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Apr 1, 2025
@mergify mergify bot dismissed kaizencc’s stale review April 1, 2025 21:18

Pull request has been modified.

@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Apr 1, 2025
Copy link
Contributor

mergify bot commented Apr 2, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 4695ec1
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

Copy link
Contributor

mergify bot commented Apr 2, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit 2ebc51e into aws:main Apr 2, 2025
20 checks passed
Copy link
Contributor

github-actions bot commented Apr 2, 2025

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 2, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p2 pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. repeat-contributor [Pilot] contributed between 3-5 PRs to the CDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants