`autoBuildOptions` creates bucket for build logs that cannot be deleted
webdog opened this issue · 2 comments
When creating a Pipeline, the construct uses autoBuildOptions to determine whether or not to create an S3 Bucket for CodeBuild logs via the publicLogs
optional property:
aws-delivlib/lib/auto-build.ts
Lines 9 to 65 in 8b6eac1
When publicLogs
is set to true
, the Pipeline then uses aws-sam.serverless.CfnApplication
to create a bucket, which is a SAM application managed in this repositoy: https://github.com/jlhood/github-codebuild-logs by @jlhood
aws-delivlib/lib/auto-build.ts
Lines 117 to 131 in 8b6eac1
Once deployed by the SAM, the resource contains create logic, but not destroy logic AFAICT:
If I run cdk destroy
on the Pipeline stack, and CodeBuild has run to a point where it has successfully generated logs, the stack deletion will return DELETE_FAILED
because of this behavior (It is standard behavior to have buckets being unable to be deleted when there are objects present).
❯ cdk destroy
Are you sure you want to delete: PipelineStack (y/n)? y
PipelineStack: destroying...
2:31:54 PM | DELETE_FAILED | AWS::CloudFormation::Stack | PipelineAutoBuildG...ildLogsSAR914A0D32
Embedded stack arn:aws:cloudformation:us-east-1::stack/PipelineStack-PipelineAutoBuildGitHubCodeBuildLogsSAR was not successfully deleted: The following resource(s) failed to delete: [BuildLogs].
new AutoBuild (/pipeline/node_modules/aws-delivlib/lib/auto-build.ts:118:7)
\_ Pipeline.autoBuild (/pipeline/node_modules/aws-delivlib/lib/pipeline.ts:464:12)
\_ new Pipeline (/pipeline/node_modules/aws-delivlib/lib/pipeline.ts:277:36)
\_ new PipelineStack (/pipeline/lib/pipeline-stack.ts:55:22)
\_ Object.<anonymous> (/pipeline/bin/pipeline.ts:7:1)
2:31:54 PM | DELETE_FAILED | AWS::CloudFormation::Stack | Pipeline/AutoBuild...ubCodeBuildLogsSAR
Embedded stack arn:aws:cloudformation:us-east-1::stack/PipelineStack-PipelineAutoBuildGitHubCodeBuildLogsSAR was not successfully deleted: The following resource(s) failed to delete: [BuildLogs].
2:32:24 PM | DELETE_FAILED | AWS::CloudFormation::Stack | PipelineStack
The following resource(s) failed to delete: [PipelineAutoBuildGitHubCodeBuildLogsSAR].
❌ PipelineStack: destroy failed Error: The stack named PipelineStack is in a failed state. You may need to delete it from the AWS console : DELETE_FAILED (The following resource(s) failed to delete: [PipelineAutoBuildGitHubCodeBuildLogsSAR914A0D32]. )
at Object.waitForStackDelete (/usr/local/lib/node_modules/aws-cdk/lib/api/util/cloudformation.ts:277:11)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at Object.destroyStack (/usr/local/lib/node_modules/aws-cdk/lib/api/deploy-stack.ts:390:28)
at CdkToolkit.destroy (/usr/local/lib/node_modules/aws-cdk/lib/cdk-toolkit.ts:253:9)
at initCommandLine (/usr/local/lib/node_modules/aws-cdk/bin/cdk.ts:210:9)
The stack named PipelineStack is in a failed state. You may need to delete it from the AWS console : DELETE_FAILED (The following resource(s) failed to delete: [PipelineAutoBuildGitHubCodeBuildLogsSAR]. )
In the S3 Construct, autoDeleteObjects?
is available in s3.Bucket
which deletes objects from a bucket when the stack is deleted, as of Dec 2020 from the Pull Request merged by @jogold
Is there an opportunity to move off this external dependency and utilize the s3 Bucket construct? I am raising my
This issue is now marked as stale because it hasn't seen activity for a while. Add a comment or it will be closed soon.
Closing this issue as it hasn't seen activity for a while. Please add a comment @mentioning a maintainer to reopen.