custom-resource-handlers/aws-s3/auto-delete-objects-handler: Object locked objects prevent cdk destroy #32147
Labels
@aws-cdk/aws-s3
Related to Amazon S3
bug
This issue is a bug.
needs-triage
This issue or PR still needs to be triaged.
Describe the bug
When an s3 bucket is created with object lock governance and the s3 bucket is set for removal cdk destroy fails. This happens even when the role has permissions to bypassgovernancelock
This is because in the auto-delete-objects-handler the s3 delete objects is called without
BypassGovernanceRetention
Current:
await s3.deleteObjects({ Bucket: bucketName, Delete: { Objects: records } });
Regression Issue
Last Known Working CDK Version
No response
Expected Behavior
I expect for the cdk destroy to remove the governed objects provided the role has the necessary permissions
Current Behavior
The cdk destroy fails and the stack reverts back to its previous state
Reproduction Steps
Add some objects, then run cdk destroy
Possible Solution
await s3.deleteObjects({ Bucket: bucketName, Delete: { Objects: records }, BypassGovernanceRetention: true });
The above will work for governed objects however will fail for non object locked objects. For this reason a combination of the two will need to be used
Additional Information/Context
No response
CDK CLI Version
2.160.0 (build 7a8ae02)
Framework Version
No response
Node.js Version
v21.7.1
OS
MacOS 14.7.1
Language
TypeScript
Language Version
No response
Other information
No response
The text was updated successfully, but these errors were encountered: