From a3f863d7ddc5343747f076063c63d3fc3eec2bc1 Mon Sep 17 00:00:00 2001 From: rrigato Date: Sat, 18 May 2024 09:33:11 -0500 Subject: [PATCH] automatically expire cloudfront logs --- templates/prod_homepage.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/templates/prod_homepage.yml b/templates/prod_homepage.yml index b60302e..32a7ea8 100644 --- a/templates/prod_homepage.yml +++ b/templates/prod_homepage.yml @@ -20,13 +20,15 @@ Parameters: Default: Z2FDTNDATAQYW2 Description: Route 53 Hosted Zone id + LogFileExpirationInDays: + Type: Number + Default: 90 + ProjectName: Type: String Default: homepage - - Conditions: RetainResourcesCreated: !Equals [ !Ref BucketName, ryanrigato.com ] @@ -36,6 +38,14 @@ Resources: Type: AWS::S3::Bucket Properties: BucketName: !Sub '${ProjectName}-logging' + LifecycleConfiguration: + Rules: + - Id: LogFileExpirationRule + Status: Enabled + ExpirationInDays: !Ref LogFileExpirationInDays + NoncurrentVersionExpirationInDays: !Ref LogFileExpirationInDays + AbortIncompleteMultipartUpload: + DaysAfterInitiation: !Ref LogFileExpirationInDays OwnershipControls: Rules: - ObjectOwnership: BucketOwnerPreferred