1.0.0 • Published 6 years ago

@repit/lambda-ip v1.0.0

Weekly downloads
1
License
MIT
Repository
-
Last release
6 years ago

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 --save

Usage

'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

1.0.0

6 years ago

0.0.1

7 years ago