Skip to content

Commit

Permalink
Don't apply archival storageclass rule unless necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
yuvipanda committed Jan 16, 2024
1 parent e9da67b commit 95443af
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions terraform/aws/buckets.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,21 @@ resource "aws_s3_bucket_lifecycle_configuration" "user_bucket_expiry" {
}
}

rule {
id = "archival-storageclass"
status = each.value.delete_after != null ? "Enabled" : "Disabled"
dynamic "rule" {
# Only set up this rule if it will be enabled. Prevents unnecessary
# churn in terraform
for_each = each.value.archival_storageclass_after != null ? [1] : []

transition {
# Transition this to much cheaper object storage after a few days
days = each.value.archival_storageclass_after
# Glacier Instant is fast enough while also being pretty cheap
storage_class = "GLACIER_IR"
content {
id = "archival-storageclass"
status = "Enabled"

transition {
# Transition this to much cheaper object storage after a few days
days = each.value.archival_storageclass_after
# Glacier Instant is fast enough while also being pretty cheap
storage_class = "GLACIER_IR"
}
}
}
}
Expand Down

0 comments on commit 95443af

Please sign in to comment.