How to use CommaDelimitedList type in IoT provisioning template

0

I am trying to add an array of strings as an attribute to my IoT thing provisioning template.

My template looks like this:

{
  "Parameters": {
    "SerialNumber": {
      "Type": "String"
    },
    "CertificateId": {
      "Type": "String"
    },
    "UserGroup": {
      "Type": "String"
    },
    "Roles": {
      "Type": "CommaDelimitedList"
    },
    "ReleaseStage": {
      "Type": "String"
    }
  },
  "Resources": {
    "certificate": {
      "Properties": {
        "CertificateId": {
          "Ref": "CertificateId"
        },
        "Status": "Active"
      },
      "Type": "AWS::IoT::Certificate"
    },
    "thing": {
      "OverrideSettings": {
        "AttributePayload": "MERGE",
        "ThingGroups": "DO_NOTHING",
        "ThingTypeName": "REPLACE"
      },
      "Properties": {
        "AttributePayload": {
          "userGroup": { "Ref": "UserGroup" },
          "roles": { "Ref": "Roles" },
          "environment": { "Ref": "ReleaseStage" }
        },
        "ThingGroups": [],
        "ThingName": {
          "Ref": "SerialNumber"
        }
      },
      "Type": "AWS::IoT::Thing"
    }
  }
}

I'm using the AWS Ruby SDK and the register_thing method like this:

template_body:,
parameters: {
  "SerialNumber": serial_number,
  "CertificateId": certificate_id,
  "UserGroup": user_group,
  "Roles": roles.map(&:parameterize).join(','),
  "ReleaseStage": ENV['RELEASE_STAGE'].presence || ENV['RAILS_ENV']
}

Previous to adding the Roles property, this was working fine. Additionally, making the Roles property a String type works.

I'm wanting the roles attribute to result in an array in AWS, but am seeing this error now:

Aws::IoT::Errors::InvalidRequestException: Invalid registration template. Template format error: unsupported type or structure with location of [Source: (String) ...(rest of template)
1 Answer
0

Hi, Currently, IoT Thing Attributes support only String DataType. Therefore, the you need to Add the CommaSeperated values of Role as single string in the template. https://docs.aws.amazon.com/iot/latest/apireference/API_CreateThing.html#API_CreateThing_RequestSyntax

profile pictureAWS
Bony_T
answered 2 months ago
profile picture
EXPERT
reviewed a month 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