diff --git a/infra/mdf/dev/main.tf b/infra/mdf/dev/main.tf index 7b9825b..bf4906a 100644 --- a/infra/mdf/dev/main.tf +++ b/infra/mdf/dev/main.tf @@ -45,6 +45,8 @@ module "dynamodb" { env = var.env namespace = var.namespace env_vars = var.env_vars + resource_tags = var.resource_tags + dynamodb_write_capacity = 20 } module "permissions" { @@ -53,6 +55,7 @@ module "permissions" { namespace = var.namespace mdf_secrets_arn = var.mdf_secrets_arn dynamo_db_arn = module.dynamodb.dynamodb_arn + legacy_table_arn = "arn:aws:dynamodb:us-east-1:557062710055:table/dev-status-0.4" } module "api_gateway" { diff --git a/infra/mdf/modules/dynamo/main.tf b/infra/mdf/modules/dynamo/main.tf index 090eab3..29aef28 100644 --- a/infra/mdf/modules/dynamo/main.tf +++ b/infra/mdf/modules/dynamo/main.tf @@ -1,8 +1,9 @@ + resource "aws_dynamodb_table" "dynamodb-table" { name = "${var.namespace}-${var.env}" billing_mode = "PROVISIONED" read_capacity = 5 - write_capacity = 5 + write_capacity = var.dynamodb_write_capacity hash_key = "source_id" range_key = "version" attribute { @@ -21,8 +22,5 @@ resource "aws_dynamodb_table" "dynamodb-table" { enabled = false } - tags = { - Name = var.namespace - Environment = var.env - } + tags = var.resource_tags } diff --git a/infra/mdf/modules/dynamo/variables.tf b/infra/mdf/modules/dynamo/variables.tf index 9a3caab..92478ad 100644 --- a/infra/mdf/modules/dynamo/variables.tf +++ b/infra/mdf/modules/dynamo/variables.tf @@ -11,4 +11,14 @@ variable "namespace" { variable "env_vars" { description = "Set of environment variables for the functions." type = map(string) +} + +variable "resource_tags" { + description = "Tags to apply to all resources." + type = map(string) +} + +variable "dynamodb_write_capacity" { + type = number + description = "The write capacity for the DynamoDB table." } \ No newline at end of file diff --git a/infra/mdf/modules/permissions/main.tf b/infra/mdf/modules/permissions/main.tf index f40f0ea..9663ca2 100644 --- a/infra/mdf/modules/permissions/main.tf +++ b/infra/mdf/modules/permissions/main.tf @@ -75,7 +75,10 @@ resource "aws_iam_policy" "lambda_dynamodb_policy" { "dynamodb:Scan", ], Effect = "Allow", - Resource = [ var.dynamo_db_arn ] + Resource = [ + var.dynamo_db_arn, + var.legacy_table_arn + ] }, ], }) diff --git a/infra/mdf/modules/permissions/variables.tf b/infra/mdf/modules/permissions/variables.tf index b77a988..1e09a56 100644 --- a/infra/mdf/modules/permissions/variables.tf +++ b/infra/mdf/modules/permissions/variables.tf @@ -16,4 +16,9 @@ variable "mdf_secrets_arn" { variable "dynamo_db_arn" { type = string description = "ARN of the DynamoDB table" +} + +variable "legacy_table_arn" { + type = string + description = "ARN of the legacy DynamoDB table" } \ No newline at end of file diff --git a/infra/mdf/prod/main.tf b/infra/mdf/prod/main.tf index 384755c..c88a17e 100644 --- a/infra/mdf/prod/main.tf +++ b/infra/mdf/prod/main.tf @@ -44,6 +44,7 @@ module "dynamodb" { env = var.env namespace = var.namespace env_vars = var.env_vars + resource_tags = var.resource_tags } module "permissions" { @@ -52,6 +53,7 @@ module "permissions" { namespace = var.namespace mdf_secrets_arn = var.mdf_secrets_arn dynamo_db_arn = module.dynamodb.dynamodb_arn + legacy_table_arn = "arn:aws:dynamodb:us-east-1:557062710055:table/prod-status-alpha-1" } module "api_gateway" {