Associating and disassociating assets (Amazon CLI)
You can use the Amazon Command Line Interface (Amazon CLI) to associate and disassociate assets.
For this procedure, you must know the ID of the hierarchy (hierarchyId
) in
the parent asset model that defines the relationship to the child asset model. Use the
DescribeAsset
operation to find the hierarchy ID in the response.
To find a hierarchy ID
-
Run the following command to describe the parent asset. Replace
parent-asset-id
with the parent asset's ID or external ID.aws iotsitewise describe-asset --asset-id
parent-asset-id
The operation returns a response that contains the asset's details. The response contains an
assetHierarchies
list that has the following structure:{ ... "assetHierarchies": [ { "id": "
String
", "name": "String
" } ], ... }The hierarchy ID is the
id
value for a hierarchy in the list of asset hierarchies.
After you have the hierarchy ID, you can associate or disassociate an asset with that hierarchy.
To associate a child asset to a parent asset, use the AssociateAssets operation. To disassociate a child asset from a parent asset, use the DisassociateAssets operation. Specify the following parameters, which are the same for both operations:
-
assetId
– The parent asset's ID or external ID. -
hierarchyId
– The hierarchy ID or external ID in the parent asset. -
childAssetId
– The child asset's ID or external ID.
To associate an asset (Amazon CLI)
-
Run the following command to associate a child asset to a parent asset. Replace
parent-asset-id
,hierarchy-id
, andchild-asset-id
with the respective IDs:aws iotsitewise associate-assets \ --asset-id
parent-asset-id
\ --hierarchy-idhierarchy-id
\ --child-asset-idchild-asset-id
To disassociate an asset (Amazon CLI)
-
Run the following command to disassociate a child asset from a parent asset. Replace
parent-asset-id
,hierarchy-id
, andchild-asset-id
with the respective IDs:aws iotsitewise disassociate-assets \ --asset-id
parent-asset-id
\ --hierarchy-idhierarchy-id
\ --child-asset-idchild-asset-id