Skip to content

Commit ba31adf

Browse files
authored
Merge pull request #38 from NHSDigital/AMB-1709-backend-error-handling-new
Creating catch_all_lambda configuration
2 parents a51c34c + 38e9aa3 commit ba31adf

File tree

24 files changed

+928
-100
lines changed

24 files changed

+928
-100
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ build-proxy:
3838
scripts/build_proxy.sh
3939

4040
#Files to loop over in release
41-
_dist_include="pytest.ini poetry.lock poetry.toml pyproject.toml Makefile build/. tests specification sandbox terraform lambda_typescript scripts"
41+
_dist_include="pytest.ini poetry.lock poetry.toml pyproject.toml Makefile build/. tests specification sandbox terraform lambda_typescript scripts catch_all_lambda"
4242

4343
#Create /dist/ sub-directory and copy files into directory
4444
release: clean publish build-proxy

azure/templates/post-deploy.yml

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@ steps:
88
- ${{ if parameters.is_ptl }}:
99
- template: "azure/components/aws-assume-role.yml@common"
1010
parameters:
11-
role: "auto-ops"
12-
profile: "apm_ptl"
11+
role: "auto-ops"
12+
profile: "apm_ptl"
1313

1414
- template: "azure/components/get-aws-secrets-and-ssm-params.yml@common"
1515
parameters:
16-
secret_file_ids:
17-
- ptl/app-credentials/jwt_testing/non-prod/JWT_TESTING_PRIVATE_KEY
18-
secret_ids:
19-
- ptl/app-credentials/immunisation-fhir-api-testing-app/non-prod/INTROSPECTION_CLIENT_ID
20-
- ptl/app-credentials/immunisation-fhir-api-testing-app/non-prod/INTROSPECTION_CLIENT_SECRET
21-
- ptl/app-credentials/immunisation-fhir-api-testing-app/non-prod/INTROSPECTION_CLIENT_ID_INT
22-
- ptl/app-credentials/immunisation-fhir-api-testing-app/non-prod/INTROSPECTION_CLIENT_SECRET_INT
16+
secret_file_ids:
17+
- ptl/app-credentials/jwt_testing/non-prod/JWT_TESTING_PRIVATE_KEY
18+
secret_ids:
19+
- ptl/app-credentials/immunisation-fhir-api-testing-app/non-prod/INTROSPECTION_CLIENT_ID
20+
- ptl/app-credentials/immunisation-fhir-api-testing-app/non-prod/INTROSPECTION_CLIENT_SECRET
21+
- ptl/app-credentials/immunisation-fhir-api-testing-app/non-prod/INTROSPECTION_CLIENT_ID_INT
22+
- ptl/app-credentials/immunisation-fhir-api-testing-app/non-prod/INTROSPECTION_CLIENT_SECRET_INT
2323

2424
- bash: |
2525
make install-python
@@ -55,9 +55,20 @@ steps:
5555
echo pr_no: $pr_no
5656
5757
cd terraform
58+
59+
cd ../lambda_typescript && \
60+
chmod +x ./deploy.sh && \
61+
./deploy.sh
62+
63+
cd ../catch_all_lambda && \
64+
chmod +x ./deploy.sh && \
65+
./deploy.sh
66+
67+
cd ../terraform
68+
5869
make init
5970
make apply aws_account_no=${aws_account_no} environment=$workspace
60-
71+
6172
fi
6273
displayName: Deploy sandbox
6374
workingDirectory: "$(Pipeline.Workspace)/s/$(SERVICE_NAME)/$(SERVICE_ARTIFACT_NAME)"
@@ -76,11 +87,11 @@ steps:
7687
marker="not sandbox_int"
7788
if [[ $APIGEE_ENVIRONMENT =~ .*-*sandbox ]]
7889
then
79-
echo "Sandox env tests"
90+
echo "Sandbox env tests"
8091
marker="not nhsd_apim_authorization and not sandbox_int"
8192
elif [[ $APIGEE_ENVIRONMENT == "int" ]]
8293
then
83-
echo "Int tests to be set as of now"
94+
echo "Int tests to be set as of now"
8495
fi
8596
echo $marker
8697
poetry run pytest -v -m "$marker" --api-name=immunisation-fhir-api --proxy-name=$PROXY_NAME -o junit_logging=all --junitxml=test-report.xml

catch_all_lambda/deploy.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
3+
# Create a dist folder and copy only the catch_all.py file to dist.
4+
mkdir -p ../catch_all_lambda/dist &&\
5+
cp -r ../catch_all_lambda/src/catch_all_lambda.py ../catch_all_lambda/dist &&\
6+
cd ../catch_all_lambda/dist &&\
7+
find . -name "*.zip" -type f -delete && \
8+
#Create zips directory under terraform, delete existing one
9+
mkdir -p ../../terraform/zips && \
10+
# Zip everything in the dist folder and move to terraform directory
11+
zip -r ../../terraform/zips/catch_all_lambda_function_code.zip . && \
12+
#Delete Distibution folder
13+
cd .. && rm -rf dist
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import json
2+
3+
4+
def handler():
5+
response = {
6+
"statusCode": 404, # HTTP status code
7+
"headers": {
8+
"Content-Type": "application/json", # Specify the content type
9+
},
10+
"body": json.dumps({
11+
"resourceType": "OperationOutcome",
12+
"id": "a5abca2a-4eda-41da-b2cc-95d48c6b791d",
13+
"meta": {
14+
"profile": [
15+
"https://simplifier.net/guide/UKCoreDevelopment2/ProfileUKCore-OperationOutcome"
16+
]
17+
},
18+
"issue": [
19+
{
20+
"severity": "error",
21+
"code": "not-found",
22+
"details": {
23+
"coding": [
24+
{
25+
"system": "https://fhir.nhs.uk/Codesystem/http-error-codes",
26+
"code": "NOT_FOUND"
27+
}
28+
]
29+
},
30+
"diagnostics": "The requested resource was not found."
31+
}
32+
]
33+
})
34+
}
35+
36+
return response

0 commit comments

Comments
 (0)