Skip to content

Commit ebe6f42

Browse files
authored
feat: add bucket_namespace argument (#291)
1 parent 3128637 commit ebe6f42

4 files changed

Lines changed: 21 additions & 12 deletions

File tree

README.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -200,29 +200,29 @@ module "s3_bucket" {
200200
## Requirements
201201

202202
| Name | Version |
203-
|------|---------|
203+
| ---- | ------- |
204204
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.0 |
205-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.9.0 |
205+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 6.37.0 |
206206
| <a name="requirement_time"></a> [time](#requirement\_time) | >= 0.7 |
207207

208208
## Providers
209209

210210
| Name | Version |
211-
|------|---------|
212-
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.9.0 |
211+
| ---- | ------- |
212+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 6.37.0 |
213213
| <a name="provider_time"></a> [time](#provider\_time) | >= 0.7 |
214214

215215
## Modules
216216

217217
| Name | Source | Version |
218-
|------|--------|---------|
218+
| ---- | ------ | ------- |
219219
| <a name="module_s3_user"></a> [s3\_user](#module\_s3\_user) | cloudposse/iam-s3-user/aws | 1.2.0 |
220220
| <a name="module_this"></a> [this](#module\_this) | cloudposse/label/null | 0.25.0 |
221221

222222
## Resources
223223

224224
| Name | Type |
225-
|------|------|
225+
| ---- | ---- |
226226
| [aws_iam_policy.replication](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource |
227227
| [aws_iam_role.replication](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
228228
| [aws_iam_role_policy_attachment.replication](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
@@ -256,7 +256,7 @@ module "s3_bucket" {
256256
## Inputs
257257

258258
| Name | Description | Type | Default | Required |
259-
|------|-------------|------|---------|:--------:|
259+
| ---- | ----------- | ---- | ------- | :------: |
260260
| <a name="input_access_key_enabled"></a> [access\_key\_enabled](#input\_access\_key\_enabled) | Set to `true` to create an IAM Access Key for the created IAM user | `bool` | `true` | no |
261261
| <a name="input_acl"></a> [acl](#input\_acl) | The [canned ACL](https://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#canned-acl) to apply.<br/>Deprecated by AWS in favor of bucket policies.<br/>Automatically disabled if `s3_object_ownership` is set to "BucketOwnerEnforced".<br/>Defaults to "private" for backwards compatibility, but we recommend setting `s3_object_ownership` to "BucketOwnerEnforced" instead. | `string` | `"private"` | no |
262262
| <a name="input_additional_tag_map"></a> [additional\_tag\_map](#input\_additional\_tag\_map) | Additional key-value pairs to add to each map in `tags_as_list_of_maps`. Not added to `tags` or `id`.<br/>This is for some rare cases where resources want additional configuration of tags<br/>and therefore take a list of maps with tag key, value, and additional configuration. | `map(string)` | `{}` | no |
@@ -270,6 +270,7 @@ module "s3_bucket" {
270270
| <a name="input_blocked_encryption_types"></a> [blocked\_encryption\_types](#input\_blocked\_encryption\_types) | List of encryption types to block on the bucket, passed to the `rule` block of<br/>`aws_s3_bucket_server_side_encryption_configuration`.<br/><br/>Defaults to `null` (attribute omitted) so the module remains compatible with `hashicorp/aws` provider<br/>versions older than 6.22.0, which do not know this field.<br/><br/>On provider >= 6.22.0, AWS's `GetBucketEncryption` returns `blocked_encryption_types = ["NONE"]` by default,<br/>which does not round-trip with an omitted/empty list and causes perpetual in-place diffs on<br/>`aws_s3_bucket_server_side_encryption_configuration`. To silence that drift, set this to `["NONE"]`. | `list(string)` | `null` | no |
271271
| <a name="input_bucket_key_enabled"></a> [bucket\_key\_enabled](#input\_bucket\_key\_enabled) | Set this to true to use Amazon S3 Bucket Keys for SSE-KMS, which may or may not reduce the number of AWS KMS requests.<br/>For more information, see: https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucket-key.html | `bool` | `false` | no |
272272
| <a name="input_bucket_name"></a> [bucket\_name](#input\_bucket\_name) | Bucket name. If provided, the bucket will be created with this name instead of generating the name from the context | `string` | `null` | no |
273+
| <a name="input_bucket_namespace"></a> [bucket\_namespace](#input\_bucket\_namespace) | Namespace for the bucket. Determines bucket naming scope. Valid values: account-regional, global. | `string` | `"global"` | no |
273274
| <a name="input_context"></a> [context](#input\_context) | Single object for setting entire context at once.<br/>See description of individual variables for details.<br/>Leave string and numeric variables as `null` to use default value.<br/>Individual variable settings (non-null) override settings in context object,<br/>except for attributes, tags, and additional\_tag\_map, which are merged. | `any` | <pre>{<br/> "additional_tag_map": {},<br/> "attributes": [],<br/> "delimiter": null,<br/> "descriptor_formats": {},<br/> "enabled": true,<br/> "environment": null,<br/> "id_length_limit": null,<br/> "label_key_case": null,<br/> "label_order": [],<br/> "label_value_case": null,<br/> "labels_as_tags": [<br/> "unset"<br/> ],<br/> "name": null,<br/> "namespace": null,<br/> "regex_replace_chars": null,<br/> "stage": null,<br/> "tags": {},<br/> "tenant": null<br/>}</pre> | no |
274275
| <a name="input_cors_configuration"></a> [cors\_configuration](#input\_cors\_configuration) | Specifies the allowed headers, methods, origins and exposed headers when using CORS on this bucket | <pre>list(object({<br/> id = optional(string)<br/> allowed_headers = optional(list(string))<br/> allowed_methods = optional(list(string))<br/> allowed_origins = optional(list(string))<br/> expose_headers = optional(list(string))<br/> max_age_seconds = optional(number)<br/> }))</pre> | `[]` | no |
275276
| <a name="input_create_s3_directory_bucket"></a> [create\_s3\_directory\_bucket](#input\_create\_s3\_directory\_bucket) | Control the creation of the S3 directory bucket. Set to true to create the bucket, false to skip. | `bool` | `false` | no |
@@ -327,7 +328,7 @@ module "s3_bucket" {
327328
## Outputs
328329

329330
| Name | Description |
330-
|------|-------------|
331+
| ---- | ----------- |
331332
| <a name="output_access_key_id"></a> [access\_key\_id](#output\_access\_key\_id) | The access key ID, if `var.user_enabled && var.access_key_enabled`.<br/>While sensitive, it does not need to be kept secret, so this is output regardless of `var.store_access_key_in_ssm`. |
332333
| <a name="output_access_key_id_ssm_path"></a> [access\_key\_id\_ssm\_path](#output\_access\_key\_id\_ssm\_path) | The SSM Path under which the S3 User's access key ID is stored |
333334
| <a name="output_bucket_arn"></a> [bucket\_arn](#output\_bucket\_arn) | Bucket ARN |

main.tf

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@ data "aws_partition" "current" { count = local.enabled ? 1 : 0 }
3232
data "aws_canonical_user_id" "default" { count = local.enabled ? 1 : 0 }
3333

3434
resource "aws_s3_bucket" "default" {
35-
count = local.enabled ? 1 : 0
36-
bucket = local.bucket_name
37-
force_destroy = var.force_destroy
35+
count = local.enabled ? 1 : 0
36+
bucket = local.bucket_name
37+
bucket_namespace = var.bucket_namespace
38+
force_destroy = var.force_destroy
3839

3940
object_lock_enabled = local.object_lock_enabled
4041

variables.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,13 @@ variable "bucket_name" {
342342
description = "Bucket name. If provided, the bucket will be created with this name instead of generating the name from the context"
343343
}
344344

345+
variable "bucket_namespace" {
346+
type = string
347+
default = "global"
348+
description = "Namespace for the bucket. Determines bucket naming scope. Valid values: account-regional, global."
349+
}
350+
351+
345352
variable "object_lock_configuration" {
346353
type = object({
347354
mode = string # Valid values are GOVERNANCE and COMPLIANCE.

versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ terraform {
44
required_providers {
55
aws = {
66
source = "hashicorp/aws"
7-
version = ">= 4.9.0"
7+
version = ">= 6.37.0"
88
}
99
time = {
1010
source = "hashicorp/time"

0 commit comments

Comments
 (0)