aws-solutions-constructs icon indicating copy to clipboard operation
aws-solutions-constructs copied to clipboard

[CloudFrontToS3] Default behavior of origin S3 bucket moves non-current objects to Glacier, but doesn't manage logging buckets

Open ranrotx opened this issue 5 years ago • 4 comments

The default behavior of the S3 bucket created by this construct will use S3 lifecycle management to move objects in the origin S3 bucket to Glacier. This behavior is an anti-pattern for how most people host websites using S3 as an origin. The impact of this is that after 90 days of content creation (which is the default for the lifecycle management rule), anyone that requests an object via the CloudFront distribution will get an error as the object would be inaccessible by CloudFront (since it's been moved to Glacier).

Conversely, the logging S3 buckets do not have any lifecycle management rules. It seems like there is an oversight/mix-up for how lifecycle rules are implemented in this Construct as the logging buckets are the buckets that could benefit from a lifecycle management rule to move old log entries to Glacier after a period of time.

I'd suggest fixing this behavior so that it's more intuitive while this module is in experimental status.

Reproduction Steps

Deploying the stack with the example code below is enough to exhibit the current behavior described above.

new CloudFrontToS3(this, 'CloudFrontToS3', {});

Error Log

No error messages, it's just that the behavior described above appears to be an anti-pattern for how most people use S3 origins.

Environment

Other


This is :bug: Bug Report

ranrotx avatar Sep 16 '21 15:09 ranrotx

It will ONLY move the previous versions of the objects from S3 to Glacier after 90 days, so for example, if you have v1 of index.html in the bucket and never update that file for 90 days, it will NOT move to Glacier, but say you overwrite the index.html after 30 days, hence creating v2 of the file, in that case v1 of index.html will move to Glacier after 90 days, you will always have the latest version of index.html in the S3 bucket

Logging bucket never receive the new versions of the log files, so the above policy will be meaningless as all the log files have only one version, they never get overwritten

hnishar avatar Sep 16 '21 15:09 hnishar

Thanks for the clarification. You can close this unless you think there's value in adding a lifecycle policy to the logging buckets to prevent runaway spend due to the accumulation of log files.

ranrotx avatar Sep 16 '21 18:09 ranrotx

We're currently working on some PRs that expose props for logging buckets in the interface for S3 constructs that will allow people to address your concern. We'll leave this open until we merge the PR that exposes the logging bucket for this construct. Thanks.

biffgaut avatar Sep 17 '21 13:09 biffgaut

We've added the ability to control logging buckets across all constructs. This update should allow you to specify props for the logging bucket that allow you to define the behavior you want.

biffgaut avatar Jan 18 '22 20:01 biffgaut