Skip to content
This repository has been archived by the owner on Sep 27, 2024. It is now read-only.

Commit

Permalink
[pre-commit.ci lite] apply automatic fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci-lite[bot] authored and Shanawaze committed May 13, 2024
1 parent 5de0fb5 commit 0af30b4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ No modules.
| <a name="input_s3_bucket_names"></a> [s3\_bucket\_names](#input\_s3\_bucket\_names) | n/a | `list(string)` | `[]` | no |
| <a name="input_sse_algorithm"></a> [sse\_algorithm](#input\_sse\_algorithm) | The server-side encryption algorithm to use. Valid values are AES256 and aws:kms, defaults to aws:kms. | `string` | `"aws:kms"` | no |
| <a name="input_tags"></a> [tags](#input\_tags) | n/a | `map(any)` | `{}` | no |
| <a name="input_version_lifecycle_expiration_days"></a> [version\_lifecycle\_expiration\_days](#input\_version\_lifecycle\_expiration\_days) | Number of days for a bucket version's lifecycle to expire. Defaults to 0, which disables the rule | `number` | `"0"` | no |
| <a name="input_versioning_enabled"></a> [versioning\_enabled](#input\_versioning\_enabled) | n/a | `bool` | `false` | no |

## Outputs
Expand Down
8 changes: 4 additions & 4 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,12 @@ resource "aws_s3_bucket_server_side_encryption_configuration" "bucket" {
# Lifecycle configuration for the dev buckets to remove all objects older than var.lifecycle_expiration_days.
resource "aws_s3_bucket_lifecycle_configuration" "lifecycle_expiration_days" {
## Iterate over the list from var's to avoid some chicken/egg problems
for_each = var.lifecycle_expiration_days || var.version_lifecycle_expiration_days > 0 ? toset(var.s3_bucket_names) : []
for_each = (var.lifecycle_expiration_days > 0) || (var.version_lifecycle_expiration_days > 0) ? toset(var.s3_bucket_names) : []
## Refer to the id from the bucket resource to retain the dependency
bucket = aws_s3_bucket.landing_zone_buckets[each.value].id

dynamic "rule" {
for_each = var.lifecycle_expiration_days > 0 ? [1] : []
for_each = var.lifecycle_expiration_days > 0 ? var.s3_bucket_names : []

content {
id = "delete-old-objects"
Expand All @@ -155,8 +155,8 @@ resource "aws_s3_bucket_lifecycle_configuration" "lifecycle_expiration_days" {
}
}

dynamic "version_rule" {
for_each = var.version_lifecycle_expiration_days > 0 ? [1] : []
dynamic "rule" {
for_each = var.version_lifecycle_expiration_days > 0 ? var.s3_bucket_names : []

content {
id = "delete-old-versions"
Expand Down

0 comments on commit 0af30b4

Please sign in to comment.