Skip to content

Commit 6c11408

Browse files
feat: add bucket lifecycle and currency (#54)
* feat: maintaining lifecycle for the bucket objects to control costs * feat: modify defaults to be higher for deletion and clean failed uploads
1 parent b08e044 commit 6c11408

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

function.tf

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,26 @@ resource "google_storage_bucket" "this" {
5151
# Since the bucket is just a temporary storage for asset export objects until
5252
# the function can process them, we want to implicitly delete any leftover objects
5353
# if Terraform plans to remove the bucket
54+
55+
# added for maintaining the bucket file and folder lifecycle
56+
lifecycle_rule {
57+
condition {
58+
age = var.bucket_lifecycle_delete_days
59+
}
60+
action {
61+
type = "Delete"
62+
}
63+
}
64+
65+
lifecycle_rule {
66+
condition {
67+
age = var.bucket_lifecycle_abort_upload_days
68+
}
69+
action {
70+
type = "AbortIncompleteMultipartUpload"
71+
}
72+
}
73+
5474
}
5575

5676
resource "google_storage_bucket_iam_member" "bucket_iam" {

variables.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,4 +239,16 @@ variable "cloud_function_debug_level" {
239239
description = "The debug level for the GCP cloud functions"
240240
type = string
241241
default = "WARNING"
242+
}
243+
244+
variable "bucket_lifecycle_delete_days" {
245+
description = "The number of days to wait before Delete of temporary bucket files."
246+
type = number
247+
default = 14
248+
}
249+
250+
variable "bucket_lifecycle_abort_upload_days" {
251+
description = "The number of days to wait before deleting AbortIncompleteMultipartUpload."
252+
type = number
253+
default = 7
242254
}

0 commit comments

Comments
 (0)