fix(codepipeline): prevent S3 bucket orphaning in cross-region support stacks #35692
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue # (if applicable)
Closes #35654.
Reason for this change
When using CDK Pipelines with cross-region deployments, the S3 replication bucket created by the cross-region support stack is orphaned during
cdk destroy
operations. This prevents clean teardown of preview/ephemeral environments and causes redeployment failures due to existing bucket conflicts.Description of changes
Added
removalPolicy: cdk.RemovalPolicy.DESTROY
to the S3 replication bucket inCrossRegionSupportConstruct
. This aligns the bucket's lifecycle management with the existing KMS key pattern in the same file and enables proper cleanup during stack destruction.Key changes:
removalPolicy: cdk.RemovalPolicy.DESTROY
to S3 bucket configuration (line 85 incross-region-support-stack.ts
)DeletionPolicy: Delete
Design decision: Used
removalPolicy
only (notautoDeleteObjects
) to avoid bootstrap asset dependencies and ensure compatibility with all synthesis modes, includingBootstraplessSynthesizer
.CloudFormation impact: Adds
DeletionPolicy: Delete
to the S3 bucket resource in cross-region support stacks. Existing stacks can be updated without issues.Describe any new or updated permissions being added
N/A - No IAM permissions changes. This change only affects CloudFormation resource deletion behavior.
Description of how you validated changes
DeletionPolicy: Delete
DeletionPolicy: Delete
on S3 bucket resourceChecklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license