How can I retrieve a user's public IP address via Amazon API Gateway + Lambda (node)

前端 未结 5 1103
暗喜
暗喜 2020-12-13 05:52

I\'m currently writing a Node.js lambda function, in which I want to log the incoming requester\'s public IP address. I\'ve been looking through both the API Gateway and Lam

5条回答
  •  南笙
    南笙 (楼主)
    2020-12-13 06:46

    In the API Gateway, it's the value

    $context.identity.sourceIp
    

    http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html#context-variable-reference

    You can pass that through to your Lambda via a mapping template.

提交回复
热议问题