Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/complete/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 4.9.0"
version = ">= 5.27"
}
time = {
source = "hashicorp/time"
Expand Down
9 changes: 9 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@ resource "aws_s3_bucket_logging" "default" {

target_bucket = var.logging[0]["bucket_name"]
target_prefix = var.logging[0]["prefix"]

dynamic target_object_key_format {
for_each = try(var.logging[0]["object_key_partition_date"], "") != "" ? [1] : []
content {
partitioned_prefix {
partition_date_source = var.logging[0]["object_key_partition_date"]
}
}
}
}

# https://docs.aws.amazon.com/AmazonS3/latest/dev/bucket-encryption.html
Expand Down
5 changes: 3 additions & 2 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ variable "versioning_enabled" {

variable "logging" {
type = list(object({
bucket_name = string
prefix = string
bucket_name = string
prefix = string
object_key_partition_date = string
}))
default = []
description = "Bucket access logging configuration. Empty list for no logging, list of 1 to enable logging."
Expand Down
2 changes: 1 addition & 1 deletion versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 4.9.0"
version = ">= 5.27"
}
time = {
source = "hashicorp/time"
Expand Down