AWS IoT - NodeJS

0

Hi, I'm starting as a developer and I have to use nodeJS as a way to send messages to connected devices in AWS IoT. I saw that the examples require that the nodejs code has device certificates such as: KeyPath, CertPath and CaPath. I put the data in the code and it worked normally, but in this case I am going to connect more than 1000 devices to AWS IoT and there will be no way to keep adding the certificates to the code, as there will be many devices. I wanted to know if there's anything I can do to get around this dilemma. Thank you!

example:

` var device = awsIot.device({

keyPath: ''***********************************-private.pem.key',
certPath: '***********************************-certificate.pem.crt',
caPath: 'AmazonRootCA1.pem',
clientId: 'esp32-device',
region: 'sa-east-1',
host: '************-ats.iot.sa-east-1.amazonaws.com',
qos: 0

}) `

asked 2 years ago438 views
2 Answers
0

Hi,

you can provide keyPath, certPath and other settings as command line parameters. So you would run your device with a command such as:

mydevice.js /path/to/key /path/to/cert

KR,

Philipp

AWS
EXPERT
answered 2 years ago
0

Good morning AWS-User-9708397,

Thanks for raising your concern.

If I understand correctly, you'd like to build a NodeJS app to remotely Command/Control your IoT devices; but the code samples you came across appear so tightly coupled to the devices (certificates) themselves that you are afraid it might not be scalable. Is that accurate?

If so, then you are probably right. One of the recommended approach for this use case would be to decouple your NodeJS App from your devices (by using AWS Amplify for example).

Enter image description here

With AWS Amplify, you can build your desired NodeJS App, add App user identities to it and use those same identities in the cloud to connect to AWS IoT Core. Then using standard MQTT Publish/Subscribe/Connect functions, you can communicate with any (subset) of your devices via AWS IoT Core.

Here is a very detailed example for reference.

Let us know if that was helpful!

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