Skip to content

Commit 904c510

Browse files
authored
[NDR-50] Refactor Get document reference (#296)
* [NDR-50] rename retrieve document reference endpoint
1 parent a54a39b commit 904c510

File tree

5 files changed

+43
-16
lines changed

5 files changed

+43
-16
lines changed

infrastructure/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
| Name | Version |
1010
|------|---------|
11-
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.86.1 |
11+
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.84.0 |
1212

1313
## Modules
1414

@@ -80,7 +80,7 @@
8080
| <a name="module_generate-lloyd-george-stitch-alarm"></a> [generate-lloyd-george-stitch-alarm](#module\_generate-lloyd-george-stitch-alarm) | ./modules/lambda_alarms | n/a |
8181
| <a name="module_generate-lloyd-george-stitch-alarm-topic"></a> [generate-lloyd-george-stitch-alarm-topic](#module\_generate-lloyd-george-stitch-alarm-topic) | ./modules/sns | n/a |
8282
| <a name="module_generate-lloyd-george-stitch-lambda"></a> [generate-lloyd-george-stitch-lambda](#module\_generate-lloyd-george-stitch-lambda) | ./modules/lambda | n/a |
83-
| <a name="module_get-doc-nrl-lambda"></a> [get-doc-nrl-lambda](#module\_get-doc-nrl-lambda) | ./modules/lambda | n/a |
83+
| <a name="module_get-doc-fhir-lambda"></a> [get-doc-fhir-lambda](#module\_get-doc-fhir-lambda) | ./modules/lambda | n/a |
8484
| <a name="module_get-report-by-ods-alarm"></a> [get-report-by-ods-alarm](#module\_get-report-by-ods-alarm) | ./modules/lambda_alarms | n/a |
8585
| <a name="module_get-report-by-ods-alarm-topic"></a> [get-report-by-ods-alarm-topic](#module\_get-report-by-ods-alarm-topic) | ./modules/sns | n/a |
8686
| <a name="module_get-report-by-ods-gateway"></a> [get-report-by-ods-gateway](#module\_get-report-by-ods-gateway) | ./modules/gateway | n/a |
@@ -250,8 +250,8 @@
250250
| [aws_iam_role.cross_account_backup_iam_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
251251
| [aws_iam_role.data_collection_ecs_execution](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
252252
| [aws_iam_role.data_collection_task_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
253+
| [aws_iam_role.get_fhir_doc_presign_url_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
253254
| [aws_iam_role.manifest_presign_url_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
254-
| [aws_iam_role.nrl_get_doc_presign_url_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
255255
| [aws_iam_role.ods_report_presign_url_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
256256
| [aws_iam_role.s3_backup_iam_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
257257
| [aws_iam_role.splunk_sqs_forwarder](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
@@ -274,9 +274,9 @@
274274
| [aws_iam_role_policy_attachment.data_collection_ssm_access_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
275275
| [aws_iam_role_policy_attachment.data_collection_statistical_reports_store](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
276276
| [aws_iam_role_policy_attachment.data_collection_statistics_dynamodb_table](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
277+
| [aws_iam_role_policy_attachment.get_doc_presign_url](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
277278
| [aws_iam_role_policy_attachment.lambda_stitch-lambda](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
278279
| [aws_iam_role_policy_attachment.manifest_presign_url](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
279-
| [aws_iam_role_policy_attachment.nrl_get_doc_presign_url](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
280280
| [aws_iam_role_policy_attachment.ods_report_presign_url](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
281281
| [aws_iam_role_policy_attachment.policy_audit_get-report-by-ods-lambda](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
282282
| [aws_iam_role_policy_attachment.policy_audit_search-patient-details-lambda](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |

infrastructure/api.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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.get-doc-fhir-lambda,
6061
module.get-report-by-ods-gateway,
6162
module.get-report-by-ods-lambda,
6263
module.lloyd-george-stitch-gateway,

infrastructure/iam.tf

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ resource "aws_iam_role_policy_attachment" "manifest_presign_url" {
115115

116116

117117
resource "aws_iam_policy" "s3_document_data_policy_for_get_doc_ref_lambda" {
118-
name = "${terraform.workspace}_get_document_only_policy_for_nrl_get_doc_lambda"
118+
name = "${terraform.workspace}_get_document_only_policy_for_get_doc_lambda"
119119

120120
policy = jsonencode({
121121
"Version" : "2012-10-17",
@@ -132,23 +132,27 @@ resource "aws_iam_policy" "s3_document_data_policy_for_get_doc_ref_lambda" {
132132
}
133133

134134
data "aws_iam_policy_document" "assume_role_policy_for_get_doc_ref_lambda" {
135+
count = local.is_production ? 0 : 1
135136
statement {
136137
actions = ["sts:AssumeRole"]
137138

138139
principals {
139140
type = "AWS"
140-
identifiers = [module.get-doc-nrl-lambda.lambda_execution_role_arn]
141+
identifiers = [module.get-doc-fhir-lambda[0].lambda_execution_role_arn]
141142
}
142143
}
143144
}
144145

145-
resource "aws_iam_role" "nrl_get_doc_presign_url_role" {
146-
name = "${terraform.workspace}_nrl_get_doc_presign_url_role"
147-
assume_role_policy = data.aws_iam_policy_document.assume_role_policy_for_get_doc_ref_lambda.json
146+
resource "aws_iam_role" "get_fhir_doc_presign_url_role" {
147+
count = local.is_production ? 0 : 1
148+
name = "${terraform.workspace}_get_fhir_doc_presign_url_role"
149+
assume_role_policy = data.aws_iam_policy_document.assume_role_policy_for_get_doc_ref_lambda[0].json
148150
}
149151

150-
resource "aws_iam_role_policy_attachment" "nrl_get_doc_presign_url" {
151-
role = aws_iam_role.nrl_get_doc_presign_url_role.name
152+
153+
resource "aws_iam_role_policy_attachment" "get_doc_presign_url" {
154+
count = local.is_production ? 0 : 1
155+
role = aws_iam_role.get_fhir_doc_presign_url_role[0].name
152156
policy_arn = aws_iam_policy.s3_document_data_policy_for_get_doc_ref_lambda.arn
153157
}
154158

infrastructure/lambda-get-document-nrl.tf renamed to infrastructure/lambda-get-document-fhir.tf

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
resource "aws_api_gateway_resource" "get_document_reference" {
2+
count = local.is_production ? 0 : 1
23
rest_api_id = aws_api_gateway_rest_api.ndr_doc_store_api.id
34
parent_id = module.create-doc-ref-gateway.gateway_resource_id
45
path_part = "{id}"
56
}
67

78
resource "aws_api_gateway_method" "get_document_reference" {
9+
count = local.is_production ? 0 : 1
810
rest_api_id = aws_api_gateway_rest_api.ndr_doc_store_api.id
9-
resource_id = aws_api_gateway_resource.get_document_reference.id
11+
resource_id = aws_api_gateway_resource.get_document_reference[0].id
1012
http_method = "GET"
1113
authorization = "NONE"
1214
api_key_required = true
@@ -15,17 +17,20 @@ resource "aws_api_gateway_method" "get_document_reference" {
1517
}
1618
}
1719

18-
module "get-doc-nrl-lambda" {
20+
21+
module "get-doc-fhir-lambda" {
22+
count = local.is_production ? 0 : 1
1923
source = "./modules/lambda"
2024
name = "GetDocumentReference"
21-
handler = "handlers.nrl_get_document_reference_handler.lambda_handler"
25+
handler = "handlers.get_fhir_document_reference_handler.lambda_handler"
2226
iam_role_policy_documents = [
2327
module.ndr-app-config.app_config_policy,
2428
module.lloyd_george_reference_dynamodb_table.dynamodb_read_policy_document,
2529
aws_iam_policy.ssm_access_policy.policy,
30+
module.ndr-lloyd-george-store.s3_read_policy_document,
2631
]
2732
rest_api_id = aws_api_gateway_rest_api.ndr_doc_store_api.id
28-
resource_id = aws_api_gateway_resource.get_document_reference.id
33+
resource_id = aws_api_gateway_resource.get_document_reference[0].id
2934
http_methods = ["GET"]
3035
api_execution_arn = aws_api_gateway_rest_api.ndr_doc_store_api.execution_arn
3136
lambda_environment_variables = {
@@ -34,8 +39,9 @@ module "get-doc-nrl-lambda" {
3439
APPCONFIG_CONFIGURATION = module.ndr-app-config.app_config_configuration_profile_id
3540
WORKSPACE = terraform.workspace
3641
ENVIRONMENT = var.environment
37-
PRESIGNED_ASSUME_ROLE = aws_iam_role.nrl_get_doc_presign_url_role.arn
42+
PRESIGNED_ASSUME_ROLE = aws_iam_role.get_fhir_doc_presign_url_role[0].arn
3843
LLOYD_GEORGE_DYNAMODB_NAME = "${terraform.workspace}_${var.lloyd_george_dynamodb_table_name}"
44+
OIDC_CALLBACK_URL = contains(["prod"], terraform.workspace) ? "https://${var.domain}/auth-callback" : "https://${terraform.workspace}.${var.domain}/auth-callback"
3945
CLOUDFRONT_URL = module.cloudfront-distribution-lg.cloudfront_url
4046
PDS_FHIR_IS_STUBBED = local.is_sandbox
4147
}

infrastructure/moved-resources.tf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# NDR-50
2+
3+
moved {
4+
from = module.get-doc-nrl-lambda
5+
to = module.get-doc-fhir-lambda[0]
6+
}
7+
8+
moved {
9+
from = aws_iam_role.nrl_get_doc_presign_url_role
10+
to = aws_iam_role.get_fhir_doc_presign_url_role[0]
11+
}
12+
13+
moved {
14+
from = aws_iam_role_policy_attachment.nrl_get_doc_presign_url
15+
to = aws_iam_role_policy_attachment.get_doc_presign_url[0]
16+
}

0 commit comments

Comments
 (0)