While it takes some technical acumen to insert and retrieve data from Amazon’s DynamoDB NoSQL database, Mulesoft’s Amazon DynamoDB Connector – Mule 4 can help you streamline and simplify the process.
The following guide explains what you’ll need to get started and highlights some of the functionality in DynamoDB made possible by Mule 4. Why do users choose Amazon DynamoDB?
Data is a competitive field today, with plenty of platforms and providers offering solutions to help organisations build and deliver internet-scale applications, create media metadata stores, deliver seamless retail experiences, and scale gaming platforms, to name a few use cases.
However, because the Amazon DynamoDB is fully managed, its Key-Value NoSQL Database scales so well, backs up data proactively, uses TTL processes to expire and delete extraneous data, and generally handles data with a rapid and robust framework, it remains a favourite among many users – especially when using key-value pairs. Naturally, DynamoDB works well with many APIs. However, the Amazon DynamoDB Connector – Mule 4 provides connectivity to the AmazonDB API, enabling you to create a database table that can store and retrieve any amount of data and handle large volumes of data traffic.
With a few API code lines set up, Mule 4 provides a fantastic way for users to perform various operations on their data while maintaining consistent, fast performance.
Getting started
You need to have a few essentials in place to perform a quick setup of Mule 4 to support your DynamoDB operations.
- Ensure you have an AWS account that has DynamoDB accessibility.
- Ensure you have AWS Identity and Access Management (IAM) credentials.
- Ensure that you have IAM credentials featuring both access and secret key functionality.
Functionality made possible by Mule 4
With all that in hand, here are some examples of the most commonly used features and functionality Mule 4 can help you accomplish in DynamoDB.
Creating tables
Naturally, adding new tables to your AWS account is one of the basic bread-and-butter functions you can expect from Mule 4. Table names have to be unique in each instance, however.
Listing tables
You can quickly and intuitively generate a list of all the tables created within the AWS account you’re using, providing a helpful overview at a glance.
Updating tables
Topping up the data held by your tables or their functionality within your larger datasets is made easy by updating tables. Users can modify the provisioned throughput settings, global secondary indexes, and a table’s DynamoDB stream settings.
Deleting tables
Whenever necessary, you can easily erase both a table and all of its contents – keep in mind that this is irreversible.
Putting items
This is the process by which new items are created – remember that the new item will replace an existing item if their Primary Keys are the same.
Querying
Users can use queries to not only find items based on Primary Key values but also secondary index items in a table with a primary composite key too.
Scanning
This is a quick and simple way of returning any items to the user that match the defined attributes.
Updating items
Users can add new items to the table that do not exist using this feature or update an existing item’s attributes as required.
Batch delete item commands
Users can delete items across one or multiple tables with this feature.
Batch get item commands
This enables you to quickly return the defined attributes of one or several items across single or multiple tables within DynamoDB.
Batch put item commands
Easily add one or several items onto single or multiple tables in one convenient action.
Describing tables
This feature returns information about the table for which it is used.
How to create a new table in DynamoDB?
Creating new tables is very much at the core of daily DynamoDB use, and it’s a pretty straightforward process. Once you have logged into your AWS dashboard, go to the Databases section of the menu and select DynamoDB.
We’re going to create an example exercise here. On your DynamoDB account page, select Create Table. For the purposes of this exercise, we’ll call it “Students”, with the partionKey of “StudentID” and the sortKey as “Email”.
Now that table exists, it’s time to use Mule 4 to add data to the DynamoDB table using the Put Item connector.
For this example, we will be adding the following Student Data JSON to DynamoDB:

As simple as that, the data is added to your DynamoDB account. We have created the table in which the information is to be stored. We have used the Put Item connector to set up the instruction that we can easily add new data to that table, and we have now successfully added an example subset of data using that code above.
However, to make the most of this guide and the interoperability of Mule 4 and DynamoDB, we will need to add some dependencies to unlock its greatest potential.
Creating a new dependency in Mule 4 for DynamoDB
Enhancing what you can do with Mule 4 to streamline what you do with DynamoDB is a brilliant way to achieve far greater efficiency throughout your workflow. To do this, the first step is to open Mule 4’s pom.xml file.
With that file open, and its code now rolling beautifully down your screen, creating a new dependency is as simple as using the following example code:

Once this dependency has been successfully added and you have saved your changes to the pom.xml file, you will notice a new item appearing in the left-hand menu of your Mule 4 Palette dashboard. This Amazon DynamoDB item is the perfect connector to add effective new functionality, which we will continue exploring below.
However, keep in mind that before doing so, there is an extra layer of security to help keep your data safe during this process.
When you click to configure the DynamoDB connector in Mule 4, you have the opportunity to provide both the Access Key and the Secret Key – vital for keeping prying eyes away from what could well be highly sensitive or confidential data.
Creating operations in the DynamoDB connector
With the DynamoDB connector successfully up and running in Mule 4, it’s time to add the operations that will further enhance what you can do with this software.
Using the Get-Item connector
Much of this process is relatively intuitive. For example, the Get-Item connector makes it easy to quickly retrieve data from within your DynamoDB tables. It does so by using the “StudentID” Primary Key we defined in our earlier example in this case. However, as you become more confident in using Mule 4 and its connectors with DynamoDB, you can enhance the Get-Item connector to retrieve any Primary Key data you like.
For our example work, the data will be returned in a format like this:













Use Dataweave Transformation to obtain data from the DynamoDB response
As you can see above, the response from DynamoDB when returning requested data is not always easy on the eye. Fortunately, this is once again an easy fix.
To more successfully extract data from that DynamoDB response, use the below transformation:

Using the Scan connector to retrieve data from DynamoDB
Limiting the number of hits against a given database is often more efficient. Using the Scan connector within DynamoDB to do that is a big help. It allows a large volume of data to be stored in a variable as cache data, which can then be used independently.
Using the Scan connector will yield this kind of DynamoDB response:


























Use Dataweave Transformation to obtain data from the DynamoDB response
Once again, using a transformation can help extract this DynamoDB response into better workable data. For this, use the following:


DynamoDB and Mule 4 for faster, better data
Using the examples and guidelines above, you should be able to quickly and enjoyably create a more streamlined and efficient way of making DynamoDB and Mule 4 collect, collate, store and display your data.
We hope this guide has proven useful – stick with us for other tech and coding advice!
If you would like to find out more about how we can help you leverage the DynamoDB and MuleSoft, give us a call or email us at salesforce@coforge.com.
Other useful links:
Best practices to implement Salesforce right the first time.
No need to search: technology, trends and insights for 2022.