Skip to content

feat(cdk): retain the static website bucket by default - #57

Merged
c19yamamoto merged 4 commits into
mainfrom
copilot/c19yamamoto-56-retain-deletion-policy
Nov 16, 2026
Merged

c19yamamoto merged 4 commits into
mainfrom
copilot/c19yamamoto-56-retain-deletion-policy

Conversation

@c19yamamoto

@c19yamamoto c19yamamoto commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Configure the website bucket to retain its contents when the stack is deleted or replaced.

  • Bucket lifecycle: Set RemovalPolicy.RETAIN and disable automatic object deletion.
  • Coverage: Assert both retention policies and verify the auto-delete custom resource is absent.
bucketProps: {
  bucketName: `${props.domainName}-static-website`,
  removalPolicy: RemovalPolicy.RETAIN,
},

Copilot AI linked an issue Nov 15, 2026 that may be closed by this pull request
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
@c19yamamoto c19yamamoto changed the title [WIP] Update deletion policy to retain by default Retain the static website bucket by default Nov 15, 2026
@c19yamamoto c19yamamoto changed the title Retain the static website bucket by default feat(cdk): retain the static website bucket by default Nov 16, 2026
@c19yamamoto

Copy link
Copy Markdown
Owner Author

@copilot

下記対応して

  console.error
    lib/construct/static-website-construct.ts:25:27
    WARNING AccessControl: AccessControl property is deprecated. Use bucket policies instead (CloudFormation Validate)
       StaticWebsiteTestStack/Website/CloudFrontToS3/CloudfrontLoggingBucket/Resource (WebsiteCloudFrontToS3CloudfrontLoggingBucketF02A63E9) aws-cdk-lib.aws_s3.CfnBucket
       Suggested fix: Remove AccessControl and use an AWS::S3::BucketPolicy resource
       Acknowledge with 'CloudFormation-Validate::W3045'
    
    A copy of this report can be found in: /tmp/cdk.outEA2VBE/validation-report.json

      41 |   });
      42 |
    > 43 |   return Template.fromStack(stack);
         |                   ^
      44 | }
      45 |
      46 | let websiteTemplate: Template;

      at validateTemplates (node_modules/aws-cdk-lib/core/lib/private/synthesis-validation.js:6:173)
      at synthesize (node_modules/aws-cdk-lib/core/lib/private/synthesis.js:1:3089)
      at App.synth (node_modules/aws-cdk-lib/core/lib/stage.js:1:5061)
      at App.synth (node_modules/aws-cdk-lib/core/lib/app.js:1:5364)
      at toTemplate (node_modules/aws-cdk-lib/assertions/lib/template.js:2:247)
      at Template.fromStack (node_modules/aws-cdk-lib/assertions/lib/template.js:1:2681)
      at createWebsiteTemplate (test/cdk.test.ts:43:19)
      at Object.<anonymous> (test/cdk.test.ts:49:21)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

Copilot AI commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

@copilot

下記対応して
...

enableLogging: false で CloudFront のアクセスログを無効にし、非推奨の ACL を設定するログバケットが生成されないようにしました。CDK テスト(6件)とビルドは通過しています。コミット: dc48668

@c19yamamoto

Copy link
Copy Markdown
Owner Author

@copilot

基本 override しなくて良い

  console.log
    WARN AWS_SOLUTIONS_CONSTRUCTS_WARNING:  An override has been provided for the property: enableLogging.
      at printWarning (node_modules/@aws-solutions-constructs/core/lib/utils.ts:104:11)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

Copilot AI commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

@copilot

基本 override しなくて良い
...

enableLogging: false の指定と無効化テストを削除し、CloudFront のデフォルト設定に戻しました。CDK テスト(5件)とビルドは通過しています。コミット: f1eef18

@c19yamamoto
c19yamamoto marked this pull request as ready for review November 16, 2026 00:31
Copilot AI balanced review requested due to automatic review settings November 16, 2026 00:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approved

No active review issues remain for the website bucket-retention change.

No open issues 🎉

What changed in this PR

This PR addresses #56 by configuring the CDK static website bucket to retain its contents when the stack is deleted or the bucket is replaced.

Changes:

  • Switch the website bucket to RemovalPolicy.RETAIN and remove automatic object deletion.
  • Update assertions and the template snapshot to verify retention and the absence of auto-delete resources.
File Description
cdk/​test/​cdk.test.ts Assert both retention policies and no auto-delete custom resource.
cdk/​test/​__snapshots__/​cdk.test.ts.snap Reflect retention and removal of auto-delete resources and permissions.
cdk/​lib/​construct/​static-website-construct.ts Retain the website bucket and disable automatic object deletion.

Review effort: Balanced

@c19yamamoto
c19yamamoto merged commit bfbe53e into main Nov 16, 2026
3 checks passed
@c19yamamoto
c19yamamoto deleted the copilot/c19yamamoto-56-retain-deletion-policy branch November 16, 2026 00:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

destroy → retain

3 participants