This example is based on AWS coreMQTT mutual authentication demo and demonstrates how to use cloud-connectivity on Arm Virtual Hardware (AVH) via VSocket interface, and how to verify such communication with Continuous Integration (CI) workflows. The project is maintained in the GitHub repository github.com/ARM-software/AVH-AWS_MQTT_Demo that also contains additional description of the example.
The AWS MQTT Example application connects to AWS MQTT broker using TLS with mutual authentication between the client and the server. As a network interface either Ethernet or WiFi can be used on hardware boards, or VSocket on Arm FVP models. The application subscribes to MQTT topics and publishes messages that can be observed in AWS IoT MQTT client.
Automated test execution is managed with GitHub Actions and gets triggered on every code change in the repository. The program gets built and run on Arm Virtual Hardware cloud infrastructure in AWS and the test results can be then observed in repository's GitHub Actions.
Following is required to reproduce operation of the example project:
In order to communicate with the AWS IoT service the embedded application needs to be commissioned with proper connection and security parameters that match the configuration in the cloud service. Create AWS IoT Thing describes how to setup necessary endpoint in the AWS and Commission parameters to device explains how to apply the parameters in the embedded code.
The communication and security parameters can be obtained from AWS IoT Core service. Steps below explain the process for this example and AWS tutorial Create AWS IoT provides general overview and additional references.
Create an AWS IoT Thing for your device as follows:
Now you have all information required for connecting your device to the AWS IoT Cloud.
In the example code the required commissioning parameters are defined in the following files:
Note: when the project is imported to uVision these files are present in the demos_include
group.
Specifically following definitions need to be updated:
clientcredentialMQTT_BROKER_ENDPOINT
: Device data endpointclientcredentialIOT_THING_NAME
: Thing NamekeyCLIENT_CERTIFICATE_PEM
: Client Security CertificatekeyCLIENT_PRIVATE_KEY_PEM
: Client Private KeyclientcredentialWIFI_SSID
: WiFi Access Point SSID (when connecting via WiFi, can be empty otherwise).clientcredentialWIFI_PASSWORD
: WiFi Access Point Password (when connecting via WiFi, can be empty otherwise).Note that when running the example on Arm Virtual Hardware using GitHub Actions, corresponding definitions (non-WiFi) are automatically updated in the code with values stored in GitHub Secrets.
To build and run this application program with a GitHub Actions workflow the following steps are required. For details refer to Run AMI with GitHub Actions.
The following (secret) configuration values need to be added to the repositories as GitHub Secrets.
Secret Name | Description |
---|---|
AWS Access | Settings and credentials required to acces AWS EC2 and S3 services |
AWS_IAM_PROFILE | The IAM Role to be used for AWS access. |
AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY | Access key pair for the AWS account (as IAM user) that shall be used by the CI workflow for AWS access. |
AWS_S3_BUCKET_NAME | The name of the S3 storage bucket to be used for data exchange between GitHub and AWS AMI. |
AWS_DEFAULT_REGION | The data center region the AVH AMI will be run on. For example eu-west-1 . |
AWS_SECURITY_GROUP_ID | The id of the VPC security group to add the EC2 instance to. Shall have format sg-xxxxxxxx . |
AWS_SUBNET_ID | The id of the VPC subnet to connect the EC2 instance to. Shall have format subnet-xxxxxxxx . |
IoT Cloud Access | Settings and credentials required to connect an AWS IoT Thing |
CLIENT_CERTIFICATE_PEM | Client (device) certificate |
CLIENT_PRIVATE_KEY_PEM | Client (device) private key |
IOT_THING_NAME | Client (device) name |
MQTT_BROKER_ENDPOINT | MQTT broker host name |