Skip to content

Commit d76ad65

Browse files
authored
Fix: [AEA-5895] - forward apigw logs to csoc (#2316)
## Summary - Routine Change ### Details - forward apigw logs to csoc
1 parent 31f4c9e commit d76ad65

File tree

8 files changed

+48
-4
lines changed

8 files changed

+48
-4
lines changed

.github/scripts/release_code.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,5 @@ sam deploy \
7171
NotifyRoutingPlanIDValue="$NOTIFY_ROUTING_PLAN_ID" \
7272
NotifyAPIBaseURLValue="$NOTIFY_API_BASE_URL" \
7373
RequireApplicationName="$REQUIRE_APPLICATION_NAME" \
74-
EnableBackup="$ENABLE_BACKUP"
74+
EnableBackup="$ENABLE_BACKUP" \
75+
ForwardCsocLogs="$FORWARD_CSOC_LOGS"

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ jobs:
9090
NOTIFY_API_BASE_URL: "https://int.api.service.nhs.uk"
9191
MTLS_KEY: psu-mtls-1
9292
IS_PULL_REQUEST: false
93+
FORWARD_CSOC_LOGS: false
9394
secrets:
9495
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.DEV_CLOUD_FORMATION_DEPLOY_ROLE }}
9596
DEV_CLOUD_FORMATION_CHECK_VERSION_ROLE: ${{ secrets.DEV_CLOUD_FORMATION_CHECK_VERSION_ROLE }}
@@ -129,6 +130,7 @@ jobs:
129130
NOTIFY_API_BASE_URL: "https://int.api.service.nhs.uk"
130131
MTLS_KEY: psu-mtls-1
131132
IS_PULL_REQUEST: false
133+
FORWARD_CSOC_LOGS: false
132134
secrets:
133135
REGRESSION_TESTS_PEM: ${{ secrets.REGRESSION_TESTS_PEM }}
134136
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.DEV_CLOUD_FORMATION_DEPLOY_ROLE }}
@@ -165,6 +167,7 @@ jobs:
165167
NOTIFY_API_BASE_URL: "https://int.api.service.nhs.uk"
166168
MTLS_KEY: psu-mtls-1
167169
IS_PULL_REQUEST: false
170+
FORWARD_CSOC_LOGS: false
168171
secrets:
169172
REGRESSION_TESTS_PEM: ${{ secrets.REGRESSION_TESTS_PEM }}
170173
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.QA_CLOUD_FORMATION_DEPLOY_ROLE }}

.github/workflows/pull_request.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ jobs:
118118
NOTIFY_API_BASE_URL: "https://int.api.service.nhs.uk"
119119
MTLS_KEY: psu-mtls-1
120120
IS_PULL_REQUEST: true
121+
FORWARD_CSOC_LOGS: false
121122
secrets:
122123
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.DEV_CLOUD_FORMATION_DEPLOY_ROLE }}
123124
PROXYGEN_ROLE: ${{ secrets.PROXYGEN_PTL_ROLE }}
@@ -152,6 +153,7 @@ jobs:
152153
NOTIFY_API_BASE_URL: "https://int.api.service.nhs.uk"
153154
MTLS_KEY: psu-mtls-1
154155
IS_PULL_REQUEST: true
156+
FORWARD_CSOC_LOGS: false
155157
secrets:
156158
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.DEV_CLOUD_FORMATION_DEPLOY_ROLE }}
157159
PROXYGEN_ROLE: ${{ secrets.PROXYGEN_PTL_ROLE }}

