Author: Mrunali Rane
This article will show how MuleSoft applications can invoke AWS Lambda functions using the Amazon Lambda connector in Mule 4.
- Create an AWS Lambda Function
- To create a Function in AWS click on Create function button under Lambda Services.

- Select the Author from scratch.

- Provide Basic Information like the Name of the function, Function Languages, and Architecture.

- In our example, we are writing a function in Python 3.8 and x86_64 as architecture.

- For this POC we will be creating a simple Hello <FirstName> <LastName> function.
- The function will take FirstName and LastName as input in JSON format and will return Hello FirstName LastName.
- The python code is as follows:
def lambda_handler(event, context): message = 'Hello {} {}!'.format(event['first_name'], event['last_name']) return {'message' : message}
- Get Access Key and Secret Key
- Go to IAM in AWS Console and ask the administrator to create one user and assign the AWSLambda_FullAccess policy to that user.
- Get the Access Key and Secret Key for that user.
- Download AWS Lambda Connector from Exchange
- Install the AWS Lambda Operation from Exchange.

- The Mule 4 Amazon Lambda connector includes the following operation.

- Configure the Invoke Operation
- Provide the Access Key, Secret Key, and Region under General Tab in Lambda Connector Configuration.
- Check the connectivity by clicking on the Test Connectivity button.

- Provide Function Name and X Amz Invocation Type as REQUEST_RESPONSE in Invoke Operation configuration.

- In the flow I have added, the Invoke connector and a transforming message will pick the first and last names from query parameters.
- 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:

References:
- https://dzone.com/articles/amazon-lamda-connector-mule-4
- https://docs.mulesoft.com/amazon-lambda-connector/1.0/