Skip to content

Commit

Permalink
feat: add s3 request payment config (#259)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
nitrocode and gberenice authored Nov 14, 2024
1 parent e8dcd23 commit ed48258
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
8 changes: 8 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
17 changes: 17 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ed48258

Please sign in to comment.