diff --git a/aws/dynamodb/dynamo.tf b/aws/dynamodb/dynamo.tf index 569b288f5..d141f7545 100644 --- a/aws/dynamodb/dynamo.tf +++ b/aws/dynamodb/dynamo.tf @@ -48,6 +48,11 @@ resource "aws_dynamodb_table" "vault" { type = "S" } + attribute { + name = "Status#CreatedAt" + type = "S" + } + global_secondary_index { name = "Status" hash_key = "FormID" @@ -55,6 +60,14 @@ resource "aws_dynamodb_table" "vault" { projection_type = "ALL" } + global_secondary_index { + name = "StatusCreatedAt" + hash_key = "FormID" + range_key = "Status#CreatedAt" + projection_type = "INCLUDE" + non_key_attributes = ["CreatedAt", "Name"] + } + server_side_encryption { enabled = true kms_key_arn = var.kms_key_dynamodb_arn diff --git a/lambda-code/reliability/lib/dataLayer.ts b/lambda-code/reliability/lib/dataLayer.ts index c483a5583..c64011639 100644 --- a/lambda-code/reliability/lib/dataLayer.ts +++ b/lambda-code/reliability/lib/dataLayer.ts @@ -124,6 +124,7 @@ export async function saveToVault( CreatedAt: Number(createdAt), SecurityAttribute: securityAttribute, Status: "New", + "Status#CreatedAt": `New#${Number(createdAt)}`, ConfirmationCode: confirmationCode, Name: name, FormSubmissionHash: formSubmissionHash, diff --git a/localstack_migration.sh b/localstack_migration.sh deleted file mode 100755 index b9b574831..000000000 --- a/localstack_migration.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/bash - -export TF_VAR_cognito_client_id="" -export TF_VAR_cognito_endpoint_url="" -export TF_VAR_cognito_user_pool_arn="" -export TF_VAR_email_address_contact_us="" -export TF_VAR_email_address_support="" -export APP_ENV="local" - - -color='\033[1;95m' -reset='\033[0m' # No Color -# Set proper terraform and terragrunt versions - -tgswitch 0.63.2 -tfswitch 1.9.2 - -ACTION=$1 -DRY_RUN="-dry-run" - -if [[ "$ACTION" == "for_real" ]]; then - DRY_RUN="" -fi - -basedir=$(pwd) - -cd $basedir/env/cloud/app -printf "${color}=> Removing S3 buckets from state${reset}\n" -s3Buckets=( - aws_s3_bucket.archive_storage - aws_s3_bucket.lambda_code - aws_s3_bucket.reliability_file_storage - aws_s3_bucket.vault_file_storage -) - -for i in "${s3Buckets[@]}" -do - terragrunt state rm $DRY_RUN $i -done - -printf "${color}=> Removing Cloudwatch logs from state${reset}\n" - -cloudwatchLogs=( - aws_cloudwatch_log_group.reliability - aws_cloudwatch_log_group.submission - aws_cloudwatch_log_group.archiver - aws_cloudwatch_log_group.dead_letter_queue_consumer - aws_cloudwatch_log_group.archive_form_templates - aws_cloudwatch_log_group.audit_logs - aws_cloudwatch_log_group.nagware - aws_cloudwatch_log_group.vault_data_integrity_check -) - -for i in "${cloudwatchLogs[@]}" -do - terragrunt state rm $DRY_RUN $i -done \ No newline at end of file