Skip to content

Commit b37b7c9

Browse files
authored
feat: Added region variable to object and table-bucket submodules (#344)
1 parent c5243c9 commit b37b7c9

File tree

8 files changed

+26
-0
lines changed

8 files changed

+26
-0
lines changed

modules/object/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ No modules.
5151
| <a name="input_object_lock_mode"></a> [object\_lock\_mode](#input\_object\_lock\_mode) | The object lock retention mode that you want to apply to this object. Valid values are GOVERNANCE and COMPLIANCE. | `string` | `null` | no |
5252
| <a name="input_object_lock_retain_until_date"></a> [object\_lock\_retain\_until\_date](#input\_object\_lock\_retain\_until\_date) | The date and time, in RFC3339 format, when this object's object lock will expire. | `string` | `null` | no |
5353
| <a name="input_override_default_tags"></a> [override\_default\_tags](#input\_override\_default\_tags) | Ignore provider default\_tags. S3 objects support a maximum of 10 tags. | `bool` | `false` | no |
54+
| <a name="input_region"></a> [region](#input\_region) | Region where the resource(s) will be managed. Defaults to the region set in the provider configuration | `string` | `null` | no |
5455
| <a name="input_server_side_encryption"></a> [server\_side\_encryption](#input\_server\_side\_encryption) | Specifies server-side encryption of the object in S3. Valid values are "AES256" and "aws:kms". | `string` | `null` | no |
5556
| <a name="input_source_hash"></a> [source\_hash](#input\_source\_hash) | Triggers updates like etag but useful to address etag encryption limitations. Set using filemd5("path/to/source") (Terraform 0.11.12 or later). (The value is only stored in state and not saved by AWS.) | `string` | `null` | no |
5657
| <a name="input_storage_class"></a> [storage\_class](#input\_storage\_class) | Specifies the desired Storage Class for the object. Can be either STANDARD, REDUCED\_REDUNDANCY, ONEZONE\_IA, INTELLIGENT\_TIERING, GLACIER, DEEP\_ARCHIVE, or STANDARD\_IA. Defaults to STANDARD. | `string` | `null` | no |

modules/object/main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
resource "aws_s3_object" "this" {
22
count = var.create ? 1 : 0
33

4+
region = var.region
5+
46
bucket = var.bucket
57
key = var.key
68
force_destroy = var.force_destroy

modules/object/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ variable "create" {
44
default = true
55
}
66

7+
variable "region" {
8+
description = "Region where the resource(s) will be managed. Defaults to the region set in the provider configuration"
9+
type = string
10+
default = null
11+
}
12+
713
variable "bucket" {
814
description = "The name of the bucket to put the file in. Alternatively, an S3 access point ARN can be specified."
915
type = string

modules/table-bucket/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ No modules.
3939
| <a name="input_create_table_bucket_policy"></a> [create\_table\_bucket\_policy](#input\_create\_table\_bucket\_policy) | Whether to create s3 table bucket policy | `bool` | `false` | no |
4040
| <a name="input_encryption_configuration"></a> [encryption\_configuration](#input\_encryption\_configuration) | Map of encryption configurations | `any` | `null` | no |
4141
| <a name="input_maintenance_configuration"></a> [maintenance\_configuration](#input\_maintenance\_configuration) | Map of table bucket maintenance configurations | `any` | `null` | no |
42+
| <a name="input_region"></a> [region](#input\_region) | Region where the resource(s) will be managed. Defaults to the region set in the provider configuration | `string` | `null` | no |
4243
| <a name="input_table_bucket_name"></a> [table\_bucket\_name](#input\_table\_bucket\_name) | Name of the table bucket. Must be between 3 and 63 characters in length. Can consist of lowercase letters, numbers, and hyphens, and must begin and end with a lowercase letter or number | `string` | `null` | no |
4344
| <a name="input_table_bucket_override_policy_documents"></a> [table\_bucket\_override\_policy\_documents](#input\_table\_bucket\_override\_policy\_documents) | List of IAM policy documents that are merged together into the exported document. In merging, statements with non-blank `sid`s will override statements with the same `sid` | `list(string)` | `[]` | no |
4445
| <a name="input_table_bucket_policy"></a> [table\_bucket\_policy](#input\_table\_bucket\_policy) | Amazon Web Services resource-based policy document in JSON format | `string` | `null` | no |

modules/table-bucket/main.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
resource "aws_s3tables_table_bucket" "this" {
22
count = var.create ? 1 : 0
33

4+
region = var.region
5+
46
name = var.table_bucket_name
57
encryption_configuration = var.encryption_configuration
68
maintenance_configuration = var.maintenance_configuration
@@ -9,6 +11,8 @@ resource "aws_s3tables_table_bucket" "this" {
911
resource "aws_s3tables_table_bucket_policy" "this" {
1012
count = var.create && var.create_table_bucket_policy ? 1 : 0
1113

14+
region = var.region
15+
1216
resource_policy = var.table_bucket_policy != null ? var.table_bucket_policy : data.aws_iam_policy_document.table_bucket_policy[0].json
1317
table_bucket_arn = aws_s3tables_table_bucket.this[0].arn
1418
}
@@ -64,6 +68,8 @@ data "aws_iam_policy_document" "table_bucket_policy" {
6468
resource "aws_s3tables_table" "this" {
6569
for_each = { for k, v in var.tables : k => v if var.create }
6670

71+
region = var.region
72+
6773
format = each.value.format
6874
name = try(each.value.table_name, each.key)
6975
namespace = each.value.namespace
@@ -75,6 +81,8 @@ resource "aws_s3tables_table" "this" {
7581
resource "aws_s3tables_table_policy" "this" {
7682
for_each = { for k, v in var.tables : k => v if var.create && try(v.create_table_policy, false) }
7783

84+
region = var.region
85+
7886
name = aws_s3tables_table.this[each.key].name
7987
namespace = each.value.namespace
8088
resource_policy = data.aws_iam_policy_document.table_policy[each.key].json

modules/table-bucket/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ variable "create" {
44
default = true
55
}
66

7+
variable "region" {
8+
description = "Region where the resource(s) will be managed. Defaults to the region set in the provider configuration"
9+
type = string
10+
default = null
11+
}
12+
713
variable "table_bucket_name" {
814
description = "Name of the table bucket. Must be between 3 and 63 characters in length. Can consist of lowercase letters, numbers, and hyphens, and must begin and end with a lowercase letter or number"
915
type = string

wrappers/object/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ module "wrapper" {
2424
object_lock_mode = try(each.value.object_lock_mode, var.defaults.object_lock_mode, null)
2525
object_lock_retain_until_date = try(each.value.object_lock_retain_until_date, var.defaults.object_lock_retain_until_date, null)
2626
override_default_tags = try(each.value.override_default_tags, var.defaults.override_default_tags, false)
27+
region = try(each.value.region, var.defaults.region, null)
2728
server_side_encryption = try(each.value.server_side_encryption, var.defaults.server_side_encryption, null)
2829
source_hash = try(each.value.source_hash, var.defaults.source_hash, null)
2930
storage_class = try(each.value.storage_class, var.defaults.storage_class, null)

wrappers/table-bucket/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module "wrapper" {
77
create_table_bucket_policy = try(each.value.create_table_bucket_policy, var.defaults.create_table_bucket_policy, false)
88
encryption_configuration = try(each.value.encryption_configuration, var.defaults.encryption_configuration, null)
99
maintenance_configuration = try(each.value.maintenance_configuration, var.defaults.maintenance_configuration, null)
10+
region = try(each.value.region, var.defaults.region, null)
1011
table_bucket_name = try(each.value.table_bucket_name, var.defaults.table_bucket_name, null)
1112
table_bucket_override_policy_documents = try(each.value.table_bucket_override_policy_documents, var.defaults.table_bucket_override_policy_documents, [])
1213
table_bucket_policy = try(each.value.table_bucket_policy, var.defaults.table_bucket_policy, null)

0 commit comments

Comments
 (0)