Subscribe device shadows using mqtt bridge component

0

Hi,

I want to subscribe to the device shadow changes on IoTCore. For example if someone changes the device shadow via AWS Greengrass console, I want to get the change on my local mqtt broker on the device. For this purpose I made a deployment to the device with this aws.greengrass.clientdevices.mqtt.Bridge configuration.

{
  "reset": [],
  "merge": {
    "mqttTopicMapping": {
      "HelloWorldIotCore": {
        "topic": "clients/{iot:thingName}/hello/world",
        "source": "LocalMqtt",
        "target": "IotCore"
      },
      "IotCoreToDevice": {
        "topic": "clients/{iot:thingName}/iotcore/to/device",
        "source": "IotCore",
        "target": "LocalMqtt"
      },
      "GetApplicationsShadowLocalMqttToIoTCore": {
        "topic": "$aws/things/+/shadow/name/applications-shadow/get",
        "source": "LocalMqtt",
        "target": "IotCore"
      },
      "PublishApplicationsShadowLocalMqttToIoTCore": {
        "topic": "$aws/things/+/shadow/name/applications-shadow/update",
        "source": "LocalMqtt",
        "target": "IotCore"
      },
      "GetApplicationsShadowAcceptedIotCoreToLocalMqtt": {
        "topic": "$aws/things/+/shadow/name/applications-shadow/get/accepted",
        "source": "IotCore",
        "target": "LocalMqtt"
      },
      "UpdateApplicationsShadowAcceptedIotCoreToLocalMqtt": {
        "topic": "$aws/things/+/shadow/name/applications-shadow/update/accepted",
        "source": "IotCore",
        "target": "LocalMqtt"
      },
    },
    "brokerUri": "tcp://localhost:1883"
  }
}

I can send a message using HelloWorldIoTCore topic from the local mqtt broker (localhost:1883) to cloud and receive a message from the cloud on local mqtt broker using IotCoreToDevice topic. But it seems if I make an update on the named shadow, applications-shadow, I can not get the change on local mqtt broker using $aws/things/+/shadow/name/applications-shadow/update/accepted topic. What am I missing here?

Thanks

質問済み 1年前289ビュー
1回答
1

Good afternoon savcuoglu,

Sorry for the issues you are going through.

My initial piece of advice will be to check your Greengrass Core Device policy, and make sure it allows subscribing, sending and/or receiving to/from shadow topics. Policy should include something like:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "iot:Subscribe"
      ],
      "Resource": [
        "arn:aws:iot:region:account:topicfilter/$aws/things/thingName/shadow/name/applications-shadow/update/accepted"
      ]
    },
    {
      "Effect": "Allow",
      "Action": [
        "iot:Receive"
      ],
      "Resource": [
        "arn:aws:iot:region:account:topic/$aws/things/thingName/shadow/name/applications-shadow/update/accepted"
      ]
    }
  ]
}

You can always refer to documentation here, to tailor your policy to the corresponding shadow topic you are willing to track.

profile pictureAWS
エキスパート
回答済み 1年前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