Skip to content

Commit

Permalink
Add Intelligent Tiering lifecycle to bucket
Browse files Browse the repository at this point in the history
  • Loading branch information
psychomantys committed Jun 27, 2024
1 parent 672adab commit a6aa80f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
18 changes: 14 additions & 4 deletions _variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,32 @@ variable "tiering_archive_access" {
default = 90
}

variable "glacier_enabled" {
variable "infrequent_access_enabled" {
type = bool
default = false
}

variable "glacier_days" {
variable "infrequent_access_days" {
type = number
default = 7
}

variable "infrequent_access_enabled" {
variable "intelligent_tiering_enabled" {
type = bool
default = false
}

variable "infrequent_access_days" {
variable "intelligent_tiering_days" {
type = number
default = 7
}

variable "glacier_enabled" {
type = bool
default = false
}

variable "glacier_days" {
type = number
default = 30
}
Expand Down
19 changes: 15 additions & 4 deletions lifecycle.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@ resource "aws_s3_bucket_lifecycle_configuration" "bucket_lifecycle" {

bucket = aws_s3_bucket.bucket[0].id

rule {
id = "Transition to Standard-IA"

transition {
storage_class = "STANDARD_IA"
days = var.infrequent_access_days
}

status = var.infrequent_access_enabled ? "Enabled" : "Disabled"
}

rule {
id = "Transition to Glacier Instant Retrieval"

Expand All @@ -15,14 +26,14 @@ resource "aws_s3_bucket_lifecycle_configuration" "bucket_lifecycle" {
}

rule {
id = "Transition to Standard-IA"
id = "Transition to Intelligent Tiering"

transition {
storage_class = "STANDARD_IA"
days = var.infrequent_access_days
storage_class = "INTELLIGENT_TIERING"
days = var.intelligent_tiering_days
}

status = var.infrequent_access_enabled ? "Enabled" : "Disabled"
status = var.intelligent_tiering_enabled ? "Enabled" : "Disabled"
}

rule {
Expand Down

0 comments on commit a6aa80f

Please sign in to comment.