Skip to content

Commit c236b34

Browse files
feat: Allow a more flexible module extension
* Allow using conditionals when extending the module to pass configuration * Applies to the inventory, the logging and the replication * Solves issue 297
1 parent c686a8b commit c236b34

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ resource "aws_s3_directory_bucket" "this" {
7474
}
7575

7676
resource "aws_s3_bucket_logging" "this" {
77-
count = local.create_bucket && length(keys(var.logging)) > 0 && !var.is_directory_bucket ? 1 : 0
77+
count = local.create_bucket && var.logging != null && length(keys(var.logging)) > 0 && !var.is_directory_bucket ? 1 : 0
7878

7979
region = var.region
8080

@@ -433,7 +433,7 @@ resource "aws_s3_bucket_object_lock_configuration" "this" {
433433
}
434434

435435
resource "aws_s3_bucket_replication_configuration" "this" {
436-
count = local.create_bucket && length(keys(var.replication_configuration)) > 0 && !var.is_directory_bucket ? 1 : 0
436+
count = local.create_bucket && var.replication_configuration != null && length(keys(var.replication_configuration)) > 0 && !var.is_directory_bucket ? 1 : 0
437437

438438
region = var.region
439439

@@ -1240,7 +1240,7 @@ resource "aws_s3_bucket_metric" "this" {
12401240
}
12411241

12421242
resource "aws_s3_bucket_inventory" "this" {
1243-
for_each = { for k, v in var.inventory_configuration : k => v if local.create_bucket && !var.is_directory_bucket }
1243+
for_each = local.create_bucket && !var.is_directory_bucket && var.inventory_configuration != null && length(keys(var.inventory_configuration)) > 0 ? var.inventory_configuration : {}
12441244

12451245
region = var.region
12461246

0 commit comments

Comments
 (0)