Create AWS IoT Core Things using AWS SDK

AWS IoT Core is a highly scalable platform for IoT devices. I automated the creation of Certificates, Things, and Attaching policy using AWS SDK with the below steps.

Step 1:

I created an IAM user with programmatic access and attached the AWSIoTFullAccess policy.

Step 2:

We will need to create Security Policy that can be attached to Certificates created for every device.

I have made a policy so that, the device can only connect using its ThingName as clientId, can subscribe or publish to topics starting from its ThingName.

Step 3:

Code flow:

  • We create a certificate for the device using the createKeysAndCertificate method.
  • Attach policy to the certificate
  • Create AWS IoT Core Thing
  • Attach Certificate To Thing


The certificate which we just created is attached to Policy and Thing.

Output on the console:

Source Code:


Share this with anybody you think would benefit from this. Have any suggestions? Feel free to message me on LinkedIn.

Software Architect, Full Stack Web developer, MEAN/MERN stack, Microservices, etc