Skip to main content
Version: 1.8.5

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 FieldDescription
NameName of the connection.
Account prefixAccount 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 RegionRegion 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 IDID of the access key generated for your AWS IoT account, 20 alphanumeric characters. See Access Key ID and Secret Access Key.
Secret Access KeySecret access key generated with the access key ID.
ProtocolSSL (MQTT over TLS v1.2 with the certificate of your AWS IoT account) or WSS (MQTT over secure WebSockets). Default SSL.
Certificate IDID (ARN) of the certificate registered in your AWS IoT account. SSL only. See Certificate and Policy.
CertificateCertificate file registered in your AWS IoT account. SSL only.
Private KeyPrivate key file of this certificate. SSL only.
Published topic patternTopic where the connector publishes the uplinks. Default tpx/things/{DevEUI}/uplink. See Topic Pattern Expression.
Subscribed topic patternTopic where the connector receives the downlinks. Default tpx/things/{DevEUI}/downlink.
DescriptionOptional description of the connection.

The following settings are in the Advanced Settings section of the connection details, once the connection is created:

UI FieldDescription
Device TypeAWS 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 portLoRaWAN® 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.

  1. Open the AWS IoT console. AWS IoT console

  2. Click Domain configuration. The page shows the endpoint of your account. Endpoint of the AWS IoT account

  3. Copy the account prefix and the region from the endpoint: in this example, a2e8k469sk385s-ats and eu-central-1.

Note

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:

  1. In the Manage section, click Types to open the list of thing types. Thing types in the AWS IoT console

  2. Click Create. Create a thing type

  3. Enter the name of the new thing type and click Create thing type. Thing type form

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:

  1. Click Services in the banner.

  2. Click IAM (Identity and Access Management). IAM in the AWS services

  3. In the dashboard, click Users. Users in the IAM dashboard

  4. Click Add user.

  5. In the Add user page, enter a user name. User name of the new IAM user

  6. Click Next: Permissions.

  7. In the Set permissions page, click Attach existing policies directly. Set the permissions of the IAM user

  8. Click Create policy.

  9. In the Create policy page, open the JSON editor and enter the policy.

Note

The minimum actions to allow in the policy are:

  • iot:ListThings
  • iot:CreateThing
  • iot: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: Policy in the JSON editor

  1. Click Review policy.

  2. In the review page, click Create policy. Review the policy

  3. Close the Policy tab.

  4. In the Add user page, click Refresh.

  5. Select the policy that you created and click Next. Select the policy

  6. In the Review and create page, click Create user. Create the IAM user

A page confirms that the user is created.

  1. Open the user, go to the Security credentials tab and click Create access key. Create an access key

  2. Select Application running outside AWS and click Next. Type of access key

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

Certificate and Policy​

With the SSL protocol, the connection needs a certificate registered in your AWS IoT account, with a policy attached.

  1. In AWS IoT Core, go to Manage -> Security -> Certificates. Certificates in AWS IoT Core

  2. Click Add certificate.

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

  4. Click Create.

  5. Download the certificate file and its private key. Download the certificate and the private key

  6. Click Continue. A notification confirms that the certificate is created.

  7. Open the certificate you created: its details give the Certificate ARN, which is the Certificate ID of the connection. Certificate ARN

  8. Go to Policies and click Create policy. Create a policy

  9. 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": "*"
}
]
}

Policy statements

  1. Click Create. A notification confirms that the policy is created.

  2. Go back to the details of your certificate and click Attach policy. Attach a policy to the certificate

  3. Select your policy and click Attach policy. Select the policy to attach

A notification confirms that the policy is attached to your certificate.

Creating a Connection With UI​

  1. In ThingPark Enterprise, click Connections -> + Add Connection -> ThingPark X IoT Flow. Add a ThingPark X IoT Flow connection in ThingPark Enterprise

  2. In ThingPark X IoT Flow, click AWS IoT Core in the list of connectors. Select the AWS IoT Core connector

  3. 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. Set your AWS IoT Core connection
  4. Click Create. A notification confirms that the connection has been created, and the connection details open.

  5. In the connection details, check that the connection is OPENED (see Connection States).

Note

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.

  1. Click the Edit button next to Protocol and Authentication.

  2. In the Protocol and Authentication window, select the new protocol. With SSL, enter the Certificate ID and select the Certificate and Private Key files.

  3. 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 /connections to create a new Connection instance
  • PUT /connections to update a Connection instance
  • DELETE /connections to delete a Connection instance
Note

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.

PropertyConfiguration value
connectorIdMust be set to actility-aws-iot.
configuration/uplinkTopicPatternPattern 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/downlinkTopicPatternPattern 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/deviceTypeAWS IoT thing type associated with the devices of the connection.
configuration/regionRegion of the AWS IoT datacenter, for example:
  • eu-central-1: EU (Frankfurt)
  • us-east-1: US East (N. Virginia)
  • cn-north-1: China (Beijing)
For more information, see the AWS documentation.
configuration/accountPrefixAccount prefix of the AWS IoT account.
configuration/protocolSSL or WSS. Default SSL.
configuration/secretAccessKeySecret access key of the AWS IoT account, required to register the devices.
configuration/accessKeyIdID of the access key of the AWS IoT account, required to register the devices.
configuration/certificateIdID (ARN) of the certificate registered in the AWS IoT account. SSL only.
configuration/certificateContent of the certificate file registered in the AWS IoT account, required for the MQTT over TLS v1.2 connection.
configuration/privateKeyContent of the private key file registered in the AWS IoT account, required for the MQTT over TLS v1.2 connection.
Important note

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​

  1. In your AWS account, open the Test menu. Test menu of AWS IoT Core

  2. Check that you are connected to the right endpoint (on the right of the window).

  3. Subscribe to a topic, for example tpx/things/65EF801200000345/uplink. Subscribe to a topic

The uplinks of the device appear: Uplinks received in the AWS IoT test client

All received messages are displayed in the same window. All the received messages

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 both payload_hex and payload in the same message.
  • Confirmed: 0 requests an unconfirmed downlink; 1 requests 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: 0 leaves the existing queue unchanged. 1 requests 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​

LimitationDescription
ProtocolMQTT over TLS v1.2 (SSL) is the protocol recommended by Amazon.
Uplink
  • The uplink rate is limited to 1000 msg/s (the connection pool has at most 10 MQTT clients).
  • Uplinks are sent with QoS 0.
DownlinkThe downlink rate is limited to 100 msg/s.
Device
  • Device shadows are not supported.
  • The number of devices is unlimited.

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.