Send data to AWS IoT MQTT broker
In this section we'll explore how to send data from your flow to AWS IoT MQTT broker. The instructions here are specific to the AWS broker, but the principals are the same for any MQTT broker.
Create a Policy and Thing
You'll need to create a Policy to associate with your Thing. To do this, go to IoT Device Management in the Internet of Things section of Services
Expand the Secure menu, select Policies, and then Create a new policy
Give your policy a name and then set the policy action to "iot.*" so that all actions are available. Since we're only testing here, you can set the Resource ARN to "*" as well so that you have access to everything.
Make sure that you select the Allow checkbox and then click Create.
You can now create a Thing from the Manage menu
Create a certificate in the second step of Thing creation
Download the certificate and private key and Activate the certificate
Now you need to attach the policy created earlier to your Thing and register it
Configure the AWS MQTT node in your Thingstream flow
We've already covered creating and deploying a flow, so here we will just look at adding and configuring the AWS MQTT node to an existing flow.
You'll find the AWS MQTT node in the AWS section of the node palette. Connect that to your flow and double click to configure.
Select the pencil icon to the right hand side of the Server box to update the details of the AWS IoT MQTT connection.
You'll find the Server endpoint value in the AWS console (see AWS screen below). Just copy and paste it to the Server box in your flow.
The client ID should match the name of the Thing you created in AWS
You should upload the certificate and private key that you downloaded earlier when you created the Thing in AWS and then click update.
Go back to AWS, select Test from the menu and then subscribe to the topic that you told the AWS MQTT node in Thingstream to publish to
Now when the flow executes, you'll see the payload published in the AWS console