I need to enable Custom Access Logging in API Gateway. The cloudformation is written in yaml. But for the format of the custom logs it is in json, xml such formats but nothing is mentioned how to set format of access log in yaml. Does anyone knows how to do it?
Asked
Active
Viewed 283 times
1 Answers
0
From the CloudFormation user guide, the Format
attribute requires your input to be String
.
DestinationArn: String
Format: String
For example:
DestinationArn: !Sub ${ApiAccessLogGroup.Arn}
Format: "{ 'requestId':'$context.requestId', 'ip': '$context.identity.sourceIp', 'caller':'$context.identity.caller', 'user':'$context.identity.user','requestTime':'$context.requestTime', 'xrayTraceId':'$context.xrayTraceId', 'wafResponseCode':'$context.wafResponseCode', 'httpMethod':'$context.httpMethod','resourcePath':'$context.resourcePath', 'status':'$context.status','protocol':'$context.protocol', 'responseLength':'$context.responseLength' }"
To simplify your String
or make it looks better, please use !Sub
as this post.

Binh Nguyen
- 1,891
- 10
- 17