diff --git a/terraform/modules/dynamo/main.tf b/terraform/modules/dynamo/main.tf index 169b9621..59f6331c 100644 --- a/terraform/modules/dynamo/main.tf +++ b/terraform/modules/dynamo/main.tf @@ -358,3 +358,56 @@ resource "aws_dynamodb_table" "store_inventory" { type = "S" } } + +resource "aws_dynamodb_table" "store_carts_orders" { + billing_mode = "PAY_PER_REQUEST" + name = "${var.ProjectId}-store-carts-orders" + deletion_protection_enabled = true + hash_key = "orderId" + range_key = "lineItemId" + point_in_time_recovery { + enabled = true + } + attribute { + name = "orderId" + type = "S" + } + attribute { + name = "lineItemId" + type = "S" + } + attribute { + name = "itemId" + type = "S" + } + + attribute { + name = "createdAt" + type = "S" + } + global_secondary_index { + name = "ItemIdIndex" + hash_key = "itemId" + range_key = "createdAt" + projection_type = "ALL" + } +} + +resource "aws_dynamodb_table" "store_limits" { + billing_mode = "PAY_PER_REQUEST" + name = "${var.ProjectId}-store-limits" + deletion_protection_enabled = true + hash_key = "userId" + range_key = "limitId" + point_in_time_recovery { + enabled = true + } + attribute { + name = "userId" + type = "S" + } + attribute { + name = "limitId" + type = "S" + } +} diff --git a/terraform/modules/lambdas/main.tf b/terraform/modules/lambdas/main.tf index cca9c86f..8a6239e8 100644 --- a/terraform/modules/lambdas/main.tf +++ b/terraform/modules/lambdas/main.tf @@ -235,6 +235,12 @@ resource "aws_iam_policy" "shared_iam_policy" { "arn:aws:dynamodb:${data.aws_region.current.region}:${data.aws_caller_identity.current.account_id}:table/infra-core-api-keys", "arn:aws:dynamodb:${data.aws_region.current.region}:${data.aws_caller_identity.current.account_id}:table/infra-core-api-sigs", "arn:aws:dynamodb:${data.aws_region.current.region}:${data.aws_caller_identity.current.account_id}:table/infra-core-api-sigs/index/*", + + // added permissions for 3 new tables + "arn:aws:dynamodb:${data.aws_region.current.region}:${data.aws_caller_identity.current.account_id}:table/infra-core-api-store-inventory", + "arn:aws:dynamodb:${data.aws_region.current.region}:${data.aws_caller_identity.current.account_id}:table/infra-core-api-store-carts-orders", + "arn:aws:dynamodb:${data.aws_region.current.region}:${data.aws_caller_identity.current.account_id}:table/infra-core-api-store-carts-orders/index/*", + "arn:aws:dynamodb:${data.aws_region.current.region}:${data.aws_caller_identity.current.account_id}:table/infra-core-api-store-limits" ] }, { @@ -459,3 +465,4 @@ output "core_sqs_consumer_lambda_name" { value = local.core_sqs_consumer_lambda_name } +