AWS Lambda
This filter should be configured with the name envoy.filters.http.aws_lambda.
Attention
The AWS Lambda filter is currently under active development.
The HTTP AWS Lambda filter is used to trigger an AWS Lambda function from a standard HTTP/1.x or HTTP/2 request. It supports a few options to control whether to pass through the HTTP request payload as is or to wrap it in a JSON schema.
If payload_passthrough is set to , then the payload is sent to Lambda without any transformations. Note: This means you lose access to all the HTTP headers in the Lambda function.
However, if is set to false
, then the HTTP request is transformed to a JSON payload with the following schema:
rawPath
is the HTTP request resource path (including the query string)method
is the HTTP request method. For exampleGET
,PUT
, etc.headers
are the HTTP request headers. If multiple headers share the same name, their values are coalesced into a single comma-separated value.body
the body of the HTTP request is base64-encoded by the filter if thecontent-type
header exists and is _not_ one of the following:
Otherwise, the body of HTTP request is added to the JSON payload as is.
On the other end, the response of the Lambda function must conform to the following schema:
"statusCode": ...
"headers": {"header-key": "header-value", ... },
"body": "...",
"isBase64Encoded": true|false
}
The
statusCode
field is an integer used as the HTTP response code. If this key is missing, Envoy returns a200 OK
.The
headers
are used as the HTTP response headers.The
body
is base64-decoded if it is marked as base64-encoded and sent as the body of the HTTP response.
Note
The target cluster must have its endpoint set to the regional Lambda endpoint. Use the same region as the Lambda function.
AWS IAM credentials must be defined in either environment variables, EC2 metadata or ECS task metadata.
The filter supports .
If you use the per-filter configuration, the target cluster _must_ have the following metadata:
Below are some examples that show how the filter can be used in different deployment scenarios.
In this configuration, the filter applies to all routes in the filter chain of the http connection manager:
http_filters:
"@type": type.googleapis.com/envoy.extensions.filters.http.aws_lambda.v3.Config
arn: "arn:aws:lambda:us-west-2:987654321:function:hello_envoy"
payload_passthrough: true
The corresponding regional endpoint must be specified in the target cluster. So, for example if the Lambda function is in us-west-2:
weighted_clusters:
clusters:
- name: lambda_egress_gateway
weight: 42
typed_per_filter_config:
envoy.filters.http.aws_lambda:
"@type": type.googleapis.com/envoy.extensions.filters.http.aws_lambda.v3.PerRouteConfig
invoke_config:
An example with the Lambda metadata applied to a weighted-cluster: