Skip to content

Commit

Permalink
feat: Added lifecycle policy to the s3 bucket.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesiarmes committed Feb 11, 2025
1 parent b9a34d3 commit 0843d1e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
17 changes: 17 additions & 0 deletions s3.tf
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,20 @@ resource "aws_s3_bucket_policy" "tfstate" {
bucket : aws_s3_bucket.tfstate.bucket
})
}

resource "aws_s3_bucket_lifecycle_configuration" "tfstate" {
bucket = aws_s3_bucket.tfstate.id

rule {
id = "state"
status = "Enabled"

abort_incomplete_multipart_upload {
days_after_initiation = 7
}

noncurrent_version_expiration {
noncurrent_days = var.state_version_expiration
}
}
}
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ variable "project" {
description = "Project that these resources are supporting."
}

variable "state_version_expiration" {
type = number
description = "Age (in days) before non-current versions of the state file are expired."
default = 30
}

variable "tags" {
type = map(string)
description = "Tags to apply to all resources."
Expand Down

0 comments on commit 0843d1e

Please sign in to comment.