Skip to content

sourceIP missing with ALB? #331

Closed
Closed
@alsonkemp

Description

@alsonkemp

We've got a fairly generic ALB -> Lambda config and are seeing the following issue. sourceIp is not defined on event.requestContext.identity (or rather identity is not defined).

{
    "errorType": "Runtime.UnhandledPromiseRejection",
    "errorMessage": "TypeError: Cannot read property 'sourceIp' of undefined",
    "reason": {
        "errorType": "TypeError",
        "errorMessage": "Cannot read property 'sourceIp' of undefined",
        "stack": [
            "TypeError: Cannot read property 'sourceIp' of undefined",
            "    at getRequestValuesFromEvent (/var/task/api/_dist/node_modules/@vendia/serverless-express/src/event-sources/utils.js:52:50)",

Usage is as follows (app is in a Promise so we need to await it and then proxy it?):

module.exports.handler = async (event, context, callback): Promise<any> => {
    console.debug('index.handler: running');
    console.debug(` event: ${util.inspect(event)}`);
    console.debug(` context: ${util.inspect(context)}`);

    // Start a server (if one doesn't exist), then memoize it.
    if (!_server) {
        console.debug('index.handler: creating AWSServerlessExpress');
        const app = await __setup();
        _server = configure({ app, binaryMimeTypes });
        dog_log('api', 'boot', 'complete');
    }

    return _server.proxy({ event, context, callback });
};

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions