@@ -149,19 +149,45 @@ def __init__(self, scope: Construct, id: str, **kwargs) -> None:
149149 self , "landsat_output_bucket" , OUTPUT_BUCKET
150150 )
151151
152+ sentinel_input_bucket_expiration_days = int (
153+ os .environ ["HLS_SENTINEL_INPUT_BUCKET_EXPIRATION_DAYS" ]
154+ )
155+
152156 # Must be created as part of the stack due to trigger requirements
153157 self .sentinel_input_bucket = aws_s3 .Bucket (
154158 self ,
155159 "SentinelInputBucket" ,
156160 bucket_name = SENTINEL_INPUT_BUCKET ,
157161 removal_policy = RemovalPolicy .DESTROY ,
162+ lifecycle_rules = [
163+ # Setting expired_object_delete_marker cannot be done within a
164+ # lifecycle rule that also specifies expiration, expiration_date, or
165+ # tag_filters.
166+ aws_s3 .LifecycleRule (expired_object_delete_marker = True ),
167+ aws_s3 .LifecycleRule (
168+ abort_incomplete_multipart_upload_after = Duration .days (1 ),
169+ expiration = Duration .days (sentinel_input_bucket_expiration_days ),
170+ noncurrent_version_expiration = Duration .days (1 ),
171+ ),
172+ ],
158173 )
159174
160175 self .sentinel_input_bucket_historic = aws_s3 .Bucket (
161176 self ,
162177 "SentinelInputBucketHistoric" ,
163178 bucket_name = SENTINEL_INPUT_BUCKET_HISTORIC ,
164179 removal_policy = RemovalPolicy .DESTROY ,
180+ lifecycle_rules = [
181+ # Setting expired_object_delete_marker cannot be done within a
182+ # lifecycle rule that also specifies expiration, expiration_date, or
183+ # tag_filters.
184+ aws_s3 .LifecycleRule (expired_object_delete_marker = True ),
185+ aws_s3 .LifecycleRule (
186+ abort_incomplete_multipart_upload_after = Duration .days (1 ),
187+ expiration = Duration .days (sentinel_input_bucket_expiration_days ),
188+ noncurrent_version_expiration = Duration .days (1 ),
189+ ),
190+ ],
165191 )
166192
167193 self .landsat_input_bucket_historic = aws_s3 .Bucket (
@@ -176,15 +202,25 @@ def __init__(self, scope: Construct, id: str, **kwargs) -> None:
176202 "LandsatIntermediateBucket" ,
177203 bucket_name = LANDSAT_INTERMEDIATE_OUTPUT_BUCKET ,
178204 removal_policy = RemovalPolicy .DESTROY ,
179- lifecycle_rules = [aws_s3 .LifecycleRule (expiration = Duration .days (60 ))],
205+ lifecycle_rules = [
206+ aws_s3 .LifecycleRule (
207+ abort_incomplete_multipart_upload_after = Duration .days (1 ),
208+ expiration = Duration .days (60 ),
209+ )
210+ ],
180211 )
181212
182213 self .gibs_intermediate_output_bucket = aws_s3 .Bucket (
183214 self ,
184215 "GibsIntermediateBucket" ,
185216 bucket_name = GIBS_INTERMEDIATE_OUTPUT_BUCKET ,
186217 removal_policy = RemovalPolicy .DESTROY ,
187- lifecycle_rules = [aws_s3 .LifecycleRule (expiration = Duration .days (60 ))],
218+ lifecycle_rules = [
219+ aws_s3 .LifecycleRule (
220+ abort_incomplete_multipart_upload_after = Duration .days (1 ),
221+ expiration = Duration .days (60 ),
222+ )
223+ ],
188224 )
189225
190226 self .efs = Efs (self , "Efs" , network = self .network )
0 commit comments