-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathpatient_check.tf
More file actions
88 lines (77 loc) · 2.89 KB
/
patient_check.tf
File metadata and controls
88 lines (77 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
resource "aws_api_gateway_request_validator" "patient_check_validator" {
rest_api_id = module.eligibility_signposting_api_gateway.rest_api_id
name = "validate-path-params"
validate_request_body = false
validate_request_parameters = true
}
resource "aws_api_gateway_method" "get_patient_check" {
#checkov:skip=CKV_AWS_59: API is secured via Apigee proxy with mTLS, API keys are not used
rest_api_id = module.eligibility_signposting_api_gateway.rest_api_id
resource_id = aws_api_gateway_resource.patient.id
http_method = "GET"
authorization = "NONE"
api_key_required = false
request_validator_id = aws_api_gateway_request_validator.patient_check_validator.id
request_parameters = {
"method.request.path.id" = true # Require the 'id' path parameter
}
depends_on = [
aws_api_gateway_resource.patient,
aws_api_gateway_resource.patient_check,
]
}
resource "aws_api_gateway_integration" "get_patient_check" {
rest_api_id = module.eligibility_signposting_api_gateway.rest_api_id
resource_id = aws_api_gateway_resource.patient.id
http_method = aws_api_gateway_method.get_patient_check.http_method
integration_http_method = "POST" # Needed for lambda proxy integration
type = "AWS_PROXY"
uri = module.eligibility_signposting_lambda_function.aws_lambda_invoke_arn
depends_on = [
aws_api_gateway_method.get_patient_check
]
}
resource "aws_lambda_permission" "get_patient_check" {
statement_id = "AllowExecutionFromAPIGateway"
action = "lambda:InvokeFunction"
function_name = module.eligibility_signposting_lambda_function.aws_lambda_function_name
principal = "apigateway.amazonaws.com"
source_arn = "${module.eligibility_signposting_api_gateway.execution_arn}/*/*"
}
resource "aws_api_gateway_gateway_response" "bad_request_parameters" {
rest_api_id = module.eligibility_signposting_api_gateway.rest_api_id
response_type = "BAD_REQUEST_PARAMETERS"
status_code = "400"
response_templates = {
"application/json" = jsonencode({
resourceType = "OperationOutcome"
id = "$context.requestId"
meta = {
lastUpdated = "$context.requestTime"
}
issue = [
{
severity = "error"
code = "invalid"
details = {
coding = [
{
system = "https://fhir.nhs.uk/STU3/ValueSet/Spine-ErrorOrWarningCode-1",
code = "BAD_REQUEST",
display = "Bad Request"
}
]
}
diagnostics = "Missing required NHS Number from path parameters",
location = [
"parameters/id"
]
}
]
})
}
response_parameters = {
"gatewayresponse.header.Access-Control-Allow-Origin" = "'*'"
"gatewayresponse.header.Content-Type" = "'application/fhir+json'"
}
}