Skip to content

Basic Lambda with Gloo

What you'll need

  • Kubernetes v1.8+ deployed somewhere. Minikube is a great way to get a cluster up quickly.
  • kubectl to interact with kubernetes.
  • glooctl to interact with gloo.
  • aws (the aws cli) to create resources on AWS.


  1. Create a lambda function:

    # download the zipped function from github
    # get the ARN for the "lambda_basic_execution" role
    ROLE_ARN=$(aws iam get-role --role-name lambda_basic_execution --query Role.Arn --output text)
    # create the function    
    aws lambda create-function \
    --region us-east-1 \
    --function-name helloWorld \
    --zip-file fileb:// \
    --handler helloWorld.handler \
    --runtime nodejs6.10 \
    --role $ROLE_ARN
  2. Install Gloo:

    glooctl install kube
  3. Create a kubernetes secret with your AWS credentials:

    glooctl secret create aws --name aws-lambda-us-east-1
  4. Create an upstream for your AWS Account (for the us-east-1 region)

    cat <<EOF | glooctl upstream create -f -
    name: aws-lambda-us-east-1
    type: aws
      region: us-east-1
      secret_ref: aws-lambda-us-east-1
  5. Verify that the upstream was created and the function was auto-discovered

    glooctl upstream get aws-lambda-us-east-1 -o yaml
    - name: helloWorld:$LATEST
        function_name: helloWorld
        qualifier: ""
      namespace: gloo-system
      resource_version: "5540"
    name: aws-lambda-us-east-1
      region: us-east-1
      secret_ref: aws-lambda-us-east-1
      state: Accepted
    type: aws
  6. Create a route to the function

    glooctl route create --sort \
       --upstream aws-lambda-us-east-1 \
       --function 'helloWorld:$LATEST' \
       --path-exact /hello
  7. Get the url of the ingress.
    If you installed kubernetes using minikube, you can use this command:

    export GATEWAY_URL=http://$(minikube ip):$(kubectl get svc ingress -n gloo-system -o 'jsonpath={.spec.ports[?("http")].nodePort}')
    1. Try out the route using curl:

      curl $GATEWAY_URL/hello

      {"statusCode":200,"body":"AWS Lambda, brought to you by Gloo."}