Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update: [AEA-4176] - add check prescription status endpoint to PTL environment #401

Merged
merged 49 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
3112395
add get prescription status endpoint to oas
anthony-nhs Jun 18, 2024
dd2e55c
infra setup
anthony-nhs Jun 18, 2024
13c3d6d
working lambda
anthony-nhs Jun 19, 2024
60ae28a
correct logic
anthony-nhs Jun 19, 2024
daa19a1
refactor 1
anthony-nhs Jun 19, 2024
0bb688b
refactor 2
anthony-nhs Jun 19, 2024
1b996f1
refactor 2
anthony-nhs Jun 19, 2024
25836e5
add common error handler
anthony-nhs Jun 19, 2024
27df8bc
add common error handler
anthony-nhs Jun 19, 2024
0777e69
add more coverage
anthony-nhs Jun 19, 2024
b67992d
Merge remote-tracking branch 'origin/main' into return_info
anthony-nhs Jun 19, 2024
0cdc02f
Merge branch 'main' into return_info
anthony-nhs Jun 19, 2024
dc1c776
add back in missing code
anthony-nhs Jun 19, 2024
f3a80b7
remove unneeded .eslintrc
anthony-nhs Jun 19, 2024
8501c67
refactor to use a type
anthony-nhs Jun 19, 2024
27414c7
Merge remote-tracking branch 'origin/main' into return_info
anthony-nhs Jun 20, 2024
f4e707d
merge
anthony-nhs Jun 24, 2024
c4294e7
Merge remote-tracking branch 'origin/main' into return_info
anthony-nhs Jun 24, 2024
331a8b7
update apigateway deployment
anthony-nhs Jun 24, 2024
2fc933c
Merge branch 'main' into return_info
anthony-nhs Jun 24, 2024
454d1f2
use redocly
anthony-nhs Jun 24, 2024
2e436d8
Merge branch 'main' into return_info
anthony-nhs Jun 24, 2024
71d3289
update deps
anthony-nhs Jun 24, 2024
4410667
Merge remote-tracking branch 'origin/main' into return_info
anthony-nhs Jun 24, 2024
a7b682a
param to decide if deploy check prescription status update endpoint
anthony-nhs Jun 25, 2024
eece065
Merge remote-tracking branch 'origin/main' into return_info
anthony-nhs Jun 25, 2024
ef213df
update
anthony-nhs Jun 25, 2024
6a685f3
fix deploy script
anthony-nhs Jun 25, 2024
0c3e131
do not deploy check psu
anthony-nhs Jun 25, 2024
87a9a20
deploy to pr
anthony-nhs Jun 25, 2024
adb9fee
Merge branch 'main' into return_info
anthony-nhs Jun 26, 2024
f6e5be2
Merge remote-tracking branch 'origin/main' into return_info
anthony-nhs Jun 26, 2024
68e9c42
Merge remote-tracking branch 'origin/main' into return_info
anthony-nhs Jul 3, 2024
b89aae5
new oas
anthony-nhs Jul 3, 2024
79f3b31
refactor
anthony-nhs Jul 3, 2024
a767bf6
fix makefile
anthony-nhs Jul 3, 2024
61060e3
correct sandbox
anthony-nhs Jul 3, 2024
c108dd1
Merge remote-tracking branch 'origin/main' into return_info
anthony-nhs Jul 3, 2024
0066211
update versions
anthony-nhs Jul 3, 2024
184a924
Merge branch 'main' into return_info
anthony-nhs Jul 3, 2024
4e281cf
refactor to avoid duplication
anthony-nhs Jul 3, 2024
21915ab
update postman
anthony-nhs Jul 3, 2024
8fd99cf
do not deploy check prescription status udpate if not needed
anthony-nhs Jul 3, 2024
1bbf7f6
correct comment
anthony-nhs Jul 3, 2024
23a7e13
remove depends on
anthony-nhs Jul 3, 2024
7796e03
test no endpoint
anthony-nhs Jul 3, 2024
12842cb
string output
anthony-nhs Jul 3, 2024
901c83c
revert test no endpoint
anthony-nhs Jul 3, 2024
11ed8f5
work around dependson limitation
anthony-nhs Jul 3, 2024
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
9 changes: 9 additions & 0 deletions .github/scripts/deploy_api.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ echo "AWS environment: ${AWS_ENVIRONMENT}"
echo "Apigee environment: ${APIGEE_ENVIRONMENT}"
echo "Proxygen private key name: ${PROXYGEN_PRIVATE_KEY_NAME}"
echo "Proxygen KID: ${PROXYGEN_KID}"
echo "Deploy Check Prescription Status Update: ${DEPLOY_CHECK_PRESCRIPTION_STATUS_UPDATE}"
echo "Dry run: ${DRY_RUN}"

is_pull_request=false
Expand Down Expand Up @@ -71,6 +72,14 @@ 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
fi
# remove checkprescriptionstatusupdates if its not needed
if [[ "${DEPLOY_CHECK_PRESCRIPTION_STATUS_UPDATE}" == "false" ]]; then
if [[ "${API_TYPE}" == "standard" ]]; then
echo "Removing checkprescriptionstatusupdates endpoint"
jq 'del(.paths."/checkprescriptionstatusupdates")' "$SPEC_PATH" > temp.json && mv temp.json "$SPEC_PATH"
fi
fi


echo

Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ jobs:
DEPLOY_APIGEE: true
DYNAMODB_AUTOSCALE: false
DEPLOY_APIGEE_CPSU: true
DEPLOY_CHECK_PRESCRIPTION_STATUS_UPDATE: true
secrets:
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.DEV_CLOUD_FORMATION_DEPLOY_ROLE }}
DEV_CLOUD_FORMATION_CHECK_VERSION_ROLE: ${{ secrets.DEV_CLOUD_FORMATION_CHECK_VERSION_ROLE }}
Expand All @@ -135,6 +136,7 @@ jobs:
DEPLOY_APIGEE: true
DYNAMODB_AUTOSCALE: false
DEPLOY_APIGEE_CPSU: true
DEPLOY_CHECK_PRESCRIPTION_STATUS_UPDATE: true
secrets:
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.DEV_CLOUD_FORMATION_DEPLOY_ROLE }}

Expand All @@ -155,5 +157,6 @@ jobs:
DEPLOY_APIGEE: true
DYNAMODB_AUTOSCALE: false
DEPLOY_APIGEE_CPSU: true
DEPLOY_CHECK_PRESCRIPTION_STATUS_UPDATE: true
secrets:
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.QA_CLOUD_FORMATION_DEPLOY_ROLE }}
2 changes: 2 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ jobs:
DEPLOY_APIGEE: true
DYNAMODB_AUTOSCALE: false
DEPLOY_APIGEE_CPSU: true
DEPLOY_CHECK_PRESCRIPTION_STATUS_UPDATE: true
secrets:
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.DEV_CLOUD_FORMATION_DEPLOY_ROLE }}

Expand All @@ -94,5 +95,6 @@ jobs:
DEPLOY_APIGEE: true
DYNAMODB_AUTOSCALE: false
DEPLOY_APIGEE_CPSU: true
DEPLOY_CHECK_PRESCRIPTION_STATUS_UPDATE: true
secrets:
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.DEV_CLOUD_FORMATION_DEPLOY_ROLE }}
7 changes: 7 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ jobs:
DEPLOY_APIGEE: true
DYNAMODB_AUTOSCALE: false
DEPLOY_APIGEE_CPSU: true
DEPLOY_CHECK_PRESCRIPTION_STATUS_UPDATE: true
secrets:
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.DEV_CLOUD_FORMATION_DEPLOY_ROLE }}
DEV_CLOUD_FORMATION_CHECK_VERSION_ROLE: ${{ secrets.DEV_CLOUD_FORMATION_CHECK_VERSION_ROLE }}
Expand All @@ -154,6 +155,7 @@ jobs:
DEPLOY_APIGEE: true
DYNAMODB_AUTOSCALE: false
DEPLOY_APIGEE_CPSU: true
DEPLOY_CHECK_PRESCRIPTION_STATUS_UPDATE: true
secrets:
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.DEV_CLOUD_FORMATION_DEPLOY_ROLE }}

Expand Down Expand Up @@ -182,6 +184,7 @@ jobs:
DEPLOY_APIGEE: true
DYNAMODB_AUTOSCALE: true
DEPLOY_APIGEE_CPSU: true
DEPLOY_CHECK_PRESCRIPTION_STATUS_UPDATE: true
secrets:
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.REF_CLOUD_FORMATION_DEPLOY_ROLE }}

Expand Down Expand Up @@ -210,6 +213,7 @@ jobs:
DEPLOY_APIGEE: true
DYNAMODB_AUTOSCALE: false
DEPLOY_APIGEE_CPSU: true
DEPLOY_CHECK_PRESCRIPTION_STATUS_UPDATE: true
secrets:
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.QA_CLOUD_FORMATION_DEPLOY_ROLE }}

Expand All @@ -233,6 +237,7 @@ jobs:
DEPLOY_APIGEE: true
DYNAMODB_AUTOSCALE: false
DEPLOY_APIGEE_CPSU: true
DEPLOY_CHECK_PRESCRIPTION_STATUS_UPDATE: true
secrets:
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.INT_CLOUD_FORMATION_DEPLOY_ROLE }}
DEV_CLOUD_FORMATION_CHECK_VERSION_ROLE: ${{ secrets.DEV_CLOUD_FORMATION_CHECK_VERSION_ROLE }}
Expand All @@ -257,6 +262,7 @@ jobs:
DEPLOY_APIGEE: true
DYNAMODB_AUTOSCALE: false
DEPLOY_APIGEE_CPSU: true
DEPLOY_CHECK_PRESCRIPTION_STATUS_UPDATE: true
secrets:
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.INT_CLOUD_FORMATION_DEPLOY_ROLE }}

Expand Down Expand Up @@ -287,6 +293,7 @@ jobs:
DEPLOY_APIGEE: false
DYNAMODB_AUTOSCALE: true
DEPLOY_APIGEE_CPSU: false
DEPLOY_CHECK_PRESCRIPTION_STATUS_UPDATE: false
secrets:
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.PROD_CLOUD_FORMATION_DEPLOY_ROLE }}
DEV_CLOUD_FORMATION_CHECK_VERSION_ROLE: ${{ secrets.DEV_CLOUD_FORMATION_CHECK_VERSION_ROLE }}
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/run_release_code_and_api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ on:
DEPLOY_APIGEE_CPSU:
type: boolean
default: true
DEPLOY_CHECK_PRESCRIPTION_STATUS_UPDATE:
type: boolean
default: false
secrets:
CLOUD_FORMATION_DEPLOY_ROLE:
required: true
Expand Down Expand Up @@ -174,6 +177,7 @@ jobs:
TRUSTSTORE_FILE: ${{ inputs.TRUSTSTORE_FILE }}
VERSION_NUMBER: ${{ inputs.VERSION_NUMBER }}
DYNAMODB_AUTOSCALE: ${{ inputs.DYNAMODB_AUTOSCALE }}
DEPLOY_CHECK_PRESCRIPTION_STATUS_UPDATE: ${{ inputs.DEPLOY_CHECK_PRESCRIPTION_STATUS_UPDATE }}
run: ./release_code.sh

- name: Deploy PSU API
Expand All @@ -191,6 +195,7 @@ jobs:
PROXYGEN_PRIVATE_KEY_NAME: PSUProxygenPrivateKey
PROXYGEN_KID: "eps-cli-key-1"
DRY_RUN: false
DEPLOY_CHECK_PRESCRIPTION_STATUS_UPDATE: ${{ inputs.DEPLOY_CHECK_PRESCRIPTION_STATUS_UPDATE }}
run: poetry run ./deploy_api.sh

