Skip to content

Commit 5f1eb44

Browse files
authored
Mqtt5 Support (#375)
Adds MQTT5 support to the Python V2 SDK.
1 parent e4b02fd commit 5f1eb44

17 files changed

+1874
-24
lines changed

.github/workflows/ci.yml

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ env:
2020
DA_SHADOW_VALUE_DEFAULT: OFF
2121
CI_UTILS_FOLDER: "./aws-iot-device-sdk-python-v2/utils"
2222
CI_SAMPLES_FOLDER: "./aws-iot-device-sdk-python-v2/samples"
23-
CI_IOT_CONTAINERS: ${{ secrets.AWS_CI_IOT_CONTAINERS }}
23+
CI_IOT_CONTAINERS_ROLE: ${{ secrets.AWS_CI_IOT_CONTAINERS }}
2424
CI_PUBSUB_ROLE: ${{ secrets.AWS_CI_PUBSUB_ROLE }}
2525
CI_CUSTOM_AUTHORIZER_ROLE: ${{ secrets.AWS_CI_CUSTOM_AUTHORIZER_ROLE }}
2626
CI_SHADOW_ROLE: ${{ secrets.AWS_CI_SHADOW_ROLE }}
@@ -34,18 +34,17 @@ jobs:
3434
permissions:
3535
id-token: write # This is required for requesting the JWT
3636
steps:
37-
- name: configure AWS credentials (containers)
38-
uses: aws-actions/configure-aws-credentials@v1
39-
with:
40-
role-to-assume: ${{ env.CI_IOT_CONTAINERS }}
41-
aws-region: ${{ env.AWS_DEFAULT_REGION }}
4237
- name: Build ${{ env.PACKAGE_NAME }}
38+
env:
39+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_DA_ROLE_KEY }}
40+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_DA_ROLE_PRIVATE_KEY }}
4341
# There's hackery in builder.json so that when we run on manylinux
4442
# we build and test using every version of python that we support.
4543
run: |
4644
aws s3 cp s3://aws-crt-test-stuff/ci/${{ env.BUILDER_VERSION }}/linux-container-ci.sh ./linux-container-ci.sh && chmod a+x ./linux-container-ci.sh
4745
./linux-container-ci.sh ${{ env.BUILDER_VERSION }} aws-crt-manylinux2014-x64 build -p ${{ env.PACKAGE_NAME }}
4846
47+
4948
al2:
5049
runs-on: ubuntu-latest
5150
permissions:
@@ -54,7 +53,7 @@ jobs:
5453
- name: configure AWS credentials (containers)
5554
uses: aws-actions/configure-aws-credentials@v1
5655
with:
57-
role-to-assume: ${{ env.CI_IOT_CONTAINERS }}
56+
role-to-assume: ${{ env.CI_IOT_CONTAINERS_ROLE }}
5857
aws-region: ${{ env.AWS_DEFAULT_REGION }}
5958
# We can't use the `uses: docker://image` version yet, GitHub lacks authentication for actions -> packages
6059
- name: Build ${{ env.PACKAGE_NAME }}
@@ -76,7 +75,7 @@ jobs:
7675
- name: configure AWS credentials (containers)
7776
uses: aws-actions/configure-aws-credentials@v1
7877
with:
79-
role-to-assume: ${{ env.CI_IOT_CONTAINERS }}
78+
role-to-assume: ${{ env.CI_IOT_CONTAINERS_ROLE }}
8079
aws-region: ${{ env.AWS_DEFAULT_REGION }}
8180
# set arm arch
8281
- name: Install qemu/docker
@@ -107,6 +106,9 @@ jobs:
107106
- name: run PubSub sample
108107
run: |
109108
python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language Python --sample_file "${{ env.CI_SAMPLES_FOLDER }}/pubsub.py" --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key'
109+
- name: run MQTT5 PubSub sample
110+
run: |
111+
python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language Python --sample_file "${{ env.CI_SAMPLES_FOLDER }}/mqtt5_pubsub.py" --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key'
110112
- name: run Windows Certificate Connect sample
111113
run: |
112114
python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language Python --sample_file "${{ env.CI_SAMPLES_FOLDER }}/windows_cert_connect.py" --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' --sample_run_certutil true
@@ -141,6 +143,9 @@ jobs:
141143
- name: run PubSub sample
142144
run: |
143145
python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language Python --sample_file "${{ env.CI_SAMPLES_FOLDER }}/pubsub.py" --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key'
146+
- name: run MQTT5 PubSub sample
147+
run: |
148+
python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language Python --sample_file "${{ env.CI_SAMPLES_FOLDER }}/mqtt5_pubsub.py" --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key'
144149
- name: configure AWS credentials (Device Advisor)
145150
uses: aws-actions/configure-aws-credentials@v1
146151
with:
@@ -172,6 +177,9 @@ jobs:
172177
- name: run PubSub sample
173178
run: |
174179
python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language Python --sample_file "${{ env.CI_SAMPLES_FOLDER }}/pubsub.py" --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key'
180+
- name: run MQTT5 PubSub sample
181+
run: |
182+
python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language Python --sample_file "${{ env.CI_SAMPLES_FOLDER }}/mqtt5_pubsub.py" --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key'
175183
- name: configure AWS credentials (Device Advisor)
176184
uses: aws-actions/configure-aws-credentials@v1
177185
with:
@@ -213,6 +221,15 @@ jobs:
213221
- name: run PubSub sample
214222
run: |
215223
python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language Python --sample_file "${{ env.CI_SAMPLES_FOLDER }}/pubsub.py" --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key'
224+
- name: run MQTT5 PubSub sample
225+
run: |
226+
python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language Python --sample_file "${{ env.CI_SAMPLES_FOLDER }}/mqtt5_pubsub.py" --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key'
227+
- name: run MQTT5 PKCS11 Connect sample
228+
run: |
229+
mkdir -p /tmp/mqtt5/tokens
230+
export SOFTHSM2_CONF=/tmp/softhsm2.conf
231+
echo "directories.tokendir = /tmp/mqtt5/tokens" > /tmp/softhsm2.conf
232+
python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language Python --sample_file "${{ env.CI_SAMPLES_FOLDER }}/mqtt5_pkcs11_connect.py" --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/keyp8' --sample_run_softhsm 'true' --sample_arguments '--pkcs11_lib /usr/lib/softhsm/libsofthsm2.so --pin 0000 --token_label my-token --key_label my-key'
216233
- name: run PKCS11 Connect sample
217234
run: |
218235
mkdir -p /tmp/tokens
@@ -227,6 +244,9 @@ jobs:
227244
- name: run CustomAuthorizerConnect sample
228245
run: |
229246
python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language Python --sample_file "${{ env.CI_SAMPLES_FOLDER }}/custom_authorizer_connect.py" --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_custom_authorizer_name 'ci/CustomAuthorizer/name' --sample_secret_custom_authorizer_password 'ci/CustomAuthorizer/password'
247+
- name: run MQTT5 CustomAuthorizerConnect sample
248+
run: |
249+
python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language Python --sample_file "${{ env.CI_SAMPLES_FOLDER }}/mqtt5_custom_authorizer_connect.py" --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_custom_authorizer_name 'ci/CustomAuthorizer/name' --sample_secret_custom_authorizer_password 'ci/CustomAuthorizer/password'
230250
- name: configure AWS credentials (Shadow)
231251
uses: aws-actions/configure-aws-credentials@v1
232252
with:

awsiot/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
'iotshadow',
99
'greengrass_discovery',
1010
'mqtt_connection_builder',
11+
'mqtt5_client_builder',
1112
]
1213

1314
from awscrt import mqtt

0 commit comments

Comments
 (0)