how to return a random ThingName in provision by claim

0

Hello there AWS team!

I'm currently doing provision by claim and it works correctly.

The problem I'm facing is that I need to send a serialNumber from my device to AWS. I want to do the opposite: I need AWS to send me a random ThingName. Is this possible?

The policy JSON I'm using is:

{
  "Parameters": {
    "SerialNumber": {
      "Type": "String"
    },
    "AWS::IoT::Certificate::Id": {
      "Type": "String"
    }
  },
  "Resources": {
    "policy_esp32_fleet_policy": {
      "Type": "AWS::IoT::Policy",
      "Properties": {
        "PolicyName": "esp32_fleet_policy"
      }
    },
    "certificate": {
      "Type": "AWS::IoT::Certificate",
      "Properties": {
        "CertificateId": {
          "Ref": "AWS::IoT::Certificate::Id"
        },
        "Status": "Active"
      }
    },
    "thing": {
      "Type": "AWS::IoT::Thing",
      "OverrideSettings": {
        "AttributePayload": "MERGE",
        "ThingGroups": "DO_NOTHING",
        "ThingTypeName": "REPLACE"
      },
      "Properties": {
        "AttributePayload": {},
        "ThingGroups": [],
        "ThingName": {
          "Fn::Join": [
            "",
            [
              "",
              {
                "Ref": "SerialNumber"
              }
            ]
          ]
        }
      }
    }
  }
}

Thanks a lot in advance!

1 Answer
0

Hi - Thanks for checking. It would be great to know what is the requirement to return a random ThingName. A thing is a representation of a specific device or logical entity. It can be a physical device or sensor (for example, a light bulb or a switch on a wall). It can also be a logical entity like an instance of an application or physical entity that does not connect to AWS IoT but is related to other devices that do (for example, a car that has engine sensors or a control panel). The solution should enable each device (or Thing) to have a unique name (or ThingName) in the device registry and identified of what they are. So giving a proper name, or serial number or other identifier based on your organization is a best practice.

The thingName is a required attribute which needs to be provided and you can't change a thing's name after you create it. To change a thing's name, you must create a new thing, give it the new name, and then delete the old thing.

profile pictureAWS
EXPERT
answered a year ago

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