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달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인