Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 45 additions & 6 deletions infrastructure/stacks/api-layer/patient_check.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

resource "aws_api_gateway_request_validator" "patient_check_validator" {
rest_api_id = module.eligibility_signposting_api_gateway.rest_api_id
name = "validate-path-params"
Expand Down Expand Up @@ -27,12 +26,12 @@ resource "aws_api_gateway_method" "get_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
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
type = "AWS_PROXY"
uri = module.eligibility_signposting_lambda_function.aws_lambda_invoke_arn

depends_on = [
aws_api_gateway_method.get_patient_check
Expand All @@ -47,3 +46,43 @@ resource "aws_lambda_permission" "get_patient_check" {

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'"
}
}