File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed
infra/modules/aws/code_bucket Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -10,3 +10,18 @@ resource "aws_s3_bucket_ownership_controls" "lambda" {
1010 object_ownership = " BucketOwnerEnforced"
1111 }
1212}
13+
14+ resource "aws_s3_bucket_lifecycle_configuration" "delete_old_files" {
15+ count = var. s3_expiration_days > 0 ? 1 : 0
16+
17+ bucket = aws_s3_bucket. lambda . id
18+
19+ rule {
20+ id = " delete-expired-objects"
21+ status = " Enabled"
22+
23+ expiration {
24+ days = var. s3_expiration_days
25+ }
26+ }
27+ }
Original file line number Diff line number Diff line change 1+ # ## start of static vars set in root.hcl ###
12variable "lambda_bucket" {
23 description = " S3 bucket to host lambda code files"
34 type = string
45}
6+ # ## end of static vars set in root.hcl ###
7+
8+
9+ variable "s3_expiration_days" {
10+ description = " Number of days before objects are deleted (set to 0 to disable)"
11+ type = number
12+ default = 0
13+ }
You can’t perform that action at this time.
0 commit comments