Update custom composite models (components)
You can use the AWS IoT SiteWise API to update a custom composite model, or the AWS IoT SiteWise console to update components.
Update a component (console)
You can use the AWS IoT SiteWise console to update a component.
To update a component (console)
Navigate to the AWS IoT SiteWise console
. In the navigation pane, choose Models.
-
Choose the asset model where the component is.
-
On the Properties tab, choose Components.
-
Choose the component that you want to update.
-
Choose Edit.
-
On the Edit component page, do any of the following:
-
In Model details, change the Name of the model.
-
Change any of the Attribute definitions. You can't change the Data type of existing attributes. For more information, see Define static data (attributes).
-
Change any of the Measurement definitions. You can't change the Data type of existing measurements. For more information, see Define data streams from equipment (measurements).
-
Change any of the Transform definitions. For more information, see Transform data (transforms).
-
Change any of the Metric definitions. You can't change the Time interval of existing metrics. For more information, see Aggregate data from properties and other assets (metrics).
-
-
Choose Save.
Update a custom composite model (AWS CLI)
Use the AWS Command Line Interface (AWS CLI) to update a custom composite model.
To update the name or description, use the UpdateAssetModelCompositeModel operation. For inline custom composite models only, you can also update the properties. You can't update the properties of a component-model-based custom composite model, because its referenced component model provides its associated properties.
Important
If you remove a property from a custom composite model, AWS IoT SiteWise deletes all previous data for that property. You can’t change the type or data type of an existing property.
To replace an existing composite model property with a new one with the same name
, do the following:
Submit an
UpdateAssetModelCompositeModel
request with the entire existing property removed.Submit a second
UpdateAssetModelCompositeModel
request that includes the new property. The new asset property will have the samename
as the previous one and AWS IoT SiteWise will generate a new uniqueid
.
To update a custom composite model (AWS CLI)
-
To retrieve the existing composite model definition, run the following command. Replace
composite-model-id
with the ID or the external ID of the custom composite model to update, andasset-model-id
with the asset model that the custom composite model is associated with. For more information, see the AWS IoT SiteWise User Guide.-
Run the command below:
aws iotsitewise describe-asset-model-composite-model \ --asset-model-composite-model-id
composite-model-id
\ --asset-model-idasset-model-id
-
The above command returns the composite model definition corresponding to associated model’s latest version. For an use case where an asset model is in a
FAILED
state, retrieve the valid model definition corresponding to its active version to build your update request. See Asset model versions for details. -
Run the following command to retrieve the active model definition:
aws iotsitewise describe-asset-model-composite-model \ --asset-model-composite-model-id
composite-model-id
\ --asset-model-idasset-model-id
\ --asset-model-version ACTIVE -
For more information, see the DescribeAssetModelCompositeModel operation.
-
-
Create a file called
update-custom-composite-model.json
, and then copy the previous command's response into the file. -
Remove every key-value pair from the JSON object in
update-custom-composite-model.json
except for the following fields:assetModelCompositeModelName
assetModelCompositeModelDescription
(if present)assetModelCompositeModelProperties
(if present)
-
In
update-custom-composite-model.json
, do any of the following:Change the value of
assetModelCompositeModelName
.Add or remove
assetModelCompositeModelDescription
, or change its value.For inline custom composite models only: Change, add, or remove any of the asset model's properties in
assetModelCompositeModelProperties
.
For more information about the required format for this file, see the request syntax for UpdateAssetModelCompositeModel.
-
Run the following command to update the custom composite model with the definition stored in
update-custom-composite-model.json
. Replacecomposite-model-id
with the ID of the composite model, andasset-model-id
with the ID of the asset model it's in.aws iotsitewise update-asset-model-composite-model \ --asset-model-composite-model-id
composite-model-id
\ --asset-model-idasset-model-id
\ --cli-input-json file://update-custom-composite-model.json
Important
When multiple users update an asset model at the same time, an user's changes may be inadvertently overwritten by another user. To prevent this, you must define a conditional update request. See Optimistic locking for asset model writes.