Skip to content

Commit

Permalink
feat: allow overriding the dynamodb table name
Browse files Browse the repository at this point in the history
  • Loading branch information
nitrocode authored Apr 10, 2024
1 parent c23de8e commit 0d4a004
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
@@ -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(
[
{
Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0d4a004

Please sign in to comment.