Skip to content

Conversation

magreenbaum
Copy link
Member

@magreenbaum magreenbaum commented Feb 1, 2025

Description

Support for directory buckets.

Motivation and Context

https://docs.aws.amazon.com/AmazonS3/latest/userguide/directory-buckets-overview.html

Breaking Changes

No.

How Has This Been Tested?

  • I have updated at least one of the examples/* to demonstrate and validate my change(s)
  • I have tested and validated these changes using one or more of the provided examples/* projects
  • I have executed pre-commit run -a on my pull request

@@ -0,0 +1,111 @@
locals {
region = "eu-west-1"
zone_id = "euw1-az1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you make AZ ID discoverable using a data source? There are cases where some AZs are not available in some accounts.

bucket_name = "${var.bucket_name_prefix}--${var.availability_zone_id}--x-s3"
}

resource "aws_s3_directory_bucket" "this" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This submodule creates one unique resource type (aws_s3_directory_bucket), and the rest are the same as those in the main S3 bucket module.

Given there are rather big differences in features, do you think we can have this resource aws_s3_directory_bucket in the main module and make the creation of it conditionally (e.g. is_directory_bucket = true/false)? This way, we will have less code repetition.

Or am I missing a bigger picture? What do you think?

Copy link
Member Author

@magreenbaum magreenbaum Feb 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That works as well. I was initially thinking since most of the resources in the main module didn't apply to the directory bucket, it would be easier to have a sub-module, but using is_directory_bucket also works. I refactored to this. Let me know if that looks good to you.

Copy link
Member

@antonbabenko antonbabenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comment and we are good to go :) Thanks!


is_directory_bucket = true
bucket = "${random_pet.this.id}-complete"
availability_zone = "${local.region}b"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I mentioned earlier. b or other AZs may not be present in some AWS accounts. I hit this issue in the past myself. Please update the example to use data-source to find first-available AZ in the account.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see, my apologies, I misunderstood initially. I added a data source to find available AZs but I found that even though an AZ is available to me, it might not be an option for directory buckets. In the example, if I set it to index 0, it attempts to use euw1-az2 which is available for my account but not available for directory buckets so I used index 1 here. https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-express-Endpoints.html

I guess this may not work for everyone so I'm happy to modify this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! 👍

@antonbabenko antonbabenko merged commit 0700a07 into terraform-aws-modules:master Feb 12, 2025
17 checks passed
antonbabenko pushed a commit that referenced this pull request Feb 12, 2025
## [4.6.0](v4.5.0...v4.6.0) (2025-02-12)

### Features

* Support S3 Directory Bucket ([#310](#310)) ([0700a07](0700a07))
@antonbabenko
Copy link
Member

This PR is included in version 4.6.0 🎉

@magreenbaum magreenbaum deleted the feat/directory_bucket branch February 13, 2025 00:53
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 15, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants