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
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Implementing Budget Policies and Budget Limits on Databricks
  • Setting Up CORS and Integration on AWS API Gateway Using CloudFormation
  • Mastering Multi-Cloud Integration: SAFe 5.0, MuleSoft, and AWS - A Personal Journey
  • Understanding Custom Authorization Mechanisms in Amazon API Gateway and AWS AppSync

Trending

  • Querying Without a Query Language
  • Spec-Driven Integration: Turning API Sprawl Into a Governed Capability Fleet for AI
  • Building Enterprise-Grade Real-Time IoT Dashboards with Vue 3, MQTT, and Kafka
  • Java Backend Development in the Era of Kubernetes and Docker
  1. DZone
  2. Software Design and Architecture
  3. Integration
  4. Migrating MuleSoft System API to AWS Lambda (Part 1)

Migrating MuleSoft System API to AWS Lambda (Part 1)

In this article, we will be discussing how to migrate a System API running in MuleSoft to AWS Lambda in a quick and efficient manner with the least effort.

By 
Pranav K user avatar
Pranav K
DZone Core CORE ·
Nov. 06, 23 · Tutorial
Likes (2)
Comment
Save
Tweet
Share
7.3K Views

Join the DZone community and get the full member experience.

Join For Free

In this article, we will be discussing how to migrate a System API running in MuleSoft to AWS Lambda in a quick and efficient manner with the least effort. To start, let's understand what system API is in MuleSoft. 

What Is System API?

System APIs provide access to data stored in an organization's central systems of record. They can extract information from essential systems such as ERP, customer, and billing databases, as well as proprietary data repositories. 

MuleSoft API Flow To Be Migrated

The MuleSoft system API flow has contact details to create and fetch operations from the MSSQL database. 

flowIn the above flow, the resource exposed by the API is:

  • :System API flow /contact.
  • To create contact : [POST] /contact 
  • To fetch contact by ID: [GET] /contact/id

When creating the contact, the following JSON payload is passed as input.

JSON
 
{ 
  "firstname" : "Tom",
  "lastname" : "Harris",
  "Depname" : "Finance",
  "empId" : "38993",
  "contact_info": {
    "contact_email" : "[email protected]",
    "contact_workphone" : "+04-993992909",
    "contact_mobile" : "",
    "contact_site" : ""
  }
}


The response for this API will be the JSON given below.

JSON
 
{
  "contact_firstname" : "",
  "contact_id" : "<<New Id generated by system>>"
}


Similarly, when fetching the contact details by ID, the following will be the JSON response.

JSON
 
{ 
  "empId" : "38993",
  "contactId" : "5555",
  "contact_info": {
    "contact_email" : "[email protected]",
    "contact_workphone" : "+04-993992909",
    "contact_mobile" : "",
    "contact_site" : ""
  }
}


Migration Journey

We are migrating the above MuleSoft flow to serverless compute of AWS, which is AWS Lambda. The flow implementation will be developed using Kumologica and will be running on the NodeJS runtime of Lambda. 

The following are key areas considered when migrating the flow.

API Kit Router: The API kit router of MuleSoft will route the API flow to the appropriate path of create or fetch operation. We will be using EventListener node in Kumologica for this purpose.

Dataweave: The dataweave will transform the incoming put JSON to the canonical payload expected inside the flow before sending the database. We will be using datamapper node in Kumologica to replace it.

DBConnector: MuleSoft flow uses a database connector to connect with the MSSQL database. In Kumologica, we will be using an MSSQL node for this purpose.

Security: MuleSoft API is secured via API gateway using API key-based security. In AWS, this will be done via AWS API Gateway and API key authorizer.

Building the Flow in Kumologica

Open the Kumologica developer studio using the command kl open

Plain Text
 
If you are not familiar with Kumologica designer you may follow the following steps to 
install the designer.

npm install @kumologica/sdk

Ensure your are having node version >= 16.14.0 and npm version 8.3.1


On the canvas, drag and drop the EventListener node and set the following configuration.

Plain Text
 
For create contact:

Provider : AWS
Event Source : Amazon API gateway
Verb : POST
URL : /contact

For get contact by Id:

Provider : AWS
Event Source : Amazon API gateway
Verb : GET
URL : /contact/:id


Wire the EventListener node to datamapper node and provide the following mapping.

JSON
 
{ 
  "db_fname" : msg.payload.firstname,
  "db_lname" : msg.payload.lastname,
  "db_dep" : msg.payload.Depname,
  "db_empid" : msg.payload.empId,
  "info": {
    "db_cemail" : msg.payload.contact_email,
    "db_cworkphone" : msg.payload.contact_workphone,
    "db_cmobile" :  msg.payload.contact_mobile,
    "db_csite" : msg.payload.contact_site
  }
}


Now wire the datamapper node to the MSSQL connector. 

Plain Text
 
For create contact:
INSERT into CONTACT C_fname, C_lname, C_dep, C_empid, C_email, C_workphone, C_mobile,C_site 
VALUES msg.payload.db_fname, msg.payload.db_lname, msg.payload.db_dep, msg.payload.db_empid, msg.payload.db_cemail, msg.payload.db_cworkphone, msg.payload.db_cmobile, msg.payload.db_csite

For get contact by id:

SELECT * FROM CONTACT WHERE C_id = msg.payload.id


The final Kumologica flow will look as follows.

Kumologica flow

Kumologica flow

We will be discussing the testing and production deployment mechanism of this flow in detail in our next article.

API AWS AWS Lambda Database JSON MuleSoft Integration

Opinions expressed by DZone contributors are their own.

Related

  • Implementing Budget Policies and Budget Limits on Databricks
  • Setting Up CORS and Integration on AWS API Gateway Using CloudFormation
  • Mastering Multi-Cloud Integration: SAFe 5.0, MuleSoft, and AWS - A Personal Journey
  • Understanding Custom Authorization Mechanisms in Amazon API Gateway and AWS AppSync

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • 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