CREATING AN AWS CONNECTION
The AWS IoT Core connector publishes the messages of your devices to topics of your AWS IoT Core account, and subscribes to a topic of the account to receive the downlinks that your applications publish there. It also registers your devices as things of your AWS IoT account.
The data follows this path: LoRaWAN® device → ThingPark Enterprise → ThingPark X IoT Flow connection → AWS IoT Core.
Before you create the connection, you need an active AWS IoT account. ThingPark does not create any AWS application instance. You also need to be aware of the application provisioning constraints of ThingPark Enterprise.
The connection uses one of two protocols:
- SSL: MQTT over TLS v1.2, with a certificate and a private key registered in your AWS IoT account. This is the protocol recommended by Amazon.
- WSS: MQTT over secure WebSockets. No certificate or private key is needed.
Collecting Expected Information
Parameters required
| UI Field | Description |
|---|---|
| Name | Name of the connection. |
| Account prefix | Account prefix of your AWS IoT account. The endpoint of your account is <accountPrefix>.iot.<region>.amazonaws.com: for example, the account prefix is a2shubp7zpiozr for a2shubp7zpiozr.iot.us-west-2.amazonaws.com. See Account Prefix and Region. |
| AWS Region | Region of your AWS IoT account, for example us-west-2. If your endpoint is accountPrefix.iot.exampleregion.amazonaws.com, your region is exampleregion. |
| Access Key ID | ID of the access key generated for your AWS IoT account, 20 alphanumeric characters. See Access Key ID and Secret Access Key. |
| Secret Access Key | Secret access key generated with the access key ID. |
| Protocol | SSL (MQTT over TLS v1.2 with the certificate of your AWS IoT account) or WSS (MQTT over secure WebSockets). Default SSL. |
| Certificate ID | ID (ARN) of the certificate registered in your AWS IoT account. SSL only. See Certificate and Policy. |
| Certificate | Certificate file registered in your AWS IoT account. SSL only. |
| Private Key | Private key file of this certificate. SSL only. |
| Published topic pattern | Topic where the connector publishes the uplinks. Default tpx/things/{DevEUI}/uplink. See Topic Pattern Expression. |
| Subscribed topic pattern | Topic where the connector receives the downlinks. Default tpx/things/{DevEUI}/downlink. |
| Description | Optional description of the connection. |
The following settings are in the Advanced Settings section of the connection details, once the connection is created:
| UI Field | Description |
|---|---|
| Device Type | AWS IoT thing type associated with the devices of the connection, for example waterSensorType. Default actilityDeviceType. Only one device type is supported per connection. See Device Type. |
| Downlink port | LoRaWAN® port used to send a downlink that does not give one. As a connection has only one downlink port and one device type, associate it with a homogeneous set of devices. |
Account Prefix and Region
After you have created your AWS IoT account, retrieve the account prefix and the region of the account.
-
Open the AWS IoT console.

-
Click Domain configuration. The page shows the endpoint of your account.

-
Copy the account prefix and the region from the endpoint: in this example,
a2e8k469sk385s-atsandeu-central-1.
The Endpoint has the format accountPrefix.iot.region.amazonaws.com. If the account prefix does not end with -ats, follow the instructions to set up your Amazon Trust Services (ATS) endpoint, to avoid connection issues due to deprecated trust CAs.
TPE-OCP only: configure your firewall to allow the outgoing traffic on ports 443, 8443 and 8883 towards:
- accountPrefix.iot.region.amazonaws.com
- iot.region.amazonaws.com
Device Type
The Device Type setting is the name of a thing type of your AWS IoT account. To create a thing type:
-
In the Manage section, click Types to open the list of thing types.

-
Click Create.

-
Enter the name of the new thing type and click Create thing type.

The thing type is created and appears in the list of types.
Access Key ID and Secret Access Key
The access key ID and the secret access key are required to register the devices. To get them, create an IAM user:
-
Click Services in the banner.
-
Click IAM (Identity and Access Management).

-
In the dashboard, click Users.

-
Click Add user.
-
In the Add user page, enter a user name.

-
Click Next: Permissions.
-
In the Set permissions page, click Attach existing policies directly.

-
Click Create policy.
-
In the Create policy page, open the JSON editor and enter the policy.
The minimum actions to allow in the policy are:
iot:ListThingsiot:CreateThingiot:AttachThingPrincipal
We recommend this list of actions:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"iot:ListThings",
"iot:CreateThing",
"iot:DescribeThing",
"iot:AttachThingPrincipal",
"iot:Connect",
"iot:Subscribe",
"iot:Receive",
"iot:Publish"
],
"Resource": "*"
}
]
}
The policy in the JSON editor:

