- Newest
- Most votes
- Most comments
Hi lacteolus,
The device SDK provides clients and APIs for accessing the AWS IoT cloud data plane services. It also provides a client for talking with the Greengrass v2 IPC.
The IoTShadowClient in the device SDK is a client for talking directly with the AWS IoT Device Shadow Service in the cloud.
It maintains its own connection - hence the need for the device certificate information. This client does not work through the Greengrass IPC.
At this time, there is no equivalent to the local shadow service / sync that Greengrass v1 provides.
In order to talk to the cloud shadow service, you do not need to use the IoT shadow client. A V2 component can talk with IoT Shadow via the Greengrass managed MQTT connection.
The following access control policy allows your component to subscribe and publish to the shadow MQTT topics
"accessControl": { "aws.greengrass.ipc.mqttproxy": { "shadow-mqtt-example": { "policyDescription": "Allows access to shadow.", "operations": [ "*" ], "resources": [ "$aws/things/+/shadow/#" ] } } }
Your python component can follow the MQTT pub/sub example here: https://docs.aws.amazon.com/greengrass/v2/developerguide/ipc-iot-core-mqtt.html
You can subscribe to $aws/things/thingName/shadow/update/accepted to get any remote shadow updates
and publish state to $aws/things/thingName/shadow/update
In this case, thingName is the name of the thing you want to update.
You can use the environment variable $AWS_IOT_THING_NAME to use the thing name of the core device
See https://docs.aws.amazon.com/iot/latest/developerguide/device-shadow-mqtt.html for more detail about using the shadow MQTT topics.
Edited by: rob-aws on Mar 8, 2021 11:05 AM
Hi rob-aws,
Thanks for info. So it means that we need to implement something similar to IoTShadowClient but using IPC and subscriptions to all needed shadow topics (update, delta, get etc.).
I looked at https://github.com/aws/aws-iot-device-sdk-python-v2/blob/main/samples/shadow.py example and it seemed to be convenient - it has special classes for different shadow requests and methods for publishing and subscribing to named and classis shadow topice etc.
Relevant content
- asked 2 years ago
- Confused about permissions in IOT Core/PubSub/Shadows, Greengrass, IAM roles, service roles and IPC.Accepted Answerasked 2 years ago
- Accepted Answerasked 2 years ago
- AWS OFFICIALUpdated 3 months ago
- AWS OFFICIALUpdated 7 months ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago