From d82392794a7602fb7132f2d1a498ec0b5c95f7b9 Mon Sep 17 00:00:00 2001 From: Adam Cooper Date: Thu, 14 Dec 2023 11:10:01 +0000 Subject: [PATCH] Add identity index to DynamoDB (#2459) --- service-api/docker/seeding/start.sh | 2 +- terraform/environment/dynamodb.tf | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/service-api/docker/seeding/start.sh b/service-api/docker/seeding/start.sh index d299d42031..c092b30b1a 100755 --- a/service-api/docker/seeding/start.sh +++ b/service-api/docker/seeding/start.sh @@ -25,13 +25,13 @@ if ! [[ -z "${AWS_ENDPOINT_DYNAMODB}" ]]; then --region eu-west-1 \ --endpoint $DYNAMODN_ENDPOINT \ --global-secondary-indexes \ + IndexName=IdentityIndex,KeySchema=["{AttributeName=Identity,KeyType=HASH}"],Projection="{ProjectionType=ALL}",ProvisionedThroughput="{ReadCapacityUnits=10,WriteCapacityUnits=10}" \ IndexName=EmailIndex,KeySchema=["{AttributeName=Email,KeyType=HASH}"],Projection="{ProjectionType=ALL}",ProvisionedThroughput="{ReadCapacityUnits=10,WriteCapacityUnits=10}" \ IndexName=NewEmailIndex,KeySchema=["{AttributeName=NewEmail,KeyType=HASH}"],Projection="{ProjectionType=ALL}",ProvisionedThroughput="{ReadCapacityUnits=10,WriteCapacityUnits=10}" \ IndexName=ActivationTokenIndex,KeySchema=["{AttributeName=ActivationToken,KeyType=HASH}"],Projection="{ProjectionType=KEYS_ONLY}",ProvisionedThroughput="{ReadCapacityUnits=10,WriteCapacityUnits=10}" \ IndexName=PasswordResetTokenIndex,KeySchema=["{AttributeName=PasswordResetToken,KeyType=HASH}"],Projection="{ProjectionType=KEYS_ONLY}",ProvisionedThroughput="{ReadCapacityUnits=10,WriteCapacityUnits=10}"\ IndexName=EmailResetTokenIndex,KeySchema=["{AttributeName=EmailResetToken,KeyType=HASH}"],Projection="{ProjectionType=KEYS_ONLY}",ProvisionedThroughput="{ReadCapacityUnits=10,WriteCapacityUnits=10}" - aws dynamodb update-time-to-live \ --table-name ActorUsers \ --region eu-west-1 \ diff --git a/terraform/environment/dynamodb.tf b/terraform/environment/dynamodb.tf index 1af40e444b..53f88a208f 100644 --- a/terraform/environment/dynamodb.tf +++ b/terraform/environment/dynamodb.tf @@ -92,6 +92,10 @@ resource "aws_dynamodb_table" "actor_users_table" { name = "Id" type = "S" } + attribute { + name = "Identity" + type = "S" + } attribute { name = "Email" type = "S" @@ -113,6 +117,11 @@ resource "aws_dynamodb_table" "actor_users_table" { type = "S" } + global_secondary_index { + name = "IdentityIndex" + hash_key = "Identity" + projection_type = "ALL" + } global_secondary_index { name = "EmailIndex" hash_key = "Email"