terraform: abort incomplete multipart uploads on cache buckets
The hydra queue runner now uploads large NARs (>4 GiB) to S3 via multipart uploads with presigned part URLs. When a build aborts mid-upload the multipart upload is never completed or explicitly aborted, leaving orphaned parts that accrue storage cost indefinitely. Add a lifecycle rule to reap incomplete multipart uploads after 7 days on both the production nix-cache bucket and the shared cache-bucket module used by the staging caches. Normal uploads finish within an hour, so 7 days is ample headroom.
Jörg Thalheim committed
Jun 17, 2026 at 21:25 UTC
293f3b7b709f54e623ccd95de5e149622b35df1c
2 files changed
+26
terraform/cache-bucket/main.tf
+13
@@ -24,6 +24,19 @@ resource "aws_s3_bucket_lifecycle_configuration" "cache" {
24
storage_class = "STANDARD_IA"
25
}
26
}
27
+
28
+ # Reap multipart uploads (large NARs) that were never completed, e.g. when a
29
+ # build aborts mid-upload. Uploads normally finish within an hour.
30
+ rule {
31
+ id = "Abort incomplete multipart uploads"
32
+ status = "Enabled"
33
+
34
+ filter {}
35
+
36
+ abort_incomplete_multipart_upload {
37
+ days_after_initiation = 7
38
+ }
39
+ }
40
}
41
42
resource "aws_s3_bucket_cors_configuration" "cache" {
terraform/cache.tf
+13
@@ -49,6 +49,19 @@ resource "aws_s3_bucket_lifecycle_configuration" "cache" {
49
noncurrent_days = 30
50
}
51
}
52
+
53
+ # Reap multipart uploads (large NARs) that were never completed, e.g. when a
54
+ # build aborts mid-upload. Uploads normally finish within an hour.
55
+ rule {
56
+ id = "Abort incomplete multipart uploads"
57
+ status = "Enabled"
58
+
59
+ filter {}
60
+
61
+ abort_incomplete_multipart_upload {
62
+ days_after_initiation = 7
63
+ }
64
+ }
65
}
66
67
import {