<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Louis Borsu</title>
    <description>This is the blog of Louis Borsu</description>
    <link>https://blog.louisborsu.be</link>
    <atom:link href="https://blog.louisborsu.be/feed.xml" rel="self" type="application/rss+xml" />
    
      <item>
        <title>AWS IoT - Getting started tutorial with node.js</title>
        <description>&lt;p&gt;During his 2015 edition if the re:Invent show, AWS has released a new tool dedicated to our electronic devices.&lt;/p&gt;

&lt;p&gt;The tool is a pub/sub system that includes a full SDK, TLS connections, and more…&lt;/p&gt;

&lt;p&gt;Let’s get started with a simple example and run our first application with the node.js platform (used by the &lt;a href=&quot;http://beagleboard.org/black&quot;&gt;Beaglebone&lt;/a&gt; for instance).&lt;/p&gt;

&lt;p&gt;We first need to create our first project. As we’re speaking about the internet-of-&lt;em&gt;thing&lt;/em&gt; topic, AWS decided to call the projects &lt;em&gt;things&lt;/em&gt;. Let’s respect that super creativity by picking a super original name : &lt;code class=&quot;highlighter-rouge&quot;&gt;Tutorial&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.louisborsu.be/images/posts/2015-10-22-aws-iot-getting-sarted-tutorial-with-nodejs/2-create-a-new-project.png&quot; alt=&quot;Create a new project&quot; title=&quot;Create a new project&quot; /&gt;&lt;/p&gt;

&lt;p&gt;You now have your first &lt;em&gt;thing&lt;/em&gt; in your dashboard :&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.louisborsu.be/images/posts/2015-10-22-aws-iot-getting-sarted-tutorial-with-nodejs/3-you-now-have-a-thing-in-yout-list.png&quot; alt=&quot;You now have a thing in your list&quot; title=&quot;You now have a thing in your list&quot; /&gt;&lt;/p&gt;

&lt;p&gt;To be able to publish or receive any messages, we have to create a device into our project. To do it, we will click on our &lt;em&gt;thing&lt;/em&gt; and select &lt;code class=&quot;highlighter-rouge&quot;&gt;Connect a device&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.louisborsu.be/images/posts/2015-10-22-aws-iot-getting-sarted-tutorial-with-nodejs/4-add-a-device-to-your-thing.png&quot; alt=&quot;Add a device to your thing&quot; title=&quot;Add a device to your thing&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Here, the wizard will ask you on which platform you want to develop your application, in our case we are gonna use &lt;em&gt;node.js&lt;/em&gt;. The wizard will then give you the ability to download your certificates.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;!! Download those three ones now, as you’ll not have the ability later !!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Yes, as AWS does for all the credentials, it’s a one time access, which makes sense on a security perspective.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.louisborsu.be/images/posts/2015-10-22-aws-iot-getting-sarted-tutorial-with-nodejs/5-select-your-plateform-and-download-your-certificates.png&quot; alt=&quot;Select your platform and download your certificates&quot; title=&quot;Select your platform and download your certificates&quot; /&gt;&lt;/p&gt;

&lt;p&gt;You will also need a root certificate (also called CA certificate) to be able to open the &lt;em&gt;TLS&lt;/em&gt; connection with the server. &lt;a href=&quot;https://www.symantec.com/content/en/us/enterprise/verisign/roots/VeriSign-Class%203-Public-Primary-Certification-Authority-G5.pem&quot;&gt;This one is available on Verisign website&lt;/a&gt;. Download this file and name it &lt;code class=&quot;highlighter-rouge&quot;&gt;root-CA.crt&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Let’s clean a bit and rename/move our certificate to our project folder. The names that I’ll use in this example are:&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;certificate.pem.crt&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;private.pem.key&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;public.pem.key&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;root-CA.crt&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;If you want to copy/paste the code, use the same names.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.louisborsu.be/images/posts/2015-10-22-aws-iot-getting-sarted-tutorial-with-nodejs/6-rename-and-put-those-certificates-in-a-folder.png&quot; alt=&quot;Rename and put those certificates in a folder&quot; title=&quot;Rename and put those certificates in a folder&quot; /&gt;&lt;/p&gt;

&lt;p&gt;We now have everything ready on AWS side, and you should see three items in your dashboard, a &lt;em&gt;thing&lt;/em&gt;, a &lt;em&gt;certificate&lt;/em&gt; and an &lt;em&gt;access policy&lt;/em&gt;:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.louisborsu.be/images/posts/2015-10-22-aws-iot-getting-sarted-tutorial-with-nodejs/7-you-should-now-have-three-items.png&quot; alt=&quot;You should now have three items&quot; title=&quot;You should now have three items&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The last step of the setup will be to install the required SDK. AWS has released a &lt;em&gt;npm&lt;/em&gt; package for us:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# npm i aws-iot-device-sdk&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I did create a &lt;code class=&quot;highlighter-rouge&quot;&gt;test.js&lt;/code&gt; file in the project folder and required the sdk at the top:&lt;/p&gt;

&lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;awsIot&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'aws-iot-device-sdk'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Now that all our setup is ready, let’s write our first lines of code!&lt;/p&gt;

&lt;p&gt;We first need to define our &lt;em&gt;device&lt;/em&gt;. To do it, we have to create a device object.&lt;/p&gt;

&lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;device&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;awsIot&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;device&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt;
   &lt;span class=&quot;na&quot;&gt;keyPath&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'./certs/private.pem.key'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;certPath&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'./certs/certificate.pem.crt'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;caPath&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'./certs/root-CA.crt'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;clientId&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'Tutorial'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;region&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'eu-west-1'&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Do not forget to adapt your region.&lt;/p&gt;

&lt;p&gt;Now that we have our device object, let’s act on the connection event that is triggered when the connection with the AWS IoT server has succeed:&lt;/p&gt;

&lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nx&quot;&gt;device&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;on&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'connect'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'connected'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;At this step, if we run our application, we will see that it is correctly connecting to the AWS IoT servers.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# node test.js&lt;/span&gt;
connected
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Ok, this is a good start, but let’s do something a bit more sexy.&lt;/p&gt;

&lt;p&gt;AWS IoT offers us a messaging queue service that allows us to publish message over topics and receive message from topic we have subscribed to.&lt;/p&gt;

&lt;p&gt;We can also define actions on AWS side for messages that have been published on specific topics.&lt;/p&gt;

&lt;p&gt;Let’s subscribe to our first topic:&lt;/p&gt;

&lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nx&quot;&gt;device&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;on&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'connect'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'connected'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;device&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;subscribe&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'topic_1'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;error&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;If we run the application, we receive back the confirmation that we have correctly subscribed to the &lt;code class=&quot;highlighter-rouge&quot;&gt;topic_1&lt;/code&gt; (name that we have choose arbitrarily)&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# node test.js&lt;/span&gt;
connected
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; topic: &lt;span class=&quot;s1&quot;&gt;'topic_1'&lt;/span&gt;, qos: 0 &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;We will also need a piece of logic that will display a message when one will be published on the topic:&lt;/p&gt;

&lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nx&quot;&gt;device&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;on&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'message'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;topic&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;payload&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'message'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;topic&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;payload&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;toString&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;());&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;You can run your application, but you will not see anything unexpected here. Indeed a message has to be published to make our application reacts.&lt;/p&gt;

&lt;p&gt;Unfortunately, AWS doesn’t offer yet the ability to publish a message from the interface like they do for SQS, we will then need to publish a message ourself if we want to see something happening. We gonna take that as a opportunity to discover the third concept of those AWS IoT features, the &lt;em&gt;rules&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Those give us the ability to define an action when the server receives a message.&lt;/p&gt;

&lt;p&gt;Let’s create our first one, to do it, you have to click on the &lt;code class=&quot;highlighter-rouge&quot;&gt;Create a ressource&lt;/code&gt; button:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.louisborsu.be/images/posts/2015-10-22-aws-iot-getting-sarted-tutorial-with-nodejs/8-let-s-add-a-new-ressource.png&quot; alt=&quot;Let's add a new ressource&quot; title=&quot;Let's add a new ressource&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Then you will have to select the &lt;em&gt;rule&lt;/em&gt; type.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.louisborsu.be/images/posts/2015-10-22-aws-iot-getting-sarted-tutorial-with-nodejs/9-pick-up-the-rule-item-in-the-menu.png&quot; alt=&quot;Pick up the rule item in the menu&quot; title=&quot;Pick up the rule item in the menu&quot; /&gt;&lt;/p&gt;

&lt;p&gt;We gonna write the query to match to any messages published to our new queue &lt;code class=&quot;highlighter-rouge&quot;&gt;topic_2&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.louisborsu.be/images/posts/2015-10-22-aws-iot-getting-sarted-tutorial-with-nodejs/10-let-s-pick-up-all-message-from-topic-2.png&quot; alt=&quot;Let's pick up all messages from topic 2&quot; title=&quot;Let's pick up all messages from topic 2&quot; /&gt;&lt;/p&gt;

&lt;p&gt;And we will pick the republishing action. That way we’ll be able to republish our messages to the queue we have subscribed to : &lt;code class=&quot;highlighter-rouge&quot;&gt;topic_1&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.louisborsu.be/images/posts/2015-10-22-aws-iot-getting-sarted-tutorial-with-nodejs/11-republish-message-to-an-other-queue.png&quot; alt=&quot;republish messages to an other queue&quot; title=&quot;republish messages to an other queue&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.louisborsu.be/images/posts/2015-10-22-aws-iot-getting-sarted-tutorial-with-nodejs/12-let-s-use-the-queue-we-ve-subscribed-to.png&quot; alt=&quot;Let's use the queue we've subscribed to&quot; title=&quot;Let's use the queue we've subscribed to&quot; /&gt;&lt;/p&gt;

&lt;p&gt;To be able to publish to our queue, we need permissions, which means creating a new policy in the IAM. Hopefully, AWS helps us here by automating the process. Indeed, if you click on &lt;code class=&quot;highlighter-rouge&quot;&gt;Create a new role&lt;/code&gt; you are redirected to a pre-filled policy generator:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.louisborsu.be/images/posts/2015-10-22-aws-iot-getting-sarted-tutorial-with-nodejs/13-we-have-to-create-a-policy-to-have-access.png&quot; alt=&quot;We have to create a policy to have access&quot; title=&quot;We have to create a policy to have access&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Just validate it as it is and it will be automatically added to our &lt;em&gt;rule&lt;/em&gt;:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.louisborsu.be/images/posts/2015-10-22-aws-iot-getting-sarted-tutorial-with-nodejs/14-the-policy-is-automatically-added.png&quot; alt=&quot;The policy is automatically added&quot; title=&quot;The policy is automatically added&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Now, just click on &lt;code class=&quot;highlighter-rouge&quot;&gt;Add Action&lt;/code&gt; and you’ll be able to finish the &lt;em&gt;rule&lt;/em&gt; creation process:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.louisborsu.be/images/posts/2015-10-22-aws-iot-getting-sarted-tutorial-with-nodejs/15-your-action-is-added.png&quot; alt=&quot;Your action is added&quot; title=&quot;Your action is added&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Now, let’s publish a message to that topic and read what we get in return:&lt;/p&gt;

&lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nx&quot;&gt;device&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;on&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'connect'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'connected'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;device&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;subscribe&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'topic_1'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;device&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;publish&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'topic_2'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;JSON&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;stringify&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;test_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}));&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Then if we run our application, we receive back our message in return:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# node test.js&lt;/span&gt;
connected
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; topic: &lt;span class=&quot;s1&quot;&gt;'topic_1'&lt;/span&gt;, qos: 0 &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;
message topic_1 &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;test_data&quot;&lt;/span&gt;:1&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Here is the end of our tutorial, it’s a very basic introduction to the usage of AWS IoT, but it gives you a good view of the pub/sub system that this service offers. With that process in mind, you could easily tweak it to:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Store sensors values into a dynamoDb&lt;/li&gt;
  &lt;li&gt;Light up a led from a web server&lt;/li&gt;
  &lt;li&gt;…&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can also find more advanced examples on the &lt;a href=&quot;https://github.com/aws/aws-iot-device-sdk-js&quot;&gt;AWS JS SDK repository&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you want a French and updated version of this article, you can find it here : &lt;a href=&quot;https://lacavediy.com/2018/01/01/aws-iot-connexion-avec-le-guide-assiste/&quot;&gt;https://lacavediy.com/2018/01/01/aws-iot-connexion-avec-le-guide-assiste/&lt;/a&gt;&lt;/p&gt;

</description>
        <pubDate>Thu, 22 Oct 2015 00:00:00 +0000</pubDate>
        <link>https://blog.louisborsu.be/aws-iot-getting-started-tutorial-with-nodejs/</link>
        <guid isPermaLink="true">https://blog.louisborsu.be/aws-iot-getting-started-tutorial-with-nodejs/</guid>
      </item>
    
      <item>
        <title>Une contre histoire de l'internet</title>
        <description>&lt;p&gt;This documentary is a good one, it’s in french, but I trust you to find subtitles :)&lt;/p&gt;

&lt;iframe width=&quot;560&quot; height=&quot;315&quot; src=&quot;https://www.youtube.com/embed/tztUbIPb5oQ&quot; frameborder=&quot;0&quot; allowfullscreen=&quot;&quot;&gt;&lt;/iframe&gt;
</description>
        <pubDate>Mon, 02 Mar 2015 00:00:00 +0000</pubDate>
        <link>https://blog.louisborsu.be/une-contre-histoire-de-l-internet/</link>
        <guid isPermaLink="true">https://blog.louisborsu.be/une-contre-histoire-de-l-internet/</guid>
      </item>
    
      <item>
        <title>DEFCON Documentary</title>
        <description>&lt;p&gt;Pretty interesting documentary about the DEFCON&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://vimeo.com/69695831&quot;&gt;https://vimeo.com/69695831&lt;/a&gt;&lt;/p&gt;
</description>
        <pubDate>Wed, 25 Feb 2015 00:00:00 +0000</pubDate>
        <link>https://blog.louisborsu.be/defcon-documentary/</link>
        <guid isPermaLink="true">https://blog.louisborsu.be/defcon-documentary/</guid>
      </item>
    
      <item>
        <title>I've started at Betacowork!</title>
        <description>&lt;p&gt;So, today, I’ve started to &lt;strong&gt;cowork&lt;/strong&gt; with &lt;a href=&quot;https://be.linkedin.com/in/aborsu&quot;&gt;Gus&lt;/a&gt;. Yes, finally after years of work at my place, I wanted to leave my house a bit during the week.
&lt;br /&gt;
So, we decide to find a place to rent with a great womminuty to work with. After few searchs, we’ve found the &lt;a href=&quot;http://www.betacowork.com/&quot;&gt;Betacowork&lt;/a&gt; space in Etterbeek. Yes, like 5minutes walk from our acutal place! And like &lt;a href=&quot;https://be.linkedin.com/in/aborsu&quot;&gt;Gus&lt;/a&gt; said, 5minutes walk if we’re slow.
&lt;br /&gt;
We took some info from &lt;a href=&quot;http://www.betacowork.com/profile/?profile_id=851&quot;&gt;Stefania Scognamiglio&lt;/a&gt; on their website (instant chat) and we subscribe for a trial day the day after.
&lt;br /&gt;
We started our day with a visit kindly done by &lt;a href=&quot;http://www.betacowork.com/profile/1610/sara-magnabosco/&quot;&gt;Sara Magnabosco&lt;/a&gt;, after that, we sit with &lt;a href=&quot;http://www.betacowork.com/profile/?profile_id=181&quot;&gt;Ramon Suarez&lt;/a&gt; during his lunch (with the non-enought knowed spicy sauce :) ) and explained him our project. The place is quiet, lighty and the team that leads the project seems fun and proactive. Let’s try then!
&lt;br /&gt;
We choosed our local between the three availables (two “noisy” and a quiet one). We pick up a “noisy” (it means that you can skype there or receive a phone call) and seriously, I’m sure I am more noisy when I sleep, so it’s really confortable.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;http://www.betacowork.com/wp-content/uploads/2013/05/David_Plas_Betagroup_8373-550x365.jpg&quot; alt=&quot;CoWorking Zone&quot; title=&quot;Here is a coworking zone&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;The first day was a great experience, we gain in productivity and I came back home workless. And this last one is really the plus of this solution.&lt;/p&gt;

</description>
        <pubDate>Wed, 20 Aug 2014 00:00:00 +0000</pubDate>
        <link>https://blog.louisborsu.be/I-ve-started-at-betacowork!/</link>
        <guid isPermaLink="true">https://blog.louisborsu.be/I-ve-started-at-betacowork!/</guid>
      </item>
    
      <item>
        <title>A project for Galaxy Studio</title>
        <description>&lt;p&gt;I did sign hard NDA’s so I couldn’t speak about what we do, but I’m happy and proud to count the Galaxy Studio as one of our customers!&lt;/p&gt;
</description>
        <pubDate>Mon, 18 Aug 2014 00:00:00 +0000</pubDate>
        <link>https://blog.louisborsu.be/A-project-for-Galaxy-Studio/</link>
        <guid isPermaLink="true">https://blog.louisborsu.be/A-project-for-Galaxy-Studio/</guid>
      </item>
    
      <item>
        <title>Welcome to my blog!</title>
        <description>
&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-fortran&quot; data-lang=&quot;fortran&quot;&gt;&lt;span class=&quot;k&quot;&gt;program&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;hello&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;  &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Hello World!&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;program&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;hello&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;welcome-to-this-blog-&quot;&gt;Welcome to this blog !&lt;/h2&gt;

&lt;p&gt;This blog is here to provide you the progress of my projects.&lt;/p&gt;

&lt;p&gt;&lt;br /&gt;
I will post here some news about my different projects and the technical choices/discoveries that I’ve met during the development process. I do not have the greatest pen in the world, and I will not be the most diligent author, but the purpose of this blog is mainly to share technical findings that may help others.&lt;/p&gt;

&lt;p&gt;&lt;br /&gt;
And if nobody reads it, I will be a good snippets system for me :)&lt;/p&gt;

&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
</description>
        <pubDate>Fri, 18 Jul 2014 00:00:00 +0000</pubDate>
        <link>https://blog.louisborsu.be/welcome-on-my-blog!/</link>
        <guid isPermaLink="true">https://blog.louisborsu.be/welcome-on-my-blog!/</guid>
      </item>
    
  </channel>
</rss>