Ingesting data into Mendix through AWS IoT SiteWise

Ingesting data into Mendix through AWS IoT SiteWise

In this tutorial, you will learn how to ingest data from AWS IoT SiteWise into Mendix

Published Jun 24, 2024
Last Modified Aug 14, 2024

Summary

AWS IoT SiteWise is a managed service that makes it easy to collect, store, organize and monitor data from industrial equipment at scale to help you make better, data-driven decisions.
Mendix is a low-code application development platform used by businesses in manufacturing, banking and other verticals to develop apps at scale
In this tutorial, you will learn how to ingest data from AWS IoT SiteWise into Mendix.

Prerequisites

  • An active AWS account
  • Mendix Studio Pro 10.6.1 or above installed on your computer
  • This workshop will run us_east_1 AWS region

Tools

  • AWS IoT SiteWise is a managed service that makes it easy to collect, store, organize and monitor data from industrial equipment at scale to help you make better, data-driven decisions.
  • AWS Identity and Access Management (IAM) helps you securely manage access to your AWS resources by controlling who is authenticated and authorized to use them.
  • Mendix is a low-code application development platform from Siemens, an AWS partner. Mendix is used by businesses in manufacturing, banking and other verticals to develop apps at scale.

Epics

Set up your environment

Create AWS credentials for Mendix

1. On the AWS IAM console, create user named mendix-user (see instructions here)
2. On the AWS IAM console, create access keys for mendix-user (see instructions here

Create and attach policy for your AWS credentials

1. Create an IAM policy to mendix-user to utilize AWS IoT SiteWise. Here’s an example policy:
2. Attach the policy to mendix-user.
For this tutorial only, we use the policy above. However, for other cases, we recommend using a more restrictive following least privilege principle.

Create a Mendix application

1. Launch Mendix Studio Pro and sign in into Mendix Studio Pro
2. Under Studio Pro, choose Create New App.
3. Under Choose your starting point, choose Blank Web App, and then choose Use this starting point.
4. In App Settings enter AWSApp for App name & choose Create app.

Download AWS connectors in Mendix

The following versions for Mendix connectors were tested for this tutorial:
  • AWSAuthentication 3.0.2
  • AWS IoT SiteWise Connector 2.0.0
1. Choose the shopping cart icon on the top right-hand side corner of Studio Pro to open the Mendix Marketplace.
2. In the search field, enter AWS Authentication Connector and choose on the first search result.
3. Choose Download, and then choose Import on the popup that opens and afterwards confirm the information message by choosing OK.
4. Search for AWS IoT SiteWise Connector in the Mendix marketplace
5. Follow steps 1 through 4 for other connectors
Amazon Connectors on Mendix

Configure AWSAuthentication connector with AWS credentials

1. In the App Explorer, expand the App AWSApp section and double-click on Settings to open the App Settings in a popup.
2. We need to create a new configuration profile. Choose New to create a new configuration, which will open a popup and name it AWSCredentials.
3. Navigate to the Constants tab and choose New.
4. In the search field, type AccessKey, select the AccessKey constant of the AWSAuthentication connector, and choose Select.
5. In the popup that opens, enter your Access Key in the Value field and confirm with OK.
6. Choose New one more time and this time search for SecretAccessKey, select the SecretAccessKey constant of the AWSAuthenticationConnector, and then choose Select.
7. Enter your Secret Access Key and choose OK and OK again to save your configuration.
8. Make sure, that your configuration is set to Active. You can confirm that by checking the active column has a green check mark.
9. Choose Ok to escape the App Settings.
AWS Credentials in Mendix

Configure your application

Create an Asset Model in AWS IoT SiteWise

1. In the AWS IoT SiteWise console, browse to Build > Models on the left hand menu, and then select Create Model.
2. In the Model details section enter the name of the model wind_turbine and a description.
3. In the Definitions section, select Attributes and add two attributes called serial number and model with both having a data type of String. The default values for serial number and model are 0001 and M1 respectively.

Create a microflow to ingest data from AWS IoT SiteWise

1. In the App Explorer, right-click on your module named "MyFirstModule", and then click Add microflow.
2. Enter a ListSiteWiseModels for the name of your microflow and click OK.
3. In the App Explorer, in the AWSIoTSiteWiseConnector > Operations section, find the ListAssetModels activity.
4. In your Toolbox, find the Create Object activity and drag it into your microflow.
5. In the Entity field, select ListAssetModelsRequest.
6. In the Toolbox pane, search for the Retrieve activity and drag it into the microflow area.
7. Position the Retrieve activity between the ListAssetModels activity and the microflow end event.
8. Double-click the Retrieve activity.
9. In the Select Association dialog box, in the Association section, click Select, and then select ListAssetModels as the association and Click Ok
10. In your Toolbox, find the Get Static Credentials activity and drag it to the beginning of your microflow.
11. Double-click the ListSiteWiseModels microflow activity to configure the required parameters.
12. In the Edit parameters section, edit the ENUM_Region parameter, and enter AWSAuthentication.ENUM_Region.us_east_1
13. In the Edit parameters section, edit the Credentials parameter, and select the output variable from Get Static Credentials activity and click OK.
The resulting microflow should like the image below:
List asset model microflow

Create a model list page and navigation microflow for you model list page

1. In the App Explorer, in your module named "MyFirstModule", copy your Home_Web and rename the copy page to AssetModelList.
2. In the Toolbox pane, search for the List view activity and drag it into AssetModelList page.
3. In the App Explorer, right-click on the name of your module, and then click Add microflow.
4. Enter a name for your microflow, for example, NAV_AssetModelList_Overview, and then click OK.
5. In the App Explorer pane, search for the ListSiteWiseModels microflow and the AssetModelList page and drag them into the microflow area.
The resulting microflow should look the image below:
List asset model navigation page microflow
6. In the AssetModelList page, double click on your list, select the data source tab
7. Select microflow as type, select AssetModelList for the microflow and click ok
AssetModelList configuration

Configure Navigation on Mendix

1. In the App Explorer, under AWSApp, double click on Navigation
2. Change home page by selecting Home_Web page, under MyFirstModule
3. In Menu, click on New Item:
  • In Caption, enter Asset Model
  • In Icon, press Select.
  • In Filter, type notes-checklist and select notes-checklist icon
  • In On Click, select Call a microflow.
  • In Search, type NAV_AssetModelList_Overview and select NAV_AssetModelList_Overview
  • Click on OK
Configuring Navigation

Build and Test your application

Build your application

Press on the green triangle located at the top bar to run your application locally.

View and test application

1. When application is built, click on view app. This will open a tab on your browser showing the app
2. Navigate the Asset Model page by clicking on notes-checklist icon
3. You will see your asset name and ARN
Asset Model page

Clean up

Delete IAM user

1. Navigate to the AWS IAM console
2. In the left menu, choose Users.
3. Choose mendix-user, and then choose Delete
4. Under To confirm deletion, enter mendix-user, and then choose Delete user.

Remove Asset Model in AWS IoT SiteWise

1. In the AWS IoT SiteWise console, browse to Build > Models and delete the Asset Model you created.
Delete Asset Model in AWS IoT SiteWise

 

Comments