DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • End-to-End Event Streaming With Kafka, Spring Boot and AWS SQS/SNS (Production-Ready Code Guide)
  • AWS Bedrock: The Future of Enterprise AI
  • Understanding Custom Authorization Mechanisms in Amazon API Gateway and AWS AppSync
  • AWS Transfer Family SFTP Setup (Password + SSH Key Users) Using Lambda Identity Provider + S3

Trending

  • Google Cloud KMS vs. AWS KMS: Java Encryption Guide
  • Why Your GPU Fleet Is Both Full and Idle: Building a Capacity Orchestration Layer
  • After the AI Commit: What Eight Retrospectives Taught Me About Working With Coding Agents
  • DuckDB for Python Developers

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  1. DZone
  2. Software Design and Architecture
  3. Cloud Architecture
  4. Amazon Lambda Connector: Mule 4

Amazon Lambda Connector: Mule 4

Bring your Mule projects to the serverless world.

By 
Nitin Gupta
·
Oct. 23, 21 · Tutorial
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
16.0K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

AWS Lambda is a serverless architecture that runs your code in response to events and automatically manages the underlying compute resources for you. You can use AWS Lambda to extend other AWS services with custom logic or create your own back-end services that operate at AWS scale, performance, and security.

In this article, I will present how MuleSoft can call AWS Lambda functions using the Amazon Lambda connector in Mule 4. 

The Mule 4 Amazon Lambda connector includes the following operation.

In the following steps, I will present how we can call a Lambda function, list all Lambda functions, invoke async, and get details for particular AWS Lambda functions.

Step 1: Create an AWS Lambda Function

The following screenshot shows lamdafunction_1 and what happens when the Lambda function is called.


Step 2: Make a Secure Connection

  • Log into your AWS console.
  • Go to IAM, then create one user. 
  • Assign AWSLambda_FullAccess policy to user.
  • Click on the Security Tab and click Access Key.

An Access Key ID and Secret Access key will be used to make the Mule 4 AWS Lambda connection with AWS. Below is the screenshot.

Step 3: Call Different AWS Lambda Connector Functions Using MuleSoft.

List functions:

JSON response:

JSON
 
{
    "Functions": [
        {
            "Description": "",
            "TracingConfig": {
                "Mode": "PassThrough"
            },
            "VpcConfig": null,
            "SigningJobArn": null,
            "RevisionId": "7e901225-ef74-4d4e-a8ac-b0faf6099e3e",
            "LastModified": "2021-10-21T07:10:35.842+0000",
            "FileSystemConfigs": null,
            "FunctionName": "lamdafunction_1",
            "Runtime": "java8",
            "Version": "$LATEST",
            "PackageType": "Zip",
            "LastUpdateStatus": null,
            "Layers": null,
            "FunctionArn": "arn:aws:lambda:ap-south-1:509774463154:function:lamdafunction_1",
            "KMSKeyArn": null,
            "MemorySize": 512,
            "ImageConfigResponse": null,
            "LastUpdateStatusReason": null,
            "DeadLetterConfig": null,
            "Timeout": 15,
            "Handler": "example.Hello::handleRequest",
            "CodeSha256": "+5OFdvMKaO8/kzr0r4xnwDOEQnUU0/aHkDjIF2GtoUw=",
            "Role": "arn:aws:iam::509774463154:role/service-role/lamdafunction_1-role-t9qs577q",
            "SigningProfileVersionArn": null,
            "MasterArn": null,
            "CodeSize": 8881,
            "State": null,
            "StateReason": null,
            "Environment": null,
            "StateReasonCode": null,
            "LastUpdateStatusReasonCode": null,
            "Architectures": [
                "x86_64"
            ]
        }
    ],
    "NextMarker": null
}

Invoke function:

JSON response from AWS Lambda function via MuleSoft connector.

JSON
 
{
    "body": "Hello from Lambda!",
    "statusCode": 200
}

Get function:


JSON response from AWS Lambda function via MuleSoft connector.

JSON
 
{
    "Configuration": {
        "Description": "",
        "TracingConfig": {
            "Mode": "PassThrough"
        },
        "VpcConfig": null,
        "SigningJobArn": null,
        "RevisionId": "7e901225-ef74-4d4e-a8ac-b0faf6099e3e",
        "LastModified": "2021-10-21T07:10:35.842+0000",
        "FileSystemConfigs": null,
        "FunctionName": "lamdafunction_1",
        "Runtime": "java8",
        "Version": "$LATEST",
        "PackageType": "Zip",
        "LastUpdateStatus": "Successful",
        "Layers": null,
        "FunctionArn": "arn:aws:lambda:ap-south-1:509774463154:function:lamdafunction_1",
        "KMSKeyArn": null,
        "MemorySize": 512,
        "ImageConfigResponse": null,
        "LastUpdateStatusReason": null,
        "DeadLetterConfig": null,
        "Timeout": 15,
        "Handler": "example.Hello::handleRequest",
        "CodeSha256": "+5OFdvMKaO8/kzr0r4xnwDOEQnUU0/aHkDjIF2GtoUw=",
        "Role": "arn:aws:iam::509774463154:role/service-role/lamdafunction_1-role-t9qs577q",
        "SigningProfileVersionArn": null,
        "MasterArn": null,
        "CodeSize": 8881,
        "State": "Active",
        "StateReason": null,
        "Environment": null,
        "StateReasonCode": null,
        "LastUpdateStatusReasonCode": null,
        "Architectures": [
            "x86_64"
        ]
    },
    "Concurrency": null,
    "Code": {
        "ResolvedImageUri": null,
        "RepositoryType": "S3",
        "ImageUri": null,
        "Location": "https://awslambda-ap-s-1-tasks.s3.ap-south-1.amazonaws.com/snapshots/509774463154/lamdafunction_1-56c32c45-9cd9-4052-91f3-ff893eabbd0b?versionId=GMF4Z42m4gSBxUjEOAUJWt3huO0FkVrx&X-Amz-Security-Token=AIhALBMSi7rmnt%2Fj3GiMU%2BrwDz1cRjTN3yi%2FGNN4q2QNwhADclQtfJOe5QIy1v8aYkPEKNRnlXHmPaHcDCzXktiD%2FeX8BD0RDZAhTpHDdgbZTMnPCy3ilsKteHH2FnM%2B9TYkb%2FLGth07SqAYVgRRpb34bigWnoSqvYQTuD1QRLwoUVY2D0MhG2L7gFQLGb023D%3D&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20211022T044544Z&X-Amz-SignedHeaders=host&X-Amz-Expires=600&X-Amz-Credential=ASIAX5456DIN37H34JPZ%2F20211022%2Fap-south-1%2Fs3%2Faws4_request&X-Amz-Signature=3343shjhjsds"
    },
    "Tags": null
}


We can also call the AWS Lambda connector asynchronously using the Invoke Async function.

Thanks.

Connector (mathematics) AWS Lambda AWS

Opinions expressed by DZone contributors are their own.

Related

  • End-to-End Event Streaming With Kafka, Spring Boot and AWS SQS/SNS (Production-Ready Code Guide)
  • AWS Bedrock: The Future of Enterprise AI
  • Understanding Custom Authorization Mechanisms in Amazon API Gateway and AWS AppSync
  • AWS Transfer Family SFTP Setup (Password + SSH Key Users) Using Lambda Identity Provider + S3

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook