Skip to content

Commit a9e154f

Browse files
authored
[PRM-823] Remove document store references (#655)
Signed-off-by: NogaNHS <127490765+NogaNHS@users.noreply.github.com>
1 parent 55127ca commit a9e154f

22 files changed

Lines changed: 18 additions & 217 deletions

infrastructure/backup-cross-account.tf

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,7 @@ resource "aws_backup_selection" "cross_account_backup_selection" {
5353
plan_id = aws_backup_plan.cross_account_backup_schedule[0].id
5454

5555
resources = [
56-
module.ndr-document-store.bucket_arn,
5756
module.ndr-lloyd-george-store.bucket_arn,
58-
module.document_reference_dynamodb_table.dynamodb_table_arn,
5957
module.lloyd_george_reference_dynamodb_table.dynamodb_table_arn,
6058
module.bulk_upload_report_dynamodb_table.dynamodb_table_arn,
6159
module.statistical-reports-store.bucket_arn,

infrastructure/backups.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ resource "aws_backup_selection" "s3_continuous_backup" {
2424
plan_id = aws_backup_plan.s3_continuous_backup.id
2525

2626
resources = [
27-
module.ndr-document-store.bucket_arn,
2827
module.ndr-lloyd-george-store.bucket_arn,
2928
module.statistical-reports-store.bucket_arn,
3029
module.ndr-document-pending-review-store.bucket_arn

infrastructure/buckets.tf

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,6 @@ locals {
44
}
55

66
# Bucket Modules
7-
module "ndr-document-store" {
8-
source = "./modules/s3/"
9-
access_logs_enabled = local.is_production
10-
access_logs_bucket_id = local.access_logs_bucket_id
11-
bucket_name = var.docstore_bucket_name
12-
enable_cors_configuration = true
13-
enable_bucket_versioning = true
14-
environment = var.environment
15-
owner = var.owner
16-
force_destroy = local.is_force_destroy
17-
cors_rules = [
18-
{
19-
allowed_headers = ["*"]
20-
allowed_methods = ["POST", "PUT", "DELETE"]
21-
allowed_origins = [local.base_url]
22-
expose_headers = ["ETag"]
23-
max_age_seconds = 3000
24-
},
25-
{
26-
allowed_methods = ["GET"]
27-
allowed_origins = [local.base_url]
28-
}
29-
]
30-
}
31-
327
module "ndr-zip-request-store" {
338
source = "./modules/s3/"
349
access_logs_enabled = local.is_production
@@ -209,19 +184,6 @@ resource "aws_s3_bucket_lifecycle_configuration" "lg-lifecycle-rules" {
209184
}
210185
}
211186

212-
resource "aws_s3_bucket_lifecycle_configuration" "doc-store-lifecycle-rules" {
213-
bucket = module.ndr-document-store.bucket_id
214-
rule {
215-
id = "default-to-intelligent-tiering"
216-
status = "Enabled"
217-
transition {
218-
storage_class = "INTELLIGENT_TIERING"
219-
days = 0
220-
}
221-
filter {}
222-
}
223-
}
224-
225187
resource "aws_s3_bucket_lifecycle_configuration" "staging-store-lifecycle-rules" {
226188
bucket = module.ndr-bulk-staging-store.bucket_id
227189

infrastructure/dynamo_db.tf

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,3 @@
1-
module "document_reference_dynamodb_table" {
2-
source = "./modules/dynamo_db"
3-
table_name = var.docstore_dynamodb_table_name
4-
hash_key = "ID"
5-
deletion_protection_enabled = var.deletion_protection_enabled
6-
stream_view_type = "OLD_IMAGE"
7-
ttl_enabled = true
8-
ttl_attribute_name = "TTL"
9-
point_in_time_recovery_enabled = !local.is_sandbox
10-
11-
attributes = [
12-
{
13-
name = "ID"
14-
type = "S"
15-
},
16-
{
17-
name = "FileLocation"
18-
type = "S"
19-
},
20-
{
21-
name = "NhsNumber"
22-
type = "S"
23-
}
24-
]
25-
26-
global_secondary_indexes = [
27-
{
28-
name = "FileLocationsIndex"
29-
hash_key = "FileLocation"
30-
projection_type = "ALL"
31-
},
32-
{
33-
name = "NhsNumberIndex"
34-
hash_key = "NhsNumber"
35-
projection_type = "ALL"
36-
}
37-
]
38-
39-
environment = var.environment
40-
owner = var.owner
41-
}
421

432
module "cloudfront_edge_dynamodb_table" {
443
source = "./modules/dynamo_db"

infrastructure/ecs.tf

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,6 @@ module "ndr-ecs-fargate-data-collection" {
6565
"name" : "LLOYD_GEORGE_DYNAMODB_NAME",
6666
"value" : "${terraform.workspace}_${var.lloyd_george_dynamodb_table_name}"
6767
},
68-
{
69-
"name" : "DOCUMENT_STORE_BUCKET_NAME",
70-
"value" : "${terraform.workspace}-${var.docstore_bucket_name}"
71-
},
72-
{
73-
"name" : "DOCUMENT_STORE_DYNAMODB_NAME",
74-
"value" : "${terraform.workspace}_${var.docstore_dynamodb_table_name}"
75-
},
7668
{
7769
"name" : "STATISTICAL_REPORTS_BUCKET",
7870
"value" : "${terraform.workspace}-${var.statistical_reports_bucket_name}"
@@ -150,17 +142,6 @@ resource "aws_iam_role_policy_attachment" "data_collection_lloyd_george_store" {
150142
policy_arn = module.ndr-lloyd-george-store.s3_list_object_policy
151143
}
152144

153-
resource "aws_iam_role_policy_attachment" "data_collection_document_store" {
154-
count = local.is_sandbox ? 0 : 1
155-
role = aws_iam_role.data_collection_task_role[0].name
156-
policy_arn = module.ndr-document-store.s3_list_object_policy
157-
}
158-
159-
resource "aws_iam_role_policy_attachment" "data_collection_document_reference_dynamodb_table" {
160-
count = local.is_sandbox ? 0 : 1
161-
role = aws_iam_role.data_collection_task_role[0].name
162-
policy_arn = module.document_reference_dynamodb_table.dynamodb_policy
163-
}
164145

165146
resource "aws_iam_role_policy_attachment" "data_collection_cloudwatch_log_query_policy" {
166147
count = local.is_sandbox ? 0 : 1

infrastructure/iam.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ resource "aws_iam_policy" "s3_document_data_policy_put_only" {
99
"Action" : [
1010
"s3:PutObject",
1111
],
12-
"Resource" : ["${module.ndr-bulk-staging-store.bucket_arn}/*", "${module.ndr-document-store.bucket_arn}/*"]
12+
"Resource" : ["${module.ndr-bulk-staging-store.bucket_arn}/*"]
1313
}
1414
]
1515
})

infrastructure/lambda-create-doc-ref.tf

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,6 @@ module "create-doc-ref-lambda" {
4949
module.ndr-bulk-staging-store.s3_write_policy_document,
5050
module.ndr-lloyd-george-store.s3_write_policy_document,
5151
module.ndr-lloyd-george-store.s3_read_policy_document,
52-
module.ndr-document-store.s3_read_policy_document,
53-
module.ndr-document-store.s3_write_policy_document,
54-
module.document_reference_dynamodb_table.dynamodb_write_policy_document,
55-
module.document_reference_dynamodb_table.dynamodb_read_policy_document,
5652
module.stitch_metadata_reference_dynamodb_table.dynamodb_read_policy_document,
5753
module.stitch_metadata_reference_dynamodb_table.dynamodb_write_policy_document,
5854
module.lloyd_george_reference_dynamodb_table.dynamodb_write_policy_document,
@@ -67,8 +63,6 @@ module "create-doc-ref-lambda" {
6763
api_execution_arn = aws_api_gateway_rest_api.ndr_doc_store_api.execution_arn
6864
lambda_environment_variables = {
6965
STAGING_STORE_BUCKET_NAME = "${terraform.workspace}-${var.staging_store_bucket_name}"
70-
DOCUMENT_STORE_BUCKET_NAME = "${terraform.workspace}-${var.docstore_bucket_name}"
71-
DOCUMENT_STORE_DYNAMODB_NAME = "${terraform.workspace}_${var.docstore_dynamodb_table_name}"
7266
LLOYD_GEORGE_DYNAMODB_NAME = "${terraform.workspace}_${var.lloyd_george_dynamodb_table_name}"
7367
STITCH_METADATA_DYNAMODB_NAME = "${terraform.workspace}_${var.stitch_metadata_dynamodb_table_name}"
7468
PDS_FHIR_IS_STUBBED = local.is_sandbox,
@@ -78,12 +72,10 @@ module "create-doc-ref-lambda" {
7872
depends_on = [
7973
module.document_reference_gateway,
8074
aws_api_gateway_rest_api.ndr_doc_store_api,
81-
module.document_reference_dynamodb_table,
8275
module.lloyd_george_reference_dynamodb_table,
8376
module.ndr-bulk-staging-store,
8477
module.ndr-app-config,
8578
module.lloyd_george_reference_dynamodb_table,
86-
module.document_reference_dynamodb_table,
8779
module.stitch_metadata_reference_dynamodb_table
8880
]
8981
}

infrastructure/lambda-data-collection.tf

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,25 +52,19 @@ module "data-collection-lambda" {
5252
module.statistics_dynamodb_table.dynamodb_write_policy_document,
5353
module.ndr-lloyd-george-store.s3_read_policy_document,
5454
module.ndr-lloyd-george-store.s3_write_policy_document,
55-
module.ndr-document-store.s3_read_policy_document,
56-
module.ndr-document-store.s3_write_policy_document,
5755
module.lloyd_george_reference_dynamodb_table.dynamodb_read_policy_document,
5856
module.lloyd_george_reference_dynamodb_table.dynamodb_write_policy_document,
59-
module.document_reference_dynamodb_table.dynamodb_read_policy_document,
60-
module.document_reference_dynamodb_table.dynamodb_write_policy_document,
6157
aws_iam_policy.cloudwatch_log_query_policy.policy
6258
]
6359
kms_deletion_window = var.kms_deletion_window
6460
rest_api_id = null
6561
api_execution_arn = null
6662

6763
lambda_environment_variables = {
68-
LLOYD_GEORGE_BUCKET_NAME = "${terraform.workspace}-${var.lloyd_george_bucket_name}"
69-
LLOYD_GEORGE_DYNAMODB_NAME = "${terraform.workspace}_${var.lloyd_george_dynamodb_table_name}"
70-
DOCUMENT_STORE_BUCKET_NAME = "${terraform.workspace}-${var.docstore_bucket_name}"
71-
DOCUMENT_STORE_DYNAMODB_NAME = "${terraform.workspace}_${var.docstore_dynamodb_table_name}"
72-
WORKSPACE = terraform.workspace
73-
STATISTICS_TABLE = "${terraform.workspace}_${var.statistics_dynamodb_table_name}"
64+
LLOYD_GEORGE_BUCKET_NAME = "${terraform.workspace}-${var.lloyd_george_bucket_name}"
65+
LLOYD_GEORGE_DYNAMODB_NAME = "${terraform.workspace}_${var.lloyd_george_dynamodb_table_name}"
66+
WORKSPACE = terraform.workspace
67+
STATISTICS_TABLE = "${terraform.workspace}_${var.statistics_dynamodb_table_name}"
7468
}
7569
is_gateway_integration_needed = false
7670
is_invoked_from_gateway = false
@@ -79,8 +73,6 @@ module "data-collection-lambda" {
7973
module.ndr-app-config,
8074
module.statistics_dynamodb_table,
8175
module.lloyd_george_reference_dynamodb_table,
82-
module.document_reference_dynamodb_table,
83-
module.ndr-document-store,
8476
module.ndr-lloyd-george-store,
8577
aws_iam_policy.cloudwatch_log_query_policy
8678
]

infrastructure/lambda-delete-doc-object.tf

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,6 @@ module "delete-document-object-lambda" {
4343
handler = "handlers.delete_document_object_handler.lambda_handler"
4444
lambda_timeout = 900
4545
iam_role_policy_documents = [
46-
module.document_reference_dynamodb_table.dynamodb_read_policy_document,
47-
module.document_reference_dynamodb_table.dynamodb_write_policy_document,
48-
module.ndr-document-store.s3_read_policy_document,
49-
module.ndr-document-store.s3_write_policy_document,
5046
module.lloyd_george_reference_dynamodb_table.dynamodb_read_policy_document,
5147
module.lloyd_george_reference_dynamodb_table.dynamodb_write_policy_document,
5248
module.ndr-lloyd-george-store.s3_read_policy_document,
@@ -74,7 +70,6 @@ resource "aws_iam_policy" "dynamodb_stream_delete_object_policy" {
7470
Effect = "Allow"
7571
Resource = [
7672
module.lloyd_george_reference_dynamodb_table.dynamodb_stream_arn,
77-
module.document_reference_dynamodb_table.dynamodb_stream_arn,
7873
module.unstitched_lloyd_george_reference_dynamodb_table.dynamodb_stream_arn
7974
]
8075
},
@@ -124,23 +119,3 @@ resource "aws_lambda_event_source_mapping" "unstitched_lloyd_george_dynamodb_str
124119
}
125120
}
126121

127-
resource "aws_lambda_event_source_mapping" "document_reference_dynamodb_stream" {
128-
event_source_arn = module.document_reference_dynamodb_table.dynamodb_stream_arn
129-
function_name = module.delete-document-object-lambda.lambda_arn
130-
batch_size = 1
131-
starting_position = "LATEST"
132-
133-
filter_criteria {
134-
filter {
135-
pattern = jsonencode({
136-
"eventName" : [
137-
"REMOVE"
138-
],
139-
userIdentity = {
140-
type = ["Service"],
141-
principalId = ["dynamodb.amazonaws.com"]
142-
}
143-
})
144-
}
145-
}
146-
}

infrastructure/lambda-delete-doc-ref.tf

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,6 @@ module "delete-doc-ref-lambda" {
5656
name = "DeleteDocRefLambda"
5757
handler = "handlers.delete_document_reference_handler.lambda_handler"
5858
iam_role_policy_documents = [
59-
module.document_reference_dynamodb_table.dynamodb_read_policy_document,
60-
module.document_reference_dynamodb_table.dynamodb_write_policy_document,
61-
module.ndr-document-store.s3_read_policy_document,
62-
module.ndr-document-store.s3_write_policy_document,
6359
module.lloyd_george_reference_dynamodb_table.dynamodb_read_policy_document,
6460
module.lloyd_george_reference_dynamodb_table.dynamodb_write_policy_document,
6561
module.ndr-lloyd-george-store.s3_read_policy_document,
@@ -77,7 +73,6 @@ module "delete-doc-ref-lambda" {
7773
http_methods = ["DELETE"]
7874
api_execution_arn = aws_api_gateway_rest_api.ndr_doc_store_api.execution_arn
7975
lambda_environment_variables = {
80-
DOCUMENT_STORE_DYNAMODB_NAME = "${terraform.workspace}_${var.docstore_dynamodb_table_name}"
8176
LLOYD_GEORGE_DYNAMODB_NAME = "${terraform.workspace}_${var.lloyd_george_dynamodb_table_name}"
8277
STITCH_METADATA_DYNAMODB_NAME = "${terraform.workspace}_${var.stitch_metadata_dynamodb_table_name}"
8378
UNSTITCHED_LLOYD_GEORGE_DYNAMODB_NAME = "${terraform.workspace}_${var.unstitched_lloyd_george_dynamodb_table_name}"
@@ -86,7 +81,6 @@ module "delete-doc-ref-lambda" {
8681
}
8782
depends_on = [
8883
aws_api_gateway_rest_api.ndr_doc_store_api,
89-
module.document_reference_dynamodb_table,
9084
module.stitch_metadata_reference_dynamodb_table,
9185
module.delete-doc-ref-gateway,
9286
module.ndr-app-config

0 commit comments

Comments
 (0)