从负载均衡器接收事件是用例:
现在,应用程序负载均衡器支持通过 HTTP 和 HTTPS 对请求进行 Lambda 调用。如果内容类型是以下类型之一,则负载均衡器将正文按原样发送到 Lambda 函数并将 isBase64Encoded 设置为 false:text/*、application/json、application/javascript 和 application/xml。对于所有其他类型,负载均衡器 Base64 对主体进行编码并将 isBase64Encoded 设置为 true
以下是一个示例事件。
{
"requestContext": {
"elb": {
"targetGroupArn":
"arn:awscn:elasticloadbalancing:region:123456789012:targetgroup/my-target- group/6d0ecf831eec9f09" // ALB reference
}
},
"httpMethod": "GET",
"path": "/",
"queryStringParameters": {parameters},
"headers": {
"accept": "text/html,application/xhtml+xml",
"accept-language": "en-US,en;q=0.8",
"content-type": "text/plain",
"cookie": "cookies",
"host": "lambda-846800462-us-east-2.elb.amazonaws.com", //this is where Lambda CNAME is declared
"user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6)",
"x-amzn-trace-id": "Root=1-5bdb40ca-556d8b0c50dc66f0511bf520",
"x-forwarded-for": "72.21.198.66",
"x-forwarded-port": "443",
"x-forwarded-proto": "https"
},
"isBase64Encoded": false,
"body": "request_body"
}
遵循将描述您的用例的官方 AWS 指南