Skip to content

Commit ed48258

Browse files
nitrocodegberenice
andauthored
feat: add s3 request payment config (#259)
* feat: add s3 request payment config var * fix: set optional key and add validation * feat: use s3 request payment config * fix: set default to BucketOwner * fix: validation for contains --------- Co-authored-by: Veronika Gnilitska <30597968+gberenice@users.noreply.github.com>
1 parent e8dcd23 commit ed48258

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

main.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,3 +626,11 @@ resource "aws_s3_directory_bucket" "default" {
626626
name = var.availability_zone_id
627627
}
628628
}
629+
630+
resource "aws_s3_bucket_request_payment_configuration" "default" {
631+
count = local.enabled && var.s3_request_payment_configuration.enabled ? 1 : 0
632+
633+
bucket = local.bucket_id
634+
expected_bucket_owner = var.s3_request_payment_configuration.expected_bucket_owner
635+
payer = lower(var.s3_request_payment_configuration.payer) == "requester" ? "Requester" : "BucketOwner"
636+
}

variables.tf

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,23 @@ variable "event_notification_details" {
494494
}
495495
}
496496

497+
variable "s3_request_payment_configuration" {
498+
type = object({
499+
enabled = bool
500+
expected_bucket_owner = optional(string)
501+
payer = string
502+
})
503+
description = "S3 request payment configuration"
504+
default = {
505+
enabled = false
506+
payer = "BucketOwner"
507+
}
508+
validation {
509+
condition = contains(["bucketowner", "requester"], lower(var.s3_request_payment_configuration.payer))
510+
error_message = "The s3 request payment config's payer must be either BucketOwner or Requester"
511+
}
512+
}
513+
497514
variable "create_s3_directory_bucket" {
498515
description = "Control the creation of the S3 directory bucket. Set to true to create the bucket, false to skip."
499516
type = bool

0 commit comments

Comments
 (0)