From 0d4a0046de1133ca9563df1bb2792e543a52c355 Mon Sep 17 00:00:00 2001 From: nitrocode <7775707+nitrocode@users.noreply.github.com> Date: Wed, 10 Apr 2024 09:37:49 -0500 Subject: [PATCH] feat: allow overriding the dynamodb table name --- main.tf | 4 +++- variables.tf | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) 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