Skip to content

Latest commit

 

History

History
79 lines (55 loc) · 4.03 KB

File metadata and controls

79 lines (55 loc) · 4.03 KB
description
This page provides the technical details of the AWS Lambda policy

AWS Lambda

Overview

The AWS Lambda policy can be used to request a Lambda instead of or in addition to the backend.

By default, the Lambda is called in addition to the backend, meaning the consumer will not receive the response from the Lambda.

Functional and implementation information for the aws-lambda policy is organized into the following sections:

Examples

{% hint style="warning" %} This policy can only be applied to v2 APIs. It cannot be applied to v4 message APIs or v4 proxy APIs. {% endhint %}

{% tabs %} {% tab title="Proxy API example" %} Sample policy configuration:

"configuration": {
    "variables": [
      {
        "name": "lambdaResponse",
        "value": "{#jsonPath(#lambdaResponse.content, '$')}"
      }
    ],
    "secretKey": "secretKey",
    "accessKey":"accessKey",
    "payload": "{ \"key\": \"value\" }",
    "scope": "REQUEST",
    "function": "lambda-example",
    "region": "us-east-1",
    "sendToConsumer": true,
    "endpoint": "http://aws-lambda-url/function"
}

{% endtab %} {% endtabs %}

Configuration

Phases

The phases checked below are supported by the aws-lambda policy:

v2 PhasesCompatible?v4 PhasesCompatible?
onRequesttrueonRequestfalse
onResponsetrueonResponsefalse
onRequestContenttrueonMessageRequestfalse
onResponseContenttrueonMessageResponsefalse

Options

You can configure the aws-lambda policy with the following options:

PropertyRequiredDescriptionTypeDefault
scopetrueThe scope on which apply the policystringREQUEST
regiontrueThe AWS regionstringus-east-1
accessKeyfalseAWS Access Keystring-
secretKeyfalseAWS Secret Keystring-
functiontrueThe name of the AWS Lambda function to callstring-
payloadfalsePayload of the request to AWS Lambda functionstring-
variablesfalseThe variables to set in the execution context when retrieving content of HTTP call (support EL)List of variables-
sendToConsumerfalseCheck this option if you want to send the response of the lambda to the initial consumer without going to the final upstream (endpoints) selected by the gateway.booleanfalse

Errors

HTTP status code Message
500 Request processing broken

You can override the default response provided by the policy with the response templates feature. These templates must be defined at the API level with the APIM Console Proxy > Response Templates function.

The error keys sent by this policy are as follows:

KeyDefault statusParameters
AWS_LAMBDA_INVALID_RESPONSE500-
AWS_LAMBDA_INVALID_STATUS_CODE400-

Changelogs

{% @github-files/github-code-block url="https://github.com/gravitee-io/gravitee-policy-json-xml/blob/master/CHANGELOG.md" %}