Skip to content

fix(codepipeline): clean up cross-region replication buckets#37880

Open
nanookclaw wants to merge 2 commits into
aws:mainfrom
nanookclaw:fix/cross-region-replication-bucket-destroy
Open

fix(codepipeline): clean up cross-region replication buckets#37880
nanookclaw wants to merge 2 commits into
aws:mainfrom
nanookclaw:fix/cross-region-replication-bucket-destroy

Conversation

@nanookclaw
Copy link
Copy Markdown

Issue # (if applicable)

Closes #35654.

Reason for this change

CodePipeline cross-region support stacks currently retain their replication bucket by default, which can leave an orphaned bucket after destroying the pipeline stack. Because changing the default removal policy could be disruptive for existing deployments, this adds the cleanup behavior behind an opt-in feature flag.

Description of changes

  • Adds @aws-cdk/aws-codepipeline:crossRegionReplicationBucketDestroy as a recommended feature flag.
  • When the flag is enabled, cross-region replication buckets are created with RemovalPolicy.DESTROY and autoDeleteObjects: true.
  • Keeps existing retain behavior when the flag is unset/disabled.
  • Adds coverage for both legacy retain behavior and the feature-flag-enabled cleanup behavior.

Description of how you validated changes

  • PATH=/tmp/yarn-bin:$PATH npx lerna run build --scope aws-cdk-lib --skip-nx-cache --stream
  • cd packages/aws-cdk-lib && node ../../node_modules/jest/bin/jest.js --config jest.config.js cx-api/test/features.test.ts aws-codepipeline/test/cross-env.test.ts --runInBand --coverage=false
  • cd packages/aws-cdk-lib && NODE_OPTIONS='--max-old-space-size=8192' ../../node_modules/.bin/eslint aws-codepipeline/lib/private/cross-region-support-stack.ts aws-codepipeline/test/cross-env.test.ts cx-api/lib/features.ts cx-api/test/features.test.ts

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 beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK label May 15, 2026
@github-actions github-actions Bot added bug This issue is a bug. effort/medium Medium work item – several days of effort p2 labels May 15, 2026
Copy link
Copy Markdown
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)

@nanookclaw
Copy link
Copy Markdown
Author

Added the integration-test coverage requested by the PR linter in 89c8f6901f.

The follow-up enables @aws-cdk/aws-codepipeline:crossRegionReplicationBucketDestroy in the existing dry-run cross-region CodePipeline integ (integ.codepipeline-with-nested-stack) and updates the committed snapshot. The snapshot now shows the generated cross-region replication bucket moving to DeletionPolicy: Delete / UpdateReplacePolicy: Delete with the Custom::S3AutoDeleteObjects resources present.

Verification run after the snapshot update:

  • PATH=/tmp/yarn-bin:$PATH NODE_OPTIONS='--max-old-space-size=8192' npx lerna run build --scope aws-cdk-lib --skip-nx-cache --stream
  • cd packages/aws-cdk-lib && NODE_OPTIONS='--max-old-space-size=8192' ../../node_modules/jest/bin/jest.js --config jest.config.js cx-api/test/features.test.ts aws-codepipeline/test/cross-env.test.ts --runInBand --coverage=false
  • cd packages/aws-cdk-lib && NODE_OPTIONS='--max-old-space-size=8192' ../../node_modules/.bin/eslint aws-codepipeline/lib/private/cross-region-support-stack.ts aws-codepipeline/test/cross-env.test.ts cx-api/lib/features.ts cx-api/test/features.test.ts
  • cd packages/@aws-cdk-testing/framework-integ && PATH=/tmp/yarn-bin:$PATH NODE_OPTIONS='--max-old-space-size=8192' yarn build
  • cd packages/@aws-cdk-testing/framework-integ && PATH=/tmp/yarn-bin:$PATH NODE_OPTIONS='--max-old-space-size=8192' yarn integ aws-codepipeline-actions/test/integ.codepipeline-with-nested-stack --update-on-failed --dry-run

@aws-cdk-automation aws-cdk-automation dismissed their stale review May 15, 2026 04:54

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

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 bug This issue is a bug. effort/medium Medium work item – several days of effort p2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(cdk pipelines): cdk pipeline support stacks should delete and not orphan s3 buckets

2 participants