I know I can get the description of an IoT thing with aws iot describe-thing
, given the name of an IoT thing. And I know I can get the contents of a thing shadow given the name of the shadow with aws iot-data get-thing-shadow
.
The describe-thing
command returns, for example,
{
"defaultClientId": "MyLightBulb",
"thingName": "MyLightBulb",
"thingId": "40da2e73-c6af-406e-b415-15acae538797",
"thingArn": "arn:aws:iot:us-west-2:123456789012:thing/MyLightBulb",
"thingTypeName": "LightBulb",
"attributes": {
"model": "123",
"wattage": "75"
},
"version": 1
}
Note that this output does not include the names of any agent shadows(s).
How can I retrieve the name of an IoT thing's shadow if I know the thing's name, so that I can ultimately use get-thing-shadow
with the name of the shadow to get the shadow's contents?
You can list the shadow for your thing-name by running this aws cli:
aws iot-data list-named-shadows-for-thing --thing-name your-thing
and then run the get-thing-shadow by specifying the named shadow (for classic shadow you can ommit --shadow-name
)
aws iot-data get-thing-shadow --thing-name your-thing --shadow-name shadow-name output.txt
If you have aws fleet indexing enabled (on your shadow and named shadow), you can retrieve the entire thing information (attributes, thingGroup, connectivity, classic and named shadow) using the search-index
command:
aws iot search-index --index-name "AWS_Things" --query-string "thingName:your-thing-name"