AWS Lambda allows to create HTTP APIs fronted by API Gateway (REST and HTTP) and ALB (Application Load Balancer) endpoints. However, the input events vary depending on the endpoint. In order to write code that is compatible with all endpoint, certain differences need to be accounted for.
The following endpoint configuration was applied to each endpoint type:
ALBEvent(single)
: ALB, default Internet-visible HTTP endpoint, no auth, single-value query/headers.ALBEvent(multi)
: ALB, default Internet-visible HTTP endpoint, no auth, multi-value query/headers.APIGatewayProxyEvent(rest)
: REST API Gateway, default HTTPS endpoint, no auth.APIGatewayProxyEvent(1.0)
: HTTP API Gateway, default HTTPS endpoint, no auth, 1.0 payload format.APIGatewayProxyEventV2
: HTTP API Gateway, default HTTPS endpoint, no auth, 2.0 payload format.
The following curl
basic request was sent to each endpoint:
curl -H 'no-value-header;' -H 'multi-value-header: 1' -H 'multi-value-header;' -H 'multi-value-header: 2' -H 'multi-value-header: 3,4' -H 'Mixed-Case: header' "http://${endpoint}/?multi-value-query=1&multi-value-query&multi-value-query=&multi-value-query=2&multi-value-query=3,4&no-equal-query&no-value-query=&enco%2Fded=qu%2Fery"
which translates to:
GET /?multi-value-query=1&multi-value-query&multi-value-query=&multi-value-query=2&multi-value-query=3,4&no-equal-query&no-value-query=&enco%2Fded=qu%2Fery HTTP/1.1
no-value-header:
multi-value-header: 1
multi-value-header:
multi-value-header: 2
multi-value-header: 3,4
Mixed-Case: header
host: {endpoint}
The request was sent five times, each time with the following additional arguments:
# a: uppercase Cookie, single header with two cookies, space separated, trailing semicolon
-H 'Cookie: cookie1=1; cookie2=a;'
# b: lowercase cookie, single header with two cookies, no spaces, no trailing semicolon
-H 'cookie: cookie1=1;cookie2=b'
# c: lowercase cookie, single header with two cookies, no spaces, trailing semicolon
-H 'cookie: cookie1=1;cookie2=c;'
# d: lowercase cookie, two headers, no trailing semicolon
-H 'cookie: cookie1=1' -H 'cookie: cookie2=d'
# e: lowercase cookie, two headers, trailing semicolon
-H 'cookie: cookie1=1;' -H 'cookie: cookie2=e;'
As of 2024-11-27
, the results are as follows.