From e2d2c8bca81778aaa9706e94987067574b7d55bb Mon Sep 17 00:00:00 2001 From: Timo Hajati <20628630+hajati@users.noreply.github.com> Date: Thu, 21 Mar 2024 10:19:30 +0100 Subject: [PATCH 1/2] Allow lifecycle rules for noncurrent objects --- README.md | 18 ++++++++++++++++++ rds-s3-dumps.tf | 17 +++++++++++++++++ s3.tf | 17 +++++++++++++++++ variables.tf | 18 ++++++++++++++++++ 4 files changed, 70 insertions(+) diff --git a/README.md b/README.md index 4bd8e6f..2745d28 100644 --- a/README.md +++ b/README.md @@ -1333,6 +1333,15 @@ list(object({ date = optional(string) storage_class = string })), []) + noncurrent_version_expiration = optional(list(object({ + noncurrent_days = optional(number) + newer_noncurrent_versions = optional(string) + })), []) + noncurrent_version_transition = optional(list(object({ + noncurrent_days = optional(number) + newer_noncurrent_versions = optional(string) + storage_class = string + })), []) })) ``` @@ -1787,6 +1796,15 @@ list(object({ date = optional(string) storage_class = string })), []) + noncurrent_version_expiration = optional(list(object({ + noncurrent_days = optional(number) + newer_noncurrent_versions = optional(string) + })), []) + noncurrent_version_transition = optional(list(object({ + noncurrent_days = optional(number) + newer_noncurrent_versions = optional(string) + storage_class = string + })), []) })) ``` diff --git a/rds-s3-dumps.tf b/rds-s3-dumps.tf index 4cdbc52..c1377fe 100644 --- a/rds-s3-dumps.tf +++ b/rds-s3-dumps.tf @@ -217,6 +217,23 @@ resource "aws_s3_bucket_lifecycle_configuration" "rds_dumps" { storage_class = transition.value.storage_class } } + + dynamic "noncurrent_version_expiration" { + for_each = rule.value.noncurrent_version_expiration + content { + noncurrent_days = noncurrent_version_expiration.value.noncurrent_days + newer_noncurrent_versions = noncurrent_version_expiration.value.newer_noncurrent_versions + } + } + + dynamic "noncurrent_version_transition" { + for_each = rule.value.noncurrent_version_transition + content { + noncurrent_days = noncurrent_version_transition.value.noncurrent_days + newer_noncurrent_versions = noncurrent_version_transition.value.newer_noncurrent_versions + storage_class = noncurrent_version_transition.value.storage_class + } + } } } } diff --git a/s3.tf b/s3.tf index b80134a..2a212c4 100644 --- a/s3.tf +++ b/s3.tf @@ -83,6 +83,23 @@ resource "aws_s3_bucket_lifecycle_configuration" "this" { storage_class = transition.value.storage_class } } + + dynamic "noncurrent_version_expiration" { + for_each = rule.value.noncurrent_version_expiration + content { + noncurrent_days = noncurrent_version_expiration.value.noncurrent_days + newer_noncurrent_versions = noncurrent_version_expiration.value.newer_noncurrent_versions + } + } + + dynamic "noncurrent_version_transition" { + for_each = rule.value.noncurrent_version_transition + content { + noncurrent_days = noncurrent_version_transition.value.noncurrent_days + newer_noncurrent_versions = noncurrent_version_transition.value.newer_noncurrent_versions + storage_class = noncurrent_version_transition.value.storage_class + } + } } } } diff --git a/variables.tf b/variables.tf index fd412d8..167ab98 100644 --- a/variables.tf +++ b/variables.tf @@ -804,6 +804,15 @@ variable "rds_s3_dump_lifecycle_rules" { date = optional(string) storage_class = string })), []) + noncurrent_version_expiration = optional(list(object({ + noncurrent_days = optional(number) + newer_noncurrent_versions = optional(string) + })), []) + noncurrent_version_transition = optional(list(object({ + noncurrent_days = optional(number) + newer_noncurrent_versions = optional(string) + storage_class = string + })), []) })) validation { @@ -1196,6 +1205,15 @@ variable "s3_lifecycle_rules" { date = optional(string) storage_class = string })), []) + noncurrent_version_expiration = optional(list(object({ + noncurrent_days = optional(number) + newer_noncurrent_versions = optional(string) + })), []) + noncurrent_version_transition = optional(list(object({ + noncurrent_days = optional(number) + newer_noncurrent_versions = optional(string) + storage_class = string + })), []) })) validation { From ff61464a2b1d6ae909ceec8ea4bb77272dbeba46 Mon Sep 17 00:00:00 2001 From: Timo Hajati <20628630+hajati@users.noreply.github.com> Date: Thu, 21 Mar 2024 10:25:42 +0100 Subject: [PATCH 2/2] fmt --- README.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 2745d28..16afa1a 100644 --- a/README.md +++ b/README.md @@ -1334,13 +1334,13 @@ list(object({ storage_class = string })), []) noncurrent_version_expiration = optional(list(object({ - noncurrent_days = optional(number) - newer_noncurrent_versions = optional(string) + noncurrent_days = optional(number) + newer_noncurrent_versions = optional(string) })), []) noncurrent_version_transition = optional(list(object({ - noncurrent_days = optional(number) - newer_noncurrent_versions = optional(string) - storage_class = string + noncurrent_days = optional(number) + newer_noncurrent_versions = optional(string) + storage_class = string })), []) })) ``` @@ -1797,13 +1797,13 @@ list(object({ storage_class = string })), []) noncurrent_version_expiration = optional(list(object({ - noncurrent_days = optional(number) - newer_noncurrent_versions = optional(string) + noncurrent_days = optional(number) + newer_noncurrent_versions = optional(string) })), []) noncurrent_version_transition = optional(list(object({ - noncurrent_days = optional(number) - newer_noncurrent_versions = optional(string) - storage_class = string + noncurrent_days = optional(number) + newer_noncurrent_versions = optional(string) + storage_class = string })), []) })) ```