Introduction
As you scale your AWS IoT SiteWise purposes and transfer them into manufacturing, it’s possible you’ll take into account adopting frequent CI/CD methodologies that separate growth and QA environments from manufacturing environments. This separation permits you to automate the deployment of those purposes by way of deployment pipelines. You additionally could have a number of enterprise items and/or industrial websites with frequent asset fashions and hierarchies that you simply want to share and reuse throughout your group. In these instances, clients usually have totally different AWS accounts to separate environments, whether or not between dev and prod or between totally different enterprise items. The next diagram depicts such an instance the place growth is separated from QA and manufacturing environments:
To assist clients replicate AWS IoT SiteWise sources between environments, we created AWS IoT SiteWise Tools, a set of utilities that permit you export AWS IoT SiteWise Asset Models, Assets, and AWS IoT SiteWise Monitor Dashboards into AWS CloudFormation templates. The exported templates can then be used to recreate the exported sources into one other AWS surroundings. On this weblog, you will notice a pattern walkthrough of find out how to use AWS IoT SiteWise Instruments to export fashions adopted by an instance structure of find out how to automate the export and replication course of in a CI/CD pipeline.
Asset Mannequin Export Walkthrough
The utilities within the AWS IoT SiteWise Instruments repository provide the flexibility to copy solely the sources you want on your particular use case. You possibly can select to solely export AWS IoT SiteWise asset fashions, or additionally export the corresponding property and AWS IoT SiteWise Monitor dashboards. The export software can be utilized manually from the command line (e.g. for a one-time export of an asset mannequin into one other surroundings) or could be built-in into your automation pipelines for CI/CD deployment situations. The utility will also be used to repeat AWS IoT SiteWise sources for multi-region deployments throughout the similar account. The AWS IoT SiteWise Instruments repository has detailed documentation on find out how to use every of the utilities however for a fundamental demonstration of the instruments, we created two asset fashions of a CNC Machine and Manufacturing Line as seen under. Every mannequin comprises a property and a hierarchical relationship between the 2 fashions.
To maintain it easy, we are going to solely export the fashions. Utilizing the AWS IoT SiteWise export instruments, we optionally specify the area we need to export fashions from and run the command with no different flags (in case you additionally need to export property together with the fashions, you’ll merely add the -a, --assets
flag). The command output will look one thing like the next:
If the command succeeds, a CloudFormation template can be saved to a folder within the native listing named cfnexport. In our instance case the CloudFormation will appear like the next:
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "SiteWise Export",
"Assets": {
"CNCMachineResource": {
"Sort": "AWS::IoTSiteWise::AssetModel",
"Properties": {
"AssetModelName": "CNC Machine",
"AssetModelProperties": [
{
"Name": "SpindleSpeed",
"DataType": "DOUBLE",
"Unit": "RPM",
"Type": {
"TypeName": "Measurement"
},
"LogicalId": "SpindleSpeed9f2e03dd"
}
],
"AssetModelHierarchies": []
}
},
"ProductionLineResource": {
"Sort": "AWS::IoTSiteWise::AssetModel",
"Properties": {
"AssetModelName": "Manufacturing Line",
"AssetModelProperties": [
{
"Name": "Location",
"DataType": "STRING",
"Type": {
"TypeName": "Attribute",
"Attribute": {}
},
"LogicalId": "Locationafc85231"
}
],
"AssetModelHierarchies": [
{
"Name": "CNC Machines",
"ChildAssetModelId": {
"Ref": "CNCMachineResource"
},
"LogicalId": "CNCMachines"
}
]
}
}
}
}
This CloudFormation template can now be launched in one other area or one other AWS Account to create the identical asset fashions we outlined above.
That’s it, now you may have an understanding how the export utility works. Within the subsequent part we are going to present an instance structure that reveals how one can combine the utilities into your CI/CD automation pipelines.
Instance CI/CD Structure
On this instance structure we assume you may have an present CI/CD pipeline that may deploy AWS companies utilizing CloudFormation and the AWS SDKs.
Construct
For the construct stage of the structure, the CI/CD pipeline initiates a Step Function workflow within the supply surroundings which executes three Lambda features, one for every useful resource kind – asset fashions, property, and dashboards. The Lambda features could be run in parallel and use the export utilities to question the AWS IoT SiteWise service API to generate the corresponding CloudFormation templates for the sources you want to replicate. The Lambda operate will then retailer the generated information in an Amazon S3 bucket to be used through the deploy stage of the pipeline. For the S3 bucket, you may both use a standard shared bucket throughout your entire AWS environments or use S3 replication to robotically copy the information between separate buckets in each environment.
Deploy
Within the deploy stage, the AWS IoT SiteWise sources must be created or modified in a particular order within the goal surroundings, particularly, asset fashions, property, and dashboards. To do that, AWS StepFunction workflow states are outlined for every useful resource kind and the workflow is configured to execute them within the correct order. Every workflow state will use Lambda operate duties that reference the corresponding CloudFormation template in S3. The sources first must be created by the CI/CD pipeline, due to this fact the preliminary workflow deployment duties will create the CloudFormation stacks.
As soon as the stacks are created, subsequent updates from the CI/CD pipeline will use the workflow and step features to replace these stacks which can modify and replace the AWS IoT SiteWise sources. The asset and dashboard states will watch for the earlier state to complete deploying in CloudFormation earlier than they begin as a result of they require these sources to exist earlier than they are often created. Please see the structure under for a visible illustration.
For manufacturing workloads, clients can use CloudFormation change sets of their deployment pipeline and have a guide approval gate to confirm the CloudFormation updates earlier than they’re made. Lastly, if dashboards are a part of your deployment pipeline, an AWS IoT SiteWise Monitor Portal should be created beforehand within the goal surroundings.
Conclusion
On this weblog put up we launched the AWS IoT SiteWise Tools for replicating AWS IoT SiteWise sources between AWS environments and confirmed an instance structure how they are often built-in into an automatic deployment pipeline. We acknowledge that every group has totally different necessities, procedures and instruments in the case of automating and deploying their IT infrastructure and purposes. We designed the instruments to be versatile to adapt the structure on your personal necessities and to have the ability to combine them into your particular automation pipelines. We welcome enhancements or additions to the utilities. When you have one thing to contribute again to the repository, be at liberty to submit a pull request within the repository for evaluation.
In regards to the Authors
![]() |
![]() |
![]() |
![]() |