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

asked a year ago320 views
1 Answer
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
EXPERT
answered a year ago
  • 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

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions