AWS IoT Core: Enabling Remote Device Control with AWS IoT Core Jobs
Introduction
AWS IoT Core is a utility meant to interact with Amazon Web Services cloud platform. It provides AWS IoT Core Jobs, allowing users to control devices from the AWS IoT Core platform using the device's API. This makes it straightforward to operate and handle devices remotely through the cloud.
Prerequisites
- A Teltonika Networks device with access to the internet;
- An AWS account and registered Thing (IoT device).
Device Configuration
To begin, we need to prepare and configure the device correctly. The first step is to install the AWS IoT Core package, followed by setting up a Thing instance for connection. Once this is done, we will be able to manage the device via the API from the AWS cloud.
AWS IoT Core package Installation
To install the AWS IoT Core package, please navigate to the System → Package Manager page in the router's WebUI. There, locate the AWS IoT Core package and click the Install button.
Adding a thing on Teltonika Networks devices and AWS IoT Core platform
This Wiki guide is specifically focused on remote device management via AWS IoT Core platform. If you are looking for instructions on how to add your Teltonika Networks device to AWS IoT Core, please refer to the tutorial available here.
Device Management With API via AWS IoT Core Jobs
Device can be managed via API by using the AWS IoT Core Jobs service, which allows users to send remote commands securely and efficiently to networking devices. When integrated with Teltonika Networks devices, this setup enables network administrators to trigger specific API endpoints—such as updating configurations, or querying system data and similar - without requiring direct access to the device WebUI.
Once your device is successfully connected to the AWS platform, you can use either the AWS web interface or the AWS cloudshell to remotely send commands to it. This Wiki guide provides demonstration of both approaches.
Managing devices via Cloudshell
To open the AWS CloudShell interface, click the CloudShell icon located on the AWS toolbar. Once opened, you will be able to enter commands directly into the CloudShell terminal, as illustrated in the screenshot below.
Once the interface is opened, you can begin executing commands. In this example, we demonstrate an API call that modifies the state of an output pin on a RUT241 device via the Modbus protocol.
To accomplish it, we are using the following command:
aws iot create-job --job-id t1 --targets arn:xxxxxxxxxxxxxxxxxxxxx:thing/RUT241_JS \
> --document '{"http_method":"post","endpoint":"/modbus/client/tcp/1/requests/actions/test_request","request_body":"{\"data\": {\"server_id\":\"1\",\"timeout\":\"1\",\"function\":\"6\",\"first_reg\":\"326\",\"reg_count\":\"1\",\"data_type\":\"16bit_uint_hi_first\",\"no_brackets \":\"0\",\"dev_ipaddr\":\"192.168.1.1\",\"port\":\"502\",\"delay\":\"1\"}}"}';
Syntax Breakdown:
aws iot create-job:
The AWS CLI command to create a new IoT Job.
--job-id t1:
Assigns the job a unique identifier (t1). This ID is used to track or manage the job later. You can choose any ID, which is not used for another call already.
--targets arn:XXXXXXXXXXX:thing/RUT241_JS:
Specifies the target device(s) by their AWS IoT thing ARN. In this case, the command targets a single device registered as RUT241_JS. Please note, that instead of XXXXXXX, you should specify your exact ARN.
--document:
Contains the job document in JSON format. This is the set of instructions that the device will execute. In this case, the job document simulates an HTTP API request.
"http_method": "post"
The type of HTTP request to make—here, a POST request.
"endpoint": "/modbus/client/tcp/1/requests/actions/test_request"
The internal API endpoint on the Teltonika RUT241 device used to initiate a Modbus TCP client request. All API endpoints of RUTOS can be found here https://developers.teltonika-networks.com/
"request_body"
A JSON string containing the parameters for the Modbus request. More information about Modbus can be found [[1]]
When this command is executed, the device register will be updated to the value "1", thereby setting the output PIN state to "High Level".
After executing this command, you can verify the status of the created job using the following command:
aws iot describe-job-execution --thing-name RUT241_JS --job-id t1
The output will indicate whether the job is still in progress or has been executed successfully.
You can check whether the status was changed sucesfully by executing the following command in the cloudshell
aws iot create-job --job-id 2 --targets arn:aws:iot:eu-north-1:xxxxxxxx:thing/RUT241_JS \
> --document '{"http_method":"get","endpoint":"/io/status"}'
This creates a second Job, which sends GET request to the /io/status endpoint.
To view the result of this command, you need to execute an additional command using the describe-job-execution parameter. The full command for this purpose is:
aws iot describe-job-execution --job-id 2 --thing-name RUT241_JS
In the details of this output, you can locate that the output value is changed to the "1".
You can find more detailed explanations of AWS Jobs syntax and usage in the official AWS explanation guide here here
You can find more detailed explanations about how to manage jobs using AWS cloudshell here here
This section demonstrated how CloudShell can be used to modify the device configuration and verify whether the changes were successfully applied and the new parameters were set correctly.
Managing devices via AWS WebUI
If the CloudShell approach is not suitable for your needs, the same results can be achieved using the AWS Web Console (WebUI). This section will demonstrate how to perform the same operations previously shown in CloudShell, but through the AWS WebUI interface. This is achieved by configuring a "Jobs".
Jobs define a set of remote operations to send to and run on one or more devices that are connected to AWS IoT. If you have remote operations that are frequently performed, such as rebooting or installing new applications, use job templates to create reusable jobs.
To configure a Job, certain components must be set up in advance on AWS. As a prerequisite, you must have a registered Thing and a Job document uploaded to your AWS S3 storage bucket.
Job documents specify the remote action to send to and run on devices that are connected to AWS IoT. Jobs that are used often can be converted to a job template for quicker deployment.
1. Creating a bucket
Buckets are containers for data stored in S3.
To create a bucket, navigate to the S3 service in the AWS Management Console and click the "Create bucket" button.
For the purpose of this Wiki gyuide, we will create a basic bucket using the default settings, without modifying most of the configuration options of the bucket.
2. Adding job document
Once the bucket has been created, click on it to open its contents and upload a Job document, which defines the remote actions to be executed. To upload the Job document, click the "Upload" button. In the upload window, either add the file manually or drag and drop it into the designated area, then click the "Upload" button at the bottom to complete the process.
The AWS Job document used in this Wiki is designed to set the output PIN to a high level, replicating the same configuration demonstrated earlier via CloudShell. You can create a new Job document based on the RUTOS API, as outlined previously.
3. Creating a job
Once a Thing is connected, a bucket is created, and the Job document has been uploaded, you can proceed with creating a Job. To do so, navigate to Manage → Remote Actions → Jobs in the AWS Management Console, then click the "Create job" button.
In the next window, press "Create Custom job" option and press "Next" button.
Further, enter Job name and optionally description. We are going to name this job js241test for this guide.
Next, we have to select Thing on which the job will be executed and the job document, which we previously uploaded to the bucket created on S3.
Lastly, you have to choose job run type. For this guide, we will choose snapshot type.
After selecting the job type, click the "Submit" button to create and save the Job. You will then be redirected to the Jobs page, where you can view all created Jobs along with their current status.















