Skip to content

fix(codepipeline): replace account root principal with current pipeline role in the trust policy under ff: @aws-cdk/pipelines:reduceStageRoleTrustScope #33742

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 10 commits into from
Mar 13, 2025

Conversation

QuantumNeuralCoder
Copy link
Contributor

Issue # (if applicable)

aws-codepipeline creates roles with broad trust policies.

Closes #33709

Reason for this change

Captured in Description of the issue.

Description of changes

  1. Introduced feature flag @aws-cdk/pipelines:reduceStageRoleTrustScope (default: true).
  2. Under the feature flag when enabled, the root account principal will not be added to the trust policy of stage role. Instead the stage role can now be assumed by the current role created for the pipeline.

Describe any new or updated permissions being added

Described above.

Description of how you validated changes

integ test snapshots are being updated.

Checklist


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

@QuantumNeuralCoder QuantumNeuralCoder marked this pull request as draft March 12, 2025 00:08
@github-actions github-actions bot added bug This issue is a bug. effort/medium Medium work item – several days of effort p0 labels Mar 12, 2025
@aws-cdk-automation aws-cdk-automation requested a review from a team March 12, 2025 00:08
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Mar 12, 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)

Copy link

codecov bot commented Mar 12, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.38%. Comparing base (5687d85) to head (0ce944a).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #33742   +/-   ##
=======================================
  Coverage   82.38%   82.38%           
=======================================
  Files         120      120           
  Lines        6937     6937           
  Branches     1170     1170           
=======================================
  Hits         5715     5715           
  Misses       1119     1119           
  Partials      103      103           
Flag Coverage Δ
suite.unit 82.38% <ø> (ø)

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 82.38% <ø> (ø)
🚀 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.

@paulhcsun paulhcsun changed the title fix(aws-codepipeline): replace account root principal with current pipeline role in the trust policy under ff: @aws-cdk/pipelines:reduceStageRoleTrustScope fix(codepipeline): replace account root principal with current pipeline role in the trust policy under ff: @aws-cdk/pipelines:reduceStageRoleTrustScope Mar 12, 2025
@aws-cdk-automation aws-cdk-automation dismissed their stale review March 12, 2025 18:21

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

@QuantumNeuralCoder QuantumNeuralCoder marked this pull request as ready for review March 12, 2025 18:25
@paulhcsun
Copy link
Contributor

For the failing test I think you just need to add [feats.PIPELINE_REDUCE_STAGE_ROLE_TRUST_SCOPE]: true, to this test: https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/cx-api/test/features.test.ts#L24

@paulhcsun
Copy link
Contributor

Integ test snapshot in the aws-scheduler-targets-alpha needs to be updated. Deploying that now and will push the changes.

@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Mar 13, 2025
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

@@ -79,6 +79,7 @@ export class StackSetPipelineStack extends Stack {
const app = new App({
postCliContext: {
'@aws-cdk/aws-codepipeline:defaultPipelineTypeToV2': false,
'@aws-cdk/pipelines:reduceStageRoleTrustScope': false,
Copy link
Contributor

Choose a reason for hiding this comment

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

What are the rationales that some tests have '@aws-cdk/pipelines:reduceStageRoleTrustScope': false while the others do not (and therefore is implicitly using '@aws-cdk/pipelines:reduceStageRoleTrustScope': true) ?

Copy link
Contributor

Choose a reason for hiding this comment

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

This is because Code Repository doesn't allow new code repos, so we would not be able to deploy these tests.

diffAssets: true,
});

app.synth();
Copy link
Contributor

Choose a reason for hiding this comment

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

Note that this does not invoke the CodePipeline and therefore, will not reveal permission misconfiguration. Since I know we have manually tested this, I am okay without assertions but please consider adding assertions.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed, we can add assertions in a follow up PR.

Copy link
Contributor

mergify bot commented Mar 13, 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 a64b01c into aws:main Mar 13, 2025
23 checks passed
Copy link
Contributor

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 Mar 13, 2025
@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Mar 13, 2025
@paulhcsun paulhcsun deleted the i33709 branch March 13, 2025 16:57
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue is a bug. contribution/core This is a PR that came from AWS. effort/medium Medium work item – several days of effort p0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

aws-codepipeline: trusted entities are too broad
4 participants