diff --git a/README.md b/README.md index 909eb7f..91b6d99 100644 --- a/README.md +++ b/README.md @@ -305,6 +305,7 @@ Available targets: | [stage](#input\_stage) | ID element. Usually used to indicate role, e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release' | `string` | `null` | no | | [stream\_view\_type](#input\_stream\_view\_type) | When an item in the table is modified, what information is written to the stream | `string` | `""` | no | | [tags](#input\_tags) | Additional tags (e.g. `{'BusinessUnit': 'XYZ'}`).
Neither the tag keys nor the tag values will be modified by this module. | `map(string)` | `{}` | no | +| [tags\_enabled](#input\_tags\_enabled) | Set to `false` to disable tagging. This can be helpful if you're managing tables on dynamodb-local with terraform as it doesn't support tagging. | `bool` | `true` | no | | [tenant](#input\_tenant) | ID element \_(Rarely used, not included by default)\_. A customer identifier, indicating who this instance of a resource is for | `string` | `null` | no | | [ttl\_attribute](#input\_ttl\_attribute) | DynamoDB table TTL attribute | `string` | `"Expires"` | no | | [ttl\_enabled](#input\_ttl\_enabled) | Set to false to disable DynamoDB table TTL | `bool` | `true` | no | diff --git a/docs/terraform.md b/docs/terraform.md index 9329927..21bdc0d 100644 --- a/docs/terraform.md +++ b/docs/terraform.md @@ -73,6 +73,7 @@ | [stage](#input\_stage) | ID element. Usually used to indicate role, e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release' | `string` | `null` | no | | [stream\_view\_type](#input\_stream\_view\_type) | When an item in the table is modified, what information is written to the stream | `string` | `""` | no | | [tags](#input\_tags) | Additional tags (e.g. `{'BusinessUnit': 'XYZ'}`).
Neither the tag keys nor the tag values will be modified by this module. | `map(string)` | `{}` | no | +| [tags\_enabled](#input\_tags\_enabled) | Set to `false` to disable tagging. This can be helpful if you're managing tables on dynamodb-local with terraform as it doesn't support tagging. | `bool` | `true` | no | | [tenant](#input\_tenant) | ID element \_(Rarely used, not included by default)\_. A customer identifier, indicating who this instance of a resource is for | `string` | `null` | no | | [ttl\_attribute](#input\_ttl\_attribute) | DynamoDB table TTL attribute | `string` | `"Expires"` | no | | [ttl\_enabled](#input\_ttl\_enabled) | Set to false to disable DynamoDB table TTL | `bool` | `true` | no | diff --git a/main.tf b/main.tf index fbf31bc..df266f4 100644 --- a/main.tf +++ b/main.tf @@ -117,7 +117,7 @@ resource "aws_dynamodb_table" "default" { } } - tags = module.this.tags + tags = var.tags_enabled ? module.this.tags : null } module "dynamodb_autoscaler" { @@ -126,7 +126,7 @@ module "dynamodb_autoscaler" { enabled = local.enabled && var.enable_autoscaler && var.billing_mode == "PROVISIONED" attributes = concat(module.this.attributes, var.autoscaler_attributes) - tags = merge(module.this.tags, var.autoscaler_tags) + tags = var.tags_enabled ? merge(module.this.tags, var.autoscaler_tags) : null dynamodb_table_name = join("", aws_dynamodb_table.default.*.id) dynamodb_table_arn = join("", aws_dynamodb_table.default.*.arn) dynamodb_indexes = null_resource.global_secondary_index_names.*.triggers.name diff --git a/variables.tf b/variables.tf index f186a5d..b85355f 100644 --- a/variables.tf +++ b/variables.tf @@ -162,3 +162,9 @@ variable "replicas" { default = [] description = "List of regions to create replica" } + +variable "tags_enabled" { + type = bool + default = true + description = "Set to `false` to disable tagging. This can be helpful if you're managing tables on dynamodb-local with terraform as it doesn't support tagging." +}