Skip to content

Commit

Permalink
Allow for transfering data from legacay dynamo tables
Browse files Browse the repository at this point in the history
  • Loading branch information
BenGalewsky committed Dec 21, 2023
1 parent 94392c9 commit fbf1993
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 6 deletions.
3 changes: 3 additions & 0 deletions infra/mdf/dev/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand All @@ -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" {
Expand Down
8 changes: 3 additions & 5 deletions infra/mdf/modules/dynamo/main.tf
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -21,8 +22,5 @@ resource "aws_dynamodb_table" "dynamodb-table" {
enabled = false
}

tags = {
Name = var.namespace
Environment = var.env
}
tags = var.resource_tags
}
10 changes: 10 additions & 0 deletions infra/mdf/modules/dynamo/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}
5 changes: 4 additions & 1 deletion infra/mdf/modules/permissions/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
]
},
],
})
Expand Down
5 changes: 5 additions & 0 deletions infra/mdf/modules/permissions/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
2 changes: 2 additions & 0 deletions infra/mdf/prod/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ module "dynamodb" {
env = var.env
namespace = var.namespace
env_vars = var.env_vars
resource_tags = var.resource_tags
}

module "permissions" {
Expand All @@ -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" {
Expand Down

0 comments on commit fbf1993

Please sign in to comment.