Skip to content

Feature request: Add support for ALB integration #4758

@svozza

Description

@svozza

Use case

Currently event handler does not support the ALB lambda integration. We should add support for Application Load Balancer (ALB) events.

Solution/User Experience

The event source should be transparent to users, they should be able to define handlers that return any valid response we support (JSON object, APIGatewayProxyResult, ALBResult, Web Response object) and event handler will automatically detect the input event and convert to the appropriate response.

const app = new Router();

// this returns APIGatewayProxyResult
app.get('/test', () => ({
    statusCode: 200,
    body: JSON.stringify({ message: 'success' }),
    headers: { 'content-type': 'application/json' },
    multiValueHeaders: {
        'set-cookie': ['cookie1=value1', 'cookie2=value2']
    }
}));

const v1Result = await app.resolve(aV1Event, context);

/**
v1Result = {
    "statusCode": 200,
    "headers": {
        "content-type": "application/json",
    },
    "body": "{\"message\":\"success\"}",
    "isBase64Encoded": false,
    "multiValueHeaders": {
        "set-cookie": [
            "cookie1=value1",
            "cookie2=value2"
        ]
    }
}
 */

const albResult = await app.resolve(anALBEvent, context);

/**
albResult = {
    "statusCode": 200,
    "statusDescription": "200 OK",
    "headers": {
        "content-type": "application/json",
    },
    "body": "{\"message\":\"success\"}",
    "isBase64Encoded": false,
    "multiValueHeaders": {
        "set-cookie": [
            "cookie1=value1",
            "cookie2=value2"
        ]
    }
}
 **/

Alternative solutions

Alternative solution would be for customers to have specific resolvers for specific event sources:


const albiRouter = new AlbRouter()
// will only work with ALB events

Acknowledgment

Future readers

Please react with 👍 and your use case to help us understand customer demand.

Metadata

Metadata

Assignees

Labels

completedThis item is complete and has been merged/shippedevent-handlerThis item relates to the Event Handler Utilityfeature-requestThis item refers to a feature request for an existing or new utility

Type

No type

Projects

Status

Coming soon

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions