Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
289 commits
Select commit Hold shift + click to select a range
7a8b4e5
Merge branch 'main' into aea-5199-setup-notifications-lambda
wildjames Apr 22, 2025
7bfc023
Skip quality checks
wildjames Apr 22, 2025
b56af03
Merge branch 'aea-5199-setup-notifications-lambda' of github.com:NHSD…
wildjames Apr 22, 2025
d6d58cc
Make the notify lambda pull messages from SQS, and log them
wildjames Apr 22, 2025
8216f25
Update log message
wildjames Apr 22, 2025
6a2d224
Set up the consumer to be able to communicate with the table. Alos lo…
wildjames Apr 22, 2025
77821bc
Pass in static table name as a parameter
wildjames Apr 22, 2025
7c91533
Merge branch 'main' into aea-5199-setup-notifications-lambda
wildjames Apr 22, 2025
e39958a
Expand test coverage
wildjames Apr 22, 2025
61a897e
Merge branch 'aea-5199-setup-notifications-lambda' of github.com:NHSD…
wildjames Apr 22, 2025
adb055f
Minimal nhsnotifylambda dynamo unit test
wildjames Apr 23, 2025
804c06b
Expand test coverage
wildjames Apr 23, 2025
eb78c25
Start tests for the drainQueue functiton
wildjames Apr 23, 2025
35d8a92
Expand test coverage
wildjames Apr 23, 2025
9a55102
Merge branch 'main' into aea-5199-setup-notifications-lambda
wildjames Apr 23, 2025
ea0c3fe
Make a more official test for the handler
wildjames Apr 23, 2025
5da248d
Expand test coverage
wildjames Apr 23, 2025
90ccd53
Update type
wildjames Apr 23, 2025
338a135
Address some sonar things
wildjames Apr 23, 2025
17d6566
Move dataitem to a common types package
wildjames Apr 23, 2025
f27d70f
Minor tweaks from self-review
wildjames Apr 23, 2025
9cfb289
Use NHS number as the message ID
wildjames Apr 24, 2025
f0d35c5
Salt the nhs number and use it as the message ID.
wildjames Apr 24, 2025
6a77bde
Update log message
wildjames Apr 24, 2025
53abd70
Update tests to reflect logging change
wildjames Apr 24, 2025
440ac9e
Merge branch 'main' into aea-5274-deduplicate-notification-queue-by-n…
wildjames Apr 24, 2025
15ba4d2
Correctly grab request ID
wildjames Apr 24, 2025
501a5fd
Merge branch 'main' into aea-5199-setup-notifications-lambda
wildjames Apr 24, 2025
ba2d587
Merge branch 'aea-5199-setup-notifications-lambda' into aea-5274-dedu…
wildjames Apr 24, 2025
dd81780
Update log
wildjames Apr 24, 2025
0043ed4
Merge branch 'aea-5199-setup-notifications-lambda' into aea-5274-dedu…
wildjames Apr 24, 2025
00178b2
Remove log messages
wildjames Apr 24, 2025
67fb985
Use a FIFO queue, since it has deduplication IDs
wildjames Apr 24, 2025
989bb82
Minor adjustment to the failure catch logic to handle some elements o…
wildjames Apr 24, 2025
7fd8396
lengthen visibility timeout
wildjames Apr 24, 2025
1cf948a
Merge branch 'aea-5199-setup-notifications-lambda' into aea-5274-dedu…
wildjames Apr 24, 2025
178fc01
Update to deduplicate on both nhs number and ods code
wildjames Apr 25, 2025
9d9da72
Update test
wildjames Apr 25, 2025
21cf5f0
Resolve package lock conflict
wildjames Apr 28, 2025
5912e98
Merge branch 'aea-5199-setup-notifications-lambda' into aea-5274-dedu…
wildjames Apr 28, 2025
886c198
Rename fuinction. Comments
wildjames Apr 28, 2025
6b9dcbc
Resolve package lock conflict
wildjames Apr 28, 2025
d710874
Merge branch 'aea-5199-setup-notifications-lambda' into aea-5274-dedu…
wildjames Apr 28, 2025
f5a77bf
Create a whitelist checking function
wildjames Apr 28, 2025
c90555c
Update language usage
wildjames Apr 28, 2025
90e3e8e
Update language
wildjames Apr 28, 2025
21a1236
Update logging
wildjames Apr 28, 2025
de8033a
Update tests
wildjames Apr 28, 2025
839375f
Merge branch 'main' into aea-5274-deduplicate-notification-queue-by-n…
wildjames Apr 28, 2025
d950354
Move the deletion logic out to occur AFTER processing. Update tests t…
wildjames Apr 28, 2025
1c949b7
Update tests
wildjames Apr 28, 2025
0227196
Revert a line
wildjames Apr 28, 2025
7440946
Update mock import
wildjames Apr 28, 2025
73edbdc
Expand tests
wildjames Apr 28, 2025
2719d4f
Set the sqs salt value to some randomly generated string at deployment
wildjames Apr 29, 2025
8d10626
Merge branch 'main' into aea-5202-allowed-and-blocked-sites-and-systems
wildjames Apr 29, 2025
a22c919
Merge branch 'aea-5274-deduplicate-notification-queue-by-nhsnumber' i…
wildjames Apr 29, 2025
28adaa5
Define the enabled and disabled sites in a new Paramters template
wildjames Apr 29, 2025
bff40c5
Allow the block and enable lists to differ between prod and non-prod …
wildjames Apr 29, 2025
50e7fe5
Update tests
wildjames Apr 29, 2025
f08adba
Merge branch 'main' into aea-5202-allowed-and-blocked-sites-and-systems
wildjames Apr 29, 2025
888a1c8
Merge branch 'main' into aea-5202-allowed-and-blocked-sites-and-systems
wildjames Apr 29, 2025
b8b08a8
Fix typo
wildjames Apr 29, 2025
23c53d7
Merge branch 'aea-5202-allowed-and-blocked-sites-and-systems' of gith…
wildjames Apr 29, 2025
5939e0f
Refactor params a bit
wildjames Apr 29, 2025
e608771
Roll back a bit to find the source of the error
wildjames Apr 29, 2025
e3ef147
Comment out parameter
wildjames Apr 30, 2025
aa2a8d5
Make fallback salt a const
wildjames Apr 30, 2025
022e66f
Merge main into aea-5202-allowed-and-blocked-sites-and-systems
wildjames Apr 30, 2025
d015f13
last deployment worked. Try passing in parameters
wildjames Apr 30, 2025
b1574b1
Join array back into a single string
wildjames Apr 30, 2025
6bcd216
pass in the name and fetch the parameter values from ssm in the code
wildjames Apr 30, 2025
d9fcfce
Forgot to await
wildjames Apr 30, 2025
d0cea20
Revert change
wildjames Apr 30, 2025
17e46ea
Add logging message
wildjames Apr 30, 2025
ad32e9b
Remove await
wildjames Apr 30, 2025
055e4a0
Revert change to deploy workflow
wildjames Apr 30, 2025
d3d88f4
Merge branch 'main' into aea-5202-allowed-and-blocked-sites-and-systems
wildjames Apr 30, 2025
c0f0c50
Merge branch 'main' into aea-5202-allowed-and-blocked-sites-and-systems
wildjames Apr 30, 2025
358e203
Test fallback salt value
wildjames Apr 30, 2025
6663bac
Merge branch 'aea-5202-allowed-and-blocked-sites-and-systems' of gith…
wildjames Apr 30, 2025
3e5feb7
Minor tweak to tests
wildjames Apr 30, 2025
5c53015
Case insensitivity test!
wildjames Apr 30, 2025
2c97580
Exploratory work
wildjames May 1, 2025
73d8784
bypass quality checks
wildjames May 1, 2025
f982d2a
Checking that there's not data I think there is
wildjames May 1, 2025
f3bfcf6
Reintroduce code to push up data to dynamo
wildjames May 1, 2025
59c0977
use a string for the date instead of raw Date object
wildjames May 2, 2025
7f83dbd
Add a log message
wildjames May 2, 2025
4251aa8
Add log message
wildjames May 2, 2025
d2cffd1
Update test
wildjames May 2, 2025
d5bf6fb
re-enable PiTR
wildjames May 2, 2025
8e986e2
Fix me using the wrong table reference in the template
wildjames May 2, 2025
95f99fd
Fix expiry time calculation. Move delta to constant
wildjames May 2, 2025
d1bc62b
Batch the delete operation properly. Add request ID to the SQS messag…
wildjames May 2, 2025
f18d438
Add a log message
wildjames May 2, 2025
d5b1aa8
Update and expand tests
wildjames May 2, 2025
c1bd96c
Merge branch 'main' into aea-5280-push-notify-data-to-dynamo
wildjames May 2, 2025
430ec69
Add another unit test.
wildjames May 2, 2025
890bcdd
Reenable quality checks
wildjames May 2, 2025
f3eee15
Add another test
wildjames May 2, 2025
b07f849
Resolve merge conflict
wildjames May 2, 2025
bd895e8
Add a log message
wildjames May 2, 2025
eebc9c0
Add a log message
wildjames May 2, 2025
463348a
Alter comments
wildjames May 2, 2025
dfcc12c
Merge branch 'main' into aea-5280-push-notify-data-to-dynamo
wildjames May 6, 2025
e73b723
Change record key to be more explicit
wildjames May 6, 2025
8ce03dc
Try some explicit jest config to get coverage picked up
wildjames May 6, 2025
ba328eb
Revert last commit
wildjames May 6, 2025
a24c366
Merge branch 'main' into aea-5280-push-notify-data-to-dynamo
wildjames May 6, 2025
506fb14
Try updating sonar coverage defintion
wildjames May 6, 2025
04d90be
Address sonar issues
wildjames May 6, 2025
e7bbf5c
Remove invalid sonar config
wildjames May 6, 2025
e17395e
Update jest config
wildjames May 6, 2025
3194e5f
Write a function that checks the cooldown. Also filter incoming messa…
wildjames May 6, 2025
18564fc
Resolve sonar issue
wildjames May 6, 2025
686ee53
Merge branch 'aea-5280-push-notify-data-to-dynamo' into aea-5206-chec…
wildjames May 6, 2025
d047e98
Expand test coverage
wildjames May 6, 2025
7dadd02
Unit tests for new function
wildjames May 6, 2025
02e9717
Update logging
wildjames May 6, 2025
470d565
Merge branch 'aea-5280-push-notify-data-to-dynamo' into aea-5206-chec…
wildjames May 6, 2025
243dcb0
Update test
wildjames May 6, 2025
eea2c85
Update test
wildjames May 6, 2025
677f128
Merge branch 'aea-5280-push-notify-data-to-dynamo' into aea-5206-chec…
wildjames May 6, 2025
4eef6fa
First pass at setting up a new lambda
wildjames May 7, 2025
96b3cb5
Merge branch 'main' into aea-5308-notify-callback
wildjames May 7, 2025
88b49f5
Merge branch 'main' into aea-5206-check-cooldown-when-sending
wildjames May 7, 2025
88ffd8f
Trigger build
wildjames May 7, 2025
777b171
Update package lock
wildjames May 7, 2025
e8888f3
Pointing to wrong handler location
wildjames May 7, 2025
64656a7
Bypass quality checks
wildjames May 7, 2025
01e36ad
Check signature
wildjames May 8, 2025
fb27480
Remove todo
wildjames May 8, 2025
5b7b969
parse request body
wildjames May 8, 2025
001c649
Logging changes
wildjames May 8, 2025
b5d83a6
Update logging again
wildjames May 8, 2025
7afc105
Compare as buffers, rather than hex
wildjames May 8, 2025
107d218
Merge branch 'main' into aea-5308-notify-callback
wildjames May 8, 2025
4686dc9
Merge branch 'main' into aea-5308-notify-callback
wildjames May 8, 2025
1a5d454
Debug logging
wildjames May 8, 2025
111d53c
Remove logs
wildjames May 8, 2025
2e638f3
Comments
wildjames May 8, 2025
6179c4c
Implement table update function. re-add GSI back to table, this time …
wildjames May 8, 2025
b07b60d
Merge branch 'main' into aea-5308-notify-callback
wildjames May 8, 2025
5fba026
Logging update
wildjames May 8, 2025
bff733d
unit tests for lambda handler
wildjames May 8, 2025
9657967
Mostly tested
wildjames May 8, 2025
6305926
Last bit of coverage
wildjames May 8, 2025
789d809
re-enable quality checks
wildjames May 9, 2025
6682d19
Some cleanup bits
wildjames May 9, 2025
61a9a8d
Merge main
wildjames May 9, 2025
de8142e
Merge branch 'aea-5206-check-cooldown-when-sending' into aea-5308-not…
wildjames May 9, 2025
4eb9d37
Add secrets. Empty for now
wildjames May 9, 2025
b6b3842
Merge branch 'main' into aea-5308-notify-callback
wildjames May 9, 2025
79dd025
Fix typo
wildjames May 9, 2025
2116056
Update configuration
wildjames May 9, 2025
5a05a06
Merge branch 'aea-5308-notify-callback' of github.com:NHSDigital/eps-…
wildjames May 9, 2025
e28d282
Merge branch 'main' into aea-5308-notify-callback
wildjames May 9, 2025
e88059b
Stack name
wildjames May 9, 2025
cb5e23e
Rename resource to prevent collision
wildjames May 9, 2025
5fdb9aa
Change the value of the test ODS code
wildjames May 9, 2025
593e325
Only pass required information through the SQS message
wildjames May 12, 2025
2e29275
Merge branch 'main' into aea-5308-notify-callback
wildjames May 12, 2025
38021af
TODO notes
wildjames May 12, 2025
dfaf786
Merge branch 'aea-5308-notify-callback' of github.com:NHSDigital/eps-…
wildjames May 12, 2025
4d9e7fc
Trigger build
wildjames May 12, 2025
99c71f8
Remove the table
wildjames May 12, 2025
9a0b79e
Keep the table, but remove references to it
wildjames May 12, 2025
386acd7
Remove debugging line
wildjames May 13, 2025
9463811
Revert to previously deployed table state
wildjames May 13, 2025
61b8935
Merge branch 'main' into aea-0000-redeploy-notification-table-stage-1
wildjames May 13, 2025
3fa702d
Merge branch 'main' into aea-5308-notify-callback
wildjames May 13, 2025
e6c2f34
First pass at a script to update the secrets during deployment
wildjames May 13, 2025
bdf7f31
Trigger build
wildjames May 13, 2025
479949b
Move to the new table
wildjames May 13, 2025
288b3e0
Re-add the references to the table
wildjames May 13, 2025
1fce3a2
Merge branch 'aea-0000-redeploy-notification-table-stage-2' into aea-…
wildjames May 13, 2025
33eae84
Fix table definition
wildjames May 13, 2025
da61195
Merge branch 'main' into aea-5308-notify-callback
wildjames May 14, 2025
57e7feb
Merge branch 'main' into aea-5308-notify-callback
wildjames May 14, 2025
145e652
Fix typo
wildjames May 14, 2025
7fe18b1
Merge branch 'main' into aea-5308-notify-callback
wildjames May 15, 2025
1b66d14
Rework how I import additional policies - why did it stop working?
wildjames May 15, 2025
9c786cc
Merge branch 'main' into aea-5308-notify-callback
wildjames May 15, 2025
f3b8d11
revert to usual version of additional policies
wildjames May 15, 2025
ee28032
Update some missed name changes
wildjames May 15, 2025
96d5a78
Forgot to double brace the variable
wildjames May 15, 2025
069192c
Fix incorrectly addressing secrets
wildjames May 15, 2025
3ad4708
Throw errors if the app name or api key are not set in the callback
wildjames May 15, 2025
e82b994
Remove secret update as part of the workflow (moved secrets to accoun…
wildjames May 15, 2025
4050347
Remove reference to secrets
wildjames May 15, 2025
85dc926
Update comment - resolved toto
wildjames May 15, 2025
a446284
Merge branch 'main' into aea-5308-notify-callback
wildjames May 16, 2025
614c438
Update secret import name
wildjames May 19, 2025
7845ca9
Debugging
wildjames May 19, 2025
e6e4abe
Update the code to fetch secrets at runtime
wildjames May 19, 2025
919facf
Revert "Update the code to fetch secrets at runtime"
wildjames May 19, 2025
768ceb2
Pass in secret value at deployment time instead
wildjames May 19, 2025
f38ba4c
Merge branch 'main' into aea-5308-notify-callback
wildjames May 19, 2025
3814406
Pass in secret values a different way
wildjames May 19, 2025
900cadd
Correct name
wildjames May 19, 2025
217e0dd
Why is aws trying to parse my string into a json
wildjames May 19, 2025
beca5fd
Update postman collection
wildjames May 19, 2025
072fd79
Reenable quality checks
wildjames May 19, 2025
7be8b8e
Broke a tests, oops
wildjames May 20, 2025
319bdcf
Update docs
wildjames May 20, 2025
96502bd
Merge branch 'aea-5308-callback-specification-docs' into aea-5308-not…
wildjames May 20, 2025
936bd21
Merge branch 'main' into aea-5308-notify-callback
wildjames May 20, 2025
ab252cc
minor tweak to remove some temporary logic
wildjames May 20, 2025
1592e28
rename a field and add a fallback for SQS message ID
wildjames May 20, 2025
1dbfe6a
Remove accidentally committed file
wildjames May 21, 2025
81cd95a
Merge branch 'main' into aea-5308-notify-callback
wildjames May 21, 2025
5d044b7
Update spec
wildjames May 23, 2025
41d89a8
Update postman collection description
wildjames May 23, 2025
91eeeb1
Refactor postman script
wildjames May 23, 2025
618adb3
Use the correct proxygen security level
wildjames May 23, 2025
8e3f5cb
Merge branch 'main' into aea-5308-notify-callback
wildjames May 23, 2025
c35b774
add the parameter for API key
wildjames May 23, 2025
67d7019
Merge branch 'main' into aea-5308-notify-callback
wildjames Jun 2, 2025
b4f7c18
Rename api key parameter
wildjames Jun 2, 2025
0c47769
Update spec
wildjames Jun 2, 2025
734d01f
Update schema again
wildjames Jun 2, 2025
57bf98c
Try adding app level to grants
wildjames Jun 2, 2025
3614e78
Add the grants to the spec
wildjames Jun 2, 2025
4ee8c35
Update deployment script
wildjames Jun 2, 2025
6e0acf1
Signature issue - add a debug log statement
wildjames Jun 2, 2025
59d9db7
Remove debug logging statement
wildjames Jun 2, 2025
41ae116
Remove unnecessary access block
wildjames Jun 2, 2025
ce49a5a
Capitalise ApiKey
wildjames Jun 2, 2025
4bdc236
Merge branch 'main' into aea-5308-notify-callback
wildjames Jun 3, 2025
aaa9f1c
Tell the secrets to get the current value
wildjames Jun 3, 2025
0503ca1
Get secrets at runtime
wildjames Jun 3, 2025
d9fb311
Update and fix tests
wildjames Jun 3, 2025
7194614
Add some debug logging
wildjames Jun 3, 2025
016a61f
Add permission to read secrets
wildjames Jun 3, 2025
5fb8bef
Used the wrong policy
wildjames Jun 3, 2025
0d77e32
Try inline policy
wildjames Jun 3, 2025
4d8428e
Forgot to pass logger object in
wildjames Jun 3, 2025
e1d8a9e
Minor refactor
wildjames Jun 3, 2025
c67adb3
Fix test
wildjames Jun 3, 2025
9479dc5
Forgot to await the fetchsecrets function. Fixed that
wildjames Jun 3, 2025
964963d
Move lambda get secrets policy to the lambda role
wildjames Jun 4, 2025
5a3108f
Update postman collection
wildjames Jun 4, 2025
d522ee0
Use existing policy
wildjames Jun 4, 2025
0b22850
Merge branch 'main' into aea-5308-notify-callback
wildjames Jun 4, 2025
3983bde
Update lambda config to use new secrets
wildjames Jun 4, 2025
52f9e2f
Refactor so that bad messages are ignored, but good ones are still pr…
wildjames Jun 4, 2025
494a171
Fix secret names and role
wildjames Jun 4, 2025
7196b26
Remove debug statement
wildjames Jun 4, 2025
ae5a69c
Merge branch 'main' into aea-5308-notify-callback
wildjames Jun 5, 2025
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
14 changes: 4 additions & 10 deletions .github/scripts/deploy_api.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,11 @@ fi

# Find and replace securitySchemes
if [[ "${APIGEE_ENVIRONMENT}" == "prod" ]]; then
if [[ "${API_TYPE}" == "standard" ]]; then
jq '.components.securitySchemes."app-level3" = {"$ref": "https://proxygen.prod.api.platform.nhs.uk/components/securitySchemes/app-level3"}' "${SPEC_PATH}" > temp.json && mv temp.json "${SPEC_PATH}"
else
jq '.components.securitySchemes."app-level0" = {"$ref": "https://proxygen.prod.api.platform.nhs.uk/components/securitySchemes/app-level0"}' "${SPEC_PATH}" > temp.json && mv temp.json "${SPEC_PATH}"
fi
jq '.components.securitySchemes."app-level3" = {"$ref": "https://proxygen.prod.api.platform.nhs.uk/components/securitySchemes/app-level3"}' "${SPEC_PATH}" > temp.json && mv temp.json "${SPEC_PATH}"
jq '.components.securitySchemes."app-level0" = {"$ref": "https://proxygen.prod.api.platform.nhs.uk/components/securitySchemes/app-level0"}' "${SPEC_PATH}" > temp.json && mv temp.json "${SPEC_PATH}"
else
if [[ "${API_TYPE}" == "standard" ]]; then
jq '.components.securitySchemes."app-level3" = {"$ref": "https://proxygen.ptl.api.platform.nhs.uk/components/securitySchemes/app-level3"}' "${SPEC_PATH}" > temp.json && mv temp.json "${SPEC_PATH}"
else
jq '.components.securitySchemes."app-level0" = {"$ref": "https://proxygen.ptl.api.platform.nhs.uk/components/securitySchemes/app-level0"}' "${SPEC_PATH}" > temp.json && mv temp.json "${SPEC_PATH}"
fi
jq '.components.securitySchemes."app-level3" = {"$ref": "https://proxygen.ptl.api.platform.nhs.uk/components/securitySchemes/app-level3"}' "${SPEC_PATH}" > temp.json && mv temp.json "${SPEC_PATH}"
jq '.components.securitySchemes."app-level0" = {"$ref": "https://proxygen.ptl.api.platform.nhs.uk/components/securitySchemes/app-level0"}' "${SPEC_PATH}" > temp.json && mv temp.json "${SPEC_PATH}"
fi

# Remove target attributes if the environment is sandbox
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/run_release_code_and_api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ on:
required: false
REGRESSION_TESTS_PEM:
required: true

jobs:
release_code_and_api:
runs-on: ubuntu-22.04
Expand Down
5 changes: 5 additions & 0 deletions .vscode/eps-prescription-status-update-api.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
"name": "packages/nhsNotifyLambda",
"path": "../packages/nhsNotifyLambda"
},
{
"name": "packages/nhsNotifyUpdateCallback",
"path": "../packages/nhsNotifyUpdateCallback"
},
{
"name": "packages/capabilityStatement",
"path": "../packages/capabilityStatement"
Expand Down Expand Up @@ -97,6 +101,7 @@
"mermade",
"milliliter",
"mkhl",
"nhsapp",
"nHSCHI",
"NHSD",
"nhsdlogin",
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ lint-node: compile-node
npm run lint --workspace packages/cpsuLambda
npm run lint --workspace packages/checkPrescriptionStatusUpdates
npm run lint --workspace packages/nhsNotifyLambda
npm run lint --workspace packages/nhsNotifyUpdateCallback
npm run lint --workspace packages/common/testing
npm run lint --workspace packages/common/middyErrorHandler
npm run lint --workspace packages/common/commonTypes
Expand Down Expand Up @@ -147,6 +148,7 @@ test: compile
npm run test --workspace packages/cpsuLambda
npm run test --workspace packages/checkPrescriptionStatusUpdates
npm run test --workspace packages/nhsNotifyLambda
npm run test --workspace packages/nhsNotifyUpdateCallback
npm run test --workspace packages/common/middyErrorHandler

clean:
Expand All @@ -164,6 +166,8 @@ clean:
rm -rf packages/cpsuLambda/lib
rm -rf packages/nhsNotifyLambda/coverage
rm -rf packages/nhsNotifyLambda/lib
rm -rf packages/nhsNotifyUpdateCallback/coverage
rm -rf packages/nhsNotifyUpdateCallback/lib
rm -rf packages/checkPrescriptionStatusUpdates/lib
rm -rf packages/common/testing/lib
rm -rf packages/common/middyErrorHandler/lib
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ This is the AWS layer that provides an API for EPS Prescription Status Update.
- `packages/capabilityStatement/` Returns a static capability statement.
- `packages/cpsuLambda` Handles updating prescription status using a custom format.
- `packages/nhsNotifyLambda` Handles sending prescription notifications to the NHS notify service.
- `packages/nhsNotifyUpdateCallback` Handles receiving notification updates from the NHS notify service.
- `scripts/` Utilities helpful to developers of this specification.
- `postman/` Postman collections to call the APIs. Documentation on how to use them are in the collections.
- `SAMtemplates/` Contains the SAM templates used to define the stacks.
Expand Down
40 changes: 38 additions & 2 deletions SAMtemplates/apis/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ Parameters:
Type: String
Default: none

NHSNotifyUpdateCallbackFunctionName:
Type: String
Default: none

NHSNotifyUpdateCallbackFunctionArn:
Type: String
Default: none

LogRetentionInDays:
Type: Number

Expand Down Expand Up @@ -427,6 +435,32 @@ Resources:
- StatusCode: "400"
- StatusCode: "500"

NotificationDeliveryStatusCallbackMethod:
Type: AWS::ApiGateway::Method
Properties:
RestApiId: !Ref RestApiGateway
ResourceId: !Ref NotificationDeliveryStatusCallbackResource
HttpMethod: POST
AuthorizationType: NONE # They authenticate with a signature header
Integration:
Type: AWS_PROXY
Credentials: !GetAtt RestApiGatewayResources.Outputs.ApiGwRoleArn
IntegrationHttpMethod: POST
Uri: !Sub arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${NHSNotifyUpdateCallbackFunctionArn}/invocations
MethodResponses:
- StatusCode: "202"
- StatusCode: "401"
- StatusCode: "403"
- StatusCode: "429"
- StatusCode: "500"

NotificationDeliveryStatusCallbackResource:
Type: AWS::ApiGateway::Resource
Properties:
RestApiId: !Ref RestApiGateway
ParentId: !GetAtt RestApiGateway.RootResourceId
PathPart: notification-delivery-status-callback

StatusLambdaMethodResource:
Type: AWS::ApiGateway::Resource
Properties:
Expand Down Expand Up @@ -516,7 +550,7 @@ Resources:
# if you add a new endpoint, then change the name of this resource
# also need to change it in RestApiGatewayStage.Properties.DeploymentId
# *********************************************************************
RestApiGatewayDeploymentV1f:
RestApiGatewayDeploymentV2f:
Type: AWS::ApiGateway::Deployment
DependsOn:
# see note above if you add something in here when you add a new endpoint
Expand All @@ -525,6 +559,7 @@ Resources:
- CapabilityStatementMethod
- Format1UpdatePrescriptionStatusMethod
- CheckPrescriptionStatusUpdatesWaitCondition
- NotificationDeliveryStatusCallbackMethod
# see note above if you add something in here when you add a new endpoint
Properties:
RestApiId: !Ref RestApiGateway
Expand All @@ -533,7 +568,7 @@ Resources:
Type: AWS::ApiGateway::Stage
Properties:
RestApiId: !Ref RestApiGateway
DeploymentId: !Ref RestApiGatewayDeploymentV1f
DeploymentId: !Ref RestApiGatewayDeploymentV2f
StageName: prod
TracingEnabled: true
AccessLogSetting:
Expand All @@ -557,6 +592,7 @@ Resources:
- - Fn::ImportValue: !Sub ${StackName}:state-machines:${UpdatePrescriptionStatusStateMachineName}:ExecuteStateMachinePolicy
- Fn::ImportValue: !Sub ${StackName}:functions:${StatusFunctionName}:ExecuteLambdaPolicyArn
- Fn::ImportValue: !Sub ${StackName}:functions:${CapabilityStatementFunctionName}:ExecuteLambdaPolicyArn
- Fn::ImportValue: !Sub ${StackName}:functions:${NHSNotifyUpdateCallbackFunctionName}:ExecuteLambdaPolicyArn
- Fn::ImportValue: !Sub ${StackName}:state-machines:${Format1UpdatePrescriptionsStatusStateMachineName}:ExecuteStateMachinePolicy
- !If
- ShouldDeployCheckPrescriptionStatusUpdate
Expand Down
1 change: 1 addition & 0 deletions SAMtemplates/functions/lambda_resources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ Resources:
- !ImportValue lambda-resources:LambdaInsightsLogGroupPolicy
- !ImportValue account-resources:CloudwatchEncryptionKMSPolicyArn
- !ImportValue account-resources:LambdaDecryptSecretsKMSPolicy
- !ImportValue secrets:GetNotifySecretsManagedPolicy
- !If
- ShouldIncludeAdditionalPolicies
- !Join
Expand Down
88 changes: 69 additions & 19 deletions SAMtemplates/functions/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,18 @@ Parameters:
Type: String
Default: none

# PrescriptionNotificationStatesTableName:
# Type: String
# Default: none
PrescriptionNotificationStatesTableName:
Type: String
Default: none

NHSNotifyPrescriptionsSQSQueueUrl:
Type: String
Default: none

SQSSaltSecret:
Type: String
Default: none

EnabledSiteODSCodesParam:
Type: AWS::SSM::Parameter::Value<String>

Expand All @@ -41,7 +45,7 @@ Parameters:

BlockedSiteODSCodesParam:
Type: AWS::SSM::Parameter::Value<String>

LogLevel:
Type: String

Expand Down Expand Up @@ -69,17 +73,6 @@ Conditions:
- !Ref DeployCheckPrescriptionStatusUpdate

Resources:
SQSSaltSecret:
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been moved to the secrets/main.yaml SAM template

Type: AWS::SecretsManager::Secret
Properties:
Name: !Sub ${StackName}-SqsSalt
Description: Auto-generated salt for SQS_SALT
GenerateSecretString:
SecretStringTemplate: "{}"
GenerateStringKey: salt
PasswordLength: 32
ExcludePunctuation: true

UpdatePrescriptionStatus:
Type: AWS::Serverless::Function
Properties:
Expand Down Expand Up @@ -393,7 +386,7 @@ Resources:
Variables:
LOG_LEVEL: !Ref LogLevel
NHS_NOTIFY_PRESCRIPTIONS_SQS_QUEUE_URL: !Ref NHSNotifyPrescriptionsSQSQueueUrl
# TABLE_NAME: !Ref PrescriptionNotificationStatesTableName
TABLE_NAME: !Ref PrescriptionNotificationStatesTableName
Events:
ScheduleEvent:
Type: ScheduleV2
Expand Down Expand Up @@ -436,9 +429,58 @@ Resources:
- - Fn::ImportValue: !Sub ${StackName}-WriteNHSNotifyPrescriptionsSQSQueuePolicyArn
- Fn::ImportValue: !Sub ${StackName}-ReadNHSNotifyPrescriptionsSQSQueuePolicyArn
- Fn::ImportValue: !Sub ${StackName}-UseNotificationSQSQueueKMSKeyPolicyArn
# - Fn::ImportValue: !Sub ${StackName}:tables:${PrescriptionNotificationStatesTableName}:TableReadPolicyArn
# - Fn::ImportValue: !Sub ${StackName}:tables:${PrescriptionNotificationStatesTableName}:TableWritePolicyArn
# - Fn::ImportValue: !Sub ${StackName}:tables:UsePrescriptionNotificationStatesKMSKeyPolicyArn
- Fn::ImportValue: !Sub ${StackName}:tables:${PrescriptionNotificationStatesTableName}:TableReadPolicyArn
- Fn::ImportValue: !Sub ${StackName}:tables:${PrescriptionNotificationStatesTableName}:TableWritePolicyArn
- Fn::ImportValue: !Sub ${StackName}:tables:UsePrescriptionNotificationStatesKMSKeyPolicyArn

NHSNotifyUpdateCallback:
Type: AWS::Serverless::Function
Properties:
FunctionName: !Sub ${StackName}-NHSNotifyUpdateCallback
CodeUri: ../../packages/
Handler: lambdaHandler.handler
Role: !GetAtt NHSNotifyUpdateCallbackResources.Outputs.LambdaRoleArn
Environment:
Variables:
LOG_LEVEL: !Ref LogLevel
TABLE_NAME: !Ref PrescriptionNotificationStatesTableName
APP_NAME_SECRET: secrets-PSU-Notify-Application-Name
API_KEY_SECRET: secrets-PSU-Notify-API-Key
Metadata:
BuildMethod: esbuild
guard:
SuppressedRules:
- LAMBDA_DLQ_CHECK
- LAMBDA_INSIDE_VPC
- LAMBDA_CONCURRENCY_CHECK
BuildProperties:
Minify: true
Target: es2020
Sourcemap: true
tsconfig: nhsNotifyUpdateCallback/tsconfig.json
packages: bundle
EntryPoints:
- nhsNotifyUpdateCallback/src/lambdaHandler.ts

NHSNotifyUpdateCallbackResources:
Type: AWS::Serverless::Application
Properties:
Location: lambda_resources.yaml
Parameters:
StackName: !Ref StackName
LambdaName: !Sub ${StackName}-NHSNotifyUpdateCallback
LambdaArn: !Sub arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${StackName}-NHSNotifyUpdateCallback
IncludeAdditionalPolicies: true
AdditionalPolicies: !Join
- ","
- - Fn::ImportValue: !Sub ${StackName}:tables:${PrescriptionNotificationStatesTableName}:TableReadPolicyArn
- Fn::ImportValue: !Sub ${StackName}:tables:${PrescriptionNotificationStatesTableName}:TableWritePolicyArn
- Fn::ImportValue: !Sub ${StackName}:tables:UsePrescriptionNotificationStatesKMSKeyPolicyArn
LogRetentionInDays: !Ref LogRetentionInDays
CloudWatchKMSKeyId: !ImportValue account-resources:CloudwatchLogsKmsKeyArn
EnableSplunk: !Ref EnableSplunk
SplunkSubscriptionFilterRole: !ImportValue lambda-resources:SplunkSubscriptionFilterRole
SplunkDeliveryStreamArn: !ImportValue lambda-resources:SplunkDeliveryStream

Outputs:
UpdatePrescriptionStatusFunctionName:
Expand Down Expand Up @@ -506,3 +548,11 @@ Outputs:
NotifyProcessorFunctionArn:
Description: The function ARN of the NHS Notify lambda
Value: !GetAtt NotifyProcessor.Arn

NHSNotifyUpdateCallbackFunctionName:
Description: The function name of the NHSNotifyUpdateCallback lambda
Value: !Ref NHSNotifyUpdateCallback

NHSNotifyUpdateCallbackFunctionArn:
Description: The function ARN of the NHSNotifyUpdateCallback lambda
Value: !GetAtt NHSNotifyUpdateCallback.Arn
12 changes: 11 additions & 1 deletion SAMtemplates/main_template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ Parameters:
Type: String

Resources:
Secrets:
Type: AWS::Serverless::Application
Properties:
Location: secrets/main.yaml
Parameters:
StackName: !Ref AWS::StackName

Parameters:
Type: AWS::Serverless::Application
Properties:
Expand Down Expand Up @@ -131,6 +138,8 @@ Resources:
CapabilityStatementFunctionArn: !GetAtt Functions.Outputs.CapabilityStatementFunctionArn
CheckPrescriptionStatusUpdatesFunctionName: !GetAtt Functions.Outputs.CheckPrescriptionStatusUpdatesFunctionName
CheckPrescriptionStatusUpdatesFunctionArn: !GetAtt Functions.Outputs.CheckPrescriptionStatusUpdatesFunctionArn
NHSNotifyUpdateCallbackFunctionName: !GetAtt Functions.Outputs.NHSNotifyUpdateCallbackFunctionName
NHSNotifyUpdateCallbackFunctionArn: !GetAtt Functions.Outputs.NHSNotifyUpdateCallbackFunctionArn
LogRetentionInDays: !Ref LogRetentionInDays
EnableSplunk: !Ref EnableSplunk
DeployCheckPrescriptionStatusUpdate: !Ref DeployCheckPrescriptionStatusUpdate
Expand All @@ -142,8 +151,9 @@ Resources:
Parameters:
StackName: !Ref AWS::StackName
PrescriptionStatusUpdatesTableName: !GetAtt Tables.Outputs.PrescriptionStatusUpdatesTableName
# PrescriptionNotificationStatesTableName: !GetAtt Tables.Outputs.PrescriptionNotificationStatesTableName
PrescriptionNotificationStatesTableName: !GetAtt Tables.Outputs.PrescriptionNotificationStatesTableName
NHSNotifyPrescriptionsSQSQueueUrl: !GetAtt Messaging.Outputs.NHSNotifyPrescriptionsSQSQueueUrl
SQSSaltSecret: !GetAtt Secrets.Outputs.SQSSaltSecret
EnabledSiteODSCodesParam: !GetAtt Parameters.Outputs.EnabledSiteODSCodesParameterName
EnabledSystemsParam: !GetAtt Parameters.Outputs.EnabledSystemsParameterName
BlockedSiteODSCodesParam: !GetAtt Parameters.Outputs.BlockedSiteODSCodesParameterName
Expand Down
4 changes: 2 additions & 2 deletions SAMtemplates/parameters/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ Resources:
Value: !If
- IsProd
- > # Prod notification disabled
A83008
B3J1Z
- > # Non-prod
A83008
B3J1Z

Outputs:
EnabledSiteODSCodesParameterName:
Expand Down
25 changes: 25 additions & 0 deletions SAMtemplates/secrets/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
AWSTemplateFormatVersion: "2010-09-09"

Parameters:
StackName:
Type: String
Default: none

Resources:
SQSSaltSecret:
Type: AWS::SecretsManager::Secret
Properties:
Name: !Sub ${StackName}-SqsSaltSecret
Description: Auto-generated salt for SQS_SALT
GenerateSecretString:
SecretStringTemplate: "{}"
GenerateStringKey: salt
PasswordLength: 32
ExcludePunctuation: true

Outputs:
SQSSaltSecret:
Description: The ARN of the randomly generated SQS salt
Value: !Ref SQSSaltSecret
Export:
Name: !Join [":", [!Ref "StackName", "SQSSaltSecret"]]
2 changes: 1 addition & 1 deletion SAMtemplates/tables/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ Resources:
- !Ref "AWS::NoValue"
KeySchema:
- AttributeName: NHSNumber
KeyType: HASH # Partition key!
KeyType: HASH # Partition key
- AttributeName: ODSCode
KeyType: RANGE # Sort key
BillingMode: !If
Expand Down
Loading