diff --git a/main.tf b/main.tf index 2b7f281..9c46183 100644 --- a/main.tf +++ b/main.tf @@ -626,3 +626,11 @@ resource "aws_s3_directory_bucket" "default" { name = var.availability_zone_id } } + +resource "aws_s3_bucket_request_payment_configuration" "default" { + count = local.enabled && var.s3_request_payment_configuration.enabled ? 1 : 0 + + bucket = local.bucket_id + expected_bucket_owner = var.s3_request_payment_configuration.expected_bucket_owner + payer = lower(var.s3_request_payment_configuration.payer) == "requester" ? "Requester" : "BucketOwner" +} diff --git a/variables.tf b/variables.tf index 2b87e9a..c06ddde 100644 --- a/variables.tf +++ b/variables.tf @@ -494,6 +494,23 @@ variable "event_notification_details" { } } +variable "s3_request_payment_configuration" { + type = object({ + enabled = bool + expected_bucket_owner = optional(string) + payer = string + }) + description = "S3 request payment configuration" + default = { + enabled = false + payer = "BucketOwner" + } + validation { + condition = contains(["bucketowner", "requester"], lower(var.s3_request_payment_configuration.payer)) + error_message = "The s3 request payment config's payer must be either BucketOwner or Requester" + } +} + variable "create_s3_directory_bucket" { description = "Control the creation of the S3 directory bucket. Set to true to create the bucket, false to skip." type = bool