Amazon DynamoDB
Introduction
The Amazon DynamoDB connector provides a way for you to increase the security, scalability, and performance of your Mendix app by implementing Amazon DynamoDB.
Typical Use Cases
Amazon DynamoDB helps improve your app by giving you the tools to build scalable, performant applications on a flexible, serverless database. You can use it to develop high-traffic online platforms and applications for a variety of modern industries, such as content streaming, electronic commerce, or gaming.
Prerequisites
The Amazon DynamoDB connector requires Mendix Studio Pro 9.18.0 or above.
To use the Amazon DynamoDB connector, you must also install and configure the following modules:
- AWS Authentication connector version 2.0 or higher - This connector is required to authenticate with Amazon Web Services (AWS). It is crucial for the Amazon DynamoDB connector to function correctly. If you are using the Amazon DynamoDB connector version 2.0 or higher, it requires the AWS Authentication connector version 3.0 or higher. It is crucial for the Amazon S3 connector to function correctly. For more information about installing and configuring the AWS Authentication connector, see AWS Authentication.
- Community Commons module - This module is required to parse the
creationDateTime
attribute as returned by theDescribeTable
activity.
Licensing and Cost
This connector is available as a free download from the Mendix Marketplace, but the AWS service to which is connects may incur a usage cost. For more information, refer to AWS documentation.
Depending on your use case, your deployment environment, and the type of app that you want to build, you may also need a license for your Mendix app. For more information, refer to Licensing Apps.
Installation
Follow the instructions in How to Use Marketplace Content to import the Amazon DynamoDB connector into your app.
Configuration
After you install the connector, you can find it in the App Explorer, in the AmazonDynamoDBConnector section. The connector provides a domain model and several activities that you can use to connect your app to Amazon DynamoDB. Each activity can be implemented by using it in a microflow. To ensure that your app can connect to the AWS service, you must also configure AWS authentication for the connector.
Configuring AWS Authentication
In order to use the Amazon DynamoDB service, you must authenticate with AWS. To do so, you must set up a configuration profile in your Mendix app. After you set up the configuration profile, the connector module handles the authentication internally.
As of version 3.0.0 of the AWS Authentication Connector, all the resources and logic required to set up authentication are centralized inside the AWS Authentication Connector module.
The AWS Authentication Connector supports both static credentials and temporary credentials. For more information and detailed instructions please refer to the AWS Authentication Connector documentation page.
Configuring a Microflow for an AWS Service
After you configure the authentication profile for Amazon DynamoDB, you can implement the functions of the connector by using the provided activities in microflows. For example, to list all Amazon DynamoDB tables for a specific region, implement the ListTables activity by doing the following steps:
-
In the App Explorer, find and open the domain model for your app.
-
Right-click on the working area of the domain model, and then click Add entity.
-
Open the new entity by double-clicking on it.
-
Enter a name for the entity, for example,
DBTable
. -
In the Attributes section, click New, and then configure the attribute in the following way:
- Name - A unique name for the attribute, for example,
TableName
- Type - String
The parameters that you need to configure depend on the contents of the response that an activity expects. The ListTables activity used in this example only expects the database table name as a response. Other activities require different parameters. For more information, see Technical Reference.
- Name - A unique name for the attribute, for example,
-
In the App Explorer, right-click on the name of your module, and then click Add microflow.
-
Enter a name for your microflow, for example, DS_ListTables, and then click OK.
-
In the App Explorer, in the AmazonDynamoDBConnector > Operations section, find the ListTables activity.
-
Drag the ListTables activity onto the work area of your microflow.
-
In the Properties pane for the microflow, in the Security section, select a user role that should be allowed to run the microflow.
-
Double-click the ListTables activity to configure the required parameters.
For the
ListTables
activity, you must specify the region for which you want to retrieve the tables from, aCredentials
object and aListTablesRequest
object. Other activities may have different required parameters. -
Click Edit parameter value, edit the ENUM_Region parameter, and change Type to Expression.
-
In the expression builder, type
ENUM_Region
, and then press Ctrl + Space. -
In the autocomplete dialog, select AWSAuthentication.ENUM_Region, then type . and select your AWS region from the list.
-
Click OK, and then click OK again.
-
In the App Explorer, in the AWSAuthentication > ConnectionDetails section, find the GetStaticCredentials and GetTemporaryCredentials actions.
-
Drag the one you would like to use onto the microflow you are working on, and position it between the microflow start event and the ListTables activity.
-
Double-click the microflow action and then configure the required ENUM_Region parameter in the same way as described in step 5.
-
Double-click the ListTables activity and configure the Credentials parameter by doing the following steps:
- Click Edit parameter value.
- Edit the Credentials parameter and let it auto-fill.
-
In the Toolbox pane, search for the Create Object activity, drag it onto the microflow area, and position it between the GetStaticCredentials or GetTemporaryCredentials and the ListTables activity.
-
Double-click the Create Object activity, and then select AmazonDynamoDBConnector.ListTablesRequest as the entity.
-
Double-click the CreateBucket activity and configure the CreateBucketRequest parameter by doing the following steps:
- Click Edit parameter value.
- Edit the CreateBucketRequest parameter and let it auto-fill.
-
In the Toolbox pane, search for the Retrieve activity and drag it onto the microflow area.
-
Position the Retrieve activity between the ListTables activity and the microflow end event.
-
Double-click the Retrieve activity.
-
In the Association section, click Select.
-
In the Select Association dialog box, expand the Variable item, and then select ListTablesResponse as the association.
-
Click OK.
-
In the Toolbox pane, search for the Create list activity and drag it onto the microflow area.
-
Position the Create list activity between the microflow start event and the ListTables activity.
-
Double-click the Create list activity.
-
In the Entity section, click Select.
-
In the Select Entity dialog box, select the entity that you previously added to your domain model, for example,
DBTable
. -
In the Toolbox pane, search for the Loop activity and drag it onto the microflow area.
-
Position the Loop activity before the microflow end event.
-
Double-click the Loop activity.
-
In the Iterate over list, select ListTableList.
-
In the Toolbox pane, search for the Create object activity and drag it inside the loop area.
-
Double-click the Create object activity.
-
In the Entity section, click Select.
-
In the Select Entity dialog box, select the entity that you previously added to your domain model, for example,
DBTable
, and then click Select. -
In the Create Object dialog box, click New.
-
In the Edit Change Item dialog box, in the Member drop-down, select the attribute that you previously created, for example,
TableName
. -
In the expression editor, type
$IteratorListTable/TableName
, and then click OK. -
In the Toolbox pane, search for the Change List activity and drag it inside the loop area, to the right of the Create Object activity.
-
Double-click the Change List activity, and then set the following values:
- Type - Add
- Value - The created object, for example,
$NewDBTable
-
Double-click the end event of your microflow, and then set the following values:
- Type - List
- Entity - The entity that you previously added to your domain model, for example,
DBTable
-
Right-click the Create List activity, and then click Set {TableName} as return value.
-
In the App Explorer, right-click on the name of your module, and then click Add page.
-
In the Lists category, select the List template for the page.
-
Enter a name for your page, for example, Table_Overview, and then click OK.
-
On the page, double-click the List view widget.
-
In the Select Data Source dialog, set the Type to Microflow.
-
In the Microflow field, select the DS_ListTables microflow.
-
Click OK, and then click Yes.
-
In the Properties pane for the page, in the Navigation > Visible for section, select a user role that should be allowed to run the microflow.
-
In the App Explorer, double-click the Navigation for your app.
-
In the Menu section, click New Item.
-
In the New Menu Item dialog, configure the following settings:
- Caption - A caption for the navigation item, for example, Table
- Icon - An icon that will be displayed for this page in the navigation for your app
- On click - Show a page
- Page - Your Table_Overview page
-
Click OK.
-
Click Run Locally () to preview your app and validate your results. For more information, see Studio Pro Overview: Run and View App.
Technical Reference
The module includes technical reference documentation for the available entities, enumerations, activities, and other items that you can use in your application. You can view the information about each object in context by using the Documentation pane in Studio Pro.
The Documentation pane displays the documentation for the currently selected element. To view it, perform the following steps:
-
In the View menu of Studio Pro, select Documentation.
-
Click on the element for which you want to view the documentation.