ApigeeX and AWS Lambda

tl;dr Tips on how to connect to AWS Lambda from Apigee.

AWS Lambda can be directly invoked through an API call.
https://docs.aws.amazon.com/lambda/latest/dg/API_Invoke.html

Follow the solution described in this repo to generate the signature needed to invoke Lambda. This is a lightweight option to generate the authentication headers required to invoke AWS Lambda. 
https://github.com/DinoChiesa/Apigee-Java-AWSV4-Signature (generates the signature directly)

The repo above covers S3 as an example. Use the snippet below for AWS Lambda.

 

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<JavaCallout async="false" continueOnError="false" enabled="true" name="JC-AWS-Signature-V4">
    <DisplayName>JC-AWS-Signature-V4</DisplayName>
    <Properties>
        <Property name="debug">true</Property>
        <Property name="service">lambda</Property>
        <Property name="endpoint">https://lambda.us-east-1.amazonaws.com</Property>
        <Property name="region">us-east-1</Property>
        <Property name="key">{private.flow.sec.aws.key}</Property>
        <Property name="secret">{private.flow.sec.aws.secret}</Property>
        <Property name="message-variable-ref">lambdaCallout</Property>
    </Properties>
    <ClassName>com.google.apigee.edgecallouts.AWSSignatureV4Callout</ClassName>
    <ResourceURL>java://edge-callout-aws-signature-v4.jar</ResourceURL>
</JavaCallout>

 

 

The AssignMessage policy below sets the headers, payload and URL to talk to AWS Lambda.

 


    <Set>
        <Verb>POST</Verb>
        <Headers>
            <Header name="X-Amz-Invocation-Type">RequestResponse</Header>
        </Headers>
        <FormParams/>
        <Payload contentType="application/json">{"name":"foo", "type":"bar"}</Payload>
        <Path>/2015-03-31/functions/arn:aws:lambda:us-east-1:283052633151:function:serverlessrepo-hello-world-helloworld-1LZWPWEQFFFF/invocations</Path>
    </Set>

 

 

Contributors
Comments
vijaymurali
Bronze 1
Bronze 1

Hi

The edge-callout-aws-signature-v4.jar file is not available in the bundle

dchiesa1
Staff

I've updated the repo for the AWS V4 signature - it now includes an example for Lambda, and uses the correct JAR name.

Version history
Last update:
‎05-29-2022 09:20 PM
Updated by: