Search code examples
aws-lambdakong

Kong lambda plugin - Correlation id being dropped


so I'm using kong as an API gateway. I have a simple lambda function on aws returning headers. I'm able to see a response from the aws lambda function, however there is no correlation id. I have set the correlation-id plugin global. Would like some clarification on why the lambda plugin is not adding the correlation-id in the headers of the original response.

exports.handler = async (event) => {
    // TODO implement
    const response = {
        statusCode: 200,
        body: JSON.stringify(event.request_headers),
    };
    return response;
};

My kong.yaml

_format_version: "1.1"
routes:
- name: lambda1
  paths:
  - /lambda1
  path_handling: v0
  preserve_host: false
  protocols:
  - http
  - https
  regex_priority: 0
  strip_path: true
  https_redirect_status_code: 426
  plugins:
  - name: aws-lambda
    config:
      aws_key: XXXXXXXXXXXXXXXXXXXXXXX
      aws_region: us-east-1
      aws_secret: XXXXXXXXXXXXXXXXXXXXXXXXx
      awsgateway_compatible: false
      forward_request_body: true
      forward_request_headers: true
      forward_request_method: false
      forward_request_uri: false
      function_name: kong-lambda-plugin
      host: null
      invocation_type: RequestResponse
      is_proxy_integration: false
      keepalive: 60000
      log_type: Tail
      port: 443
      proxy_scheme: null
      proxy_url: null
      qualifier: null
      skip_large_bodies: true
      timeout: 60000
      unhandled_status: null
    enabled: true
    protocols:
    - grpc
    - grpcs
    - http
    - https
plugins:
- name: correlation-id
  config:
    echo_downstream: false
    generator: uuid#counter
    header_name: correlation-id
  enabled: true
  protocols:
  - grpc
  - grpcs
  - http
  - https

Solution

  • So what worked for me was

    https://github.com/Kong/priority-updater

    1. I created the .rock file generated by the script above.
    2. Since I'm using a dockerized version of Kong, I coppied the file over to my Kong docker host.
    3. Installed the plugin in my Kong docker host using luarocks command.
    4. Added the plugin to my 'kong.conf' file.
    5. Added it to the lambda route and worked beautifully.