Synchronizing AWS IoT SiteWise Assets with AWS IoT TwinMaker

7 minute read
Content level: Intermediate
3

This article will walk you through how to configure AWS IoT TwinMaker Asset Sync with a Brewery simulation environment. The end result will be an imported entity hierarchy from AWS IoT SiteWise. Incorporating a synchronization process of external assets with your Digital Twin is critical to achieving the required scaling efforts of an enterprise Twin where the source of truth for a registry of your assets may exist in another system, such as AWS IoT SiteWise.

Introduction

We want to introduce you to an exciting new feature in AWS IoT TwinMaker called Asset Sync. AWS IoT TwinMaker supports asset synchronization for your AWS IoT SiteWise assets and asset models. Using the AWS IoT SiteWise component type, asset sync takes existing AWS IoT SiteWise assets and asset models and converts these resources into AWS IoT TwinMaker entities (i.e. assets), components, and component types.

This article will walk you through how to configure asset sync with a Brewery simulation environment. The end result will be an imported entity hierarchy from AWS IoT SiteWise, as seen below. Incorporating a synchronization process of external assets with your Digital Twin is critical to achieving the required scaling efforts of an enterprise Twin where the source of truth for a registry of your assets may exist in another system, such as AWS IoT SiteWise. With Asset Sync, we help create a synchronization pipeline with AWS IoT SiteWise to ensure both your Twin and operational assets are in sync as your Digital Twin grows. As you look to synchronize assets from multiple systems, Asset Sync serves as one of the tools to help automate those efforts.

With your IoT SiteWise assets in sync with AWS IoT TwinMaker, a large advantage you will discover is the Knowledge Graph. This enables you to query for entity metadata within your Digital Twin with a simple Partiql Query. This can reduce the amount of API calls you have to make in AWS IoT SIteWise for asset and property metadata.

Overview

Prerequisites

  1. AWS Account
  2. Access to run AWS CloudFormation templates, AWS IAM roles, AWS IoT SiteWise, and AWS IoT TwinMaker.

Steps

  1. To begin, log on to your AWS Console and select a region that supports AWS IoT TwinMaker.

  2. Next, let’s create a demo environment in AWS IoT SiteWise. We will use the brewery-sitewise-simulator on Github aws-samples. Click on brewery-sitewise-simulator and follow the Quick Deploy steps to deploy two CloudFormation templates. This will take 10 to 15 minutes to complete.

  3. Welcome back! Navigate to the AWS IoT SiteWise to see the assets created, as seen below SiteWise Assets

  4. With the SiteWise Assets created, we can start the synchronization process. But first, an IAM service role is required for AWS IoT TwinMaker. Navigate to IAM to create this role.

  5. Select Custom Trust Policy as the use case

  6. Paste the following trust policy

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "Service": [
                    "iottwinmaker.amazonaws.com",
                    "iotsitewise.amazonaws.com"
                ]
            },
            "Action": "sts:AssumeRole"
        }
    ]
}

TrustPolicy

  1. Click Next and then Create Policy
  2. A new browser tab will open. Paste the following JSON
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": "iottwinmaker:*",
            "Resource": "*"
        },
        {
            "Effect": "Allow",
            "Action": [
                "iotsitewise:Describe*",
                "iotsitewise:List*"
            ],
            "Resource": "*"
        }
    ]
}

SyncPolicy

  1. Click Next and Create the Policy using a name such as SiteWiseSyncPolicy

  2. Click on the previous tab in the browser and click on the refresh button Refresh

  3. Search for the Policy you created and check the box next to it. Click Next to proceed to name the role SiteWiseSyncRole

  4. Now, with the IAM Role created, navigate to the AWS IoT TwinMaker service.

  5. Click on Create Workspace CreateWorkspace

  6. Provide a workspace name, such as BreweryDemo. Select Create an S3 bucket as a dropdown option for S3 bucket and Auto-generate a new role for the Execution Role. This Execution Role is different from the role you created earlier. Note, depending on how many roles you have in your account, you may need to scroll up to find the first option to auto-generate the role. WorkspaceDetails

  7. Click on Skip to Review and Create at the bottom to skip the Grafana setup.

  8. Finally, click on Create Workspace

  9. With the workspace created, you can now synchronize this with IoT SiteWise. Click on Settings on the left. Steps are also available here in the User Guide. WorkspaceView

  10. Click on Model Sources and then Connect workspace ModelSources

  11. Select the workspace you created and click on Go to workspace ConnectWorkspace

  12. Select SiteWiseSyncRole and click Add Source SiteWiseSync

  13. This process will take a few minutes. The workspace will show the status as Active once the sync is complete. Any new changes you make to the SiteWise Asset Models and Assets will automatically synchronize with this workspace. SyncStatus

  14. When viewing the Entity Model, you will see all the Asset properties imported from AWS IoT SiteWise. In addition, a Data Connector Component is associated with each Entity, allowing you to query time-series data in AWS IoT SiteWise from AWS IoT TwinMaker. Note, once in sync, the entity and component cannot be modified in AWS IoT TwinMaker. But you are able to add additional components to the entity. Any changes you need to make to the asset (i.e. Name change, Attributes, Measurements) must be done in AWS IoT SiteWise. EntityModel

  15. Next lets execute a few Knowledge Graph Queries:

    • Click on Query Editor and run this query to see the visual graph and basic isChildOf relationships. This relationship exists as part of the hierarchy of entities in the TwinMaker Entity Model.
    select parent, r, child from EntityGraph
    match (parent)<-[r:isChildOf]-(child)
    

    query1

    • As part of the SiteWise Sync, the relationships defined in AWS IoT SiteWise are imported as well. Run this query below to see how you can find specific entities that have a relationship to the Brewing area.
    select parent, r, child from EntityGraph
    match (parent)<-[r]-(child)
    where r.displayName = 'BoilKettle'
    

    query2

    • The last example below retrieves all SiteWise Measurement type properties associated with a list of machines. To do this in AWS IoT SiteWise today requires multiple API calls.
    select child.entityName, p.definition.displayName, p.propertyName, p.definition.configuration.sitewisePropertyType,
    p.definition.configuration.sitewisePropertyId
    from EntityGraph
    match (parent)<-[r:isChildOf]-(child), child.components as c, c.properties as p
    where child.entityName in [ 'Roaster100','BoilKettle100'] and
    p.definition.configuration.sitewisePropertyType = 'MEASUREMENT'
    

    query3

Clean Up

  1. Perform the clean up steps in brewery-sitewise-simulator
  2. Disconnect AWS IoT SiteWise from the Workspace you created in AWS IoT TwinMaker. The deletion process will take several minutes. cleanup
  3. Delete the AWS IoT TwinMaker Workspace

Conclusion

In this article, you learned how to synchronize your operational environment with AWS IoT TwinMaker to create an Industrial Twin of a Brewery. By incorporating a synchronization process of industrial assets with your Digital Twin, you can be assured that future changes will keep your Digital Twin up-to-date. Take the time to assess where the source of truth for your asset hierarchies are. Whether that is AWS IoT SiteWise, Manufacturing Execution Systems (MES), and/or an Enterprise Asset Management (EAM) system, a pipeline to synchronize those assets will need to be implemented as you scale to production. AWS IoT TwinMaker provides APIs and features like Asset Sync to help meet your objectives.

As you import asset hierarchies across multiple systems, IoT TwinMaker’s Knowledge Graph can help you build relationships between your assets. This article introduced you to this Knowledge Graph and highlighted how it can enhance the ability to query IoT SiteWise metadata efficiently. Stay tuned for a future article that will show how you can map additional relationships in this Knowledge Graph.