- name: Deploy CPSU API
Expand All @@ -208,6 +213,7 @@ jobs:
PROXYGEN_PRIVATE_KEY_NAME: CPSUProxygenPrivateKey
PROXYGEN_KID: eps-cli-key-cpsu-1
DRY_RUN: false
DEPLOY_CHECK_PRESCRIPTION_STATUS_UPDATE: ${{ inputs.DEPLOY_CHECK_PRESCRIPTION_STATUS_UPDATE }}
run: poetry run ./deploy_api.sh

- name: create_int_release_notes
Expand Down
10 changes: 10 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,16 @@ repos:
types_or: [ts, tsx, javascript, jsx, json]
pass_filenames: false

- id: lint-checkPrescriptionStatusUpdates
name: Lint checkPrescriptionStatusUpdates
entry: npm
args:
["run", "--prefix=packages/checkPrescriptionStatusUpdates", "lint"]
language: system
files: ^packages\/checkPrescriptionStatusUpdates
types_or: [ts, tsx, javascript, jsx, json]
pass_filenames: false

- id: lint-commonTesting
name: Lint common/testing
entry: npm
Expand Down
4 changes: 4 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/capabilityStatement",
"path": "../packages/capabilityStatement"
},
{
"name": "packages/checkPrescriptionStatusUpdates",
"path": "../packages/checkPrescriptionStatusUpdates"
},
{
"name": "packages/common/testing",
"path": "../packages/common/testing"
Expand Down
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ sam-deploy-package: guard-artifact_bucket guard-artifact_bucket_prefix guard-sta
CommitId=$$COMMIT_ID \
LogLevel=$$LOG_LEVEL \
LogRetentionInDays=$$LOG_RETENTION_DAYS \
Env=$$TARGET_ENVIRONMENT
Env=$$TARGET_ENVIRONMENT \
DeployCheckPrescriptionStatusUpdate=$$DEPLOY_CHECK_PRESCRIPTION_STATUS_UPDATE

compile-node:
npx tsc --build tsconfig.build.json
Expand All @@ -107,6 +108,7 @@ lint-node: compile-node
npm run lint --workspace packages/statusLambda
npm run lint --workspace packages/capabilityStatement
npm run lint --workspace packages/cpsuLambda
npm run lint --workspace packages/checkPrescriptionStatusUpdates
npm run lint --workspace packages/common/testing
npm run lint --workspace packages/common/middyErrorHandler

Expand Down Expand Up @@ -134,6 +136,7 @@ test: compile
npm run test --workspace packages/statusLambda
npm run test --workspace packages/capabilityStatement
npm run test --workspace packages/cpsuLambda
npm run test --workspace packages/checkPrescriptionStatusUpdates
npm run test --workspace packages/common/middyErrorHandler

clean:
Expand All @@ -149,6 +152,7 @@ clean:
rm -rf packages/capabilityStatement/lib
rm -rf packages/cpsuLambda/coverage
rm -rf packages/cpsuLambda/lib
rm -rf packages/checkPrescriptionStatusUpdates/lib
rm -rf packages/common/testing/lib
rm -rf packages/common/middyErrorHandler/lib
rm -rf .aws-sam
Expand Down
69 changes: 67 additions & 2 deletions SAMtemplates/apis/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,30 @@ Parameters:
Type: String
Default: none

CheckPrescriptionStatusUpdatesFunctionName:
Type: String
Default: none

CheckPrescriptionStatusUpdatesFunctionArn:
Type: String
Default: none

LogRetentionInDays:
Type: Number

EnableSplunk:
Type: String

DeployCheckPrescriptionStatusUpdate:
Type: String

Conditions:
ShouldUseMutualTLS: !Equals
- true
- !Ref EnableMutualTLS
ShouldDeployCheckPrescriptionStatusUpdate: !Equals
- true
- !Ref DeployCheckPrescriptionStatusUpdate

Resources:
GenerateCertificate:
Expand Down Expand Up @@ -453,18 +467,64 @@ Resources:
IntegrationHttpMethod: POST
Uri: !Sub arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${CapabilityStatementFunctionArn}/invocations

CheckPrescriptionStatusUpdatesResource:
Condition: ShouldDeployCheckPrescriptionStatusUpdate
Type: AWS::ApiGateway::Resource
Properties:
RestApiId: !Ref RestApiGateway
ParentId: !GetAtt RestApiGateway.RootResourceId
PathPart: checkprescriptionstatusupdates

CheckPrescriptionStatusUpdatesMethod:
Condition: ShouldDeployCheckPrescriptionStatusUpdate
Type: AWS::ApiGateway::Method
Properties:
RestApiId: !Ref RestApiGateway
ResourceId: !Ref CheckPrescriptionStatusUpdatesResource
HttpMethod: GET
AuthorizationType: NONE
Integration:
Type: AWS_PROXY
Credentials: !GetAtt RestApiGatewayResources.Outputs.ApiGwRoleArn
IntegrationHttpMethod: POST
Uri: !Sub arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${CheckPrescriptionStatusUpdatesFunctionArn}/invocations

# we can not use a conditional in depends on in ApiGateway::Deployment
# so instead we use a wait condition that has the conditional in it and use that as a dependency
# taken from https://garbe.io/blog/2017/07/17/cloudformation-hacks/
CheckPrescriptionStatusUpdatesHandle:
Condition: ShouldDeployCheckPrescriptionStatusUpdate
DependsOn: CheckPrescriptionStatusUpdatesMethod
Type: "AWS::CloudFormation::WaitConditionHandle"

CheckPrescriptionStatusUpdatesWaitHandle:
Type: "AWS::CloudFormation::WaitConditionHandle"

CheckPrescriptionStatusUpdatesWaitCondition:
Type: "AWS::CloudFormation::WaitCondition"
Properties:
Handle:
!If [
ShouldDeployCheckPrescriptionStatusUpdate,
!Ref CheckPrescriptionStatusUpdatesHandle,
!Ref CheckPrescriptionStatusUpdatesWaitHandle,
]
Timeout: "1"
Count: 0

# *********************************************************************
# if you add a new endpoint, then change the name of this resource
# also need to change it in RestApiGatewayStage.Properties.DeploymentId
# *********************************************************************
RestApiGatewayDeploymentV1d:
RestApiGatewayDeploymentV1e:
Type: AWS::ApiGateway::Deployment
DependsOn:
# see note above if you add something in here when you add a new endpoint
- UpdatePrescriptionStatusMethod
- StatusLambdaMethod
- CapabilityStatementMethod
- Format1UpdatePrescriptionStatusMethod
- CheckPrescriptionStatusUpdatesWaitCondition
# see note above if you add something in here when you add a new endpoint
Properties:
RestApiId: !Ref RestApiGateway
Expand All @@ -473,7 +533,7 @@ Resources:
Type: AWS::ApiGateway::Stage
Properties:
RestApiId: !Ref RestApiGateway
DeploymentId: !Ref RestApiGatewayDeploymentV1d
DeploymentId: !Ref RestApiGatewayDeploymentV1e
StageName: prod
TracingEnabled: true
AccessLogSetting:
Expand All @@ -498,6 +558,11 @@ Resources:
- Fn::ImportValue: !Sub ${StackName}:functions:${StatusFunctionName}:ExecuteLambdaPolicyArn
- Fn::ImportValue: !Sub ${StackName}:functions:${CapabilityStatementFunctionName}:ExecuteLambdaPolicyArn
- Fn::ImportValue: !Sub ${StackName}:state-machines:${Format1UpdatePrescriptionsStatusStateMachineName}:ExecuteStateMachinePolicy
- !If
- ShouldDeployCheckPrescriptionStatusUpdate
- Fn::ImportValue: !Sub ${StackName}:functions:${CheckPrescriptionStatusUpdatesFunctionName}:ExecuteLambdaPolicyArn
- !Ref AWS::NoValue

ApiName: !Sub ${StackName}-apigw
LogRetentionInDays: !Ref LogRetentionInDays
EnableSplunk: !Ref EnableSplunk
Loading