Invoke AWS Lambda

EnRoute Technical Reference

AWS Lambda Plugin

The Enroute AWS Lambda filter/plugin can be used to invoke an external AWS Lambda function. The plugin is a global plugin and is attached to a GatewayHost.

AWS Lambda Filter System Diagram

Enroute AWS Serverless Lambda
  • User makes a request [1]
  • Enroute invokes Lambda function [2,3]
  • Request is passed to the backend service [4]

AWS Lambda Filter Configuration

AWS Lambda filter configuration needs the following config

  • An external AWS Lambda function to invoke
  • Transformation before invoking lambda function
  • If this lambda function should be invoked synchronously or asynchronously
AWS Lambda Function invocation from Kubernetes IngressAWS Lambda Function invocation from Standalone

apiVersion: enroute.saaras.io/v1beta1
kind: GatewayHost
metadata:
  labels:
    app: httpbin
  name: httpbin
  namespace: enroute-gw-k8s
spec:
  virtualhost:
    fqdn: '*'
    filters:
      - name: aws_lambda_filter
        type: http_filter_lambda
  routes:
    - match: /
      services:
        - name: httpbin
          port: 80
---
apiVersion: enroute.saaras.io/v1beta1        
kind: HttpFilter
metadata:
  name: lambda_filter
  namespace: enroute-gw-k8s
spec:
  name: lambda_filter
  type: http_filter_lambda
  routeFilterConfig:
    config: |
  {
    "arn" : "lambda-function-arn",
    "passthrough" : "true/false",
    "invocation_mode_synchronous" : "true/false"
  }

# Variables for lambda global filter
FILTER_NAME="aws_lambda_filter"
FILTER_TYPE="http_filter_lambda"
FILTER_CONFIG='
  {
    "arn" : "lambda-function-arn",
    "passthrough" : "true/false",
    "invocation_mode_synchronous" : "true/false"
  }
'

curl -s -X POST localhost:1323/filter         \
        -d "Filter_name=${FILTER_NAME}"       \
        -d "Filter_type=${FILTER_TYPE}"       \
        -d "Filter_config"="${FILTER_CONFIG}"

  • AWS Lambda Filter config
FieldDescription
arnArn of the lambda function to call.
passthroughBoolean that controls if there should be any transformation to request before lambda function is invoked
invocation_mode_synchronousBoolean that controls if this AWS Lambda fuction should be invoked synchronously or asynchronously
AWS Lambda Filter Config Example
{
  "arn" : "arn:aws:lambda:us-west-2:424368873890:function:hello-enroute",
  "passthrough" : "false",
  "invocation_mode_synchronous" : "true"
}

AWS Plugin is in private beta

AWS Plugin is currently available in private beta. If you’d like to evaluate it, please get in touch with us.