Skip to content

feat(pipelines): add artifactBucketRemovalPolicy and artifactBucketAutoDeleteObjects props#37516

Open
Zelys-DFKH wants to merge 1 commit intoaws:mainfrom
Zelys-DFKH:fix/pipelines-artifact-bucket-removal-policy
Open

feat(pipelines): add artifactBucketRemovalPolicy and artifactBucketAutoDeleteObjects props#37516
Zelys-DFKH wants to merge 1 commit intoaws:mainfrom
Zelys-DFKH:fix/pipelines-artifact-bucket-removal-policy

Conversation

@Zelys-DFKH
Copy link
Copy Markdown

Issue # (if applicable)

Closes #36624

Reason for this change

When CodePipeline creates its own artifact bucket (the default behavior), there is no way to control the bucket's removal policy or enable automatic object deletion. This leaves artifacts behind when a pipeline stack is deleted, requiring manual cleanup or custom workarounds.

Description of changes

Added two optional props to CodePipelineProps:

  • artifactBucketRemovalPolicy: sets the RemovalPolicy on the managed artifact bucket
  • artifactBucketAutoDeleteObjects: enables autoDeleteObjects on the managed artifact bucket (requires artifactBucketRemovalPolicy: RemovalPolicy.DESTROY)

Both props apply only when no explicit artifactBucket is provided. Passing them alongside an existing artifactBucket or codePipeline throws a ValidationError.

Describe any new or updated permissions being added

None. The s3:DeleteObject and related permissions are handled by the existing autoDeleteObjects custom resource provider, unchanged.

Description of how you validated changes

Added five unit tests to codepipeline.test.ts:

  • managed bucket receives the given removal policy
  • managed bucket with autoDeleteObjects sets up the custom resource
  • throws when artifactBucketRemovalPolicy is set alongside an existing artifactBucket
  • throws when artifactBucketAutoDeleteObjects is set alongside an existing artifactBucket
  • throws when artifactBucketAutoDeleteObjects is true but removal policy is not DESTROY

All five tests pass.

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 effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2 labels Apr 3, 2026
@github-actions github-actions bot added the beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK label Apr 3, 2026
@aws-cdk-automation aws-cdk-automation requested a review from a team April 3, 2026 23:23
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)

…toDeleteObjects props

Adds two optional props to CodePipelineProps that control the lifecycle of the managed
artifact bucket created when no explicit artifactBucket is provided:
- artifactBucketRemovalPolicy: sets the RemovalPolicy on the managed bucket
- artifactBucketAutoDeleteObjects: enables autoDeleteObjects (requires DESTROY policy)

Closes aws#36624
@Zelys-DFKH Zelys-DFKH force-pushed the fix/pipelines-artifact-bucket-removal-policy branch from 0d19c25 to 8ab38a2 Compare April 3, 2026 23:50
@aws-cdk-automation aws-cdk-automation dismissed their stale review April 3, 2026 23:52

✅ 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 effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(pipelines): Support 'removalPolicy' and 'autoDeleteObjects' in CodePipelineProps`

2 participants