API Gateway - HTTP API CloudWatch Log Variables

0

Hi, I've build an architecture like below; Enter image description here

As you can see in the architecture, I can successfully return the PrincipalId value via Lambda Authorizer. However, according to the guidance in CloudWatch documentation, I cannot access the principalId value on logs with $context.authorizer.principalId. It comes as "-" continuously. How can I get this data?

Thanks.

2回答
0

Make sure that the IAM role associated with your API Gateway has permissions to write to CloudWatch Logs (e.g., the logs:CreateLogGroup, logs:CreateLogStream, and logs:PutLogEvents actions

profile picture
エキスパート
回答済み 2ヶ月前
0

Thanks, When I check through IAM, I see that I have the necessary permissions. Logs are below. Only principalId field always "-".

{
    "requestId": "U_wSVhG4l*******",
    "ip": "85.***.**.**",
    "requestTime": "21/Mar/2024:20:09:50 +0000",
    "httpMethod": "GET",
    "routeKey": "ANY /{proxy+}",
    "status": "200",
    "protocol": "HTTP/1.1",
    "responseLength": "87",
    "path": "/***/***/***",
    "reqLatency": "107 ms",
    "resLatency": "109 ms",
    "userAgent": "***",
    "principalId": "-"
}
Ugur
回答済み 2ヶ月前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