Skip to content

Commit 59feb8c

Browse files
authored
Merge branch 'master' into fix/lifecycle-rule-null-values
2 parents 607ec3d + fc09cc6 commit 59feb8c

25 files changed

+338
-51
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## [4.6.0](https://github.com/terraform-aws-modules/terraform-aws-s3-bucket/compare/v4.5.0...v4.6.0) (2025-02-12)
6+
7+
8+
### Features
9+
10+
* Support S3 Directory Bucket ([#310](https://github.com/terraform-aws-modules/terraform-aws-s3-bucket/issues/310)) ([0700a07](https://github.com/terraform-aws-modules/terraform-aws-s3-bucket/commit/0700a0753cbc9846a6746b921f5eb7817a6d5749))
11+
512
## [4.5.0](https://github.com/terraform-aws-modules/terraform-aws-s3-bucket/compare/v4.4.0...v4.5.0) (2025-01-23)
613

714

README.md

+12-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ These features of S3 bucket configurations are supported:
1717
- ELB log delivery bucket policy
1818
- ALB/NLB log delivery bucket policy
1919
- Account-level Public Access Block
20+
- S3 Directory Bucket
2021

2122
## Usage
2223

@@ -123,20 +124,21 @@ Users of Terragrunt can achieve similar results by using modules provided in the
123124
- [S3 Analytics](https://github.com/terraform-aws-modules/terraform-aws-s3-bucket/tree/master/examples/s3-analytics) - S3 bucket Analytics Configurations.
124125
- [S3 Inventory](https://github.com/terraform-aws-modules/terraform-aws-s3-bucket/tree/master/examples/s3-inventory) - S3 bucket Inventory configuration.
125126
- [S3 Account-level Public Access Block](https://github.com/terraform-aws-modules/terraform-aws-s3-bucket/tree/master/examples/account-public-access) - Manage S3 account-level Public Access Block.
127+
- [S3 Directory Bucket](https://github.com/terraform-aws-modules/terraform-aws-s3-bucket/tree/master/examples/directory-bucket) - S3 Directory Bucket configuration.
126128

127129
<!-- BEGIN_TF_DOCS -->
128130
## Requirements
129131

130132
| Name | Version |
131133
|------|---------|
132134
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
133-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.70 |
135+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.83 |
134136

135137
## Providers
136138

137139
| Name | Version |
138140
|------|---------|
139-
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.70 |
141+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.83 |
140142

141143
## Modules
142144

@@ -165,6 +167,7 @@ No modules.
165167
| [aws_s3_bucket_server_side_encryption_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_server_side_encryption_configuration) | resource |
166168
| [aws_s3_bucket_versioning.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_versioning) | resource |
167169
| [aws_s3_bucket_website_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_website_configuration) | resource |
170+
| [aws_s3_directory_bucket.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_directory_bucket) | resource |
168171
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
169172
| [aws_canonical_user_id.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/canonical_user_id) | data source |
170173
| [aws_iam_policy_document.access_log_delivery](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
@@ -207,13 +210,15 @@ No modules.
207210
| <a name="input_attach_policy"></a> [attach\_policy](#input\_attach\_policy) | Controls if S3 bucket should have bucket policy attached (set to `true` to use value of `policy` as bucket policy) | `bool` | `false` | no |
208211
| <a name="input_attach_public_policy"></a> [attach\_public\_policy](#input\_attach\_public\_policy) | Controls if a user defined public bucket policy will be attached (set to `false` to allow upstream to apply defaults to the bucket) | `bool` | `true` | no |
209212
| <a name="input_attach_require_latest_tls_policy"></a> [attach\_require\_latest\_tls\_policy](#input\_attach\_require\_latest\_tls\_policy) | Controls if S3 bucket should require the latest version of TLS | `bool` | `false` | no |
213+
| <a name="input_availability_zone_id"></a> [availability\_zone\_id](#input\_availability\_zone\_id) | Availability Zone ID or Local Zone ID | `string` | `null` | no |
210214
| <a name="input_block_public_acls"></a> [block\_public\_acls](#input\_block\_public\_acls) | Whether Amazon S3 should block public ACLs for this bucket. | `bool` | `true` | no |
211215
| <a name="input_block_public_policy"></a> [block\_public\_policy](#input\_block\_public\_policy) | Whether Amazon S3 should block public bucket policies for this bucket. | `bool` | `true` | no |
212216
| <a name="input_bucket"></a> [bucket](#input\_bucket) | (Optional, Forces new resource) The name of the bucket. If omitted, Terraform will assign a random, unique name. | `string` | `null` | no |
213217
| <a name="input_bucket_prefix"></a> [bucket\_prefix](#input\_bucket\_prefix) | (Optional, Forces new resource) Creates a unique bucket name beginning with the specified prefix. Conflicts with bucket. | `string` | `null` | no |
214218
| <a name="input_control_object_ownership"></a> [control\_object\_ownership](#input\_control\_object\_ownership) | Whether to manage S3 Bucket Ownership Controls on this bucket. | `bool` | `false` | no |
215219
| <a name="input_cors_rule"></a> [cors\_rule](#input\_cors\_rule) | List of maps containing rules for Cross-Origin Resource Sharing. | `any` | `[]` | no |
216220
| <a name="input_create_bucket"></a> [create\_bucket](#input\_create\_bucket) | Controls if S3 bucket should be created | `bool` | `true` | no |
221+
| <a name="input_data_redundancy"></a> [data\_redundancy](#input\_data\_redundancy) | Data redundancy. Valid values: `SingleAvailabilityZone` | `string` | `null` | no |
217222
| <a name="input_expected_bucket_owner"></a> [expected\_bucket\_owner](#input\_expected\_bucket\_owner) | The account ID of the expected bucket owner | `string` | `null` | no |
218223
| <a name="input_force_destroy"></a> [force\_destroy](#input\_force\_destroy) | (Optional, Default:false ) A boolean that indicates all objects should be deleted from the bucket so that the bucket can be destroyed without error. These objects are not recoverable. | `bool` | `false` | no |
219224
| <a name="input_grant"></a> [grant](#input\_grant) | An ACL policy grant. Conflicts with `acl` | `any` | `[]` | no |
@@ -223,7 +228,9 @@ No modules.
223228
| <a name="input_inventory_self_source_destination"></a> [inventory\_self\_source\_destination](#input\_inventory\_self\_source\_destination) | Whether or not the inventory source bucket is also the destination bucket. | `bool` | `false` | no |
224229
| <a name="input_inventory_source_account_id"></a> [inventory\_source\_account\_id](#input\_inventory\_source\_account\_id) | The inventory source account id. | `string` | `null` | no |
225230
| <a name="input_inventory_source_bucket_arn"></a> [inventory\_source\_bucket\_arn](#input\_inventory\_source\_bucket\_arn) | The inventory source bucket ARN. | `string` | `null` | no |
231+
| <a name="input_is_directory_bucket"></a> [is\_directory\_bucket](#input\_is\_directory\_bucket) | If the s3 bucket created is a directory bucket | `bool` | `false` | no |
226232
| <a name="input_lifecycle_rule"></a> [lifecycle\_rule](#input\_lifecycle\_rule) | List of maps containing configuration of object lifecycle management. | `any` | `[]` | no |
233+
| <a name="input_location_type"></a> [location\_type](#input\_location\_type) | Location type. Valid values: `AvailabilityZone` or `LocalZone` | `string` | `null` | no |
227234
| <a name="input_logging"></a> [logging](#input\_logging) | Map containing access bucket logging configuration. | `any` | `{}` | no |
228235
| <a name="input_metric_configuration"></a> [metric\_configuration](#input\_metric\_configuration) | Map containing bucket metric configuration. | `any` | `[]` | no |
229236
| <a name="input_object_lock_configuration"></a> [object\_lock\_configuration](#input\_object\_lock\_configuration) | Map containing S3 object locking configuration. | `any` | `{}` | no |
@@ -238,6 +245,7 @@ No modules.
238245
| <a name="input_server_side_encryption_configuration"></a> [server\_side\_encryption\_configuration](#input\_server\_side\_encryption\_configuration) | Map containing server-side encryption configuration. | `any` | `{}` | no |
239246
| <a name="input_tags"></a> [tags](#input\_tags) | (Optional) A mapping of tags to assign to the bucket. | `map(string)` | `{}` | no |
240247
| <a name="input_transition_default_minimum_object_size"></a> [transition\_default\_minimum\_object\_size](#input\_transition\_default\_minimum\_object\_size) | The default minimum object size behavior applied to the lifecycle configuration. Valid values: all\_storage\_classes\_128K (default), varies\_by\_storage\_class | `string` | `null` | no |
248+
| <a name="input_type"></a> [type](#input\_type) | Bucket type. Valid values: `Directory` | `string` | `"Directory"` | no |
241249
| <a name="input_versioning"></a> [versioning](#input\_versioning) | Map containing versioning configuration. | `map(string)` | `{}` | no |
242250
| <a name="input_website"></a> [website](#input\_website) | Map containing static web-site hosting or redirect configuration. | `any` | `{}` | no |
243251

@@ -255,6 +263,8 @@ No modules.
255263
| <a name="output_s3_bucket_region"></a> [s3\_bucket\_region](#output\_s3\_bucket\_region) | The AWS region this bucket resides in. |
256264
| <a name="output_s3_bucket_website_domain"></a> [s3\_bucket\_website\_domain](#output\_s3\_bucket\_website\_domain) | The domain of the website endpoint, if the bucket is configured with a website. If not, this will be an empty string. This is used to create Route 53 alias records. |
257265
| <a name="output_s3_bucket_website_endpoint"></a> [s3\_bucket\_website\_endpoint](#output\_s3\_bucket\_website\_endpoint) | The website endpoint, if the bucket is configured with a website. If not, this will be an empty string. |
266+
| <a name="output_s3_directory_bucket_arn"></a> [s3\_directory\_bucket\_arn](#output\_s3\_directory\_bucket\_arn) | ARN of the directory bucket. |
267+
| <a name="output_s3_directory_bucket_name"></a> [s3\_directory\_bucket\_name](#output\_s3\_directory\_bucket\_name) | Name of the directory bucket. |
258268
<!-- END_TF_DOCS -->
259269

260270
## Authors

examples/complete/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ Note that this example may create resources which cost money. Run `terraform des
3030
| Name | Version |
3131
|------|---------|
3232
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
33-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.70 |
33+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.83 |
3434
| <a name="requirement_random"></a> [random](#requirement\_random) | >= 2.0 |
3535

3636
## Providers
3737

3838
| Name | Version |
3939
|------|---------|
40-
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.70 |
40+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.83 |
4141
| <a name="provider_random"></a> [random](#provider\_random) | >= 2.0 |
4242

4343
## Modules

examples/complete/versions.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ terraform {
44
required_providers {
55
aws = {
66
source = "hashicorp/aws"
7-
version = ">= 5.70"
7+
version = ">= 5.83"
88
}
99
random = {
1010
source = "hashicorp/random"

examples/directory-bucket/README.md

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# S3 directory bucket
2+
3+
Configuration in this directory creates S3 directory bucket and related resources.
4+
5+
## Usage
6+
7+
To run this example you need to execute:
8+
9+
```bash
10+
$ terraform init
11+
$ terraform plan
12+
$ terraform apply
13+
```
14+
15+
Note that this example may create resources which cost money. Run `terraform destroy` when you don't need these resources.
16+
17+
<!-- BEGIN_TF_DOCS -->
18+
## Requirements
19+
20+
| Name | Version |
21+
|------|---------|
22+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
23+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.83 |
24+
| <a name="requirement_random"></a> [random](#requirement\_random) | >= 2.0 |
25+
26+
## Providers
27+
28+
| Name | Version |
29+
|------|---------|
30+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.83 |
31+
| <a name="provider_random"></a> [random](#provider\_random) | >= 2.0 |
32+
33+
## Modules
34+
35+
| Name | Source | Version |
36+
|------|--------|---------|
37+
| <a name="module_complete"></a> [complete](#module\_complete) | ../../ | n/a |
38+
| <a name="module_simple"></a> [simple](#module\_simple) | ../../ | n/a |
39+
40+
## Resources
41+
42+
| Name | Type |
43+
|------|------|
44+
| [aws_kms_key.objects](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/kms_key) | resource |
45+
| [random_pet.this](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/pet) | resource |
46+
| [aws_availability_zones.available](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/availability_zones) | data source |
47+
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
48+
| [aws_iam_policy_document.bucket_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
49+
50+
## Inputs
51+
52+
No inputs.
53+
54+
## Outputs
55+
56+
| Name | Description |
57+
|------|-------------|
58+
| <a name="output_directory_bucket_arn"></a> [directory\_bucket\_arn](#output\_directory\_bucket\_arn) | ARN of the directory bucket. |
59+
| <a name="output_directory_bucket_name"></a> [directory\_bucket\_name](#output\_directory\_bucket\_name) | Name of the directory bucket. |
60+
<!-- END_TF_DOCS -->

examples/directory-bucket/main.tf

+127
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
locals {
2+
region = "eu-west-1"
3+
}
4+
5+
provider "aws" {
6+
region = local.region
7+
8+
# Make it faster by skipping something
9+
skip_metadata_api_check = true
10+
skip_region_validation = true
11+
skip_credentials_validation = true
12+
}
13+
14+
data "aws_caller_identity" "current" {}
15+
16+
data "aws_availability_zones" "available" {
17+
state = "available"
18+
}
19+
20+
module "simple" {
21+
source = "../../"
22+
23+
is_directory_bucket = true
24+
bucket = random_pet.this.id
25+
# https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-express-Endpoints.html
26+
availability_zone_id = data.aws_availability_zones.available.zone_ids[1]
27+
}
28+
29+
module "complete" {
30+
source = "../../"
31+
32+
is_directory_bucket = true
33+
bucket = "${random_pet.this.id}-complete"
34+
# https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-express-Endpoints.html
35+
availability_zone_id = data.aws_availability_zones.available.zone_ids[1]
36+
server_side_encryption_configuration = {
37+
rule = {
38+
bucket_key_enabled = true # required for directory buckets
39+
apply_server_side_encryption_by_default = {
40+
kms_master_key_id = aws_kms_key.objects.arn
41+
sse_algorithm = "aws:kms"
42+
}
43+
}
44+
}
45+
lifecycle_rule = [
46+
{
47+
id = "test"
48+
status = "Enabled"
49+
expiration = {
50+
days = 7
51+
}
52+
},
53+
{
54+
id = "logs"
55+
status = "Enabled"
56+
expiration = {
57+
days = 5
58+
}
59+
filter = {
60+
prefix = "logs/"
61+
object_size_less_than = 10
62+
}
63+
},
64+
{
65+
id = "other"
66+
status = "Enabled"
67+
expiration = {
68+
days = 2
69+
}
70+
filter = {
71+
prefix = "other/"
72+
}
73+
}
74+
]
75+
attach_policy = true
76+
policy = data.aws_iam_policy_document.bucket_policy.json
77+
}
78+
79+
resource "random_pet" "this" {
80+
length = 2
81+
}
82+
83+
resource "aws_kms_key" "objects" {
84+
description = "KMS key is used to encrypt bucket objects"
85+
deletion_window_in_days = 7
86+
}
87+
88+
data "aws_iam_policy_document" "bucket_policy" {
89+
90+
statement {
91+
sid = "ReadWriteAccess"
92+
effect = "Allow"
93+
94+
actions = [
95+
"s3express:CreateSession",
96+
]
97+
98+
resources = [module.complete.s3_directory_bucket_arn]
99+
100+
principals {
101+
identifiers = [data.aws_caller_identity.current.account_id]
102+
type = "AWS"
103+
}
104+
}
105+
106+
statement {
107+
sid = "ReadOnlyAccess"
108+
effect = "Allow"
109+
110+
actions = [
111+
"s3express:CreateSession",
112+
]
113+
114+
resources = [module.complete.s3_directory_bucket_arn]
115+
116+
principals {
117+
identifiers = [data.aws_caller_identity.current.account_id]
118+
type = "AWS"
119+
}
120+
121+
condition {
122+
test = "StringEquals"
123+
values = ["ReadOnly"]
124+
variable = "s3express:SessionMode"
125+
}
126+
}
127+
}

examples/directory-bucket/outputs.tf

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
output "directory_bucket_name" {
2+
description = "Name of the directory bucket."
3+
value = module.complete.s3_directory_bucket_name
4+
}
5+
6+
output "directory_bucket_arn" {
7+
description = "ARN of the directory bucket."
8+
value = module.complete.s3_directory_bucket_arn
9+
}

examples/directory-bucket/variables.tf

Whitespace-only changes.

examples/directory-bucket/versions.tf

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
terraform {
2+
required_version = ">= 1.0"
3+
4+
required_providers {
5+
aws = {
6+
source = "hashicorp/aws"
7+
version = ">= 5.83"
8+
}
9+
random = {
10+
source = "hashicorp/random"
11+
version = ">= 2.0"
12+
}
13+
}
14+
}

examples/notification/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ Note that this example may create resources which cost money. Run `terraform des
2020
| Name | Version |
2121
|------|---------|
2222
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
23-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.70 |
23+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.83 |
2424
| <a name="requirement_null"></a> [null](#requirement\_null) | >= 2.0 |
2525
| <a name="requirement_random"></a> [random](#requirement\_random) | >= 2.0 |
2626

2727
## Providers
2828

2929
| Name | Version |
3030
|------|---------|
31-
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.70 |
31+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.83 |
3232
| <a name="provider_null"></a> [null](#provider\_null) | >= 2.0 |
3333
| <a name="provider_random"></a> [random](#provider\_random) | >= 2.0 |
3434

examples/notification/versions.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ terraform {
44
required_providers {
55
aws = {
66
source = "hashicorp/aws"
7-
version = ">= 5.70"
7+
version = ">= 5.83"
88
}
99
random = {
1010
source = "hashicorp/random"

examples/object/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ Note that this example may create resources which cost money. Run `terraform des
2020
| Name | Version |
2121
|------|---------|
2222
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
23-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.70 |
23+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.83 |
2424
| <a name="requirement_random"></a> [random](#requirement\_random) | >= 2.0 |
2525

2626
## Providers
2727

2828
| Name | Version |
2929
|------|---------|
30-
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.70 |
30+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.83 |
3131
| <a name="provider_random"></a> [random](#provider\_random) | >= 2.0 |
3232

3333
## Modules

examples/object/versions.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ terraform {
44
required_providers {
55
aws = {
66
source = "hashicorp/aws"
7-
version = ">= 5.70"
7+
version = ">= 5.83"
88
}
99
random = {
1010
source = "hashicorp/random"

0 commit comments

Comments
 (0)