11resource "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+
814resource "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
2138module "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+ }
0 commit comments