@repit/lambda-ip
v1.0.0
Published
Determine IP address of the client in AWS Lambda.
Readme
AWS Lambda IP
Determine IP address of the client in AWS Lambda.
Requirements
There are several requirements in order to be able to determine the IP address:
- You should use API Gateway.
- Integration Type should be Lambda Function.
- Use Lambda Proxy Integration should be enabled.
Installation
$ npm install @repit/lambda-ip --saveUsage
'use strict'
const ip = require('@repit/lambda-ip')
module.handler = (event, context, callback) => {
callback(null, {
statusCode: 200,
body: JSON.stringify({
ip: ip(event)
})
})
}Returned Values
Possible return values are:
- A valid public IPv4 address.
- A valid public IPv6 address.
null.
Security
In the modern web, it is very likely that a request to your app will hit at least one proxy before your code will be executed and it is almost impossible to be 100% sure that we get the real IP address of the client as at any moment headers may be spoofed, but we do as much as we can to determine a valid public IP address, which is probably the real IP address of the client.
License
MIT
