Skip to content

Commit fd42022

Browse files
access logs using jsoncode
1 parent 58a54f2 commit fd42022

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

infrastructure/stacks/api-layer/api_gateway.tf

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,23 @@ resource "aws_api_gateway_stage" "eligibility-signposting-api" {
5656
# A subscription filter (see csoc_log_forwarding.tf) forwards these logs to CSOC
5757
access_log_settings {
5858
destination_arn = module.eligibility_signposting_api_gateway.cloudwatch_destination_arn
59-
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\" }"
59+
format = jsonencode({
60+
requestId = "$context.requestId"
61+
ip = "$context.identity.sourceIp"
62+
caller = "$context.identity.caller"
63+
user = "$context.identity.user"
64+
requestTime = "$context.requestTime"
65+
httpMethod = "$context.httpMethod"
66+
resourcePath = "$context.resourcePath"
67+
status = "$context.status"
68+
protocol = "$context.protocol"
69+
responseLength = "$context.responseLength"
70+
accountId = "$context.accountId"
71+
apiId = "$context.apiId"
72+
stage = "$context.stage"
73+
api_key = "$context.identity.apiKey"
74+
nhse_product_id = "$context.request.header.nhse-product-id"
75+
})
6076
}
6177

6278
depends_on = [

0 commit comments

Comments
 (0)