.github/workflows/release.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ jobs:
8989
NOTIFY_API_BASE_URL: "https://int.api.service.nhs.uk"
9090
MTLS_KEY: psu-mtls-1
9191
IS_PULL_REQUEST: false
92+
FORWARD_CSOC_LOGS: false
9293
secrets:
9394
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.DEV_CLOUD_FORMATION_DEPLOY_ROLE }}
9495
DEV_CLOUD_FORMATION_CHECK_VERSION_ROLE: ${{ secrets.DEV_CLOUD_FORMATION_CHECK_VERSION_ROLE }}
@@ -127,6 +128,7 @@ jobs:
127128
NOTIFY_API_BASE_URL: "https://int.api.service.nhs.uk"
128129
MTLS_KEY: psu-mtls-1
129130
IS_PULL_REQUEST: false
131+
FORWARD_CSOC_LOGS: false
130132
secrets:
131133
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.DEV_CLOUD_FORMATION_DEPLOY_ROLE }}
132134
PROXYGEN_ROLE: ${{ secrets.PROXYGEN_PTL_ROLE }}
@@ -170,6 +172,7 @@ jobs:
170172
NOTIFY_API_BASE_URL: "https://int.api.service.nhs.uk"
171173
MTLS_KEY: psu-mtls-1
172174
IS_PULL_REQUEST: false
175+
FORWARD_CSOC_LOGS: false
173176
secrets:
174177
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.REF_CLOUD_FORMATION_DEPLOY_ROLE }}
175178
PROXYGEN_ROLE: ${{ secrets.PROXYGEN_PTL_ROLE }}
@@ -213,6 +216,7 @@ jobs:
213216
NOTIFY_API_BASE_URL: "https://int.api.service.nhs.uk"
214217
MTLS_KEY: psu-mtls-1
215218
IS_PULL_REQUEST: false
219+
FORWARD_CSOC_LOGS: false
216220
secrets:
217221
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.QA_CLOUD_FORMATION_DEPLOY_ROLE }}
218222
PROXYGEN_ROLE: ${{ secrets.PROXYGEN_PTL_ROLE }}
@@ -251,6 +255,7 @@ jobs:
251255
NOTIFY_API_BASE_URL: "https://int.api.service.nhs.uk"
252256
MTLS_KEY: psu-mtls-1
253257
IS_PULL_REQUEST: false
258+
FORWARD_CSOC_LOGS: false
254259
secrets:
255260
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.INT_CLOUD_FORMATION_DEPLOY_ROLE }}
256261
DEV_CLOUD_FORMATION_CHECK_VERSION_ROLE: ${{ secrets.DEV_CLOUD_FORMATION_CHECK_VERSION_ROLE }}
@@ -289,6 +294,7 @@ jobs:
289294
NOTIFY_API_BASE_URL: "https://int.api.service.nhs.uk"
290295
MTLS_KEY: psu-mtls-1
291296
IS_PULL_REQUEST: false
297+
FORWARD_CSOC_LOGS: false
292298
secrets:
293299
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.INT_CLOUD_FORMATION_DEPLOY_ROLE }}
294300
PROXYGEN_ROLE: ${{ secrets.PROXYGEN_PROD_ROLE }}
@@ -334,6 +340,7 @@ jobs:
334340
NOTIFY_API_BASE_URL: "https://api.service.nhs.uk"
335341
MTLS_KEY: psu-mtls-1
336342
IS_PULL_REQUEST: false
343+
FORWARD_CSOC_LOGS: true
337344
secrets:
338345
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.PROD_CLOUD_FORMATION_DEPLOY_ROLE }}
339346
DEV_CLOUD_FORMATION_CHECK_VERSION_ROLE: ${{ secrets.DEV_CLOUD_FORMATION_CHECK_VERSION_ROLE }}

.github/workflows/run_release_code_and_api.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ on:
102102
MTLS_KEY:
103103
type: string
104104
required: true
105+
FORWARD_CSOC_LOGS:
106+
required: true
107+
type: boolean
105108
secrets:
106109
CLOUD_FORMATION_DEPLOY_ROLE:
107110
required: true
@@ -203,6 +206,7 @@ jobs:
203206
BLOCKED_SITE_ODS_CODES: ${{ inputs.BLOCKED_SITE_ODS_CODES }}
204207
NOTIFY_ROUTING_PLAN_ID: ${{ inputs.NOTIFY_ROUTING_PLAN_ID }}
205208
NOTIFY_API_BASE_URL: ${{ inputs.NOTIFY_API_BASE_URL }}
209+
FORWARD_CSOC_LOGS: ${{ inputs.FORWARD_CSOC_LOGS }}
206210
run: ./release_code.sh
207211

208212
- name: get mtls secrets

SAMtemplates/apis/api_resources.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,17 @@ Parameters:
1919
EnableSplunk:
2020
Type: String
2121

22+
ForwardCsocLogs:
23+
Type: String
24+
Default: false
25+
2226
Conditions:
2327
ShouldUseSplunk: !Equals
2428
- true
2529
- !Ref EnableSplunk
30+
ShouldForwardCsocLogs: !Equals
31+
- true
32+
- !Ref ForwardCsocLogs
2633

2734
Resources:
2835
ApiGwRole:
@@ -65,6 +72,15 @@ Resources:
6572
FilterPattern: ""
6673
DestinationArn: !ImportValue lambda-resources:SplunkDeliveryStream
6774

75+
ApiGwAccessLogsCsocSubscriptionFilter:
76+
Condition: ShouldForwardCsocLogs
77+
Type: AWS::Logs::SubscriptionFilter
78+
Properties:
79+
RoleArn: !ImportValue lambda-resources:SplunkSubscriptionFilterRole
80+
LogGroupName: !Ref ApiGwAccessLogs
81+
FilterPattern: ""
82+
DestinationArn: "arn:aws:logs:eu-west-2:693466633220:destination:api_gateway_log_destination"
83+
6884
Outputs:
6985
ApiGwRoleArn:
7086
Description: The API GW role ARN

SAMtemplates/apis/main.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Parameters:
6161
NHSNotifyUpdateCallbackFunctionArn:
6262
Type: String
6363
Default: none
64-
64+
6565
LogRetentionInDays:
6666
Type: Number
6767

@@ -71,6 +71,9 @@ Parameters:
7171
DeployCheckPrescriptionStatusUpdate:
7272
Type: String
7373

74+
ForwardCsocLogs:
75+
Type: String
76+
Default: false
7477
Conditions:
7578
ShouldUseMutualTLS: !Equals
7679
- true
@@ -573,8 +576,7 @@ Resources:
573576
TracingEnabled: true
574577
AccessLogSetting:
575578
DestinationArn: !GetAtt RestApiGatewayResources.Outputs.ApiGwAccessLogsArn
576-
Format: '{ "requestTime": "$context.requestTime", "apiId": "$context.apiId", "accountId": "$context.accountId", "resourcePath": "$context.resourcePath", "stage": "$context.stage", "requestId": "$context.requestId", "extendedRequestId": "$context.extendedRequestId", "status": "$context.status", "httpMethod": "$context.httpMethod", "protocol": "$context.protocol", "path": "$context.path", "responseLatency": "$context.responseLatency", "responseLength": "$context.responseLength", "domainName": "$context.domainName", "identity": { "sourceIp": "$context.identity.sourceIp", "userAgent": "$context.identity.userAgent", "clientCert":{ "subjectDN": "$context.identity.clientCert.subjectDN", "issuerDN": "$context.identity.clientCert.issuerDN", "serialNumber": "$context.identity.clientCert.serialNumber", "validityNotBefore": "$context.identity.clientCert.validity.notBefore", "validityNotAfter": "$context.identity.clientCert.validity.notAfter" }}, "integration":{ "error": "$context.integration.error", "integrationStatus": "$context.integration.integrationStatus", "latency": "$context.integration.latency", "requestId": "$context.integration.requestId", "status": "$context.integration.status" }}'
577-
579+
Format: '{ "requestId": "$context.requestId", "ip": "$context.identity.sourceIp", "caller":"$context.identity.caller", "user":"$context.identity.user","requestTime":"$context.requestTime", "httpMethod":"$context.httpMethod","resourcePath":"$context.resourcePath", "status":"$context.status","protocol":"$context.protocol", "responseLength":"$context.responseLength", "accountId":"$context.accountId", "apiId":"$context.apiId", "stage" : "$context.stage", "api_key" : "$context.identity.apiKey", "identity": { "sourceIp": "$context.identity.sourceIp", "userAgent": "$context.identity.userAgent", "clientCert":{ "subjectDN": "$context.identity.clientCert.subjectDN", "issuerDN": "$context.identity.clientCert.issuerDN", "serialNumber": "$context.identity.clientCert.serialNumber", "validityNotBefore": "$context.identity.clientCert.validity.notBefore", "validityNotAfter": "$context.identity.clientCert.validity.notAfter" }}, "integration":{ "error": "$context.integration.error", "integrationStatus": "$context.integration.integrationStatus", "latency": "$context.integration.latency", "requestId": "$context.integration.requestId", "status": "$context.integration.status" } }'
578580
RestApiDomainMapping:
579581
Type: AWS::ApiGateway::BasePathMapping
580582
Properties:
@@ -602,3 +604,4 @@ Resources:
602604
ApiName: !Sub ${StackName}-apigw
603605
LogRetentionInDays: !Ref LogRetentionInDays
604606
EnableSplunk: !Ref EnableSplunk
607+
ForwardCsocLogs: !Ref ForwardCsocLogs

SAMtemplates/main_template.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,13 @@ Parameters:
137137
- true
138138
- false
139139

140+
ForwardCsocLogs:
141+
Type: String
142+
Default: false
143+
AllowedValues:
144+
- true
145+
- false
146+
140147
Resources:
141148
Secrets:
142149
Type: AWS::Serverless::Application
@@ -198,6 +205,7 @@ Resources:
198205
LogRetentionInDays: !Ref LogRetentionInDays
199206
EnableSplunk: !Ref EnableSplunk
200207
DeployCheckPrescriptionStatusUpdate: !Ref DeployCheckPrescriptionStatusUpdate
208+
ForwardCsocLogs: !Ref ForwardCsocLogs
201209

202210
Functions:
203211
Type: AWS::Serverless::Application

0 commit comments

Comments
 (0)