Skip to main content
All CollectionsUser Guides
Plugins: Connect AWS IoT Core to Ubidots using HTTPS
Plugins: Connect AWS IoT Core to Ubidots using HTTPS

Receive and decode data from devices connected to AWS IoT Core

Sergio M avatar
Written by Sergio M
Updated over a week ago

Ubidots and AWS have partnered to create a pre-built integration allowing users to easily forward sensor data from AWS IoT Core to Ubidots, using Plugins.

This integration will automatically create the following resources in your AWS account:

Requirements

Table of Contents

1. Creating a Policy

To Create a Policy, go to your AWS IAM Management console, then click on the Policies option in the left panel, and follow these steps:

  1. Obtain your Account ID Number by clicking on your username at the top-right corner:


  2. Click on the Create Policy button.

  3. Select the JSON tab and paste the following code. You will need to replace the <NumberAccountUser> field for your Account ID Number. Then, Move to the next page.

    {
    "Version": "2012-10-17",
    "Statement": [
    {
    "Sid": "VisualEditor0",
    "Effect": "Allow",
    "Action": [
    "iam:GetRole",
    "iam:CreateRole",
    "iam:PutRolePolicy",
    "iam:ListRolePolicies"
    ],
    "Resource": "arn:aws:iam::<NumberAccountUser>:role/Ubidots*"
    }
    ]
    }

  4. Leave the tags section as it is and move to the review page.

  5. In the Review policy page only fill out the Name field, assign a name to identify your new created policy and click on the Create policy.

2. Creating a user

  1. Click on the "Create user" button.

  2. Enter a name for the user and then click the "Next" button.

  3. Click on the option "Attach existing policies directly". Look for the policy created in the previous step and select it.

  4. Skip the tags page and move to next page.

  5. Click on the "Create user" button.

3. Retrieve your AWS Access Keys

  1. Click on the recently created user.

  2. Click the "Security Credentials" tab and scroll down to the "Access Keys" section. Then click the "Create access key" button.

  3. Select "Third-party service" and check the confirmation checkbox

  4. Copy the “Access key ID” and the “Secret access key” which will be used later to complete the AWS Plugin on Ubidots platform. You can also download the keys with the Download .csv button.

4. Creating an AWS IoT Core Plugin

The AWS IoT Core Plugin is a serverless function that exposes a private HTTPS Endpoint URL optimized to decode AWS HTTPS Rule JSON payloads. Every time an HTTP POST request is received at such URL, a pre-defined decoding function will be executed.

To create a plugin:

1. In your Ubidots account, go to the "Devices" tab, click on "Plugins", then click on the "+" icon to create a new Plugin. Search for the AWS IoT Core Plugin, click on it and follow the on-screen steps:

2. An authentication window will appear. Enter your AWS Access Key ID and Secret Access Key created earlier in this guide. By entering your AWS Access Keys, Ubidots will automatically setup the required resources in AWS to complete the integration.

IMPORTANT NOTE: As a security measure, Ubidots does NOT store any AWS Access Key IDs or Secret Keys. The permission with Access Keys is used only once at the beginning of a Plugin's setup to create a restricted role in AWS and securely setup AWS resources to stream data to Ubidots. If you’d rather not provide your AWS keys, an advanced integration can be setup using AWS IAM Role and this user guide.

3. After successful authentication, the plugin configuration options will appear:

  • AWS Region: The AWS region where you currently use AWS IoT Core, or plan to. Ubidots will create the AWS IoT Rule and HTTPS Destination in this region.

  • Associated device type: An Ubidots device type will be created and linked to this plugin. Editing the device type allows you to make batch changes to all devices that receive data through this plugin.

  • AWS IoT Rule Query Statement: The query statement applied by the AWS IoT Rule before forwarding any data to this plugin. See AWS IoT SQL Reference.

  • Ubidots token: Select the Ubidots token you'd like to use for this plugin. We recommend creating a new token dedicated to this plugin only, should you need to increase its rate limit in the future.

Ubidots will create an HTTPS AWS IoT rule action pointing to this plugin. This may take up to 3 minutes. You can check the progress in your AWS account by going to the "Destinations" option within the "Act" section of AWS IoT.

NOTE: You should see a new destination. At first, it will appear as "Disabled" while a verification process is done by AWS. After a few minutes, it will become "Enabled".

4. Finish the process and a new plugin will appear in the Plugins list.

4. Decoding your custom payloads

To edit the decoding function, click con the created plugin and go to "Decoder". By default, this plugin is pre-configured to grab data from the topic:

$aws/things/+/shadow/update

Where "+" is a unique identifier of the device, to be used in Ubidots as the unique device label. If data from an unknown device label is received, then Ubidots will automatically create a new device upon reception of the first datapoints.

The default expected data format is as follows, but of course, you can change it at will using the decoder:

{ 
"state": {
"reported": {
"temperature": 23,
"humidity":55
}
}
}

5. Feedback and suggestions

Feel free to post questions or suggestions in our community portal, or drop us a line at support@ubidots.com.

Learn more about other plugins:

Did this answer your question?