Serverless-express: can aws-serverless-express be used in lambda@edge?

Created on 14 Jun 2018  路  10Comments  路  Source: vendia/serverless-express

Sorry I cannot find any info in other places.

enhancement v4

Most helpful comment

All 10 comments

Not yet, but it is on my roadmap!

now do you have some rough idea what the things stop it work in edge?

The input and output format should be the only thing. Shouldn't be a difficult change

super. I might give it shot first

Hey @brettstack are you thinking something like this: https://github.com/awslabs/aws-serverless-express/blob/master/src/middleware.js#L12 except for parsing the ALB event, and using the same plumbing? This is huge for where I work given API Gateway isn't approved for most work, and our internal one has too much red tape.

So... it seems if we can jury rig the existing function to parse what API Gateway normally puts into headers, it should "just work" with what you have setup, ya?

Here's an example ALB event:

{
    requestContext:
    {
        elb:
        { targetGroupArn: 'arn:aws:elasticloadbalancing:us-east-1:numberandstuff' }
    },
    httpMethod: 'GET',
    path: '/user/exists/123',
    queryStringParameters: { },
    headers:
    {
        accept: '*/*',
        'accept-encoding': 'gzip, deflate',
        'cache-control': 'no-cache',
        connection: 'Keep-Alive',
        'content-length': '22',
        'content-type': 'application/json',
        host: 'internal-lambda-name-accountnum.us-east-1.elb.amazonaws.com',
        'postman-token': 'uuid',
        'user-agent': 'PostmanRuntime/7.6.0',
        'x-amzn-trace-id': 'Root=1-datnum',
        'x-forwarded-for': '0.0.0.0',
        'x-forwarded-port': '80',
        'x-forwarded-proto': 'http'
    },
    body: '{"sup": "man, a post"}',
    isBase64Encoded: false
}

If you could give me an example of what API Gateway sends in those 2 headers, I could better visualize what the above needs to be turned into.

Looking at https://github.com/awslabs/aws-serverless-express/compare/master...jgautheron:master?w=1, the APIs are different enough that it will require some careful thought to be able to support both.

Coming in v4

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bansalrachita picture bansalrachita  路  4Comments

denneulin picture denneulin  路  8Comments

janaz picture janaz  路  8Comments

Vadorequest picture Vadorequest  路  3Comments

tallpants picture tallpants  路  3Comments