generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 180
Closed
Labels
completedThis item is complete and has been merged/shippedThis item is complete and has been merged/shippedevent-handlerThis item relates to the Event Handler UtilityThis item relates to the Event Handler Utilityfeature-requestThis item refers to a feature request for an existing or new utilityThis item refers to a feature request for an existing or new utility
Description
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 eventsAcknowledgment
- This feature request meets Powertools for AWS Lambda (TypeScript) Tenets
- Should this be considered in other Powertools for AWS Lambda languages? i.e. Python, Java, and .NET
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/shippedThis item is complete and has been merged/shippedevent-handlerThis item relates to the Event Handler UtilityThis item relates to the Event Handler Utilityfeature-requestThis item refers to a feature request for an existing or new utilityThis item refers to a feature request for an existing or new utility
Type
Projects
Status
Coming soon