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
Here is a simple demonstration of using API Gateway's $context.identity.sourceIp in a Lambda function.
API Mapping template:
{
"sourceIP" : "$context.identity.sourceIp"
}
Lambda function:
'use strict';
console.log('Loading function');
exports.handler = (event, context, callback) => {
console.log('SourceIP =', event.identity.sourceIP);
callback(null, event.identity.sourceIP);
};