provision by claim with same ThingName

0

Hello there AWS team!

I'm doing provision by claim with the ESP32. Everything works as expected. I send a SerialNumber in the parameters and AWS created a ThingName with that SerialNumber.

Problem: What happens if I send a SerialNumber that is already created in aws iot core? I want AWS to reply to me back with a "fail" message or something like that.

In this post: https://docs.aws.amazon.com/iot/latest/developerguide/provision-template.html I can see that is done with the OverrideSettings. I'm trying adding "ThingName" : FAIL in the OverrideSettings but it seems it is not doable.

I'm on the right track or I'm missing something?

Thanks a lot in advance

gefragt vor einem Jahr330 Aufrufe
1 Antwort
0

Can you please share your template if possible here, did you try something like below? example ** "ThingTypeName": "FAIL",**

{
  "Resources": {
    "thing": {
      "Type": "AWS::IoT::Thing",
      "Properties": {
        "ThingName": {
          "Ref": "ThingName"
        },
        "AttributePayload": {
          "version": "v1",
          "serialNumber": {
            "Ref": "SerialNumber"
          }
        },
        "ThingTypeName": "lightBulb-versionA",
        "ThingGroups": [
          "v1-lightbulbs",
          {
            "Ref": "Location"
          }
        ]
      },
      "OverrideSettings": {
        "AttributePayload": "MERGE",
       ** "ThingTypeName": "FAIL",**
        "ThingGroups": "DO_NOTHING"
      }
    },
    "policy": {
      "Type": "AWS::IoT::Policy",
      "Properties": {
        "PolicyDocument": "{ \"Version\": \"2012-10-17\", \"Statement\": [{ \"Effect\": \"Allow\", \"Action\":[\"iot:Publish\"], \"Resource\": [\"arn:aws:iot:us-east-1:123456789012:topic/foo/bar\"] }] }"
      }
    }
  }
}
profile pictureAWS
EXPERTE
beantwortet vor einem Jahr
  • the JSON is the default in the fleet provisioning by default.

    I tried that option but it doesn't work because is thingtypename is different than thingname. It seems the correct way to do it is with a lambda function

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen