Skip to content

Commit

Permalink
support newer_noncurrent_versions (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
kei500 authored May 30, 2023
1 parent cc60357 commit 9fd6f11
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 16 deletions.
10 changes: 6 additions & 4 deletions aws/private-s3-bucket/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions aws/private-s3-bucket/bucket_options.tf
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,16 @@ resource "aws_s3_bucket_lifecycle_configuration" "b" {
dynamic "noncurrent_version_transition" {
for_each = var.lifecycle_rule[0].noncurrent_version_transition
content {
noncurrent_days = noncurrent_version_transition.value.days
storage_class = noncurrent_version_transition.value.storage_class
noncurrent_days = noncurrent_version_transition.value.days
newer_noncurrent_versions = noncurrent_version_transition.value.versions
storage_class = noncurrent_version_transition.value.storage_class
}
}
dynamic "noncurrent_version_expiration" {
for_each = var.lifecycle_rule[0].noncurrent_version_expiration
content {
noncurrent_days = noncurrent_version_expiration.value.days
noncurrent_days = noncurrent_version_expiration.value.days
newer_noncurrent_versions = noncurrent_version_expiration.value.versions
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion aws/private-s3-bucket/constraints.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
terraform {
required_version = ">= 0.14"
required_version = ">= 1.3.0"
required_providers {
aws = {
source = "hashicorp/aws"
Expand Down
6 changes: 4 additions & 2 deletions aws/private-s3-bucket/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,15 @@
* ]
* noncurrent_version_transition = [
* {
* days = 120
* days = 120
* versions = 3
* storage_class = "GLACIER"
* }
* ]
* noncurrent_version_expiration = [
* {
* days = 150
* days = 150
* versions = 3
* }
* ]
* }
Expand Down
14 changes: 8 additions & 6 deletions aws/private-s3-bucket/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,25 @@ variable "lifecycle_rule" {
abort_incomplete_multipart_upload_days = number
tags = map(string)
transition = list(object({
date = string
days = number
date = optional(string)
days = optional(number)
storage_class = string
}))
# Note for expiration, noncurrent_version_transition, noncurrent_version_expiration
# define as list for simplicity, though expected only a single object
expiration = list(object({
date = string
days = number
expired_object_delete_marker = bool
date = optional(string)
days = optional(number)
expired_object_delete_marker = optional(bool, false)
}))
noncurrent_version_transition = list(object({
days = number
versions = optional(number)
storage_class = string
}))
noncurrent_version_expiration = list(object({
days = number
days = number
versions = optional(number)
}))
}))
description = "S3 lifecycle rule"
Expand Down

0 comments on commit 9fd6f11

Please sign in to comment.