Skip to content

Commit 7b75ca8

Browse files
Merge remote-tracking branch 'origin/main' into PRMT-462
2 parents 0ccceb2 + 4159545 commit 7b75ca8

13 files changed

+92
-74
lines changed

infrastructure/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
| <a name="module_create-token-lambda"></a> [create-token-lambda](#module\_create-token-lambda) | ./modules/lambda | n/a |
5252
| <a name="module_create_doc_alarm"></a> [create\_doc\_alarm](#module\_create\_doc\_alarm) | ./modules/lambda_alarms | n/a |
5353
| <a name="module_create_doc_alarm_topic"></a> [create\_doc\_alarm\_topic](#module\_create\_doc\_alarm\_topic) | ./modules/sns | n/a |
54+
| <a name="module_create_document_reference_gateway"></a> [create\_document\_reference\_gateway](#module\_create\_document\_reference\_gateway) | ./modules/gateway | n/a |
5455
| <a name="module_create_token-alarm"></a> [create\_token-alarm](#module\_create\_token-alarm) | ./modules/lambda_alarms | n/a |
5556
| <a name="module_create_token-alarm_topic"></a> [create\_token-alarm\_topic](#module\_create\_token-alarm\_topic) | ./modules/sns | n/a |
5657
| <a name="module_data-collection-alarm"></a> [data-collection-alarm](#module\_data-collection-alarm) | ./modules/lambda_alarms | n/a |
@@ -130,6 +131,7 @@
130131
| <a name="module_pdf-stitching-alarm-topic"></a> [pdf-stitching-alarm-topic](#module\_pdf-stitching-alarm-topic) | ./modules/sns | n/a |
131132
| <a name="module_pdf-stitching-lambda"></a> [pdf-stitching-lambda](#module\_pdf-stitching-lambda) | ./modules/lambda | n/a |
132133
| <a name="module_pdf-stitching-lambda-alarms"></a> [pdf-stitching-lambda-alarms](#module\_pdf-stitching-lambda-alarms) | ./modules/lambda_alarms | n/a |
134+
| <a name="module_post-document-references-fhir-lambda"></a> [post-document-references-fhir-lambda](#module\_post-document-references-fhir-lambda) | ./modules/lambda | n/a |
133135
| <a name="module_pdm-document-store"></a> [pdm-document-store](#module\_pdm-document-store) | ./modules/s3/ | n/a |
134136
| <a name="module_pdm_dynamodb_table"></a> [pdm\_dynamodb\_table](#module\_pdm\_dynamodb\_table) | ./modules/dynamo_db | n/a |
135137
| <a name="module_route53_fargate_ui"></a> [route53\_fargate\_ui](#module\_route53\_fargate\_ui) | ./modules/route53 | n/a |
@@ -196,7 +198,6 @@
196198
| [aws_api_gateway_integration_response.get_document_reference_mock_403_response](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_integration_response) | resource |
197199
| [aws_api_gateway_integration_response.get_document_reference_mock_404_response](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_integration_response) | resource |
198200
| [aws_api_gateway_method.get_document_reference](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_method) | resource |
199-
| [aws_api_gateway_method.get_document_references_fhir](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_method) | resource |
200201
| [aws_api_gateway_method.login_proxy_method](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_method) | resource |
201202
| [aws_api_gateway_method.sandbox_get_document_reference](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_method) | resource |
202203
| [aws_api_gateway_method_response.response_200](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_method_response) | resource |

infrastructure/api.tf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ resource "aws_api_gateway_deployment" "ndr_api_deploy" {
4747
module.access-audit-lambda,
4848
module.back-channel-logout-gateway,
4949
module.back_channel_logout_lambda,
50-
module.document_reference_gateway,
5150
module.create-doc-ref-lambda,
51+
module.create_document_reference_gateway,
5252
module.create-token-gateway,
5353
module.create-token-lambda,
5454
module.delete-doc-ref-gateway,
@@ -57,6 +57,7 @@ resource "aws_api_gateway_deployment" "ndr_api_deploy" {
5757
module.document-manifest-job-lambda,
5858
module.feature-flags-gateway,
5959
module.feature-flags-lambda,
60+
module.fhir_document_reference_gateway,
6061
module.get-doc-fhir-lambda,
6162
module.get-report-by-ods-gateway,
6263
module.get-report-by-ods-lambda,
@@ -74,6 +75,7 @@ resource "aws_api_gateway_deployment" "ndr_api_deploy" {
7475
module.update-upload-state-lambda,
7576
module.upload_confirm_result_gateway,
7677
module.upload_confirm_result_lambda,
78+
module.post-document-references-fhir-lambda,
7779
module.virus_scan_result_gateway,
7880
module.virus_scan_result_lambda
7981
]
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module "fhir_document_reference_gateway" {
2+
count = local.is_production ? 0 : 1
3+
source = "./modules/gateway"
4+
api_gateway_id = aws_api_gateway_rest_api.ndr_doc_store_api.id
5+
parent_id = aws_api_gateway_rest_api.ndr_doc_store_api.root_resource_id
6+
http_methods = ["POST", "GET"]
7+
authorization = "NONE"
8+
api_key_required = true
9+
gateway_path = "FhirDocumentReference"
10+
require_credentials = true
11+
}

infrastructure/iam.tf

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@ data "aws_iam_policy_document" "assume_role_policy_for_create_lambda" {
2020
actions = ["sts:AssumeRole"]
2121

2222
principals {
23-
type = "AWS"
24-
identifiers = [module.create-doc-ref-lambda.lambda_execution_role_arn]
23+
type = "AWS"
24+
identifiers = compact([
25+
module.create-doc-ref-lambda.lambda_execution_role_arn,
26+
local.is_production ? null : module.post-document-references-fhir-lambda[0].lambda_execution_role_arn
27+
])
2528
}
2629
}
2730
}

infrastructure/lambda-create-doc-ref.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
module "document_reference_gateway" {
1+
module "create_document_reference_gateway" {
22
source = "./modules/gateway"
33
api_gateway_id = aws_api_gateway_rest_api.ndr_doc_store_api.id
44
parent_id = aws_api_gateway_rest_api.ndr_doc_store_api.root_resource_id
55
http_methods = ["POST"]
66
authorization = "CUSTOM"
7-
gateway_path = "DocumentReference"
7+
gateway_path = "CreateDocumentReference"
88
authorizer_id = aws_api_gateway_authorizer.repo_authoriser.id
99
require_credentials = true
1010
origin = contains(["prod"], terraform.workspace) ? "'https://${var.domain}'" : "'https://${terraform.workspace}.${var.domain}'"
@@ -73,7 +73,7 @@ module "create-doc-ref-lambda" {
7373
module.ndr-app-config.app_config_policy,
7474
]
7575
rest_api_id = aws_api_gateway_rest_api.ndr_doc_store_api.id
76-
resource_id = module.document_reference_gateway.gateway_resource_id
76+
resource_id = module.create_document_reference_gateway.gateway_resource_id
7777
http_methods = ["POST"]
7878
memory_size = 512
7979

@@ -92,11 +92,11 @@ module "create-doc-ref-lambda" {
9292
PRESIGNED_ASSUME_ROLE = aws_iam_role.create_post_presign_url_role.arn
9393
}
9494
depends_on = [
95+
module.create_document_reference_gateway,
9596
aws_api_gateway_rest_api.ndr_doc_store_api,
9697
module.document_reference_dynamodb_table,
9798
module.lloyd_george_reference_dynamodb_table,
9899
module.ndr-bulk-staging-store,
99-
module.document_reference_gateway,
100100
module.ndr-app-config,
101101
module.lloyd_george_reference_dynamodb_table,
102102
module.document_reference_dynamodb_table,

infrastructure/lambda-get-document-fhir.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
resource "aws_api_gateway_resource" "get_document_reference" {
2-
count = 1
2+
count = local.is_production ? 0 : 1
33
rest_api_id = aws_api_gateway_rest_api.ndr_doc_store_api.id
4-
parent_id = module.document_reference_gateway.gateway_resource_id
4+
parent_id = module.fhir_document_reference_gateway[0].gateway_resource_id
55
path_part = "{id}"
66
}
77

88
resource "aws_api_gateway_method" "get_document_reference" {
9-
count = 1
9+
count = local.is_production ? 0 : 1
1010
rest_api_id = aws_api_gateway_rest_api.ndr_doc_store_api.id
1111
resource_id = aws_api_gateway_resource.get_document_reference[0].id
1212
http_method = "GET"
@@ -19,7 +19,7 @@ resource "aws_api_gateway_method" "get_document_reference" {
1919

2020

2121
module "get-doc-fhir-lambda" {
22-
count = 1
22+
count = local.is_production ? 0 : 1
2323
source = "./modules/lambda"
2424
name = "GetDocumentReference"
2525
handler = "handlers.get_fhir_document_reference_handler.lambda_handler"
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
module "post-document-references-fhir-lambda" {
2+
count = local.is_production ? 0 : 1
3+
source = "./modules/lambda"
4+
name = "PostDocumentReferencesFHIR"
5+
handler = "handlers.post_fhir_document_reference_handler.lambda_handler"
6+
iam_role_policy_documents = [
7+
module.document_reference_dynamodb_table.dynamodb_write_policy_document,
8+
module.lloyd_george_reference_dynamodb_table.dynamodb_write_policy_document,
9+
module.ndr-bulk-staging-store.s3_write_policy_document,
10+
module.ndr-app-config.app_config_policy,
11+
aws_iam_policy.ssm_access_policy.policy
12+
]
13+
rest_api_id = aws_api_gateway_rest_api.ndr_doc_store_api.id
14+
resource_id = module.fhir_document_reference_gateway[0].gateway_resource_id
15+
http_methods = ["POST"]
16+
api_execution_arn = aws_api_gateway_rest_api.ndr_doc_store_api.execution_arn
17+
lambda_environment_variables = {
18+
APPCONFIG_APPLICATION = module.ndr-app-config.app_config_application_id
19+
APPCONFIG_ENVIRONMENT = module.ndr-app-config.app_config_environment_id
20+
APPCONFIG_CONFIGURATION = module.ndr-app-config.app_config_configuration_profile_id
21+
DOCUMENT_STORE_DYNAMODB_NAME = "${terraform.workspace}_${var.docstore_dynamodb_table_name}"
22+
LLOYD_GEORGE_DYNAMODB_NAME = "${terraform.workspace}_${var.lloyd_george_dynamodb_table_name}"
23+
STAGING_STORE_BUCKET_NAME = "${terraform.workspace}-${var.staging_store_bucket_name}"
24+
DOCUMENT_RETRIEVE_ENDPOINT_APIM = "${local.apim_api_url}/DocumentReference"
25+
PDS_FHIR_IS_STUBBED = local.is_sandbox
26+
WORKSPACE = terraform.workspace
27+
PRESIGNED_ASSUME_ROLE = aws_iam_role.create_post_presign_url_role.arn
28+
}
29+
}

infrastructure/lambda-search-document-references-fhir.tf

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,3 @@
1-
resource "aws_api_gateway_method" "get_document_references_fhir" {
2-
count = local.is_production ? 0 : 1
3-
rest_api_id = aws_api_gateway_rest_api.ndr_doc_store_api.id
4-
resource_id = module.document_reference_gateway.gateway_resource_id
5-
http_method = "GET"
6-
authorization = "NONE"
7-
api_key_required = true
8-
}
9-
10-
111
module "search-document-references-fhir-lambda" {
122
count = local.is_production ? 0 : 1
133
source = "./modules/lambda"
@@ -23,7 +13,7 @@ module "search-document-references-fhir-lambda" {
2313
module.ndr-app-config.app_config_policy
2414
]
2515
rest_api_id = aws_api_gateway_rest_api.ndr_doc_store_api.id
26-
resource_id = module.document_reference_gateway.gateway_resource_id
16+
resource_id = module.fhir_document_reference_gateway[0].gateway_resource_id
2717
http_methods = ["GET"]
2818
api_execution_arn = aws_api_gateway_rest_api.ndr_doc_store_api.execution_arn
2919
lambda_environment_variables = {
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
output "gateway_resource_id" {
2-
value = aws_api_gateway_resource.gateway_resource.id
1+
output "gateway_resource_id" {
2+
value = aws_api_gateway_resource.gateway_resource.id
33
}

infrastructure/modules/gateway/variable.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ variable "require_credentials" {
3030
}
3131

3232
variable "origin" {
33-
type = string
33+
type = string
34+
default = "'*'"
3435
}
3536

3637
variable "api_key_required" {

0 commit comments

Comments
 (0)