diff --git a/README.md b/README.md index dc85be1..855eb08 100644 --- a/README.md +++ b/README.md @@ -268,6 +268,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 | | [table\_class](#input\_table\_class) | DynamoDB storage class of the table. Can be STANDARD or STANDARD\_INFREQUENT\_ACCESS | `string` | `"STANDARD"` | no | +| [table\_name](#input\_table\_name) | Table name. If provided, the bucket will be created with this name instead of generating the name from the context | `string` | `null` | 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 | diff --git a/docs/terraform.md b/docs/terraform.md index d7b2db8..3bbe162 100644 --- a/docs/terraform.md +++ b/docs/terraform.md @@ -75,6 +75,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 | | [table\_class](#input\_table\_class) | DynamoDB storage class of the table. Can be STANDARD or STANDARD\_INFREQUENT\_ACCESS | `string` | `"STANDARD"` | no | +| [table\_name](#input\_table\_name) | Table name. If provided, the bucket will be created with this name instead of generating the name from the context | `string` | `null` | 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 | diff --git a/main.tf b/main.tf index 7fcabe4..0fc0030 100644 --- a/main.tf +++ b/main.tf @@ -1,6 +1,8 @@ locals { enabled = module.this.enabled + table_name = var.table_name != null && var.table_name != "" ? var.table_name : module.this.id + attributes = concat( [ { @@ -45,7 +47,7 @@ resource "null_resource" "local_secondary_index_names" { resource "aws_dynamodb_table" "default" { count = local.enabled ? 1 : 0 - name = module.this.id + name = local.table_name billing_mode = var.billing_mode read_capacity = var.billing_mode == "PAY_PER_REQUEST" ? null : var.autoscale_min_read_capacity write_capacity = var.billing_mode == "PAY_PER_REQUEST" ? null : var.autoscale_min_write_capacity diff --git a/variables.tf b/variables.tf index 5ee1527..f8a57eb 100644 --- a/variables.tf +++ b/variables.tf @@ -123,6 +123,12 @@ variable "autoscaler_tags" { description = "Additional resource tags for the autoscaler module" } +variable "table_name" { + type = string + default = null + description = "Table name. If provided, the bucket will be created with this name instead of generating the name from the context" +} + variable "dynamodb_attributes" { type = list(object({ name = string