(pipelines): Support 'removalPolicy' and 'autoDeleteObjects' in CodePipelineProps`
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### Describe the feature
Currently, the `pipelines.CodePipeline` L3 construct abstracts the creation of the S3 artifact bucket. By default, this bucket is created with a `RemovalPolicy.RETAIN` policy.
While it is possible to configure this by manually creating a bucket and passing it into the `artifactBucket` property, this adds significant boilerplate for a common use case—specifically in **Dev** or **Ephemeral** environments where users want a full "clean-up" upon running `cdk destroy`.
### Use Case
When creating short-lived feature-branch pipelines or development stacks, users want to ensure that `cdk destroy` removes all resources. Currently, the artifact bucket stays behind, requiring manual deletion or the following boilerplate:
```typescript
// Current boilerplate required for a simple cleanup
const pipeline = new CodePipeline(this, 'Pipeline', {
synth: new ShellStep('Synth', { ... }),
artifactBucket: new s3.Bucket(this, 'ArtifactBucket', {
removalPolicy: RemovalPolicy.DESTROY,
autoDeleteObjects: true,
}),
});
```
### Proposed Solution
Add optional properties to `CodePipelineProps` that allow direct configuration of the internal artifact bucket's lifecycle behavior.
**Proposed API:**
```typescript
const pipeline = new CodePipeline(this, 'Pipeline', {
synth: new ShellStep('Synth', { ... }),
// New simplified props
artifactBucketRemovalPolicy: RemovalPolicy.DESTROY,
artifactBucketAutoDeleteObjects: true,
});
```
### Other Information
This would bring `CodePipeline` in line with other L3/L2 constructs that prioritize ease of lifecycle management.
### Acknowledgements
- [ ] I may be able to implement this feature request
- [ ] This feature might incur a breaking change
### AWS CDK Library version (aws-cdk-lib)
2.227.0
### AWS CDK CLI version
2.1029.3
### Environment details (OS name and version, etc.)
Mac Sequoia 15.7.2
Contributor guide
Research direction
Start at the CodePipeline construct and CodePipelineProps definitions, then trace how the internal S3 artifact bucket is created. Add the two proposed optional lifecycle properties and verify that they configure cleanup behavior for ephemeral pipelines without affecting users who provide artifactBucket.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- ci-cd, cloud
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100