Skip to content

feat(pipelines): support removalPolicy and autoDeleteObjects for artifact bucket#37985

Open
masamaru0513 wants to merge 1 commit into
aws:mainfrom
masamaru0513:feat/pipelines-artifact-bucket-removal-policy
Open

feat(pipelines): support removalPolicy and autoDeleteObjects for artifact bucket#37985
masamaru0513 wants to merge 1 commit into
aws:mainfrom
masamaru0513:feat/pipelines-artifact-bucket-removal-policy

Conversation

@masamaru0513
Copy link
Copy Markdown

Issue

Closes #36624.

Reason for this change

The CodePipeline construct creates its artifact bucket with RemovalPolicy.RETAIN by default. For dev/ephemeral environments, users must manually create a bucket with lifecycle settings — significant boilerplate for a common use case.

Description of changes

Added artifactBucketRemovalPolicy and artifactBucketAutoDeleteObjects to both:

  • PipelineProps (L2 aws-codepipeline)
  • CodePipelineProps (L3 pipelines)

The change is made at the L2 level to avoid KMS key logic duplication and construct tree path changes (as noted in #36645 review).

Validations:

  • Cannot be set with artifactBucket (mutually exclusive)
  • Cannot be set with crossRegionReplicationBuckets
  • autoDeleteObjects: true requires RemovalPolicy.DESTROY
  • Cannot be set when codePipeline is provided (L3)

Default behavior is unchangedRemovalPolicy.RETAIN when props are not specified.

How I validated

  • Unit tests: 9 new tests (L2) + 5 new tests (L3), all passing
  • Existing tests: all passing (45 L2 pipeline tests, 42 L3 tests)
  • Integration test added
  • Deployed and destroyed a real stack with --profile staging — artifact bucket was fully cleaned up on cdk destroy

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 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 labels May 24, 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)

…fact bucket

Add `artifactBucketRemovalPolicy` and `artifactBucketAutoDeleteObjects`
properties to both `PipelineProps` (aws-codepipeline L2) and
`CodePipelineProps` (pipelines L3).

When specified without an explicit `artifactBucket`, the managed bucket
is created with the given lifecycle settings. This simplifies cleanup of
dev/ephemeral pipeline stacks without requiring boilerplate bucket creation.

Closes aws#36624
@masamaru0513 masamaru0513 force-pushed the feat/pipelines-artifact-bucket-removal-policy branch from cb3cf2e to ac68010 Compare May 24, 2026 13:47
@aws-cdk-automation aws-cdk-automation dismissed their stale review May 24, 2026 13:49

✅ 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