Skip to content

Instantly share code, notes, and snippets.

@dave-malone
Last active February 11, 2020 12:57
Show Gist options
  • Save dave-malone/7e098ded47ecfd1c05ad0ab574968cec to your computer and use it in GitHub Desktop.
Save dave-malone/7e098ded47ecfd1c05ad0ab574968cec to your computer and use it in GitHub Desktop.
An example of how to create AWS IoT Things with more than three attributes
THING_TYPE_NAME=multi-attribute-type
THING_NAME=multi-attribute-thing
DYNAMIC_GROUP_NAME=multi-attribute-dynamic-group

aws iot create-thing-type --thing-type-name $THING_TYPE_NAME

aws iot create-thing \
  --thing-name $THING_NAME \
  --thing-type-name $THING_TYPE_NAME \
  --attribute-payload "{\"attributes\": {\"attr1\":\"1\", \"attr2\":\"2\", \"attr3\":\"3\", \"attr4\":\"4\", \"attr5\":\"5\"}}"

# alternatively, update an existing thing
# aws iot update-thing \
#   --thing-name $THING_NAME \
#   --attribute-payload "{\"attributes\": {\"attr1\":\"1\", \"attr2\":\"2\", \"attr3\":\"3\", \"attr4\":\"4\", \"attr5\":\"5\"}}"

aws iot describe-thing --thing-name $THING_NAME

aws iot create-dynamic-thing-group --thing-group-name $DYNAMIC_GROUP_NAME --query-string "attributes.attr4=4"

aws iot describe-thing-group --thing-group-name $DYNAMIC_GROUP_NAME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment