AWS IoT SDK for Javascript v2
Next generation AWS IoT Client SDK for Javascript.
This project is in DEVELOPER PREVIEW while we gather feedback on
interfaces and use cases. Please file issues and feature requests.
Expect breaking API changes as we incorporate feedback.
Until this project is promoted to General Availability, we advise you use the
previous SDK
for a stable development environment.
This SDK is built on the AWS Common Runtime, a collection of libraries
(1,
2,
3,
4,
5 ...) written in C to be
cross-platform, high-performance, secure, and reliable. The libraries are bound
to JS by the awscrt package.
The aws-crt package can be installed via npm
npm install aws-crt
Integration with AWS IoT Services such as
Device Shadow
and Jobs
is provided by code that been generated from a model of the service.
Installation
Minimum Requirements
Install from npm
npm install aws-iot-device-sdk-v2
Build from source
npm install
Samples
node/pub_sub
This sample uses the
Message Broker
for AWS IoT to send and receive messages
through an MQTT connection. On startup, the device connects to the server,
subscribes to a topic, and begins publishing messages to that topic.
The device should receive those same messages back from the message broker,
since it is subscribed to that same topic.
Status updates are continually printed to the console.
Source: samples/node/pub_sub
Run the sample like this:
npm install
node dist/index.js --endpoint <endpoint> --root-ca <file> --cert <file> --key <file>
Your Thing's
Policy
must provide privileges for this sample to connect, subscribe, publish,
and receive.
(see sample policy)
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"iot:Publish",
"iot:Receive"
],
"Resource": [
"arn:aws:iot:region:account:topic/samples/test"
]
},
{
"Effect": "Allow",
"Action": [
"iot:Subscribe"
],
"Resource": [
"arn:aws:iot:region:account:topicfilter/samples/test"
]
},
{
"Effect": "Allow",
"Action": [
"iot:Connect"
],
"Resource": [
"arn:aws:iot:region:account:client/samples-client-id"
]
}
]
}
node/basic_discovery
This sample intended for use directly with the
Getting Started with AWS IoT Greengrass guide.
License
This library is licensed under the Apache 2.0 License.