-
Click Review policy.
-
In the review page, click Create policy.

-
Close the Policy tab.
-
In the Add user page, click Refresh.
-
Select the policy that you created and click Next.

-
In the Review and create page, click Create user.

A page confirms that the user is created.
-
Open the user, go to the Security credentials tab and click Create access key.

-
Select Application running outside AWS and click Next.

-
Click Create access key, then copy the Access key and the Secret access key. Click Done.

Certificate and Policy
With the SSL protocol, the connection needs a certificate registered in your AWS IoT account, with a policy attached.
-
In AWS IoT Core, go to Manage -> Security -> Certificates.

-
Click Add certificate.
-
In the Create certificate page, select Auto-generate new certificate (recommended) and Active.

-
Click Create.
-
Download the certificate file and its private key.

-
Click Continue. A notification confirms that the certificate is created.
-
Open the certificate you created: its details give the Certificate ARN, which is the Certificate ID of the connection.

-
Go to Policies and click Create policy.

-
Enter a name for the policy. In Policy statements, click JSON and paste this policy:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "iot:Publish",
"Resource": "*"
},
{
"Effect": "Allow",
"Action": "iot:Subscribe",
"Resource": "*"
},
{
"Effect": "Allow",
"Action": "iot:Connect",
"Resource": "*"
},
{
"Effect": "Allow",
"Action": "iot:Receive",
"Resource": "*"
}
]
}

-
Click Create. A notification confirms that the policy is created.
-
Go back to the details of your certificate and click Attach policy.

-
Select your policy and click Attach policy.

A notification confirms that the policy is attached to your certificate.
Creating a Connection With UI
-
In ThingPark Enterprise, click Connections -> + Add Connection -> ThingPark X IoT Flow.

-
In ThingPark X IoT Flow, click AWS IoT Core in the list of connectors.

-
Fill in the form:
- Name: a clear name for the connection, for example
My AWS IoT Core Connection. - Account prefix: the first part of the endpoint of your AWS IoT account.
- AWS Region: the region of your AWS IoT account. If it is not in the list, type it and add it.
- Access Key ID: the access key ID of the IAM user.
- Secret Access Key: the secret access key of the IAM user.
- Protocol: SSL unless you use WSS.
- Certificate ID: the ARN of the certificate registered in your AWS IoT account. Only with SSL.
- Certificate: click the attachment button to select the certificate file. Only with SSL.
- Private Key: click the attachment button to select the private key file. Only with SSL.
- Published topic pattern: keep the default pattern or enter yours.
- Subscribed topic pattern: keep the default pattern or enter yours.
- Description: optional.

