Monday, 17 December 2018

private and public ip using AWS api gateway + lambda + Nodejs

I am trying to get the users private IP and public IP in an AWS environment. Based on this answer (https://stackoverflow.com/a/46021715/4283738) there should be a header X-Forwarded-For , separated ips and also from forum (https://forums.aws.amazon.com/thread.jspa?threadID=200198)

But when I have deployed my api via API Gateway + lambda + nodejs v8. I have consoled out the JSON for event and context varaibles for the nodejs handler function arguments for debugging (https://y0gh8upq9d.execute-api.ap-south-1.amazonaws.com/prod) I am not getting the private ips.

The lambda function is

const AWS = require('aws-sdk');
exports.handler = function(event, context, callback){
    callback(null, {
        "statusCode": 200,
        "body": JSON.stringify({event,context})
    });
}

API Gateway Details

GET - Integration Request

Integration type -- Lambda Function

Use Lambda Proxy integration -- True

Function API : https://y0gh8upq9d.execute-api.ap-south-1.amazonaws.com/prod



from private and public ip using AWS api gateway + lambda + Nodejs

No comments:

Post a Comment