AWS Lambda Integration With Mule 4 Using Lambda Connector

Author: Mrunali Rane

This article will show how MuleSoft applications can invoke AWS Lambda functions using the Amazon Lambda connector in Mule 4.

  1. Create an AWS Lambda Function
    1. To create a Function in AWS click on Create function button under Lambda Services.
  1. Select the Author from scratch.
  1. Provide Basic Information like the Name of the function, Function Languages, and Architecture.
  1. In our example, we are writing a function in Python 3.8 and  x86_64 as architecture. 
  1. For this POC we will be creating a simple Hello <FirstName> <LastName> function.
  2. The function will take FirstName and LastName as input in JSON format and will return Hello FirstName LastName.
  3. The python code is as follows:
def lambda_handler(event, context): message = 'Hello {} {}!'.format(event['first_name'], event['last_name']) return {'message' : message}
  1. Get Access Key and Secret Key
    1. Go to IAM in AWS Console and ask the administrator to create one user and assign the AWSLambda_FullAccess policy to that user.
    2. Get the Access Key and Secret Key for that user.
  1. Download AWS Lambda Connector from Exchange
    1. Install the AWS Lambda Operation from Exchange.
  1. The Mule 4 Amazon Lambda connector includes the following operation.
  1. Configure the Invoke Operation
    1. Provide the Access Key, Secret Key, and Region under General Tab in Lambda Connector Configuration. 
    2. Check the connectivity by clicking on the Test Connectivity button.
  1. Provide Function Name and X Amz Invocation Type as REQUEST_RESPONSE in Invoke Operation configuration.
  1. In the flow I have added, the Invoke connector and a transforming message will pick the first and last names from query parameters.
  2. Pass these values in the function call.
Testing the POC:
  • Provide the firstname and lastname as query Parameters to API calls.
  • The following output will be generated:

We use cookies on this site to enhance your user experience. For a complete overview of how we use cookies, please see our privacy policy.