- Name: a clear name for the connection, for example
-
Click Create. A notification confirms that the connection has been created, and the connection details open.
-
In the connection details, check that the connection is OPENED (see Connection States).
Parameters marked with * are mandatory.
Changing the Protocol After Creation
In the connection details, the Protocol and Authentication setting shows the protocol of the connection. With SSL, the ID of the certificate follows in parentheses.
-
Click the Edit button next to Protocol and Authentication.
-
In the Protocol and Authentication window, select the new protocol. With SSL, enter the Certificate ID and select the Certificate and Private Key files.
-
Click Save.
If you change the protocol from SSL to WSS, the Certificate ID, Certificate and Private Key fields are hidden, but their values are kept. They come back if you select SSL again.
Creating a Connection With API
MQTT over TLS v1.2 (SSL) is the protocol recommended by Amazon. The connector also supports MQTT over secure WebSockets (WSS).
You need to create an AWS connection before you can associate it with devices. The creation of a connection establishes a bidirectional messaging link between ThingPark X IoT Flow and AWS IoT Core. The messages of many devices go through this link.
To do this, you need to use the Connections group resource:
POST /connectionsto create a new Connection instancePUT /connectionsto update a Connection instanceDELETE /connectionsto delete a Connection instance
We follow the REST-full API pattern, when updating configuration properties for a connection resource. Thus, you must also provide the whole configuration again.
Example for the creation of a new connection instance:
POST /connections
{
"connectorId": "actility-aws-iot",
"name": "My AWS IoT Core Connection",
"configuration": {
"description": "AWS Europe Datacenter",
"uplinkTopicPattern": "tpx/things/{DevEUI}/uplink",
"downlinkTopicPattern": "tpx/things/{DevEUI}/downlink",
"deviceType": "actilitytestsensor",
"region": "eu-central-1",
"accountPrefix": "a1b2c3d4e5f6g7-ats",
"secretAccessKey": "{YOUR-SECRET-ACCESS-KEY}",
"accessKeyId": "AKIAIOSFODNN7EXAMPLE",
"certificateId": "arn:aws:iot:eu-central-1:123456789012:cert/0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
"certificate": "-----BEGIN CERTIFICATE-----...-----END CERTIFICATE-----",
"privateKey": "-----BEGIN RSA PRIVATE KEY-----...-----END RSA PRIVATE KEY-----"
}
}
The following table lists the properties applicable to a connection instance.
| Property | Configuration value |
|---|---|
connectorId | Must be set to actility-aws-iot. |
configuration/uplinkTopicPattern | Pattern of the MQTT topic of the uplinks, compliant with the AWS topic syntax, for example tpx/things/{DevEUI}/uplink. It can contain topic pattern expressions. For the topic syntax, see the AWS documentation. |
configuration/downlinkTopicPattern | Pattern of the MQTT topic of the downlinks. Make sure that it matches the AWS topic filter: for example, tpx/things/{DevEUI}/downlink matches tpx/things/+/downlink. |
configuration/deviceType | AWS IoT thing type associated with the devices of the connection. |
configuration/region | Region of the AWS IoT datacenter, for example:
|
configuration/accountPrefix | Account prefix of the AWS IoT account. |
configuration/protocol | SSL or WSS. Default SSL. |
configuration/secretAccessKey | Secret access key of the AWS IoT account, required to register the devices. |
configuration/accessKeyId | ID of the access key of the AWS IoT account, required to register the devices. |
configuration/certificateId | ID (ARN) of the certificate registered in the AWS IoT account. SSL only. |
configuration/certificate | Content of the certificate file registered in the AWS IoT account, required for the MQTT over TLS v1.2 connection. |
configuration/privateKey | Content of the private key file registered in the AWS IoT account, required for the MQTT over TLS v1.2 connection. |
All properties are not present in this example. You can check the rest of these properties in the common parameters section.
Associating Devices With the Connection
In ThingPark Enterprise, open Devices, select a device, and add the connection to the Connections of the device. You can also select the connection when you create a device, or for many devices at once with a CSV file in Devices -> Bulk Operations.
Displaying Information to Know if It Worked
-
In your AWS account, open the Test menu.

-
Check that you are connected to the right endpoint (on the right of the window).
-
Subscribe to a topic, for example
tpx/things/65EF801200000345/uplink.
The uplinks of the device appear:

All received messages are displayed in the same window.

Sending a Downlink
To send a downlink, publish a JSON message to the AWS IoT Core MQTT topic matching the Subscribed topic pattern of the connection. Make sure that the connection is open, that downlinks are enabled, and that your AWS IoT client is authorized to publish to the topic.
For example, if the pattern is tpx/things/{DevEUI}/downlink, publish to tpx/things/20635F0106000306/downlink with the AWS IoT MQTT test client or another authorized MQTT client. Replace the example topic with the one of your connection. The DevEUI in the message must match the device identifier in the topic.
{
"DevEUI_downlink": {
"DevEUI": "20635F0106000306",
"FPort": 2,
"payload_hex": "0302",
"Confirmed": 0,
"FlushDownlinkQueue": 0
}
}
FPort: the target LoRaWAN application port. If omitted, IoT Flow first checks the matching custom topic configuration, then the downlink port of the connection. A port must be available.payload_hex: the hexadecimal payload to send. Do not provide bothpayload_hexandpayloadin the same message.Confirmed:0requests an unconfirmed downlink;1requests a confirmed downlink, for which the device acknowledges reception in an uplink. The acknowledgment may be delayed and adds radio traffic. A transmission report alone does not guarantee device reception. Confirmed downlinks require the appropriate connectivity-plan feature and are not supported for multicast devices.FlushDownlinkQueue:0leaves the existing queue unchanged.1requests that the application-server downlink queue of the device be purged before adding the new payload. Use it only when discarding queued downlinks is intended.
The connector subscribes to downlink messages at MQTT QoS 0. A successful MQTT publication does not guarantee that the LRC accepted the downlink or that the device received it. For the complete message format, optional parameters, and downlink reports, see Downlink Message.
Limitations
| Limitation | Description |
|---|---|
| Protocol | MQTT over TLS v1.2 (SSL) is the protocol recommended by Amazon. |
| Uplink |
|
| Downlink | The downlink rate is limited to 100 msg/s. |
| Device |
|
AWS IoT Core does not store the messages for disconnected clients: the downlinks published while the connection is not established are lost. For more information, see:
Troubleshooting
There is no known issue with the AWS IoT Core connector.