diff --git a/terraform/aws/buckets.tf b/terraform/aws/buckets.tf index b1f77afb24..2b1c7244d5 100644 --- a/terraform/aws/buckets.tf +++ b/terraform/aws/buckets.tf @@ -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" + } } } }