node LTS AWS account AWS CLI credentials
- checkout project
git clone ... && cd project
- generate keys and certificate
aws iot create-keys-and-certificate \
--set-as-active \
--certificate-pem-outfile cert.crt \
--public-key-outfile public.pem.key \
--private-key-outfile private.pem.key \
--region eu-west-1 \
--profile private-default
-
register a thing type
- Go to AWS console
- Select Ireland region
- Go to IoT Core
- Manage
- Types
- Create a thing type
- Name: AGD
- Add another searchable thing attributes
- Attribute key: producent
- Create thing type
-
Create policy
- Secure
- Policies
- Create
- Name:
IoTFullAccess
- Action:
iot:*
- Resource ARN:
*
- Effect:
Allow
- Create
- Name:
-
Attach policy to certificate
- Secure
- Certificates
- (...)
- Attach policy
- Select IoTFullAccess
- Attach
-
Create a thing
- Manage
- Things
- Create
- Create a single thing
- Name:
Czajnik
- Thing type:
AGD
- producent:
amica
- Next
- Create thing without certificate
- Name:
-
Attach certificate to a thing
- Secure
- Certificates
- (...)
- Attach thing
- czajnik
- Attach
-
Install project dependencies with
npm install
- Update clientId from settings and Endpoint url in
index.js
- Run program with
node index.js
-
Type
on
,off
orstatus
to play with device shadow state. Confirm each command withenter
-
Set Action based on a rule
- Act
- Create a rule
- Name:
turnedOn
- Query:
select * from '$aws/things/czajnik/shadow/update/accepted'
- Actions:
Republish
- Topic:
AGD
- Add action
- Create Rule
- Name:
-
Update clientId from settings and Endpoint url in
thing.js
-
Turn on
thing.js
in new terminal window with
node thing.js
- Navigate to
shadow
program (previous terminal window) - Type
on
and enter - To vetify if thing was notified with shadow update navigate to thing.js terminal and check if message is visible.