Skip to content

Commit 3518e49

Browse files
committed
NDR-213 Create new api methods
1 parent 577b975 commit 3518e49

File tree

5 files changed

+89
-6
lines changed

5 files changed

+89
-6
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module "fhir_document_reference_mtls_gateway" {
2+
source = "./modules/gateway"
3+
api_gateway_id = aws_api_gateway_rest_api.ndr_doc_store_api_mtls.id
4+
parent_id = aws_api_gateway_rest_api.ndr_doc_store_api_mtls.root_resource_id
5+
http_methods = ["POST", "GET"]
6+
authorization = "NONE"
7+
api_key_required = true
8+
gateway_path = "DocumentReference"
9+
require_credentials = true
10+
}

infrastructure/gateway-document-reference.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
module "fhir_document_reference_gateway" {
22
count = 1
33
source = "./modules/gateway"
4-
api_gateway_id = aws_api_gateway_rest_api.ndr_doc_store_api_mtls.id
5-
parent_id = aws_api_gateway_rest_api.ndr_doc_store_api_mtls.root_resource_id
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
66
http_methods = ["POST", "GET"]
77
authorization = "NONE"
88
api_key_required = true

infrastructure/lambda-get-document-fhir.tf

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
resource "aws_api_gateway_resource" "get_document_reference" {
22
count = 1
3-
rest_api_id = aws_api_gateway_rest_api.ndr_doc_store_api_mtls.id
3+
rest_api_id = aws_api_gateway_rest_api.ndr_doc_store_api.id
44
parent_id = module.fhir_document_reference_gateway[0].gateway_resource_id
55
path_part = "{id}"
66
}
77

8+
resource "aws_api_gateway_resource" "get_document_reference_mtls" {
9+
rest_api_id = aws_api_gateway_rest_api.ndr_doc_store_api_mtls.id
10+
parent_id = module.fhir_document_reference_mtls_gateway.gateway_resource_id
11+
path_part = "{id}"
12+
}
13+
814
resource "aws_api_gateway_method" "get_document_reference" {
915
count = 1
10-
rest_api_id = aws_api_gateway_rest_api.ndr_doc_store_api_mtls.id
16+
rest_api_id = aws_api_gateway_rest_api.ndr_doc_store_api.id
1117
resource_id = aws_api_gateway_resource.get_document_reference[0].id
1218
http_method = "GET"
1319
authorization = "NONE"
@@ -17,6 +23,17 @@ resource "aws_api_gateway_method" "get_document_reference" {
1723
}
1824
}
1925

26+
resource "aws_api_gateway_method" "get_document_reference_mtls" {
27+
rest_api_id = aws_api_gateway_rest_api.ndr_doc_store_api_mtls.id
28+
resource_id = aws_api_gateway_resource.get_document_reference_mtls.id
29+
http_method = "GET"
30+
authorization = "NONE"
31+
api_key_required = true
32+
request_parameters = {
33+
"method.request.path.id" = true
34+
}
35+
}
36+
2037

2138
module "get-doc-fhir-lambda" {
2239
count = 1
@@ -30,10 +47,10 @@ module "get-doc-fhir-lambda" {
3047
module.ndr-lloyd-george-store.s3_read_policy_document,
3148
]
3249
kms_deletion_window = var.kms_deletion_window
33-
rest_api_id = aws_api_gateway_rest_api.ndr_doc_store_api_mtls.id
50+
rest_api_id = aws_api_gateway_rest_api.ndr_doc_store_api.id
3451
resource_id = aws_api_gateway_resource.get_document_reference[0].id
3552
http_methods = ["GET"]
36-
api_execution_arn = aws_api_gateway_rest_api.ndr_doc_store_api_mtls.execution_arn
53+
api_execution_arn = aws_api_gateway_rest_api.ndr_doc_store_api.execution_arn
3754
lambda_environment_variables = {
3855
APPCONFIG_APPLICATION = module.ndr-app-config.app_config_application_id
3956
APPCONFIG_ENVIRONMENT = module.ndr-app-config.app_config_environment_id
@@ -49,3 +66,21 @@ module "get-doc-fhir-lambda" {
4966
depends_on = [aws_api_gateway_method.get_document_reference, aws_api_gateway_resource.get_document_reference]
5067
}
5168

69+
resource "aws_api_gateway_integration" "get_doc_fhir_lambda_integration" {
70+
rest_api_id = aws_api_gateway_rest_api.ndr_doc_store_api_mtls.id
71+
resource_id = aws_api_gateway_resource.get_document_reference_mtls.id
72+
http_method = "GET"
73+
integration_http_method = "POST"
74+
type = "AWS_PROXY"
75+
uri = module.get-doc-fhir-lambda[0].lambda_invoke_arn
76+
}
77+
78+
resource "aws_lambda_permission" "lambda_permission_get_mtls_api" {
79+
statement_id = "AllowAPIGatewayInvoke"
80+
action = "lambda:InvokeFunction"
81+
function_name = module.get-doc-fhir-lambda[0].lambda_arn
82+
principal = "apigateway.amazonaws.com"
83+
# The "/*/*" portion grants access from any method on any resource
84+
# within the API Gateway REST API.
85+
source_arn = "${aws_api_gateway_rest_api.ndr_doc_store_api_mtls.execution_arn}/*/*"
86+
}

infrastructure/lambda-post-document-fhir.tf

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,22 @@ module "post-document-references-fhir-lambda" {
2828
PRESIGNED_ASSUME_ROLE = aws_iam_role.create_post_presign_url_role.arn
2929
}
3030
}
31+
32+
resource "aws_api_gateway_integration" "post_doc_fhir_lambda_integration" {
33+
rest_api_id = aws_api_gateway_rest_api.ndr_doc_store_api_mtls.id
34+
resource_id = module.fhir_document_reference_mtls_gateway.gateway_resource_id
35+
http_method = "POST"
36+
integration_http_method = "POST"
37+
type = "AWS_PROXY"
38+
uri = module.post-document-references-fhir-lambda[0].lambda_invoke_arn
39+
}
40+
41+
resource "aws_lambda_permission" "lambda_permission_post_mtls_api" {
42+
statement_id = "AllowAPIGatewayInvoke"
43+
action = "lambda:InvokeFunction"
44+
function_name = module.post-document-references-fhir-lambda[0].lambda_arn
45+
principal = "apigateway.amazonaws.com"
46+
# The "/*/*" portion grants access from any method on any resource
47+
# within the API Gateway REST API.
48+
source_arn = "${aws_api_gateway_rest_api.ndr_doc_store_api_mtls.execution_arn}/*/*"
49+
}

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,22 @@ module "search-document-references-fhir-lambda" {
3131
module.ndr-app-config
3232
]
3333
}
34+
35+
resource "aws_api_gateway_integration" "search_doc_fhir_lambda_integration" {
36+
rest_api_id = aws_api_gateway_rest_api.ndr_doc_store_api_mtls.id
37+
resource_id = module.fhir_document_reference_mtls_gateway.gateway_resource_id
38+
http_method = "GET"
39+
integration_http_method = "POST"
40+
type = "AWS_PROXY"
41+
uri = module.search-document-references-fhir-lambda[0].lambda_invoke_arn
42+
}
43+
44+
resource "aws_lambda_permission" "lambda_permission_search_mtls_api" {
45+
statement_id = "AllowAPIGatewayInvoke"
46+
action = "lambda:InvokeFunction"
47+
function_name = module.search-document-references-fhir-lambda[0].lambda_arn
48+
principal = "apigateway.amazonaws.com"
49+
# The "/*/*" portion grants access from any method on any resource
50+
# within the API Gateway REST API.
51+
source_arn = "${aws_api_gateway_rest_api.ndr_doc_store_api_mtls.execution_arn}/*/*"
52+
}

0 commit comments

Comments
 (0)