From 1712a13b4241b9844cc067317ab7f18569b57440 Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Mon, 26 Sep 2022 16:56:15 -0400 Subject: [PATCH 01/50] Initial commit for using new CI workflow in C++ --- .github/workflows/ci.yml | 104 ++++++++- builder.json | 10 +- deviceadvisor/script/DATestConfig.json | 10 +- deviceadvisor/script/DATestRun.py | 86 ++++++-- deviceadvisor/tests/mqtt_connect/main.cpp | 2 - deviceadvisor/tests/mqtt_publish/main.cpp | 2 - deviceadvisor/tests/mqtt_subscribe/main.cpp | 2 - deviceadvisor/tests/shadow_update/main.cpp | 2 - samples/device_defender/basic_report/main.cpp | 34 +-- samples/shadow/shadow_sync/main.cpp | 50 +++-- utils/delete_iot_thing_ci.py | 67 ++++++ utils/run_sample_ci.py | 197 ++++++++++++++++++ 12 files changed, 485 insertions(+), 81 deletions(-) create mode 100644 utils/delete_iot_thing_ci.py create mode 100644 utils/run_sample_ci.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3cc51f3f1..00f646f81 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,9 +13,14 @@ env: PACKAGE_NAME: aws-iot-device-sdk-cpp-v2 LINUX_BASE_IMAGE: ubuntu-16-x64 RUN: ${{ github.run_id }}-${{ github.run_number }} - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_DATEST_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_DATEST_SECRET_ACCESS_KEY }} AWS_DEFAULT_REGION: us-east-1 + CI_IOT_CONTAINERS: ${{ secrets.AWS_CI_IOT_CONTAINERS }} + CI_PUBSUB_ROLE: ${{ secrets.AWS_CI_PUBSUB_ROLE }} + CI_CUSTOM_AUTHORIZER_ROLE: ${{ secrets.AWS_CI_CUSTOM_AUTHORIZER_ROLE }} + CI_SHADOW_ROLE: ${{ secrets.AWS_CI_SHADOW_ROLE }} + CI_JOBS_ROLE: ${{ secrets.AWS_CI_JOBS_ROLE }} + CI_FLEET_PROVISIONING_ROLE: ${{ secrets.AWS_CI_FLEET_PROVISIONING_ROLE }} + CI_DEVICE_ADVISOR: ${{ secrets.AWS_CI_DEVICE_ADVISOR_ROLE }} jobs: linux-compat: @@ -28,6 +33,11 @@ jobs: - al2-x64 steps: + - name: configure AWS credentials (containers) + uses: aws-actions/configure-aws-credentials@v1 + with: + role-to-assume: ${{ env.CI_IOT_CONTAINERS }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} # We can't use the `uses: docker://image` version yet, GitHub lacks authentication for actions -> packages - name: Build ${{ env.PACKAGE_NAME }} run: | @@ -51,6 +61,11 @@ jobs: - gcc-7 - gcc-8 steps: + - name: configure AWS credentials (containers) + uses: aws-actions/configure-aws-credentials@v1 + with: + role-to-assume: ${{ env.CI_IOT_CONTAINERS }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} # We can't use the `uses: docker://image` version yet, GitHub lacks authentication for actions -> packages - name: Build ${{ env.PACKAGE_NAME }} run: | @@ -60,6 +75,11 @@ jobs: byo-crypto: runs-on: ubuntu-latest steps: + - name: configure AWS credentials (containers) + uses: aws-actions/configure-aws-credentials@v1 + with: + role-to-assume: ${{ env.CI_IOT_CONTAINERS }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} # We can't use the `uses: docker://image` version yet, GitHub lacks authentication for actions -> packages - name: Build ${{ env.PACKAGE_NAME }} run: | @@ -69,6 +89,11 @@ jobs: linux-no-cpu-extensions: runs-on: ubuntu-latest steps: + - name: configure AWS credentials (containers) + uses: aws-actions/configure-aws-credentials@v1 + with: + role-to-assume: ${{ env.CI_IOT_CONTAINERS }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} # We can't use the `uses: docker://image` version yet, GitHub lacks authentication for actions -> packages - name: Build ${{ env.PACKAGE_NAME }} run: | @@ -84,6 +109,23 @@ jobs: cd D:\a\work python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz', 'builder.pyz')" python builder.pyz build -p ${{ env.PACKAGE_NAME }} + - name: configure AWS credentials (PubSub) + uses: aws-actions/configure-aws-credentials@v1 + with: + role-to-assume: ${{ env.CI_PUBSUB_ROLE }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: run PubSub sample + run: | + python -m pip install boto3 + python ./utils/run_sample_ci.py --language CPP --sample_file '.\aws-iot-device-sdk-cpp-v2\build\samples\pub_sub\basic_pub_sub\RelWithDebInfo\basic-pub-sub.exe' --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_main_class 'pubsub.PubSub' + - name: configure AWS credentials (Device Advisor) + uses: aws-actions/configure-aws-credentials@v1 + with: + role-to-assume: ${{ env.CI_DEVICE_ADVISOR }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: run DeviceAdvisor + run: | + python3 ./deviceadvisor/script/DATestRun.py windows-vs14: runs-on: windows-2019 # windows-2019 is last env with Visual Studio 2015 (v14.0) @@ -97,6 +139,23 @@ jobs: cd D:\a\work python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder.pyz')" python builder.pyz build -p ${{ env.PACKAGE_NAME }} --cmake-extra=-Tv140 --cmake-extra=-A${{ matrix.arch }} + - name: configure AWS credentials (PubSub) + uses: aws-actions/configure-aws-credentials@v1 + with: + role-to-assume: ${{ env.CI_PUBSUB_ROLE }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: run PubSub sample + run: | + python -m pip install boto3 + python ./utils/run_sample_ci.py --language CPP --sample_file '.\aws-iot-device-sdk-cpp-v2\build\samples\pub_sub\basic_pub_sub\RelWithDebInfo\basic-pub-sub.exe' --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_main_class 'pubsub.PubSub' + - name: configure AWS credentials (Device Advisor) + uses: aws-actions/configure-aws-credentials@v1 + with: + role-to-assume: ${{ env.CI_DEVICE_ADVISOR }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: run DeviceAdvisor + run: | + python3 ./deviceadvisor/script/DATestRun.py windows-no-cpu-extensions: runs-on: windows-latest @@ -107,7 +166,24 @@ jobs: cd D:\a\work python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz', 'builder.pyz')" python builder.pyz build -p ${{ env.PACKAGE_NAME }} --cmake-extra=-DUSE_CPU_EXTENSIONS=OFF - + - name: configure AWS credentials (PubSub) + uses: aws-actions/configure-aws-credentials@v1 + with: + role-to-assume: ${{ env.CI_PUBSUB_ROLE }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: run PubSub sample + run: | + python -m pip install boto3 + python ./utils/run_sample_ci.py --language CPP --sample_file '.\aws-iot-device-sdk-cpp-v2\build\samples\pub_sub\basic_pub_sub\RelWithDebInfo\basic-pub-sub.exe' --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_main_class 'pubsub.PubSub' + - name: configure AWS credentials (Device Advisor) + uses: aws-actions/configure-aws-credentials@v1 + with: + role-to-assume: ${{ env.CI_DEVICE_ADVISOR }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: run DeviceAdvisor + run: | + python3 ./deviceadvisor/script/DATestRun.py + windows-app-verifier: runs-on: windows-2022 # latest steps: @@ -117,6 +193,11 @@ jobs: cd D:\a\work python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz', 'builder.pyz')" python builder.pyz build -p ${{ env.PACKAGE_NAME }} --cmake-extra=-DUSE_CPU_EXTENSIONS=OFF + - name: configure AWS credentials (PubSub) + uses: aws-actions/configure-aws-credentials@v1 + with: + role-to-assume: ${{ env.CI_PUBSUB_ROLE }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} - name: Run and check AppVerifier run: | cd D:\a\work @@ -132,6 +213,23 @@ jobs: python3 -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz', 'builder')" chmod a+x builder ./builder build -p ${{ env.PACKAGE_NAME }} --spec=downstream + - name: configure AWS credentials (PubSub) + uses: aws-actions/configure-aws-credentials@v1 + with: + role-to-assume: ${{ env.CI_PUBSUB_ROLE }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: run PubSub sample + run: | + python3 -m pip install boto3 + python3 ./utils/run_sample_ci.py --language CPP --sample_file '.\aws-iot-device-sdk-cpp-v2\build\samples\pub_sub\basic_pub_sub\pub-sub' --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_main_class 'pubsub.PubSub' + - name: configure AWS credentials (Device Advisor) + uses: aws-actions/configure-aws-credentials@v1 + with: + role-to-assume: ${{ env.CI_DEVICE_ADVISOR }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: run DeviceAdvisor + run: | + python3 ./deviceadvisor/script/DATestRun.py # check that docs can still build check-docs: diff --git a/builder.json b/builder.json index ecd85dd2a..4f1667327 100644 --- a/builder.json +++ b/builder.json @@ -8,11 +8,6 @@ "crt" ], "env": { - "DA_TOPIC": "test/da", - "DA_SHADOW_PROPERTY": "datest", - "DA_SHADOW_VALUE_SET": "ON", - "DA_SHADOW_VALUE_DEFAULT": "OFF", - "DA_S3_NAME": "aws-iot-sdk-deviceadvisor-logs" }, "hosts": { "manylinux": { @@ -28,10 +23,7 @@ "build", "build-samples" ], - "test_steps": [ - "python3 -m pip install boto3", - "python3 deviceadvisor/script/DATestRun.py", - "python3 devicedefender/script/DDTestRun.py"], + "test_steps": [], "variants" : { "skip_sample": { "!test_steps": [], diff --git a/deviceadvisor/script/DATestConfig.json b/deviceadvisor/script/DATestConfig.json index dacca0597..6982c6fe9 100644 --- a/deviceadvisor/script/DATestConfig.json +++ b/deviceadvisor/script/DATestConfig.json @@ -2,11 +2,11 @@ "tests" :[ "MQTT Connect", "MQTT Publish", "MQTT Subscribe", "Shadow Publish", "Shadow Update"], "test_suite_ids" : { - "MQTT Connect" : "ejbdzmo3hf3v", - "MQTT Publish" : "euw7favf6an4", - "MQTT Subscribe" : "01o8vo6no7sd", - "Shadow Publish" : "elztm2jebc1q", - "Shadow Update" : "vuydgrbbbfce" + "MQTT Connect" : "mxn32qkm8npn", + "MQTT Publish" : "gcjhujhhz50p", + "MQTT Subscribe" : "nyiuiwx5yxtj", + "Shadow Publish" : "fttdr8ufljnf", + "Shadow Update" : "ng9t8am2jnry" }, "test_exe_path" : { diff --git a/deviceadvisor/script/DATestRun.py b/deviceadvisor/script/DATestRun.py index 9afd85c40..64b3f2827 100644 --- a/deviceadvisor/script/DATestRun.py +++ b/deviceadvisor/script/DATestRun.py @@ -28,15 +28,26 @@ def process_logs(log_group, log_stream, thing_name): logGroupName=log_group, logStreamName=log_stream ) - log_file = thing_name + ".log" + log_file = "DA_Log_CPP_" + thing_name + ".log" f = open(log_file, 'w') for event in response["events"]: f.write(event['message']) f.close() - s3.Bucket(os.environ['DA_S3_NAME']).upload_file(log_file, log_file) + + try: + secrets_client = boto3.client( + "secretsmanager", region_name=os.environ["AWS_DEFAULT_REGION"]) + s3_bucket_name = secrets_client.get_secret_value("ci/DeviceAdvisor/s3bucket")["SecretString"] + s3.Bucket(s3_bucket_name).upload_file(log_file, log_file) + print("[Device Advisor] Device Advisor Log file uploaded to "+ log_file) + + except Exception: + print ("[Device Advisor] Error: could not store log in S3 bucket!") + os.remove(log_file) print("[Device Advisor] Issues on test " + test_name + ". Please check out the logs at "+thing_name+".log on S3.") +# Sleep for a random time def sleep_with_backoff(base, max): sleep(random.randint(base,max)) @@ -44,14 +55,23 @@ def sleep_with_backoff(base, max): ############################################## # Initialize variables # create aws clients -client = boto3.client('iot') -dataClient = boto3.client('iot-data') -deviceAdvisor = boto3.client('iotdeviceadvisor') -s3 = boto3.resource('s3') +try: + client = boto3.client('iot') + dataClient = boto3.client('iot-data') + deviceAdvisor = boto3.client('iotdeviceadvisor') + s3 = boto3.resource('s3') +except Exception: + print ("[Device Advisor] Error: could not create boto3 clients") + exit(-1) # const BACKOFF_BASE = 5 BACKOFF_MAX = 10 +# 60 minutes divided by the maximum back-off = longest time a DA run can last with this script. +MAXIMUM_CYCLE_COUNT = (3600 / BACKOFF_MAX) + +# Did Device Advisor fail a test? If so, this should be true +did_at_least_one_test_fail = False # load test config f = open('deviceadvisor/script/DATestConfig.json') @@ -80,21 +100,21 @@ def sleep_with_backoff(base, max): # 'thingArn': 'string', # 'thingId': 'string' # } - print("[Device Advisor]Info: Started to create thing...") + print("[Device Advisor] Info: Started to create thing...") create_thing_response = client.create_thing( thingName=thing_name ) os.environ["DA_THING_NAME"] = thing_name - except Exception as e: - print("[Device Advisor]Error: Failed to create thing: " + thing_name) + except Exception: + print("[Device Advisor] Error: Failed to create thing: " + thing_name) exit(-1) ############################################## # create certificate and keys used for testing try: - print("[Device Advisor]Info: Started to create certificate...") + print("[Device Advisor] Info: Started to create certificate...") # create_cert_response: # { # 'certificateArn': 'string', @@ -123,15 +143,18 @@ def sleep_with_backoff(base, max): os.environ["DA_CERTI"] = certificate_path os.environ["DA_KEY"] = key_path - except: - client.delete_thing(thingName = thing_name) - print("[Device Advisor]Error: Failed to create certificate.") + except Exception: + try: + client.delete_thing(thingName = thing_name) + except Exception: + print ("[Device Advisor] Error: Could not delete thing.") + print("[Device Advisor] Error: Failed to create certificate.") exit(-1) ############################################## # attach certification to thing try: - print("[Device Advisor]Info: Attach certificate to test thing...") + print("[Device Advisor] Info: Attach certificate to test thing...") # attache the certificate to thing client.attach_thing_principal( thingName = thing_name, @@ -141,7 +164,7 @@ def sleep_with_backoff(base, max): certificate_arn = create_cert_response['certificateArn'] certificate_id = create_cert_response['certificateId'] - except: + except Exception: delete_thing_with_certi(thing_name, certificate_id ,certificate_arn ) print("[Device Advisor]Error: Failed to attach certificate.") exit(-1) @@ -153,6 +176,7 @@ def sleep_with_backoff(base, max): ###################################### # set default shadow, for shadow update, if the # shadow does not exists, update will fail + print("[Device Advisor] Info: About to update shadow.") payload_shadow = json.dumps( { "state": { @@ -169,6 +193,7 @@ def sleep_with_backoff(base, max): payload = payload_shadow) get_shadow_response = dataClient.get_thing_shadow(thingName = thing_name) # make sure shadow is created before we go to next step + print("[Device Advisor] Info: About to wait for shadow update.") while(get_shadow_response is None): get_shadow_response = dataClient.get_thing_shadow(thingName = thing_name) @@ -179,24 +204,31 @@ def sleep_with_backoff(base, max): # 'suiteRunArn': 'string', # 'createdAt': datetime(2015, 1, 1) # } - print("[Device Advisor]Info: Start device advisor test: " + test_name) + print("[Device Advisor] Info: Start device advisor test: " + test_name) sleep_with_backoff(BACKOFF_BASE, BACKOFF_MAX) test_start_response = deviceAdvisor.start_suite_run( - suiteDefinitionId=DATestConfig['test_suite_ids'][test_name], - suiteRunConfiguration={ - 'primaryDevice': { - 'thingArn': create_thing_response['thingArn'], - }, - 'parallelRun': True + suiteDefinitionId=DATestConfig['test_suite_ids'][test_name], + suiteRunConfiguration={ + 'primaryDevice': { + 'thingArn': create_thing_response['thingArn'], + }, + 'parallelRun': True }) # get DA endpoint + print("[Device Advisor] Info: Getting Device Advisor endpoint.") endpoint_response = deviceAdvisor.get_endpoint( thingArn = create_thing_response['thingArn'] ) os.environ['DA_ENDPOINT'] = endpoint_response['endpoint'] + cycle_number = 0 while True: + cycle_number += 1 + if (cycle_number >= MAXIMUM_CYCLE_COUNT): + print(f"[Device Advisor] Error: {cycle_number} of cycles lasting {BACKOFF_BASE} to {BACKOFF_MAX} seconds have passed.") + raise Exception(f"ERROR - {cycle_number} of cycles lasting {BACKOFF_BASE} to {BACKOFF_MAX} seconds have passed.") + # sleep for 1s every loop to avoid TooManyRequestsException sleep_with_backoff(BACKOFF_BASE, BACKOFF_MAX) test_result_responds = deviceAdvisor.get_suite_run( @@ -214,6 +246,7 @@ def sleep_with_backoff(base, max): elif (test_result_responds['status'] == 'RUNNING' and test_result_responds['testResult']['groups'][0]['tests'][0]['status'] == 'RUNNING'): try: + print ("[Device Advisor] Info: About to get start Device Advisor companion test application.") exe_path = os.path.join("build/deviceadvisor/tests/",DATestConfig['test_exe_path'][test_name]) # Windows and MAC/LINUX has a different build folder structure if platform.system() == 'Windows': @@ -230,6 +263,7 @@ def sleep_with_backoff(base, max): test_result[test_name] = test_result_responds['status'] # If the test failed, upload the logs to S3 before clean up if(test_result[test_name] != "PASS"): + print ("[Device Advisor] Info: About to upload log to S3.") log_url = test_result_responds['testResult']['groups'][0]['tests'][0]['logUrl'] group_string = re.search('group=(.*);', log_url) log_group = group_string.group(1) @@ -238,9 +272,11 @@ def sleep_with_backoff(base, max): process_logs(log_group, log_stream, thing_name) delete_thing_with_certi(thing_name, certificate_id ,certificate_arn ) break - except Exception as e: + except Exception: delete_thing_with_certi(thing_name, certificate_id ,certificate_arn ) print("[Device Advisor]Error: Failed to test: "+ test_name) + did_at_least_one_test_fail = True + sleep_with_backoff(BACKOFF_BASE, BACKOFF_MAX) ############################################## # print result and cleanup things @@ -255,4 +291,8 @@ def sleep_with_backoff(base, max): # if the test failed, we dont clean the Thing so that we can track the error exit(-1) +if (did_at_least_one_test_fail == True): + print("[Device Advisor] At least one test failed!") + exit(-1) + exit(0) diff --git a/deviceadvisor/tests/mqtt_connect/main.cpp b/deviceadvisor/tests/mqtt_connect/main.cpp index 57c98421f..c2e72f82c 100644 --- a/deviceadvisor/tests/mqtt_connect/main.cpp +++ b/deviceadvisor/tests/mqtt_connect/main.cpp @@ -25,7 +25,6 @@ int main() String clientId(String("test-") + Aws::Crt::UUID().ToString()); /*********************** Parse Arguments ***************************/ - DeviceAdvisorEnvironment daVars; if (!daVars.init(TestType::CONNECT)) { @@ -48,7 +47,6 @@ int main() /* * Setup up mqttClients */ - Aws::Iot::MqttClient mqttClient; if (!mqttClient) { diff --git a/deviceadvisor/tests/mqtt_publish/main.cpp b/deviceadvisor/tests/mqtt_publish/main.cpp index e7dc90948..1ef9dbfc5 100644 --- a/deviceadvisor/tests/mqtt_publish/main.cpp +++ b/deviceadvisor/tests/mqtt_publish/main.cpp @@ -35,7 +35,6 @@ int main() /* * Setup client configuration with the MqttClientConnectionConfigBuilder. */ - Aws::Iot::MqttClientConnectionConfigBuilder builder = Aws::Iot::MqttClientConnectionConfigBuilder(daVars.certificatePath.c_str(), daVars.keyPath.c_str()); builder.WithEndpoint(daVars.endpoint); @@ -48,7 +47,6 @@ int main() /* * Setup up mqttClients */ - Aws::Iot::MqttClient mqttClient; if (!mqttClient) { diff --git a/deviceadvisor/tests/mqtt_subscribe/main.cpp b/deviceadvisor/tests/mqtt_subscribe/main.cpp index 7e02c6670..5259a828b 100644 --- a/deviceadvisor/tests/mqtt_subscribe/main.cpp +++ b/deviceadvisor/tests/mqtt_subscribe/main.cpp @@ -35,7 +35,6 @@ int main() /* * Setup client configuration with the MqttClientConnectionConfigBuilder. */ - Aws::Iot::MqttClientConnectionConfigBuilder builder = Aws::Iot::MqttClientConnectionConfigBuilder(daVars.certificatePath.c_str(), daVars.keyPath.c_str()); builder.WithEndpoint(daVars.endpoint); @@ -48,7 +47,6 @@ int main() /* * Setup up mqttClients */ - Aws::Iot::MqttClient mqttClient; if (!mqttClient) { diff --git a/deviceadvisor/tests/shadow_update/main.cpp b/deviceadvisor/tests/shadow_update/main.cpp index fd118a1d1..1b03a6b72 100644 --- a/deviceadvisor/tests/shadow_update/main.cpp +++ b/deviceadvisor/tests/shadow_update/main.cpp @@ -49,7 +49,6 @@ int main() /* * Setup client configuration with the MqttClientConnectionConfigBuilder. */ - Aws::Iot::MqttClientConnectionConfigBuilder builder = Aws::Iot::MqttClientConnectionConfigBuilder(daEnv.certificatePath.c_str(), daEnv.keyPath.c_str()); builder.WithEndpoint(daEnv.endpoint); @@ -62,7 +61,6 @@ int main() /* * Setup up mqttClients */ - Aws::Iot::MqttClient mqttClient; if (!mqttClient) { diff --git a/samples/device_defender/basic_report/main.cpp b/samples/device_defender/basic_report/main.cpp index fb8225a9e..f4114b081 100644 --- a/samples/device_defender/basic_report/main.cpp +++ b/samples/device_defender/basic_report/main.cpp @@ -27,8 +27,6 @@ using namespace Aws::Crt; int s_getCustomMetricNumber(double *output) { - /** Set to a random number between -50 and 50 */ - //*output = (double)((rand() % 100 + 1) - 50); *output = 100; return AWS_OP_SUCCESS; } @@ -111,9 +109,11 @@ int main(int argc, char *argv[]) } } - // Make a MQTT client and create a connection using a certificate and key - // Note: The data for the connection is gotten from cmdUtils - // (see BuildDirectMQTTConnection for implementation) + /** + * Make a MQTT client and create a connection using a certificate and key + * Note: The data for the connection is gotten from cmdUtils + * (see BuildDirectMQTTConnection for implementation) + */ Aws::Iot::MqttClient mqttClient = Aws::Iot::MqttClient(); std::shared_ptr connection = cmdUtils.BuildDirectMQTTConnection(&mqttClient); @@ -123,15 +123,15 @@ int main(int argc, char *argv[]) exit(-1); } - /* + /** * In a real world application you probably don't want to enforce synchronous behavior * but this is a sample console application, so we'll just do that with a condition variable. */ std::promise connectionCompletedPromise; std::promise connectionClosedPromise; - /* - * This will execute when an mqtt connect has completed or failed. + /** + * This will execute when an MQTT connect has completed or failed. */ auto onConnectionCompleted = [&](Mqtt::MqttConnection &, int errorCode, Mqtt::ReturnCode returnCode, bool) { if (errorCode) @@ -160,7 +160,7 @@ int main(int argc, char *argv[]) auto onResumed = [&](Mqtt::MqttConnection &, Mqtt::ReturnCode, bool) { fprintf(stdout, "Connection resumed\n"); }; - /* + /** * Invoked when a disconnect message has completed. */ auto onDisconnect = [&](Mqtt::MqttConnection &) { @@ -175,7 +175,7 @@ int main(int argc, char *argv[]) connection->OnConnectionInterrupted = std::move(onInterrupted); connection->OnConnectionResumed = std::move(onResumed); - /* + /** * Actually perform the connect dance. */ fprintf(stdout, "Connecting...\n"); @@ -187,8 +187,8 @@ int main(int argc, char *argv[]) if (connectionCompletedPromise.get_future().get()) { - // Device defender setup and metric registration - // ====================================================================== + /* Device defender setup and metric registration */ + /* ====================================================================== */ Aws::Crt::Allocator *allocator = Aws::Crt::DefaultAllocator(); Aws::Crt::Io::EventLoopGroup *eventLoopGroup = Aws::Crt::ApiHandle::GetOrCreateStaticDefaultEventLoopGroup(); @@ -205,8 +205,10 @@ int main(int argc, char *argv[]) .WithTaskCancellationUserData(&callbackSuccess); std::shared_ptr task = taskBuilder.Build(); - // Add the custom metrics - // (Inline function example) + /** + * Add the custom metrics + * (Inline function example) + */ Aws::Iotdevicedefenderv1::CustomMetricNumberFunction s_localGetCustomMetricNumber = [](double *output) { *output = 8.4; return AWS_OP_SUCCESS; @@ -225,7 +227,7 @@ int main(int argc, char *argv[]) s_getCustomMetricIpAddressList; task->RegisterCustomMetricIpAddressList("CustomIPList", std::move(s_getCustomMetricIpAddressListFunc)); - // Start the Device Defender task + /* Start the Device Defender task */ if (task->StartTask() != AWS_OP_SUCCESS) { fprintf(stdout, "Device Defender failed to initialize task.\n"); @@ -260,7 +262,7 @@ int main(int argc, char *argv[]) } } - // Stop the task so we stop sending device defender metrics + /* Stop the task so we stop sending device defender metrics */ task->StopTask(); /* Disconnect */ diff --git a/samples/shadow/shadow_sync/main.cpp b/samples/shadow/shadow_sync/main.cpp index f8d982bd5..ee10c4d1d 100644 --- a/samples/shadow/shadow_sync/main.cpp +++ b/samples/shadow/shadow_sync/main.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include "../../utils/CommandLineUtils.h" @@ -103,6 +104,7 @@ int main(int argc, char *argv[]) cmdUtils.RegisterCommand("cert", "", "Path to your client certificate in PEM format."); cmdUtils.RegisterCommand("thing_name", "", "The name of your IOT thing."); cmdUtils.RegisterCommand("shadow_property", "", "The name of the shadow property you want to change."); + cmdUtils.RegisterCommand("is_ci", "", "If set to 'True' then it will run in CI mode (will publish to shadow automatically)."); cmdUtils.AddLoggingCommands(); const char **const_argv = (const char **)argv; cmdUtils.SendArguments(const_argv, const_argv + argc); @@ -110,6 +112,7 @@ int main(int argc, char *argv[]) String thingName = cmdUtils.GetCommandRequired("thing_name"); String shadowProperty = cmdUtils.GetCommandRequired("shadow_property"); + String isCI = cmdUtils.GetCommandOrDefault("is_ci", ""); /* Get a MQTT client connection from the command parser */ auto connection = cmdUtils.BuildMQTTConnection(); @@ -412,29 +415,42 @@ int main(int argc, char *argv[]) gotInitialShadowPromise.get_future().wait(); // ==================== Shadow change value input loop ==================== - // This section is to getting user input and changing the shadow value pased on that input. + // This section is to getting user input and changing the shadow value passed to that input. + // If in CI, then input is automatically passed - fprintf(stdout, "Enter Desired state of %s:\n", shadowProperty.c_str()); - while (true) - { - String input; - std::cin >> input; - - if (input == "exit" || input == "quit") + if (isCI != "True") { + fprintf(stdout, "Enter Desired state of %s:\n", shadowProperty.c_str()); + while (true) { - fprintf(stdout, "Exiting..."); - break; - } + String input; + std::cin >> input; - if (input == currentShadowValue) - { - fprintf(stdout, "Shadow is already set to \"%s\"\n", currentShadowValue.c_str()); - fprintf(stdout, "Enter Desired state of %s:\n", shadowProperty.c_str()); + if (input == "exit" || input == "quit") + { + fprintf(stdout, "Exiting..."); + break; + } + + if (input == currentShadowValue) + { + fprintf(stdout, "Shadow is already set to \"%s\"\n", currentShadowValue.c_str()); + fprintf(stdout, "Enter Desired state of %s:\n", shadowProperty.c_str()); + } + else + { + s_changeShadowValue(shadowClient, thingName, shadowProperty, input); + } } - else - { + } else { + int messagesSent = 0; + while (messagesSent < 5) { + String input = "Shadow_Value_" + std::to_string(messagesSent); s_changeShadowValue(shadowClient, thingName, shadowProperty, input); + /* Sleep so there is a gap between shadow updates */ + std::this_thread::sleep_for(std::chrono::milliseconds(1000)); + messagesSent += 1; } + std::this_thread::sleep_for(std::chrono::milliseconds(1000)); } } diff --git a/utils/delete_iot_thing_ci.py b/utils/delete_iot_thing_ci.py new file mode 100644 index 000000000..0a4d46f95 --- /dev/null +++ b/utils/delete_iot_thing_ci.py @@ -0,0 +1,67 @@ +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0. + +# Built-in +import argparse +import sys +# Needs to be installed via pip +import boto3 # - for launching sample + +def DeleteIoTThing(parsed_commands): + try: + iot_client = boto3.client('iot', region_name=parsed_commands.region) + except Exception: + print("Error - could not make Boto3 client. Credentials likely could not be sourced") + return -1 + + thing_principals = None + try: + thing_principals = iot_client.list_thing_principals(thingName=parsed_commands.thing_name) + except Exception: + print ("Could not get thing principals!") + return -1 + + try: + if (thing_principals != None): + if (thing_principals["principals"] != None): + if (len(thing_principals["principals"]) > 0 and parsed_commands.delete_certificate == "true"): + for principal in thing_principals["principals"]: + certificate_id = principal.split("/")[1] + iot_client.detach_thing_principal(thingName=parsed_commands.thing_name, principal=principal) + iot_client.update_certificate(certificateId=certificate_id, newStatus ='INACTIVE') + iot_client.delete_certificate(certificateId=certificate_id, forceDelete=True) + except Exception as exception: + print (exception) + print ("Could not delete certificate!") + return -1 + + try: + iot_client.delete_thing(thingName=parsed_commands.thing_name) + except Exception as exception: + print (exception) + print ("Could not delete IoT thing!") + return -1 + + print ("IoT thing deleted successfully") + return 0 + + + +def main(): + argument_parser = argparse.ArgumentParser( + description="AppVerifier XML output util") + argument_parser.add_argument("--thing_name", metavar="", required=True, + help="The name of the IoT thing to delete") + argument_parser.add_argument("--region", metavar="", + required=True, default="us-east-1", help="The name of the region to use") + argument_parser.add_argument("--delete_certificate", metavar="", + required=False, default="true", help="Will delete the certificate after detaching it from the IoT thing") + parsed_commands = argument_parser.parse_args() + + print ("Deleting IoT thing...") + delete_result = DeleteIoTThing(parsed_commands) + sys.exit(delete_result) + + +if __name__ == "__main__": + main() diff --git a/utils/run_sample_ci.py b/utils/run_sample_ci.py new file mode 100644 index 000000000..720bbf150 --- /dev/null +++ b/utils/run_sample_ci.py @@ -0,0 +1,197 @@ +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0. + +# Built-in +import argparse +import os +import subprocess +import pathlib +import sys +# Needs to be installed via pip +import boto3 # - for launching sample + + +current_folder = pathlib.Path(__file__).resolve() +tmp_certificate_file_path = str(current_folder) + "tmp_certificate.pem" +tmp_private_key_path = str(current_folder) + "tmp_privatekey.pem.key" + + +def getSecretsAndLaunch(parsed_commands): + global tmp_certificate_file_path + global tmp_private_key_path + exit_code = 0 + sample_endpoint = "" + sample_certificate = "" + sample_private_key = "" + sample_custom_authorizer_name = "" + sample_custom_authorizer_password = "" + + current_folder = pathlib.Path(__file__).resolve() + # Remove the name of the python file + current_folder = str(current_folder).replace("run_sample_ci.py", "") + + print("Attempting to get credentials from secrets using Boto3...") + secrets_client = boto3.client( + "secretsmanager", region_name=parsed_commands.sample_region) + try: + if (parsed_commands.sample_secret_endpoint != ""): + sample_endpoint = secrets_client.get_secret_value( + SecretId=parsed_commands.sample_secret_endpoint)["SecretString"] + if (parsed_commands.sample_secret_certificate != ""): + sample_certificate = secrets_client.get_secret_value( + SecretId=parsed_commands.sample_secret_certificate) + with open(tmp_certificate_file_path, "w") as file: + # lgtm [py/clear-text-storage-sensitive-data] + file.write(sample_certificate["SecretString"]) + if (parsed_commands.sample_secret_private_key != ""): + sample_private_key = secrets_client.get_secret_value( + SecretId=parsed_commands.sample_secret_private_key) + with open(tmp_private_key_path, "w") as file: + # lgtm [py/clear-text-storage-sensitive-data] + file.write(sample_private_key["SecretString"]) + if (parsed_commands.sample_secret_custom_authorizer_name != ""): + sample_custom_authorizer_name = secrets_client.get_secret_value( + SecretId=parsed_commands.sample_secret_custom_authorizer_name)["SecretString"] + if (parsed_commands.sample_secret_custom_authorizer_password != ""): + sample_custom_authorizer_password = secrets_client.get_secret_value( + SecretId=parsed_commands.sample_secret_custom_authorizer_password)["SecretString"] + + except Exception: + sys.exit("ERROR: Could not get secrets to launch sample!") + + if (parsed_commands.sample_run_softhsm != ""): + print ("Setting up private key via SoftHSM") + subprocess.run("softhsm2-util --init-token --free --label my-token --pin 0000 --so-pin 0000", shell=True) + subprocess.run(f"softhsm2-util --import {tmp_private_key_path} --token my-token --label my-key --id BEEFCAFE --pin 0000", shell=True) + print ("Finished setting up private key in SoftHSM") + + print("Launching sample...") + exit_code = launch_sample(parsed_commands, sample_endpoint, sample_certificate, + sample_private_key, sample_custom_authorizer_name, sample_custom_authorizer_password) + + print("Deleting files...") + if (sample_certificate != ""): + os.remove(tmp_certificate_file_path) + if (sample_private_key != ""): + os.remove(tmp_private_key_path) + + if (exit_code == 0): + print("SUCCESS: Finished running sample! Exiting with success") + else: + print("ERROR: Sample did not return success! Exit code " + str(exit_code)) + return exit_code + + +def launch_sample(parsed_commands, sample_endpoint, sample_certificate, sample_private_key, sample_custom_authorizer_name, sample_custom_authorizer_password): + global tmp_certificate_file_path + global tmp_private_key_path + exit_code = 0 + + print("Processing arguments...") + launch_arguments = [] + launch_arguments.append("--endpoint") + launch_arguments.append(sample_endpoint) + if (sample_certificate != ""): + launch_arguments.append("--cert") + launch_arguments.append(tmp_certificate_file_path) + if (sample_private_key != "" and parsed_commands.sample_run_softhsm == ""): + launch_arguments.append("--key") + launch_arguments.append(tmp_private_key_path) + if (sample_custom_authorizer_name != ""): + launch_arguments.append("--custom_auth_authorizer_name") + launch_arguments.append(sample_custom_authorizer_name) + if (sample_custom_authorizer_password != ""): + launch_arguments.append("--custom_auth_password") + launch_arguments.append(sample_custom_authorizer_password) + if (parsed_commands.sample_arguments != ""): + sample_arguments_split = parsed_commands.sample_arguments.split(" ") + for arg in sample_arguments_split: + launch_arguments.append(arg) + + print("Launching sample...") + # Based on the programming language, we have to run it a different way + if (parsed_commands.language == "Java"): + arguments_as_string = "" + for i in range(0, len(launch_arguments)): + arguments_as_string += str(launch_arguments[i]) + if (i+1 < len(launch_arguments)): + arguments_as_string += " " + arguments = ["mvn", "compile", "exec:java"] + arguments.append("-pl") + arguments.append(parsed_commands.sample_file) + arguments.append("-Dexec.mainClass=" + + parsed_commands.sample_main_class) + arguments.append("-Daws.crt.ci=True") + + # We have to do this as a string, unfortunately, due to how -Dexec.args= works... + argument_string = subprocess.list2cmdline( + arguments) + " -Dexec.args=\"" + arguments_as_string + "\"" + sample_return = subprocess.run(argument_string, shell=True) + exit_code = sample_return.returncode + + elif (parsed_commands.language == "CPP"): + sample_return = subprocess.run( + args=launch_arguments, executable=parsed_commands.sample_file) + exit_code = sample_return.returncode + + elif (parsed_commands.language == "Python"): + sample_return = subprocess.run( + args=[sys.executable, parsed_commands.sample_file] + launch_arguments) + exit_code = sample_return.returncode + + elif (parsed_commands.language == "Javascript"): + os.chdir(parsed_commands.sample_file) + sample_return_one = subprocess.run(args=["npm", "install"]) + if (sample_return_one.returncode != 0): + exit_code = sample_return_one.returncode + else: + arguments = ["node", "dist/index.js"] + sample_return_two = subprocess.run( + args=arguments + launch_arguments) + exit_code = sample_return_two.returncode + + else: + print("ERROR - unknown programming language! Supported programming languages are 'Java', 'CPP', 'Python', and 'Javascript'") + return -1 + + # finish! + return exit_code + + +def main(): + argument_parser = argparse.ArgumentParser( + description="AppVerifier XML output util") + argument_parser.add_argument("--language", metavar="", required=True, + help="The name of the programming language. Used to determine how to launch the sample") + argument_parser.add_argument("--sample_file", + metavar="", + required=True, default="", help="Sample to launch. Format varies based on programming language") + argument_parser.add_argument("--sample_region", metavar="", + required=True, default="us-east-1", help="The name of the region to use for accessing secrets") + argument_parser.add_argument("--sample_secret_endpoint", metavar="", + required=False, default="", help="The name of the secret containing the endpoint") + argument_parser.add_argument("--sample_secret_certificate", metavar="", required=False, + default="", help="The name of the secret containing the certificate PEM file") + argument_parser.add_argument("--sample_secret_private_key", metavar="", required=False, + default="", help="The name of the secret containing the private key PEM file") + argument_parser.add_argument("--sample_secret_custom_authorizer_name", metavar="", required=False, + default="", help="The name of the secret containing the custom authorizer name") + argument_parser.add_argument("--sample_secret_custom_authorizer_password", metavar="", required=False, + default="", help="The name of the secret containing the custom authorizer password") + argument_parser.add_argument("--sample_run_softhsm", metavar="", required=False, + default="", help="Runs SoftHSM on the private key passed, storing it, rather than passing it directly to the sample. Used for PKCS11 sample") + argument_parser.add_argument("--sample_arguments", metavar="", + required=False, default="", + help="Arguments to pass to sample. In Java, these arguments will be in a double quote (\") string") + argument_parser.add_argument("--sample_main_class", metavar="", + required=False, default="", help="Java only: The main class to run") + + parsed_commands = argument_parser.parse_args() + + print("Starting to launch sample...") + sample_result = getSecretsAndLaunch(parsed_commands) + sys.exit(sample_result) + + +if __name__ == "__main__": + main() From 2262e2df954a937c29c748d576f9fe5e8ed5aaa5 Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Mon, 26 Sep 2022 16:59:10 -0400 Subject: [PATCH 02/50] Fix YAML formatting --- .github/workflows/ci.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 00f646f81..9e6b8e54e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,10 +34,10 @@ jobs: steps: - name: configure AWS credentials (containers) - uses: aws-actions/configure-aws-credentials@v1 - with: - role-to-assume: ${{ env.CI_IOT_CONTAINERS }} - aws-region: ${{ env.AWS_DEFAULT_REGION }} + uses: aws-actions/configure-aws-credentials@v1 + with: + role-to-assume: ${{ env.CI_IOT_CONTAINERS }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} # We can't use the `uses: docker://image` version yet, GitHub lacks authentication for actions -> packages - name: Build ${{ env.PACKAGE_NAME }} run: | @@ -62,10 +62,10 @@ jobs: - gcc-8 steps: - name: configure AWS credentials (containers) - uses: aws-actions/configure-aws-credentials@v1 - with: - role-to-assume: ${{ env.CI_IOT_CONTAINERS }} - aws-region: ${{ env.AWS_DEFAULT_REGION }} + uses: aws-actions/configure-aws-credentials@v1 + with: + role-to-assume: ${{ env.CI_IOT_CONTAINERS }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} # We can't use the `uses: docker://image` version yet, GitHub lacks authentication for actions -> packages - name: Build ${{ env.PACKAGE_NAME }} run: | @@ -194,10 +194,10 @@ jobs: python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz', 'builder.pyz')" python builder.pyz build -p ${{ env.PACKAGE_NAME }} --cmake-extra=-DUSE_CPU_EXTENSIONS=OFF - name: configure AWS credentials (PubSub) - uses: aws-actions/configure-aws-credentials@v1 - with: - role-to-assume: ${{ env.CI_PUBSUB_ROLE }} - aws-region: ${{ env.AWS_DEFAULT_REGION }} + uses: aws-actions/configure-aws-credentials@v1 + with: + role-to-assume: ${{ env.CI_PUBSUB_ROLE }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} - name: Run and check AppVerifier run: | cd D:\a\work From 06e60bb4f75aa1476f7e94133bdade9586efa140 Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Mon, 26 Sep 2022 17:41:23 -0400 Subject: [PATCH 03/50] Fix issue in Shadow sample, make all samples use C style comments consistently --- samples/device_defender/basic_report/main.cpp | 4 +- samples/greengrass/basic_discovery/main.cpp | 10 ++-- samples/greengrass/ipc/main.cpp | 31 +++-------- samples/identity/fleet_provisioning/main.cpp | 20 ++++---- samples/jobs/describe_job_execution/main.cpp | 16 +++--- samples/mqtt/basic_connect/main.cpp | 18 ++++--- .../mqtt/custom_authorizer_connect/main.cpp | 18 ++++--- samples/mqtt/pkcs11_connect/main.cpp | 18 ++++--- samples/mqtt/raw_connect/main.cpp | 18 ++++--- samples/mqtt/websocket_connect/main.cpp | 19 ++++--- samples/mqtt/windows_cert_connect/main.cpp | 12 +++-- .../main.cpp | 16 +++--- samples/pub_sub/basic_pub_sub/main.cpp | 18 +++---- samples/pub_sub/cycle_pub_sub/main.cpp | 34 ++++++------- .../secure_tunneling/secure_tunnel/main.cpp | 18 +++---- .../tunnel_notification/main.cpp | 10 ++-- samples/shadow/shadow_sync/main.cpp | 51 ++++++++++++------- samples/utils/CommandLineUtils.cpp | 20 ++++---- samples/utils/CommandLineUtils.h | 4 +- 19 files changed, 189 insertions(+), 166 deletions(-) diff --git a/samples/device_defender/basic_report/main.cpp b/samples/device_defender/basic_report/main.cpp index f4114b081..fd01877a4 100644 --- a/samples/device_defender/basic_report/main.cpp +++ b/samples/device_defender/basic_report/main.cpp @@ -62,7 +62,7 @@ int main(int argc, char *argv[]) { /************************ Setup the Lib ****************************/ - /* + /** * Do the global initialization for the API. */ ApiHandle apiHandle; @@ -247,7 +247,7 @@ int main(int argc, char *argv[]) fprintf(stdout, "Device Defender task in unknown status. Status: %d\n", (int)task->GetStatus()); exit(-1); } - // ====================================================================== + /* ====================================================================== */ int publishedCount = 0; while (publishedCount < count && diff --git a/samples/greengrass/basic_discovery/main.cpp b/samples/greengrass/basic_discovery/main.cpp index 098594f86..91938b7b0 100644 --- a/samples/greengrass/basic_discovery/main.cpp +++ b/samples/greengrass/basic_discovery/main.cpp @@ -22,7 +22,7 @@ using namespace Aws::Discovery; int main(int argc, char *argv[]) { /************************ Setup the Lib ****************************/ - /* + /** * Do the global initialization for the API. */ ApiHandle apiHandle; @@ -64,8 +64,8 @@ int main(int argc, char *argv[]) proxyPort = static_cast(atoi(portString.c_str())); } - /* - * We're using Mutual TLS for Mqtt, so we need to load our client certificates + /** + * We're using Mutual TLS for MQTT, so we need to load our client certificates */ Io::TlsContextOptions tlsCtxOptions = Io::TlsContextOptions::InitClientWithMtls(certificatePath.c_str(), keyPath.c_str()); @@ -89,7 +89,7 @@ int main(int argc, char *argv[]) exit(-1); } - /* + /** * Default Socket options to use. IPV4 will be ignored based on what DNS * tells us. */ @@ -119,7 +119,7 @@ int main(int argc, char *argv[]) { proxyOptions.HostName = proxyHost; proxyOptions.Port = proxyPort; - clientConfig.ProxyOptions = proxyOptions; // + clientConfig.ProxyOptions = proxyOptions; } auto discoveryClient = DiscoveryClient::CreateClient(clientConfig); diff --git a/samples/greengrass/ipc/main.cpp b/samples/greengrass/ipc/main.cpp index d9683ad56..a5c6ef4ee 100644 --- a/samples/greengrass/ipc/main.cpp +++ b/samples/greengrass/ipc/main.cpp @@ -18,7 +18,7 @@ static std::atomic_bool s_publishReceived(false); int main(int argc, char *argv[]) { /************************ Setup the Lib ****************************/ - /* + /** * Do the global initialization for the API. */ ApiHandle apiHandle; @@ -48,7 +48,7 @@ int main(int argc, char *argv[]) exit(-1); } - /* + /** * Inheriting from ConnectionLifecycleHandler allows us to define callbacks that are * called upon when connection lifecycle events occur. */ @@ -77,7 +77,7 @@ int main(int argc, char *argv[]) return true; } }; - /* + /** * Note: The lifecycle handler should be declared before the client * so that it is destroyed AFTER the client is destroyed. */ @@ -91,7 +91,7 @@ int main(int argc, char *argv[]) exit(-1); } - /* + /** * Upon receiving a message on the topic, print it and set an atomic bool so that the demo can complete. */ class SubscribeStreamHandler : public SubscribeToIoTCoreStreamHandler @@ -130,15 +130,6 @@ int main(int argc, char *argv[]) } auto subscribeResultFuture = subscribeOperation->GetResult(); - /* - // To avoid throwing exceptions, wait on the result for a specified timeout: - if (subscribeResultFuture.wait_for(std::chrono::seconds(10)) == std::future_status::timeout) - { - fprintf(stderr, "Timed out while waiting for response from Greengrass Core\n"); - exit(-1); - } - */ - auto subscribeResult = subscribeResultFuture.get(); if (subscribeResult) { @@ -150,7 +141,7 @@ int main(int argc, char *argv[]) if (errorType == OPERATION_ERROR) { OperationError *error = subscribeResult.GetOperationError(); - /* + /** * This pointer can be casted to any error type like so: * if(error->GetModelName() == UnauthorizedError::MODEL_NAME) * UnauthorizedError *unauthorizedError = static_cast(error); @@ -188,14 +179,6 @@ int main(int argc, char *argv[]) } auto publishResultFuture = publishOperation->GetResult(); - /* - // To avoid throwing exceptions, wait on the result for a specified timeout: - if (publishResultFuture.wait_for(std::chrono::seconds(10)) == std::future_status::timeout) - { - fprintf(stderr, "Timed out while waiting for response from Greengrass Core\n"); - exit(-1); - } - */ auto publishResult = publishResultFuture.get(); if (publishResult) @@ -210,7 +193,7 @@ int main(int argc, char *argv[]) if (errorType == OPERATION_ERROR) { OperationError *error = publishResult.GetOperationError(); - /* + /**a * This pointer can be casted to any error type like so: * if(error->GetModelName() == UnauthorizedError::MODEL_NAME) * UnauthorizedError *unauthorizedError = static_cast(error); @@ -228,7 +211,7 @@ int main(int argc, char *argv[]) } /* Wait for the publish to be received since this sample subscribes to the same topic it publishes to. */ - while (!s_publishReceived.load()) + while (!s_publishReceivead.load()) { continue; } diff --git a/samples/identity/fleet_provisioning/main.cpp b/samples/identity/fleet_provisioning/main.cpp index ba65d776e..00e0eff38 100644 --- a/samples/identity/fleet_provisioning/main.cpp +++ b/samples/identity/fleet_provisioning/main.cpp @@ -36,8 +36,8 @@ using namespace Aws::Crt; using namespace Aws::Iotidentity; -using namespace std::this_thread; // sleep_for, sleep_until -using namespace std::chrono; // nanoseconds, system_clock, seconds +using namespace std::this_thread; /* sleep_for, sleep_until */ +using namespace std::chrono; /* nanoseconds, system_clock, seconds */ static void sleep(int sleeptime) { @@ -56,7 +56,7 @@ static std::string getFileData(std::string const &fileName) int main(int argc, char *argv[]) { /************************ Setup the Lib ****************************/ - /* + /** * Do the global initialization for the API. */ ApiHandle apiHandle; @@ -90,15 +90,15 @@ int main(int argc, char *argv[]) /* Get a MQTT client connection from the command parser */ auto connection = cmdUtils.BuildMQTTConnection(); - /* + /** * In a real world application you probably don't want to enforce synchronous behavior * but this is a sample console application, so we'll just do that with a condition variable. */ std::promise connectionCompletedPromise; std::promise connectionClosedPromise; - /* - * This will execute when an mqtt connect has completed or failed. + /** + * This will execute when an MQTT connect has completed or failed. */ auto onConnectionCompleted = [&](Mqtt::MqttConnection &, int errorCode, Mqtt::ReturnCode returnCode, bool) { if (errorCode) @@ -113,7 +113,7 @@ int main(int argc, char *argv[]) } }; - /* + /** * Invoked when a disconnect message has completed. */ auto onDisconnect = [&](Mqtt::MqttConnection & /*conn*/) { @@ -126,7 +126,7 @@ int main(int argc, char *argv[]) connection->OnConnectionCompleted = std::move(onConnectionCompleted); connection->OnDisconnect = std::move(onDisconnect); - /* + /** * Actually perform the connect dance. */ fprintf(stdout, "Connecting...\n"); @@ -338,7 +338,7 @@ int main(int argc, char *argv[]) if (csrFile.empty()) { - // CreateKeysAndCertificate workflow + /* CreateKeysAndCertificate workflow */ std::cout << "Subscribing to CreateKeysAndCertificate Accepted and Rejected topics" << std::endl; CreateKeysAndCertificateSubscriptionRequest keySubscriptionRequest; identityClient.SubscribeToCreateKeysAndCertificateAccepted( @@ -395,7 +395,7 @@ int main(int argc, char *argv[]) } else { - // CreateCertificateFromCsr workflow + /* CreateCertificateFromCsr workflow */ std::cout << "Subscribing to CreateCertificateFromCsr Accepted and Rejected topics" << std::endl; CreateCertificateFromCsrSubscriptionRequest csrSubscriptionRequest; identityClient.SubscribeToCreateCertificateFromCsrAccepted( diff --git a/samples/jobs/describe_job_execution/main.cpp b/samples/jobs/describe_job_execution/main.cpp index 3008a215c..7eb227a5d 100644 --- a/samples/jobs/describe_job_execution/main.cpp +++ b/samples/jobs/describe_job_execution/main.cpp @@ -28,7 +28,7 @@ using namespace Aws::Iotjobs; int main(int argc, char *argv[]) { /************************ Setup the Lib ****************************/ - /* + /** * Do the global initialization for the API. */ ApiHandle apiHandle; @@ -53,14 +53,14 @@ int main(int argc, char *argv[]) /* Get a MQTT client connection from the command parser */ auto connection = cmdUtils.BuildMQTTConnection(); - /* + /** * In a real world application you probably don't want to enforce synchronous behavior * but this is a sample console application, so we'll just do that with a condition variable. */ std::promise connectionCompletedPromise; std::promise connectionClosedPromise; - /* + /** * This will execute when an mqtt connect has completed or failed. */ auto onConnectionCompleted = [&](Mqtt::MqttConnection &, int errorCode, Mqtt::ReturnCode returnCode, bool) { @@ -76,7 +76,7 @@ int main(int argc, char *argv[]) } }; - /* + /** * Invoked when a disconnect message has completed. */ auto onDisconnect = [&](Mqtt::MqttConnection & /*conn*/) { @@ -89,7 +89,7 @@ int main(int argc, char *argv[]) connection->OnConnectionCompleted = std::move(onConnectionCompleted); connection->OnDisconnect = std::move(onDisconnect); - /* + /** * Actually perform the connect dance. */ fprintf(stdout, "Connecting...\n"); @@ -107,8 +107,10 @@ int main(int argc, char *argv[]) describeJobExecutionSubscriptionRequest.ThingName = thingName; describeJobExecutionSubscriptionRequest.JobId = jobId; - // This isn't absolutely necessary but since we're doing a publish almost immediately afterwards, - // to be cautious make sure the subscribe has finished before doing the publish. + /** + * This isn't absolutely necessary but since we're doing a publish almost immediately afterwards, + * to be cautious make sure the subscribe has finished before doing the publish. + */ std::promise subAckedPromise; auto subAckHandler = [&](int) { /* if error code returns it will be recorded by the other callback */ diff --git a/samples/mqtt/basic_connect/main.cpp b/samples/mqtt/basic_connect/main.cpp index 344ba592a..5f75a90a8 100644 --- a/samples/mqtt/basic_connect/main.cpp +++ b/samples/mqtt/basic_connect/main.cpp @@ -13,7 +13,7 @@ int main(int argc, char *argv[]) { /************************ Setup the Lib ****************************/ - /* + /** * Do the global initialization for the API. */ ApiHandle apiHandle; @@ -31,17 +31,21 @@ int main(int argc, char *argv[]) cmdUtils.SendArguments(const_argv, const_argv + argc); cmdUtils.StartLoggingBasedOnCommand(&apiHandle); - // Make a MQTT client and create a connection using a certificate and key - // Note: The data for the connection is gotten from cmdUtils - // (see BuildDirectMQTTConnection for implementation) + /** + * Make a MQTT client and create a connection using a certificate and key + * Note: The data for the connection is gotten from cmdUtils + * (see BuildDirectMQTTConnection for implementation) + */ Aws::Iot::MqttClient client = Aws::Iot::MqttClient(); std::shared_ptr connection = cmdUtils.BuildDirectMQTTConnection(&client); - // Get the client ID to send with the connection + /* Get the client ID to send with the connection */ String clientId = cmdUtils.GetCommandOrDefault("client_id", String("test-") + Aws::Crt::UUID().ToString()); - // Connect and then disconnect using the connection we created - // (see SampleConnectAndDisconnect for implementation) + /** + * Connect and then disconnect using the connection we created + * (see SampleConnectAndDisconnect for implementation) + */ cmdUtils.SampleConnectAndDisconnect(connection, clientId); return 0; } diff --git a/samples/mqtt/custom_authorizer_connect/main.cpp b/samples/mqtt/custom_authorizer_connect/main.cpp index b6a675c1a..ebeee7a09 100644 --- a/samples/mqtt/custom_authorizer_connect/main.cpp +++ b/samples/mqtt/custom_authorizer_connect/main.cpp @@ -13,7 +13,7 @@ int main(int argc, char *argv[]) { /************************ Setup the Lib ****************************/ - /* + /** * Do the global initialization for the API. */ ApiHandle apiHandle; @@ -30,18 +30,22 @@ int main(int argc, char *argv[]) cmdUtils.SendArguments(const_argv, const_argv + argc); cmdUtils.StartLoggingBasedOnCommand(&apiHandle); - // Make a MQTT client and create a connection through a custom authorizer - // Note: The data for the connection is gotten from cmdUtils - // (see BuildDirectMQTTConnectionWithCustomAuthorizer for implementation) + /** + * Make a MQTT client and create a connection through a custom authorizer + * Note: The data for the connection is gotten from cmdUtils + * (see BuildDirectMQTTConnectionWithCustomAuthorizer for implementation) + */ Aws::Iot::MqttClient client = Aws::Iot::MqttClient(); std::shared_ptr connection = cmdUtils.BuildDirectMQTTConnectionWithCustomAuthorizer(&client); - // Get the client ID to send with the connection + /* Get the client ID to send with the connection */ String clientId = cmdUtils.GetCommandOrDefault("client_id", String("test-") + Aws::Crt::UUID().ToString()); - // Connect and then disconnect using the connection we created - // (see SampleConnectAndDisconnect for implementation) + /** + * Connect and then disconnect using the connection we created + * (see SampleConnectAndDisconnect for implementation) + */ cmdUtils.SampleConnectAndDisconnect(connection, clientId); return 0; } diff --git a/samples/mqtt/pkcs11_connect/main.cpp b/samples/mqtt/pkcs11_connect/main.cpp index bf65a0e80..0c134130b 100644 --- a/samples/mqtt/pkcs11_connect/main.cpp +++ b/samples/mqtt/pkcs11_connect/main.cpp @@ -13,7 +13,7 @@ int main(int argc, char *argv[]) { /************************ Setup the Lib ****************************/ - /* + /** * Do the global initialization for the API. */ ApiHandle apiHandle; @@ -34,17 +34,21 @@ int main(int argc, char *argv[]) cmdUtils.SendArguments(const_argv, const_argv + argc); cmdUtils.StartLoggingBasedOnCommand(&apiHandle); - // Make a MQTT client and create a connection using a PKCS11 - // Note: The data for the connection is gotten from cmdUtils - // (see BuildPKCS11MQTTConnection for implementation) + /** + * Make a MQTT client and create a connection using a PKCS11 + * Note: The data for the connection is gotten from cmdUtils + * (see BuildPKCS11MQTTConnection for implementation) + */ Aws::Iot::MqttClient mqttClient; std::shared_ptr connection = cmdUtils.BuildPKCS11MQTTConnection(&mqttClient); - // Get the client ID to send with the connection + /* Get the client ID to send with the connection */ String clientId = cmdUtils.GetCommandOrDefault("client_id", String("test-") + Aws::Crt::UUID().ToString()); - // Connect and then disconnect using the connection we created - // (see SampleConnectAndDisconnect for implementation) + /** + * Connect and then disconnect using the connection we created + * (see SampleConnectAndDisconnect for implementation) + */ cmdUtils.SampleConnectAndDisconnect(connection, clientId); return 0; } diff --git a/samples/mqtt/raw_connect/main.cpp b/samples/mqtt/raw_connect/main.cpp index abc83b53d..2b3f1748b 100644 --- a/samples/mqtt/raw_connect/main.cpp +++ b/samples/mqtt/raw_connect/main.cpp @@ -23,15 +23,17 @@ int main(int argc, char *argv[]) { /************************ Setup the Lib ****************************/ - /* + /** * Do the global initialization for the API. */ ApiHandle apiHandle; uint16_t proxyPort(8080); - // Valid protocol names are documented on page: - // https://docs.aws.amazon.com/iot/latest/developerguide/protocols.html - // Use "mqtt" for Custom Authentication - String protocolName("x-amzn-mqtt-ca"); // X.509 client certificate auth + /** + * Valid protocol names are documented on page: + * https://docs.aws.amazon.com/iot/latest/developerguide/protocols.html + * Use "mqtt" for Custom Authentication + */ + String protocolName("x-amzn-mqtt-ca"); /* X.509 client certificate auth */ Vector authParams; bool useWebSocket = false; @@ -185,8 +187,10 @@ int main(int argc, char *argv[]) connection->SetHttpProxyOptions(proxyOptions); } - // Connect and then disconnect using the connection we created - // (see SampleConnectAndDisconnect for implementation) + /** + * Connect and then disconnect using the connection we created + * (see SampleConnectAndDisconnect for implementation) + */ cmdUtils.SampleConnectAndDisconnect(connection, clientId); return 0; } diff --git a/samples/mqtt/websocket_connect/main.cpp b/samples/mqtt/websocket_connect/main.cpp index 7af6a1673..196924129 100644 --- a/samples/mqtt/websocket_connect/main.cpp +++ b/samples/mqtt/websocket_connect/main.cpp @@ -21,11 +21,10 @@ int main(int argc, char *argv[]) { /************************ Setup the Lib ****************************/ - /* + /** * Do the global initialization for the API. */ ApiHandle apiHandle; - // uint16_t proxyPort(8080); /*********************** Parse Arguments ***************************/ Utils::CommandLineUtils cmdUtils = Utils::CommandLineUtils(); @@ -39,17 +38,21 @@ int main(int argc, char *argv[]) cmdUtils.SendArguments(const_argv, const_argv + argc); cmdUtils.StartLoggingBasedOnCommand(&apiHandle); - // Make a MQTT client and create a connection using websockets - // Note: The data for the connection is gotten from cmdUtils - // (see BuildWebsocketMQTTConnection for implementation) + /** + * Make a MQTT client and create a connection using websockets + * Note: The data for the connection is gotten from cmdUtils + * (see BuildWebsocketMQTTConnection for implementation) + */ Aws::Iot::MqttClient mqttClient; std::shared_ptr connection = cmdUtils.BuildWebsocketMQTTConnection(&mqttClient); - // Get the client ID to send with the connection + /* Get the client ID to send with the connection */ String clientId = cmdUtils.GetCommandOrDefault("client_id", String("test-") + Aws::Crt::UUID().ToString()); - // Connect and then disconnect using the connection we created - // (see SampleConnectAndDisconnect for implementation) + /** + * Connect and then disconnect using the connection we created + * (see SampleConnectAndDisconnect for implementation) + */ cmdUtils.SampleConnectAndDisconnect(connection, clientId); return 0; } diff --git a/samples/mqtt/windows_cert_connect/main.cpp b/samples/mqtt/windows_cert_connect/main.cpp index 67efb321a..6098da2af 100644 --- a/samples/mqtt/windows_cert_connect/main.cpp +++ b/samples/mqtt/windows_cert_connect/main.cpp @@ -14,7 +14,7 @@ int main(int argc, char *argv[]) { /************************ Setup the Lib ****************************/ - /* + /** * Do the global initialization for the API. */ ApiHandle apiHandle; @@ -58,7 +58,7 @@ int main(int argc, char *argv[]) exit(-1); } - /* + /** * Note that that remainder of this code is identical to how the other connect samples setup their connection. */ @@ -86,7 +86,7 @@ int main(int argc, char *argv[]) exit(-1); } - /* + /** * Now create a connection object. Note: This type is move only * and its underlying memory is managed by the client. */ @@ -98,8 +98,10 @@ int main(int argc, char *argv[]) exit(-1); } - // Connect and then disconnect using the connection we created - // (see SampleConnectAndDisconnect for implementation) + /** + * Connect and then disconnect using the connection we created + * (see SampleConnectAndDisconnect for implementation) + */ cmdUtils.SampleConnectAndDisconnect(connection, clientId); return 0; diff --git a/samples/mqtt/x509_credentials_provider_connect/main.cpp b/samples/mqtt/x509_credentials_provider_connect/main.cpp index 10594595f..3a465fff8 100644 --- a/samples/mqtt/x509_credentials_provider_connect/main.cpp +++ b/samples/mqtt/x509_credentials_provider_connect/main.cpp @@ -41,17 +41,21 @@ int main(int argc, char *argv[]) cmdUtils.SendArguments(const_argv, const_argv + argc); cmdUtils.StartLoggingBasedOnCommand(&apiHandle); - // Make a MQTT client and create a connection using websockets and x509 - // Note: The data for the connection is gotten from cmdUtils - // (see BuildWebsocketX509MQTTConnection for implementation) + /** + * Make a MQTT client and create a connection using websockets and x509 + * Note: The data for the connection is gotten from cmdUtils + * (see BuildWebsocketX509MQTTConnection for implementation) + */ Aws::Iot::MqttClient mqttClient; std::shared_ptr connection = cmdUtils.BuildWebsocketX509MQTTConnection(&mqttClient); - // Get the client ID to send with the connection + /* Get the client ID to send with the connection */ String clientId = cmdUtils.GetCommandOrDefault("client_id", String("test-") + Aws::Crt::UUID().ToString()); - // Connect and then disconnect using the connection we created - // (see SampleConnectAndDisconnect for implementation) + /** + * Connect and then disconnect using the connection we created + * (see SampleConnectAndDisconnect for implementation) + */ cmdUtils.SampleConnectAndDisconnect(connection, clientId); return 0; } diff --git a/samples/pub_sub/basic_pub_sub/main.cpp b/samples/pub_sub/basic_pub_sub/main.cpp index ed16418be..d20b49237 100644 --- a/samples/pub_sub/basic_pub_sub/main.cpp +++ b/samples/pub_sub/basic_pub_sub/main.cpp @@ -23,7 +23,7 @@ int main(int argc, char *argv[]) { /************************ Setup the Lib ****************************/ - /* + /** * Do the global initialization for the API. */ ApiHandle apiHandle; @@ -61,15 +61,15 @@ int main(int argc, char *argv[]) /* Get a MQTT client connection from the command parser */ auto connection = cmdUtils.BuildMQTTConnection(); - /* + /** * In a real world application you probably don't want to enforce synchronous behavior * but this is a sample console application, so we'll just do that with a condition variable. */ std::promise connectionCompletedPromise; std::promise connectionClosedPromise; - /* - * This will execute when an mqtt connect has completed or failed. + /** + * This will execute when an MQTT connect has completed or failed. */ auto onConnectionCompleted = [&](Mqtt::MqttConnection &, int errorCode, Mqtt::ReturnCode returnCode, bool) { if (errorCode) @@ -90,7 +90,7 @@ int main(int argc, char *argv[]) auto onResumed = [&](Mqtt::MqttConnection &, Mqtt::ReturnCode, bool) { fprintf(stdout, "Connection resumed\n"); }; - /* + /** * Invoked when a disconnect message has completed. */ auto onDisconnect = [&](Mqtt::MqttConnection &) { @@ -105,7 +105,7 @@ int main(int argc, char *argv[]) connection->OnConnectionInterrupted = std::move(onInterrupted); connection->OnConnectionResumed = std::move(onResumed); - /* + /** * Actually perform the connect dance. */ fprintf(stdout, "Connecting...\n"); @@ -121,7 +121,7 @@ int main(int argc, char *argv[]) std::condition_variable receiveSignal; uint32_t receivedCount = 0; - /* + /** * This is invoked upon the receipt of a Publish on a subscribed topic. */ auto onMessage = [&](Mqtt::MqttConnection &, @@ -142,7 +142,7 @@ int main(int argc, char *argv[]) receiveSignal.notify_all(); }; - /* + /** * Subscribe for incoming publish messages on topic. */ std::promise subscribeFinishedPromise; @@ -188,7 +188,7 @@ int main(int argc, char *argv[]) receiveSignal.wait(receivedLock, [&] { return receivedCount >= messageCount; }); } - /* + /** * Unsubscribe from the topic. */ std::promise unsubscribeFinishedPromise; diff --git a/samples/pub_sub/cycle_pub_sub/main.cpp b/samples/pub_sub/cycle_pub_sub/main.cpp index 06d8c20dd..03070bac5 100644 --- a/samples/pub_sub/cycle_pub_sub/main.cpp +++ b/samples/pub_sub/cycle_pub_sub/main.cpp @@ -143,7 +143,7 @@ enum OPERATIONS /** * The null operation - does nothing. * - * @param current_client The client to operform the operation on + * @param current_client The client to perform the operation on * @param index The index of the client passed */ void operationNull(CycleClient *current_client, int index) @@ -156,7 +156,7 @@ void operationNull(CycleClient *current_client, int index) /** * The start operation will connect the passed-in client, if it is not already connected. * - * @param current_client The client to operform the operation on + * @param current_client The client to perform the operation on * @param index The index of the client passed */ void operationStart(CycleClient *current_client, int index) @@ -197,7 +197,7 @@ void operationStart(CycleClient *current_client, int index) /** * The stop operation will disconnect the passed-in client, if it is not already disconnected. * - * @param current_client The client to operform the operation on + * @param current_client The client to perform the operation on * @param index The index of the client passed */ void operationStop(CycleClient *current_client, int index) @@ -235,7 +235,7 @@ void operationStop(CycleClient *current_client, int index) * The subscribe operation will subscribe to the shared topic and the client Id * topic of the passed-in client, if not already subscribed. * - * @param current_client The client to operform the operation on + * @param current_client The client to perform the operation on * @param index The index of the client passed */ void operationSubscribe(CycleClient *current_client, int index) @@ -301,7 +301,7 @@ void operationSubscribe(CycleClient *current_client, int index) * The unsubscribe operation will unsubscribe to the shared topic and the client Id * topic of the passed-in client, if not already unsubscribed. * - * @param current_client The client to operform the operation on + * @param current_client The client to perform the operation on * @param index The index of the client passed */ void operationUnsubscribe(CycleClient *current_client, int index) @@ -338,7 +338,7 @@ void operationUnsubscribe(CycleClient *current_client, int index) /** * The publish operation will publish a payload to the passed-in topic using the passed-in QOS. * - * @param current_client The client to operform the operation on + * @param current_client The client to perform the operation on * @param index The index of the client passed * @param QOS The QOS to use with the publish * @param topic The topic to publish the message to @@ -364,7 +364,7 @@ void operationPublish(CycleClient *current_client, int index, Aws::Crt::Mqtt::QO /** * The publish QOS 0 operation will publish a QOS 0 message to the "topic1" topic * - * @param current_client The client to operform the operation on + * @param current_client The client to perform the operation on * @param index The index of the client passed */ void operationPublishQOS0(CycleClient *current_client, int index) @@ -375,7 +375,7 @@ void operationPublishQOS0(CycleClient *current_client, int index) /** * The publish QOS 1 operation will publish a QOS 1 message to the "topic1" topic * - * @param current_client The client to operform the operation on + * @param current_client The client to perform the operation on * @param index The index of the client passed */ void operationPublishQOS1(CycleClient *current_client, int index) @@ -387,7 +387,7 @@ void operationPublishQOS1(CycleClient *current_client, int index) * The publish to subscribed QOS 0 operation will publish a QOS 0 message to the * client Id topic. * - * @param current_client The client to operform the operation on + * @param current_client The client to perform the operation on * @param index The index of the client passed */ void operationPublishToSubscribedTopicQOS0(CycleClient *current_client, int index) @@ -399,7 +399,7 @@ void operationPublishToSubscribedTopicQOS0(CycleClient *current_client, int inde * The publish to subscribed QOS 1 operation will publish a QOS 1 message to the * client Id topic. * - * @param current_client The client to operform the operation on + * @param current_client The client to perform the operation on * @param index The index of the client passed */ void operationPublishToSubscribedTopicQOS1(CycleClient *current_client, int index) @@ -411,7 +411,7 @@ void operationPublishToSubscribedTopicQOS1(CycleClient *current_client, int inde * The publish to shared QOS 0 operation will publish a QOS 0 message to the * shared topic that all clients can be subscribed to. * - * @param current_client The client to operform the operation on + * @param current_client The client to perform the operation on * @param index The index of the client passed */ void operationPublishToSharedTopicQOS0(CycleClient *current_client, int index) @@ -423,7 +423,7 @@ void operationPublishToSharedTopicQOS0(CycleClient *current_client, int index) * The publish to shared QOS 1 operation will publish a QOS 1 message to the * shared topic that all clients can be subscribed to. * - * @param current_client The client to operform the operation on + * @param current_client The client to perform the operation on * @param index The index of the client passed */ void operationPublishToSharedTopicQOS1(CycleClient *current_client, int index) @@ -565,7 +565,7 @@ int main(int argc, char *argv[]) /******************** Start the client cycle ***********************/ - // Make the clients + /* Make the clients */ for (size_t i = 0; i < config_clients; i++) { clients_holder.push_back(CycleClient()); @@ -573,13 +573,13 @@ int main(int argc, char *argv[]) fprintf(stdout, "Created client %zu\n", i); } - // Get the current time + /* Get the current time */ auto startTime = std::chrono::steady_clock::now(); - // Seed the random number generator with the current time + /* Seed the random number generator with the current time */ srand((unsigned int)time(nullptr)); - // Start the loop + /* Start the loop */ bool done = false; auto nowTime = std::chrono::steady_clock::now(); uint64_t time_difference = 0; @@ -598,7 +598,7 @@ int main(int argc, char *argv[]) /*************************** Clean up ******************************/ - // Stop all the clients and clear the vector + /* Stop all the clients and clear the vector */ for (size_t i = 0; i < config_clients; i++) { operationStop(&clients_holder.at(i), (int)i); diff --git a/samples/secure_tunneling/secure_tunnel/main.cpp b/samples/secure_tunneling/secure_tunnel/main.cpp index 2c6da45ea..891cc4b46 100644 --- a/samples/secure_tunneling/secure_tunnel/main.cpp +++ b/samples/secure_tunneling/secure_tunnel/main.cpp @@ -54,7 +54,7 @@ int main(int argc, char *argv[]) cmdUtils.SendArguments(const_argv, const_argv + argc); cmdUtils.StartLoggingBasedOnCommand(&apiHandle); - /* + /** * Generate secure tunneling endpoint using region */ String region = cmdUtils.GetCommandRequired("region"); @@ -104,7 +104,7 @@ int main(int argc, char *argv[]) String caFile = cmdUtils.GetCommandOrDefault("ca_file", ""); - /* + /** * localProxyMode is set to destination by default unless flag is set to source */ if (cmdUtils.HasCommand("local_proxy_mode_source")) @@ -118,7 +118,7 @@ int main(int argc, char *argv[]) String message = cmdUtils.GetCommandOrDefault("message", "Hello World"); - /* + /** * For internal testing */ bool isTest = cmdUtils.HasCommand("test"); @@ -133,7 +133,7 @@ int main(int argc, char *argv[]) exit(-1); } - /* + /** * In a real world application you probably don't want to enforce synchronous behavior * but this is a sample console application, so we'll just do that with a condition variable. */ @@ -215,7 +215,7 @@ int main(int argc, char *argv[]) } }; - /* + /** * This only fires in Destination Mode */ auto OnStreamStart = [&]() { fprintf(stdout, "Stream Started in Destination Mode\n"); }; @@ -225,7 +225,7 @@ int main(int argc, char *argv[]) auto OnSessionReset = [&]() { fprintf(stdout, "Session Reset\n"); }; /*********************** Proxy Connection Setup ***************************/ - /* + /** * Setup HttpClientCommectionProxyOptions for connecting through a proxy before the Secure Tunnel */ @@ -235,7 +235,7 @@ int main(int argc, char *argv[]) proxyOptions.HostName = proxyHost.c_str(); proxyOptions.Port = proxyPort; - /* + /** * Set up Proxy Strategy if a user name and password is provided */ if (proxyUserName.length() > 0 || proxyPassword.length() > 0) @@ -255,7 +255,7 @@ int main(int argc, char *argv[]) } /*********************** Secure Tunnel Setup ***************************/ - /* + /** * Create a new SecureTunnel using the SecureTunnelBuilder */ secureTunnel = @@ -275,7 +275,7 @@ int main(int argc, char *argv[]) else { /*********************** Secure Tunnel Setup ***************************/ - /* + /** * Create a new SecureTunnel using the SecureTunnelBuilder */ secureTunnel = diff --git a/samples/secure_tunneling/tunnel_notification/main.cpp b/samples/secure_tunneling/tunnel_notification/main.cpp index 5c0c22dda..d19bc0295 100644 --- a/samples/secure_tunneling/tunnel_notification/main.cpp +++ b/samples/secure_tunneling/tunnel_notification/main.cpp @@ -32,7 +32,7 @@ using namespace Aws::Iotsecuretunneling; int main(int argc, char *argv[]) { /************************ Setup the Lib ****************************/ - /* + /** * Do the global initialization for the API. */ ApiHandle apiHandle; @@ -55,14 +55,14 @@ int main(int argc, char *argv[]) /* Get a MQTT client connection from the command parser */ auto connection = cmdUtils.BuildMQTTConnection(); - /* + /** * In a real world application you probably don't want to enforce synchronous behavior * but this is a sample console application, so we'll just do that with a condition variable. */ std::promise connectionCompletedPromise; std::promise connectionClosedPromise; - /* + /** * This will execute when an mqtt connect has completed or failed. */ auto onConnectionCompleted = [&](Mqtt::MqttConnection &, int errorCode, Mqtt::ReturnCode returnCode, bool) { @@ -78,7 +78,7 @@ int main(int argc, char *argv[]) } }; - /* + /** * Invoked when a disconnect message has completed. */ auto onDisconnect = [&](Mqtt::MqttConnection & /*conn*/) { @@ -91,7 +91,7 @@ int main(int argc, char *argv[]) connection->OnConnectionCompleted = std::move(onConnectionCompleted); connection->OnDisconnect = std::move(onDisconnect); - /* + /** * Actually perform the connect dance. */ fprintf(stdout, "Connecting...\n"); diff --git a/samples/shadow/shadow_sync/main.cpp b/samples/shadow/shadow_sync/main.cpp index ee10c4d1d..1a96ff840 100644 --- a/samples/shadow/shadow_sync/main.cpp +++ b/samples/shadow/shadow_sync/main.cpp @@ -104,7 +104,8 @@ int main(int argc, char *argv[]) cmdUtils.RegisterCommand("cert", "", "Path to your client certificate in PEM format."); cmdUtils.RegisterCommand("thing_name", "", "The name of your IOT thing."); cmdUtils.RegisterCommand("shadow_property", "", "The name of the shadow property you want to change."); - cmdUtils.RegisterCommand("is_ci", "", "If set to 'True' then it will run in CI mode (will publish to shadow automatically)."); + cmdUtils.RegisterCommand( + "is_ci", "", "If present the sample will run in CI mode (will publish to shadow automatically)."); cmdUtils.AddLoggingCommands(); const char **const_argv = (const char **)argv; cmdUtils.SendArguments(const_argv, const_argv + argc); @@ -112,19 +113,19 @@ int main(int argc, char *argv[]) String thingName = cmdUtils.GetCommandRequired("thing_name"); String shadowProperty = cmdUtils.GetCommandRequired("shadow_property"); - String isCI = cmdUtils.GetCommandOrDefault("is_ci", ""); + bool isCI = cmdUtils.HasCommand("is_ci"); /* Get a MQTT client connection from the command parser */ auto connection = cmdUtils.BuildMQTTConnection(); - /* + /** * In a real world application you probably don't want to enforce synchronous behavior * but this is a sample console application, so we'll just do that with a condition variable. */ std::promise connectionCompletedPromise; std::promise connectionClosedPromise; - /* + /** * This will execute when a mqtt connect has completed or failed. */ auto onConnectionCompleted = [&](Mqtt::MqttConnection &, int errorCode, Mqtt::ReturnCode returnCode, bool) { @@ -140,7 +141,7 @@ int main(int argc, char *argv[]) } }; - /* + /** * Invoked when a disconnect message has completed. */ auto onDisconnect = [&](Mqtt::MqttConnection & /*conn*/) { @@ -153,7 +154,7 @@ int main(int argc, char *argv[]) connection->OnConnectionCompleted = std::move(onConnectionCompleted); connection->OnDisconnect = std::move(onDisconnect); - /* + /** * Actually perform the connect dance. */ fprintf(stdout, "Connecting...\n"); @@ -167,8 +168,9 @@ int main(int argc, char *argv[]) { Aws::Iotshadow::IotShadowClient shadowClient(connection); - // ==================== Shadow Delta Updates ==================== - // This section is for when a Shadow document updates/changes, whether it is on the server side or client side. + /* ==================== Shadow Delta Updates ==================== */ + /* This section is for when a Shadow document updates/changes, whether it is on the server side or client side. + */ std::promise subscribeDeltaCompletedPromise; std::promise subscribeDeltaAcceptedCompletedPromise; @@ -261,7 +263,11 @@ int main(int argc, char *argv[]) fprintf(stdout, "Finished clearing shadow properties\n"); currentShadowValue = ""; } - fprintf(stdout, "Enter Desired state of %s:\n", shadowProperty.c_str()); + + if (isCI == false) + { + fprintf(stdout, "Enter Desired state of %s:\n", shadowProperty.c_str()); + } }; auto onUpdateShadowRejected = [&](ErrorResponse *error, int ioErr) { @@ -302,8 +308,8 @@ int main(int argc, char *argv[]) subscribeDeltaAcceptedCompletedPromise.get_future().wait(); subscribeDeltaRejectedCompletedPromise.get_future().wait(); - // ==================== Shadow Value Get ==================== - // This section is to get the initial value of the Shadow document. + /* ==================== Shadow Value Get ==================== */ + /* This section is to get the initial value of the Shadow document */ std::promise subscribeGetShadowAcceptedCompletedPromise; std::promise subscribeGetShadowRejectedCompletedPromise; @@ -408,17 +414,20 @@ int main(int argc, char *argv[]) GetShadowRequest shadowGetRequest; shadowGetRequest.ThingName = thingName; - // Get the current shadow document so we start with the correct value + /* Get the current shadow document so we start with the correct value */ shadowClient.PublishGetShadow(shadowGetRequest, AWS_MQTT_QOS_AT_LEAST_ONCE, onGetShadowRequestSubAck); onGetShadowRequestCompletedPromise.get_future().wait(); gotInitialShadowPromise.get_future().wait(); - // ==================== Shadow change value input loop ==================== - // This section is to getting user input and changing the shadow value passed to that input. - // If in CI, then input is automatically passed + /* ==================== Shadow change value input loop ==================== */ + /** + * This section is to getting user input and changing the shadow value passed to that input. + * If in CI, then input is automatically passed + */ - if (isCI != "True") { + if (isCI == false) + { fprintf(stdout, "Enter Desired state of %s:\n", shadowProperty.c_str()); while (true) { @@ -441,10 +450,14 @@ int main(int argc, char *argv[]) s_changeShadowValue(shadowClient, thingName, shadowProperty, input); } } - } else { + } + else + { int messagesSent = 0; - while (messagesSent < 5) { - String input = "Shadow_Value_" + std::to_string(messagesSent); + while (messagesSent < 5) + { + String input = "Shadow_Value_"; + input += std::to_string(messagesSent); s_changeShadowValue(shadowClient, thingName, shadowProperty, input); /* Sleep so there is a gap between shadow updates */ std::this_thread::sleep_for(std::chrono::milliseconds(1000)); diff --git a/samples/utils/CommandLineUtils.cpp b/samples/utils/CommandLineUtils.cpp index a268c7dfa..a5f71cac3 100644 --- a/samples/utils/CommandLineUtils.cpp +++ b/samples/utils/CommandLineUtils.cpp @@ -13,7 +13,7 @@ namespace Utils { CommandLineUtils::CommandLineUtils() { - // Automatically register the help command + /* Automatically register the help command */ RegisterCommand(m_cmd_help, "", "Prints this message"); } @@ -66,7 +66,7 @@ namespace Utils m_beginPosition = argv; m_endPosition = argc; - // Automatically check and print the help message if the help command is present + /* Automatically check and print the help message if the help command is present */ if (HasCommand(m_cmd_help)) { PrintHelp(); @@ -209,7 +209,7 @@ namespace Utils void CommandLineUtils::StartLoggingBasedOnCommand(Aws::Crt::ApiHandle *apiHandle) { - // Process logging command + /* Process logging command */ if (HasCommand("verbosity")) { Aws::Crt::String verbosity = GetCommand(m_cmd_verbosity); @@ -239,7 +239,7 @@ namespace Utils } else { - // If none or unknown, then do nothing + /* If none or unknown, then do nothing */ } } } @@ -564,14 +564,14 @@ namespace Utils std::shared_ptr connection, Aws::Crt::String clientId) { - /* + /** * In a real world application you probably don't want to enforce synchronous behavior * but this is a sample console application, so we'll just do that with a condition variable. */ std::promise connectionCompletedPromise; std::promise connectionClosedPromise; - /* + /** * This will execute when an mqtt connect has completed or failed. */ auto onConnectionCompleted = @@ -595,7 +595,7 @@ namespace Utils fprintf(stdout, "Connection resumed\n"); }; - /* + /** * Invoked when a disconnect message has completed. */ auto onDisconnect = [&](Aws::Crt::Mqtt::MqttConnection &) { @@ -608,7 +608,7 @@ namespace Utils connection->OnConnectionInterrupted = std::move(onInterrupted); connection->OnConnectionResumed = std::move(onResumed); - /* + /** * Actually perform the connect dance. */ fprintf(stdout, "Connecting...\n"); @@ -619,7 +619,7 @@ namespace Utils exit(-1); } - // wait for the OnConnectionCompleted callback to fire, which sets connectionCompletedPromise... + /* wait for the OnConnectionCompleted callback to fire, which sets connectionCompletedPromise... */ if (connectionCompletedPromise.get_future().get() == false) { fprintf(stderr, "Connection failed\n"); @@ -633,4 +633,4 @@ namespace Utils } } -} // namespace Utils +} /* namespace Utils */ diff --git a/samples/utils/CommandLineUtils.h b/samples/utils/CommandLineUtils.h index d43ff4fe9..094d8bec8 100644 --- a/samples/utils/CommandLineUtils.h +++ b/samples/utils/CommandLineUtils.h @@ -252,7 +252,7 @@ namespace Utils Aws::Iot::MqttClient *client, Aws::Iot::MqttClientConnectionConfigBuilder *clientConfigBuilder); - /** Constants for commonly used/needed commands */ + /* Constants for commonly used/needed commands */ const Aws::Crt::String m_cmd_endpoint = "endpoint"; const Aws::Crt::String m_cmd_ca_file = "ca_file"; const Aws::Crt::String m_cmd_cert_file = "cert"; @@ -282,4 +282,4 @@ namespace Utils const Aws::Crt::String m_cmd_custom_auth_password = "custom_auth_password"; const Aws::Crt::String m_cmd_verbosity = "verbosity"; }; -} // namespace Utils +} /* namespace Utils */ From b065c1d7a984bedfdf832bd3ac81c03eeae0866f Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Mon, 26 Sep 2022 17:49:44 -0400 Subject: [PATCH 04/50] Fix IPC sample compile issue --- samples/greengrass/ipc/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/greengrass/ipc/main.cpp b/samples/greengrass/ipc/main.cpp index a5c6ef4ee..e70130d3f 100644 --- a/samples/greengrass/ipc/main.cpp +++ b/samples/greengrass/ipc/main.cpp @@ -211,7 +211,7 @@ int main(int argc, char *argv[]) } /* Wait for the publish to be received since this sample subscribes to the same topic it publishes to. */ - while (!s_publishReceivead.load()) + while (!s_publishReceived.load()) { continue; } From 795d29d3918220f0d20f1b1f8a5e53bb1b12a111 Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Mon, 26 Sep 2022 18:00:32 -0400 Subject: [PATCH 05/50] Get proper permissions to GitHub actions for tokens, send shadow updates without converting the int --- .github/workflows/ci.yml | 18 ++++++++++++++++++ samples/shadow/shadow_sync/main.cpp | 4 +--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9e6b8e54e..c092864ad 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,6 +31,8 @@ jobs: - manylinux2014-x64 - manylinux2014-x86 - al2-x64 + permissions: + id-token: write # This is required for requesting the JWT steps: - name: configure AWS credentials (containers) @@ -60,6 +62,8 @@ jobs: - gcc-6 - gcc-7 - gcc-8 + permissions: + id-token: write # This is required for requesting the JWT steps: - name: configure AWS credentials (containers) uses: aws-actions/configure-aws-credentials@v1 @@ -74,6 +78,8 @@ jobs: byo-crypto: runs-on: ubuntu-latest + permissions: + id-token: write # This is required for requesting the JWT steps: - name: configure AWS credentials (containers) uses: aws-actions/configure-aws-credentials@v1 @@ -88,6 +94,8 @@ jobs: linux-no-cpu-extensions: runs-on: ubuntu-latest + permissions: + id-token: write # This is required for requesting the JWT steps: - name: configure AWS credentials (containers) uses: aws-actions/configure-aws-credentials@v1 @@ -102,6 +110,8 @@ jobs: windows: runs-on: windows-latest + permissions: + id-token: write # This is required for requesting the JWT steps: - name: Build ${{ env.PACKAGE_NAME }} + consumers run: | @@ -132,6 +142,8 @@ jobs: strategy: matrix: arch: [Win32, x64] + permissions: + id-token: write # This is required for requesting the JWT steps: - name: Build ${{ env.PACKAGE_NAME }} + consumers run: | @@ -159,6 +171,8 @@ jobs: windows-no-cpu-extensions: runs-on: windows-latest + permissions: + id-token: write # This is required for requesting the JWT steps: - name: Build ${{ env.PACKAGE_NAME }} + consumers run: | @@ -186,6 +200,8 @@ jobs: windows-app-verifier: runs-on: windows-2022 # latest + permissions: + id-token: write # This is required for requesting the JWT steps: - name: Build ${{ env.PACKAGE_NAME }} + consumers run: | @@ -207,6 +223,8 @@ jobs: osx: runs-on: macos-latest + permissions: + id-token: write # This is required for requesting the JWT steps: - name: Build ${{ env.PACKAGE_NAME }} + consumers run: | diff --git a/samples/shadow/shadow_sync/main.cpp b/samples/shadow/shadow_sync/main.cpp index 1a96ff840..83737160d 100644 --- a/samples/shadow/shadow_sync/main.cpp +++ b/samples/shadow/shadow_sync/main.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #include "../../utils/CommandLineUtils.h" @@ -456,8 +455,7 @@ int main(int argc, char *argv[]) int messagesSent = 0; while (messagesSent < 5) { - String input = "Shadow_Value_"; - input += std::to_string(messagesSent); + String input = "Shadow_Value_CPP"; s_changeShadowValue(shadowClient, thingName, shadowProperty, input); /* Sleep so there is a gap between shadow updates */ std::this_thread::sleep_for(std::chrono::milliseconds(1000)); From f8365e23af465d7911f9976110b79a713d3f96b5 Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Mon, 26 Sep 2022 18:10:08 -0400 Subject: [PATCH 06/50] Use proper paths to utils --- .github/workflows/ci.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c092864ad..3409b60e7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -127,7 +127,7 @@ jobs: - name: run PubSub sample run: | python -m pip install boto3 - python ./utils/run_sample_ci.py --language CPP --sample_file '.\aws-iot-device-sdk-cpp-v2\build\samples\pub_sub\basic_pub_sub\RelWithDebInfo\basic-pub-sub.exe' --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_main_class 'pubsub.PubSub' + python ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file '.\aws-iot-device-sdk-cpp-v2\build\samples\pub_sub\basic_pub_sub\RelWithDebInfo\basic-pub-sub.exe' --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_main_class 'pubsub.PubSub' - name: configure AWS credentials (Device Advisor) uses: aws-actions/configure-aws-credentials@v1 with: @@ -135,7 +135,7 @@ jobs: aws-region: ${{ env.AWS_DEFAULT_REGION }} - name: run DeviceAdvisor run: | - python3 ./deviceadvisor/script/DATestRun.py + python3 ./aws-iot-device-sdk-cpp-v2/deviceadvisor/script/DATestRun.py windows-vs14: runs-on: windows-2019 # windows-2019 is last env with Visual Studio 2015 (v14.0) @@ -159,7 +159,7 @@ jobs: - name: run PubSub sample run: | python -m pip install boto3 - python ./utils/run_sample_ci.py --language CPP --sample_file '.\aws-iot-device-sdk-cpp-v2\build\samples\pub_sub\basic_pub_sub\RelWithDebInfo\basic-pub-sub.exe' --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_main_class 'pubsub.PubSub' + python ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file '.\aws-iot-device-sdk-cpp-v2\build\samples\pub_sub\basic_pub_sub\RelWithDebInfo\basic-pub-sub.exe' --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_main_class 'pubsub.PubSub' - name: configure AWS credentials (Device Advisor) uses: aws-actions/configure-aws-credentials@v1 with: @@ -167,7 +167,7 @@ jobs: aws-region: ${{ env.AWS_DEFAULT_REGION }} - name: run DeviceAdvisor run: | - python3 ./deviceadvisor/script/DATestRun.py + python3 ./aws-iot-device-sdk-cpp-v2/deviceadvisor/script/DATestRun.py windows-no-cpu-extensions: runs-on: windows-latest @@ -188,7 +188,7 @@ jobs: - name: run PubSub sample run: | python -m pip install boto3 - python ./utils/run_sample_ci.py --language CPP --sample_file '.\aws-iot-device-sdk-cpp-v2\build\samples\pub_sub\basic_pub_sub\RelWithDebInfo\basic-pub-sub.exe' --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_main_class 'pubsub.PubSub' + python ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file '.\aws-iot-device-sdk-cpp-v2\build\samples\pub_sub\basic_pub_sub\RelWithDebInfo\basic-pub-sub.exe' --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_main_class 'pubsub.PubSub' - name: configure AWS credentials (Device Advisor) uses: aws-actions/configure-aws-credentials@v1 with: @@ -196,7 +196,7 @@ jobs: aws-region: ${{ env.AWS_DEFAULT_REGION }} - name: run DeviceAdvisor run: | - python3 ./deviceadvisor/script/DATestRun.py + python3 ./aws-iot-device-sdk-cpp-v2/deviceadvisor/script/DATestRun.py windows-app-verifier: runs-on: windows-2022 # latest @@ -239,7 +239,7 @@ jobs: - name: run PubSub sample run: | python3 -m pip install boto3 - python3 ./utils/run_sample_ci.py --language CPP --sample_file '.\aws-iot-device-sdk-cpp-v2\build\samples\pub_sub\basic_pub_sub\pub-sub' --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_main_class 'pubsub.PubSub' + python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file '.\aws-iot-device-sdk-cpp-v2\build\samples\pub_sub\basic_pub_sub\pub-sub' --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_main_class 'pubsub.PubSub' - name: configure AWS credentials (Device Advisor) uses: aws-actions/configure-aws-credentials@v1 with: @@ -247,7 +247,7 @@ jobs: aws-region: ${{ env.AWS_DEFAULT_REGION }} - name: run DeviceAdvisor run: | - python3 ./deviceadvisor/script/DATestRun.py + python3 ./aws-iot-device-sdk-cpp-v2/deviceadvisor/script/DATestRun.py # check that docs can still build check-docs: From d6896d4038508ffa7385f8bc9f3deccceb7f4424 Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Tue, 27 Sep 2022 09:10:53 -0400 Subject: [PATCH 07/50] Fix paths in CI file --- .github/workflows/ci.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3409b60e7..346ed70e0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -126,6 +126,7 @@ jobs: aws-region: ${{ env.AWS_DEFAULT_REGION }} - name: run PubSub sample run: | + cd D:\a\work python -m pip install boto3 python ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file '.\aws-iot-device-sdk-cpp-v2\build\samples\pub_sub\basic_pub_sub\RelWithDebInfo\basic-pub-sub.exe' --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_main_class 'pubsub.PubSub' - name: configure AWS credentials (Device Advisor) @@ -135,6 +136,7 @@ jobs: aws-region: ${{ env.AWS_DEFAULT_REGION }} - name: run DeviceAdvisor run: | + cd D:\a\work python3 ./aws-iot-device-sdk-cpp-v2/deviceadvisor/script/DATestRun.py windows-vs14: @@ -158,6 +160,7 @@ jobs: aws-region: ${{ env.AWS_DEFAULT_REGION }} - name: run PubSub sample run: | + cd D:\a\work python -m pip install boto3 python ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file '.\aws-iot-device-sdk-cpp-v2\build\samples\pub_sub\basic_pub_sub\RelWithDebInfo\basic-pub-sub.exe' --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_main_class 'pubsub.PubSub' - name: configure AWS credentials (Device Advisor) @@ -167,6 +170,7 @@ jobs: aws-region: ${{ env.AWS_DEFAULT_REGION }} - name: run DeviceAdvisor run: | + cd D:\a\work python3 ./aws-iot-device-sdk-cpp-v2/deviceadvisor/script/DATestRun.py windows-no-cpu-extensions: @@ -187,6 +191,7 @@ jobs: aws-region: ${{ env.AWS_DEFAULT_REGION }} - name: run PubSub sample run: | + cd D:\a\work python -m pip install boto3 python ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file '.\aws-iot-device-sdk-cpp-v2\build\samples\pub_sub\basic_pub_sub\RelWithDebInfo\basic-pub-sub.exe' --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_main_class 'pubsub.PubSub' - name: configure AWS credentials (Device Advisor) @@ -196,6 +201,7 @@ jobs: aws-region: ${{ env.AWS_DEFAULT_REGION }} - name: run DeviceAdvisor run: | + cd D:\a\work python3 ./aws-iot-device-sdk-cpp-v2/deviceadvisor/script/DATestRun.py windows-app-verifier: @@ -239,7 +245,7 @@ jobs: - name: run PubSub sample run: | python3 -m pip install boto3 - python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file '.\aws-iot-device-sdk-cpp-v2\build\samples\pub_sub\basic_pub_sub\pub-sub' --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_main_class 'pubsub.PubSub' + python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file '.\aws-iot-device-sdk-cpp-v2\build\samples\pub_sub\basic_pub_sub\basic-pub-sub' --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_main_class 'pubsub.PubSub' - name: configure AWS credentials (Device Advisor) uses: aws-actions/configure-aws-credentials@v1 with: From f3b2b4a32f1fff2aeae65b76a9b9221e50e171dd Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Tue, 27 Sep 2022 09:31:58 -0400 Subject: [PATCH 08/50] Fix DeviceAdvisor path, fix path to PubSub sample on MacOS --- .github/workflows/ci.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 346ed70e0..093b84c47 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -128,7 +128,7 @@ jobs: run: | cd D:\a\work python -m pip install boto3 - python ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file '.\aws-iot-device-sdk-cpp-v2\build\samples\pub_sub\basic_pub_sub\RelWithDebInfo\basic-pub-sub.exe' --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_main_class 'pubsub.PubSub' + python ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file '.\aws-iot-device-sdk-cpp-v2\build\samples\pub_sub\basic_pub_sub\RelWithDebInfo\basic-pub-sub.exe' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' - name: configure AWS credentials (Device Advisor) uses: aws-actions/configure-aws-credentials@v1 with: @@ -136,8 +136,8 @@ jobs: aws-region: ${{ env.AWS_DEFAULT_REGION }} - name: run DeviceAdvisor run: | - cd D:\a\work - python3 ./aws-iot-device-sdk-cpp-v2/deviceadvisor/script/DATestRun.py + cd D:\a\work\aws-iot-device-sdk-cpp-v2 + python3 ./deviceadvisor/script/DATestRun.py windows-vs14: runs-on: windows-2019 # windows-2019 is last env with Visual Studio 2015 (v14.0) @@ -162,7 +162,7 @@ jobs: run: | cd D:\a\work python -m pip install boto3 - python ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file '.\aws-iot-device-sdk-cpp-v2\build\samples\pub_sub\basic_pub_sub\RelWithDebInfo\basic-pub-sub.exe' --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_main_class 'pubsub.PubSub' + python ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file '.\aws-iot-device-sdk-cpp-v2\build\samples\pub_sub\basic_pub_sub\RelWithDebInfo\basic-pub-sub.exe' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' - name: configure AWS credentials (Device Advisor) uses: aws-actions/configure-aws-credentials@v1 with: @@ -170,8 +170,8 @@ jobs: aws-region: ${{ env.AWS_DEFAULT_REGION }} - name: run DeviceAdvisor run: | - cd D:\a\work - python3 ./aws-iot-device-sdk-cpp-v2/deviceadvisor/script/DATestRun.py + cd D:\a\work\aws-iot-device-sdk-cpp-v2 + python3 ./deviceadvisor/script/DATestRun.py windows-no-cpu-extensions: runs-on: windows-latest @@ -193,7 +193,7 @@ jobs: run: | cd D:\a\work python -m pip install boto3 - python ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file '.\aws-iot-device-sdk-cpp-v2\build\samples\pub_sub\basic_pub_sub\RelWithDebInfo\basic-pub-sub.exe' --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_main_class 'pubsub.PubSub' + python ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file '.\aws-iot-device-sdk-cpp-v2\build\samples\pub_sub\basic_pub_sub\RelWithDebInfo\basic-pub-sub.exe' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' - name: configure AWS credentials (Device Advisor) uses: aws-actions/configure-aws-credentials@v1 with: @@ -201,8 +201,8 @@ jobs: aws-region: ${{ env.AWS_DEFAULT_REGION }} - name: run DeviceAdvisor run: | - cd D:\a\work - python3 ./aws-iot-device-sdk-cpp-v2/deviceadvisor/script/DATestRun.py + cd D:\a\work\aws-iot-device-sdk-cpp-v2 + python3 ./deviceadvisor/script/DATestRun.py windows-app-verifier: runs-on: windows-2022 # latest @@ -225,7 +225,7 @@ jobs: cd D:\a\work echo "Starting to run AppVerifier with cycle pub-sub sample" python -m pip install boto3 - python .\aws-iot-device-sdk-cpp-v2\utils\appverifier_launch_sample.py --sample_file .\aws-iot-device-sdk-cpp-v2\build\samples\pub_sub\cycle_pub_sub\RelWithDebInfo\cycle-pub-sub.exe + python .\aws-iot-device-sdk-cpp-v2\utils\appverifier_launch_sample.py --sample_file .\aws-iot-device-sdk-cpp-v2\build\samples\pub_sub\cycle_pub_sub\RelWithDebInfo\cycle-pub-sub.exe --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' osx: runs-on: macos-latest @@ -245,7 +245,7 @@ jobs: - name: run PubSub sample run: | python3 -m pip install boto3 - python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file '.\aws-iot-device-sdk-cpp-v2\build\samples\pub_sub\basic_pub_sub\basic-pub-sub' --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_main_class 'pubsub.PubSub' + python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/pub_sub/basic_pub_sub/basic-pub-sub' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' - name: configure AWS credentials (Device Advisor) uses: aws-actions/configure-aws-credentials@v1 with: From 859637c9b4e600fa695ff44ecb351b90e8ec0b95 Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Tue, 27 Sep 2022 10:24:42 -0400 Subject: [PATCH 09/50] Use CI role for cycle pub-sub, fix file path on Mac CI, adjust samples README --- .github/workflows/ci.yml | 12 +++- samples/README.md | 152 +++++++++++++++++++++++++++++++++------ 2 files changed, 139 insertions(+), 25 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 093b84c47..298103e29 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,8 +14,13 @@ env: LINUX_BASE_IMAGE: ubuntu-16-x64 RUN: ${{ github.run_id }}-${{ github.run_number }} AWS_DEFAULT_REGION: us-east-1 + DA_TOPIC: test/da + DA_SHADOW_PROPERTY: datest + DA_SHADOW_VALUE_SET: ON + DA_SHADOW_VALUE_DEFAULT: OFF CI_IOT_CONTAINERS: ${{ secrets.AWS_CI_IOT_CONTAINERS }} CI_PUBSUB_ROLE: ${{ secrets.AWS_CI_PUBSUB_ROLE }} + CI_CYCLEPUBSUB_ROLE: ${{ secrets.AWS_CI_CYCLEPUBSUB_ROLE }} CI_CUSTOM_AUTHORIZER_ROLE: ${{ secrets.AWS_CI_CUSTOM_AUTHORIZER_ROLE }} CI_SHADOW_ROLE: ${{ secrets.AWS_CI_SHADOW_ROLE }} CI_JOBS_ROLE: ${{ secrets.AWS_CI_JOBS_ROLE }} @@ -218,14 +223,14 @@ jobs: - name: configure AWS credentials (PubSub) uses: aws-actions/configure-aws-credentials@v1 with: - role-to-assume: ${{ env.CI_PUBSUB_ROLE }} + role-to-assume: ${{ env.CI_CYCLEPUBSUB_ROLE }} aws-region: ${{ env.AWS_DEFAULT_REGION }} - name: Run and check AppVerifier run: | cd D:\a\work echo "Starting to run AppVerifier with cycle pub-sub sample" python -m pip install boto3 - python .\aws-iot-device-sdk-cpp-v2\utils\appverifier_launch_sample.py --sample_file .\aws-iot-device-sdk-cpp-v2\build\samples\pub_sub\cycle_pub_sub\RelWithDebInfo\cycle-pub-sub.exe --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' + python .\aws-iot-device-sdk-cpp-v2\utils\appverifier_launch_sample.py --sample_file .\aws-iot-device-sdk-cpp-v2\build\samples\pub_sub\cycle_pub_sub\RelWithDebInfo\cycle-pub-sub.exe --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/CyclePubSub/cert' --sample_secret_private_key 'ci/CyclePubSub/key' osx: runs-on: macos-latest @@ -253,7 +258,8 @@ jobs: aws-region: ${{ env.AWS_DEFAULT_REGION }} - name: run DeviceAdvisor run: | - python3 ./aws-iot-device-sdk-cpp-v2/deviceadvisor/script/DATestRun.py + cd ./aws-iot-device-sdk-cpp-v2 + python3 ./deviceadvisor/script/DATestRun.py # check that docs can still build check-docs: diff --git a/samples/README.md b/samples/README.md index 3b44b3c3e..9a2a4332f 100644 --- a/samples/README.md +++ b/samples/README.md @@ -564,27 +564,32 @@ Your Thing's [Policy](https://docs.aws.amazon.com/iot/latest/developerguide/iot- "Effect": "Allow", "Action": "iot:Publish", "Resource": [ - "arn:aws:iot:region:account:topic/test/dc/pubtopic", "arn:aws:iot:region:account:topic/$aws/events/job/*", "arn:aws:iot:region:account:topic/$aws/events/jobExecution/*", - "arn:aws:iot:region:account:topic/$aws/things/thingname/jobs/*" + "arn:aws:iot:region:account:topic/$aws/things/thingname/jobs/*/update", + "arn:aws:iot:region:account:topic/$aws/things/thingname/jobs/*/get", + "arn:aws:iot:region:account:topic/$aws/things/thingname/jobs/get" ] }, { "Effect": "Allow", "Action": "iot:Subscribe", "Resource": [ - "arn:aws:iot:region:account:topicfilter/test/dc/subtopic", - "arn:aws:iot:region:account:topic/$aws/events/jobExecution/*", - "arn:aws:iot:region:account:topicfilter/$aws/things/thingname/jobs/*" + "arn:aws:iot:region:account:topicfilter/$aws/events/jobExecution/*", + "arn:aws:iot:region:account:topicfilter/$aws/things/thingname/jobs/start-next/*", + "arn:aws:iot:region:account:topicfilter/$aws/things/thingname/jobs/*/update/*", + "arn:aws:iot:region:account:topicfilter/$aws/things/thingname/jobs/get/*", + "arn:aws:iot:region:account:topicfilter/$aws/things/thingname/jobs/*/get/*" ] }, { "Effect": "Allow", "Action": "iot:Receive", "Resource": [ - "arn:aws:iot:region:account:topic/test/dc/subtopic", - "arn:aws:iot:region:account:topic/$aws/things/thingname/jobs/*" + "arn:aws:iot:region:account:topic/$aws/things/thingname/jobs/start-next/*", + "arn:aws:iot:region:account:topic/$aws/things/thingname/jobs/*/update/*", + "arn:aws:iot:region:account:topic/$aws/things/thingname/jobs/get/*", + "arn:aws:iot:region:account:topic/$aws/things/thingname/jobs/*/get/*" ] }, { @@ -618,7 +623,7 @@ Note that if you get a `Service Error 4 occurred` error, you may have incorrectl This sample uses the AWS IoT [Fleet provisioning](https://docs.aws.amazon.com/iot/latest/developerguide/provision-wo-cert.html) -to provision devices using either a CSR or KeysAndcertificate and subsequently calls RegisterThing. +to provision devices using either a CSR or Keys-And-Certificate and subsequently calls RegisterThing. On startup, the script subscribes to topics based on the request type of either CSR or Keys topics, publishes the request to corresponding topic and calls RegisterThing. @@ -651,9 +656,7 @@ Your Thing's [Policy](https://docs.aws.amazon.com/iot/latest/developerguide/iot- "Statement": [ { "Effect": "Allow", - "Action": [ - "iot:Publish" - ], + "Action": "iot:Publish" "Resource": [ "arn:aws:iot:region:account:topic/$aws/certificates/create/json", "arn:aws:iot:region:account:topic/$aws/certificates/create-from-csr/json", @@ -662,10 +665,7 @@ Your Thing's [Policy](https://docs.aws.amazon.com/iot/latest/developerguide/iot- }, { "Effect": "Allow", - "Action": [ - "iot:Receive", - "iot:Subscribe" - ], + "Action": "iot:Receive" "Resource": [ "arn:aws:iot:region:account:topic/$aws/certificates/create/json/accepted", "arn:aws:iot:region:account:topic/$aws/certificates/create/json/rejected", @@ -675,6 +675,18 @@ Your Thing's [Policy](https://docs.aws.amazon.com/iot/latest/developerguide/iot- "arn:aws:iot:region:account:topic/$aws/provisioning-templates/templatename/provision/json/rejected" ] }, + { + "Effect": "Allow", + "Action": "iot:Subscribe" + "Resource": [ + "arn:aws:iot:region:account:topicfilter/$aws/certificates/create/json/accepted", + "arn:aws:iot:region:account:topicfilter/$aws/certificates/create/json/rejected", + "arn:aws:iot:region:account:topicfilter/$aws/certificates/create-from-csr/json/accepted", + "arn:aws:iot:region:account:topicfilter/$aws/certificates/create-from-csr/json/rejected", + "arn:aws:iot:region:account:topicfilter/$aws/provisioning-templates/templatename/provision/json/accepted", + "arn:aws:iot:region:account:topicfilter/$aws/provisioning-templates/templatename/provision/json/rejected" + ] + }, { "Effect": "Allow", "Action": "iot:Connect", @@ -719,9 +731,103 @@ aws iot create-provisioning-template \ --enabled ``` The rest of the instructions assume you have used the following for the template body: +
+(see template body) ``` sh -{\"Parameters\":{\"DeviceLocation\":{\"Type\":\"String\"},\"AWS::IoT::Certificate::Id\":{\"Type\":\"String\"},\"SerialNumber\":{\"Type\":\"String\"}},\"Mappings\":{\"LocationTable\":{\"Seattle\":{\"LocationUrl\":\"https://example.aws\"}}},\"Resources\":{\"thing\":{\"Type\":\"AWS::IoT::Thing\",\"Properties\":{\"ThingName\":{\"Fn::Join\":[\"\",[\"ThingPrefix_\",{\"Ref\":\"SerialNumber\"}]]},\"AttributePayload\":{\"version\":\"v1\",\"serialNumber\":\"serialNumber\"}},\"OverrideSettings\":{\"AttributePayload\":\"MERGE\",\"ThingTypeName\":\"REPLACE\",\"ThingGroups\":\"DO_NOTHING\"}},\"certificate\":{\"Type\":\"AWS::IoT::Certificate\",\"Properties\":{\"CertificateId\":{\"Ref\":\"AWS::IoT::Certificate::Id\"},\"Status\":\"Active\"},\"OverrideSettings\":{\"Status\":\"REPLACE\"}},\"policy\":{\"Type\":\"AWS::IoT::Policy\",\"Properties\":{\"PolicyDocument\":{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Action\":[\"iot:Connect\",\"iot:Subscribe\",\"iot:Publish\",\"iot:Receive\"],\"Resource\":\"*\"}]}}}},\"DeviceConfiguration\":{\"FallbackUrl\":\"https://www.example.com/test-site\",\"LocationUrl\":{\"Fn::FindInMap\":[\"LocationTable\",{\"Ref\":\"DeviceLocation\"},\"LocationUrl\"]}}} +{ + "Parameters": { + "DeviceLocation": { + "Type": "String" + }, + "AWS::IoT::Certificate::Id": { + "Type": "String" + }, + "SerialNumber": { + "Type": "String" + } + }, + "Mappings": { + "LocationTable": { + "Seattle": { + "LocationUrl": "https://example.aws" + } + } + }, + "Resources": { + "thing": { + "Type": "AWS::IoT::Thing", + "Properties": { + "ThingName": { + "Fn::Join": [ + "", + [ + "ThingPrefix_", + { + "Ref": "SerialNumber" + } + ] + ] + }, + "AttributePayload": { + "version": "v1", + "serialNumber": "serialNumber" + } + }, + "OverrideSettings": { + "AttributePayload": "MERGE", + "ThingTypeName": "REPLACE", + "ThingGroups": "DO_NOTHING" + } + }, + "certificate": { + "Type": "AWS::IoT::Certificate", + "Properties": { + "CertificateId": { + "Ref": "AWS::IoT::Certificate::Id" + }, + "Status": "Active" + }, + "OverrideSettings": { + "Status": "REPLACE" + } + }, + "policy": { + "Type": "AWS::IoT::Policy", + "Properties": { + "PolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Effect": "Allow", + "Action": [ + "iot:Connect", + "iot:Subscribe", + "iot:Publish", + "iot:Receive" + ], + "Resource": "*" + } + ] + } + } + } + }, + "DeviceConfiguration": { + "FallbackUrl": "https://www.example.com/test-site", + "LocationUrl": { + "Fn::FindInMap": [ + "LocationTable", + { + "Ref": "DeviceLocation" + }, + "LocationUrl" + ] + } + } +} ``` +
+ If you use a different body, you may need to pass in different template parameters. #### Running the sample and provisioning using a certificate-key set from a provisioning claim @@ -811,7 +917,7 @@ Provide the necessary arguments along with the destination access token and star ``` sh ./secure_tunnel --endpoint --ca_file --cert --key ---thing_name --region --access_token_file +--thing_name --region --access_token_file ``` Provide the necessary arguments along with the source access token and start a second sample in source mode by using the flag --localProxyModeSource. @@ -819,7 +925,7 @@ Provide the necessary arguments along with the source access token and start a s ``` sh ./secure_tunnel --endpoint --ca_file --cert --key ---thing_name --region --access_token_file +--thing_name --region --access_token_file --localProxyModeSource ``` @@ -898,7 +1004,7 @@ Your Thing's [Policy](https://docs.aws.amazon.com/iot/latest/developerguide/iot- { "Effect": "Allow", "Action": "iot:Connect", - "Resource": "arn:aws:iot:region:account:client/*" + "Resource": "arn:aws:iot:region:account:client-*" } ] } @@ -935,7 +1041,8 @@ Your Thing's [Policy](https://docs.aws.amazon.com/iot/latest/developerguide/iot- ], "Resource": [ "arn:aws:iot:region:account:topic/test/shared_topic", - "arn:aws:iot:region:account:topic/test-client-*" + "arn:aws:iot:region:account:topic/test-*", + "arn:aws:iot:region:account:topic/topic1" ] }, { @@ -946,7 +1053,8 @@ Your Thing's [Policy](https://docs.aws.amazon.com/iot/latest/developerguide/iot- ], "Resource": [ "arn:aws:iot:region:account:topicfilter/test/shared_topic", - "arn:aws:iot:region:account:topic/test-client-*" + "arn:aws:iot:region:account:topicfilter/test-*", + "arn:aws:iot:region:account:topicfilter/topic1" ] }, { @@ -955,7 +1063,7 @@ Your Thing's [Policy](https://docs.aws.amazon.com/iot/latest/developerguide/iot- "iot:Connect" ], "Resource": [ - "arn:aws:iot:region:account:client/test-client-*" + "arn:aws:iot:region:account:client/test-*" ] } ] From 09a7eb538d9684d49fd36efc0704d06fda702db4 Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Tue, 27 Sep 2022 11:23:02 -0400 Subject: [PATCH 10/50] Initial test for Linux Smoke tests in CI --- .github/workflows/ci.yml | 84 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 83 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 298103e29..8eecacff3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -220,7 +220,7 @@ jobs: cd D:\a\work python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz', 'builder.pyz')" python builder.pyz build -p ${{ env.PACKAGE_NAME }} --cmake-extra=-DUSE_CPU_EXTENSIONS=OFF - - name: configure AWS credentials (PubSub) + - name: configure AWS credentials (CyclePubSub) uses: aws-actions/configure-aws-credentials@v1 with: role-to-assume: ${{ env.CI_CYCLEPUBSUB_ROLE }} @@ -261,6 +261,88 @@ jobs: cd ./aws-iot-device-sdk-cpp-v2 python3 ./deviceadvisor/script/DATestRun.py + # Runs the samples and ensures that everything is working + linux-smoke-tests: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + version: + - 17 + permissions: + id-token: write # This is required for requesting the JWT + steps: + - name: Checkout Sources + uses: actions/checkout@v2 + - name: Setup C++ + run: | + sudo apt install build-essential + sudo apt install cmake + gcc --version + - name: Build ${{ env.PACKAGE_NAME }} + consumers + run: | + python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder.pyz')" + python builder.pyz build -p ${{ env.PACKAGE_NAME }} + - name: configure AWS credentials (Connect and PubSub) + uses: aws-actions/configure-aws-credentials@v1 + with: + role-to-assume: ${{ env.CI_PUBSUB_ROLE }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: run Basic Connect sample + run: | + python3 -m pip install boto3 + python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/mqtt/basic_connect/basic-connect' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' + - name: run Websocket Connect sample + run: | + python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/mqtt/websocket_connect/websocket-connect' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_arguments '--signing_region us-east-1' + - name: run PubSub sample + run: | + python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/pub_sub/basic_pub_sub/basic-pub-sub' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' + - name: run PKCS11 Connect sample + run: | + sudo apt-get update -y + sudo apt-get install softhsm -y + softhsm2-util --version + mkdir -p /tmp/tokens + export SOFTHSM2_CONF=/tmp/softhsm2.conf + echo "directories.tokendir = /tmp/tokens" > /tmp/softhsm2.conf + python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/mqtt/pkcs11_connect/pkcs11-connect' --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"' + - name: configure AWS credentials (Custom Authorizer) + uses: aws-actions/configure-aws-credentials@v1 + with: + role-to-assume: ${{ env.CI_CUSTOM_AUTHORIZER_ROLE }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: run CustomAuthorizerConnect sample + run: | + python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/mqtt/custom_authorizer_connect/custom-authorizer-connect' --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' + # - name: configure AWS credentials (Shadow) + # uses: aws-actions/configure-aws-credentials@v1 + # with: + # role-to-assume: ${{ env.CI_SHADOW_ROLE }} + # aws-region: ${{ env.AWS_DEFAULT_REGION }} + # - name: run Shadow sample + # run: | + # python3 ./utils/run_sample_ci.py --language Java --sample_file 'samples/Shadow' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/Shadow/cert' --sample_secret_private_key 'ci/Shadow/key' --sample_arguments '--thing_name CI_Shadow_Thing' --sample_main_class 'shadow.ShadowSample' + # - name: configure AWS credentials (Jobs) + # uses: aws-actions/configure-aws-credentials@v1 + # with: + # role-to-assume: ${{ env.CI_JOBS_ROLE }} + # aws-region: ${{ env.AWS_DEFAULT_REGION }} + # - name: run Jobs sample + # run: | + # python3 ./utils/run_sample_ci.py --language Java --sample_file 'samples/Jobs' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/Jobs/cert' --sample_secret_private_key 'ci/Jobs/key' --sample_arguments '--thing_name CI_Jobs_Thing' --sample_main_class 'jobs.JobsSample' + # - name: configure AWS credentials (Fleet provisioning) + # uses: aws-actions/configure-aws-credentials@v1 + # with: + # role-to-assume: ${{ env.CI_FLEET_PROVISIONING_ROLE }} + # aws-region: ${{ env.AWS_DEFAULT_REGION }} + # - name: run Fleet Provisioning sample + # run: | + # echo "Generating UUID for IoT thing" + # Sample_UUID=$(python3 -c "import uuid; print (uuid.uuid4())") + # python3 ./utils/run_sample_ci.py --language Java --sample_file 'samples/Identity' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/FleetProvisioning/cert' --sample_secret_private_key 'ci/FleetProvisioning/key' --sample_arguments "--template_name CI_FleetProvisioning_Template --template_parameters '{SerialNumber:${Sample_UUID}}'" --sample_main_class 'identity.FleetProvisioningSample' + # python3 utils/delete_iot_thing_ci.py --thing_name "Fleet_Thing_${Sample_UUID}" --region "us-east-1" + # check that docs can still build check-docs: runs-on: ubuntu-20.04 # latest From 03eb77c4ad665abc76dfccafa1eaf8245e2e6b92 Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Tue, 27 Sep 2022 11:27:40 -0400 Subject: [PATCH 11/50] Update submodules before building to see if that fixes the issue --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8eecacff3..33de4845a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -279,6 +279,9 @@ jobs: sudo apt install build-essential sudo apt install cmake gcc --version + cd ./aws-iot-device-sdk-cpp-v2 + git submodule update --init --recursive + cd .. - name: Build ${{ env.PACKAGE_NAME }} + consumers run: | python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder.pyz')" From d263016129e1b14c5605f255608bde32c8334043 Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Tue, 27 Sep 2022 11:39:21 -0400 Subject: [PATCH 12/50] Download source to hopefully fix builder issue --- .github/workflows/ci.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 33de4845a..da1641998 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,7 +38,6 @@ jobs: - al2-x64 permissions: id-token: write # This is required for requesting the JWT - steps: - name: configure AWS credentials (containers) uses: aws-actions/configure-aws-credentials@v1 @@ -276,16 +275,17 @@ jobs: uses: actions/checkout@v2 - name: Setup C++ run: | - sudo apt install build-essential + sudo apt-get -qq update -y + sudo apt-get -qq install -y build-essential sudo apt install cmake gcc --version - cd ./aws-iot-device-sdk-cpp-v2 - git submodule update --init --recursive - cd .. - name: Build ${{ env.PACKAGE_NAME }} + consumers run: | - python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder.pyz')" - python builder.pyz build -p ${{ env.PACKAGE_NAME }} + echo "Downloading source" + git clone --recursive https://github.com/aws/aws-iot-device-sdk-cpp-v2.git --branch ${{ github.head_ref || github.ref_name }} + echo "Running builder" + 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 + ./linux-container-ci.sh ${{ env.BUILDER_VERSION }} aws-crt-${{ matrix.image }} build -p ${{ env.PACKAGE_NAME }} - name: configure AWS credentials (Connect and PubSub) uses: aws-actions/configure-aws-credentials@v1 with: From 79960e06c5e01dd469be30ebd263986ac63d6c2b Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Tue, 27 Sep 2022 11:42:51 -0400 Subject: [PATCH 13/50] Use Python builder --- .github/workflows/ci.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index da1641998..c4ca7e4bc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -265,9 +265,6 @@ jobs: runs-on: ubuntu-latest strategy: fail-fast: false - matrix: - version: - - 17 permissions: id-token: write # This is required for requesting the JWT steps: @@ -284,8 +281,8 @@ jobs: echo "Downloading source" git clone --recursive https://github.com/aws/aws-iot-device-sdk-cpp-v2.git --branch ${{ github.head_ref || github.ref_name }} echo "Running builder" - 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 - ./linux-container-ci.sh ${{ env.BUILDER_VERSION }} aws-crt-${{ matrix.image }} build -p ${{ env.PACKAGE_NAME }} + python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder.pyz')" + python builder.pyz build -p ${{ env.PACKAGE_NAME }} --cmake-extra=-Tv140 --cmake-extra=-A${{ matrix.arch }} - name: configure AWS credentials (Connect and PubSub) uses: aws-actions/configure-aws-credentials@v1 with: From d34df5599a8fce8b317fcc34ff9e8d64551f7b5a Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Tue, 27 Sep 2022 11:46:47 -0400 Subject: [PATCH 14/50] Fix not passing parameter to CMAKE --- .github/workflows/ci.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c4ca7e4bc..1afaa9e45 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -268,21 +268,20 @@ jobs: permissions: id-token: write # This is required for requesting the JWT steps: - - name: Checkout Sources - uses: actions/checkout@v2 - name: Setup C++ run: | sudo apt-get -qq update -y sudo apt-get -qq install -y build-essential sudo apt install cmake gcc --version + cmake --version - name: Build ${{ env.PACKAGE_NAME }} + consumers run: | echo "Downloading source" git clone --recursive https://github.com/aws/aws-iot-device-sdk-cpp-v2.git --branch ${{ github.head_ref || github.ref_name }} echo "Running builder" python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder.pyz')" - python builder.pyz build -p ${{ env.PACKAGE_NAME }} --cmake-extra=-Tv140 --cmake-extra=-A${{ matrix.arch }} + python builder.pyz build -p ${{ env.PACKAGE_NAME }} - name: configure AWS credentials (Connect and PubSub) uses: aws-actions/configure-aws-credentials@v1 with: From 1cdee5603c735dbcaaf0ebd4a0c587ab1a56f4a1 Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Tue, 27 Sep 2022 12:05:31 -0400 Subject: [PATCH 15/50] Disable PKCS11 for now, run Device Advisor on Linux --- .github/workflows/ci.yml | 63 ++++++++++++++++++++++++++++++++++------ 1 file changed, 54 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1afaa9e45..ef505eb54 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -260,6 +260,48 @@ jobs: cd ./aws-iot-device-sdk-cpp-v2 python3 ./deviceadvisor/script/DATestRun.py + # Not strictly needed, but allows us to run Device Advisor and PubSub on Linux without needing to run all samples + linux-github-actions: + runs-on: ubuntu-latest + strategy: + fail-fast: false + permissions: + id-token: write # This is required for requesting the JWT + steps: + - name: Setup C++ + run: | + sudo apt-get -qq update -y + sudo apt-get -qq install -y build-essential + sudo apt install cmake + gcc --version + cmake --version + - name: Build ${{ env.PACKAGE_NAME }} + consumers + run: | + echo "Downloading source" + git clone --recursive https://github.com/aws/aws-iot-device-sdk-cpp-v2.git --branch ${{ github.head_ref || github.ref_name }} + echo "Running builder" + python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder.pyz')" + python builder.pyz build -p ${{ env.PACKAGE_NAME }} + - name: configure AWS credentials (PubSub) + uses: aws-actions/configure-aws-credentials@v1 + with: + role-to-assume: ${{ env.CI_PUBSUB_ROLE }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: run PubSub sample + run: | + python3 -m pip install boto3 + python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/pub_sub/basic_pub_sub/basic-pub-sub' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' + - name: configure AWS credentials (Device Advisor) + uses: aws-actions/configure-aws-credentials@v1 + with: + role-to-assume: ${{ env.CI_DEVICE_ADVISOR }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: run DeviceAdvisor + run: | + cd ./aws-iot-device-sdk-cpp-v2 + python3 ./deviceadvisor/script/DATestRun.py + # TODO - add Defender Defender! + # Runs the samples and ensures that everything is working linux-smoke-tests: runs-on: ubuntu-latest @@ -297,15 +339,16 @@ jobs: - name: run PubSub sample run: | python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/pub_sub/basic_pub_sub/basic-pub-sub' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' - - name: run PKCS11 Connect sample - run: | - sudo apt-get update -y - sudo apt-get install softhsm -y - softhsm2-util --version - mkdir -p /tmp/tokens - export SOFTHSM2_CONF=/tmp/softhsm2.conf - echo "directories.tokendir = /tmp/tokens" > /tmp/softhsm2.conf - python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/mqtt/pkcs11_connect/pkcs11-connect' --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"' + # TODO: Fix and run PKCS11! Currently has issue loading PKCS11 library + # - name: run PKCS11 Connect sample + # run: | + # sudo apt-get update -y + # sudo apt-get install softhsm -y + # softhsm2-util --version + # mkdir -p /tmp/tokens + # export SOFTHSM2_CONF=/tmp/softhsm2.conf + # echo "directories.tokendir = /tmp/tokens" > /tmp/softhsm2.conf + # python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/mqtt/pkcs11_connect/pkcs11-connect' --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"' - name: configure AWS credentials (Custom Authorizer) uses: aws-actions/configure-aws-credentials@v1 with: @@ -314,6 +357,7 @@ jobs: - name: run CustomAuthorizerConnect sample run: | python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/mqtt/custom_authorizer_connect/custom-authorizer-connect' --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' + # TODO: Add Shadows, Jobs, and Fleet Provisioning # - name: configure AWS credentials (Shadow) # uses: aws-actions/configure-aws-credentials@v1 # with: @@ -341,6 +385,7 @@ jobs: # Sample_UUID=$(python3 -c "import uuid; print (uuid.uuid4())") # python3 ./utils/run_sample_ci.py --language Java --sample_file 'samples/Identity' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/FleetProvisioning/cert' --sample_secret_private_key 'ci/FleetProvisioning/key' --sample_arguments "--template_name CI_FleetProvisioning_Template --template_parameters '{SerialNumber:${Sample_UUID}}'" --sample_main_class 'identity.FleetProvisioningSample' # python3 utils/delete_iot_thing_ci.py --thing_name "Fleet_Thing_${Sample_UUID}" --region "us-east-1" + # TODO: Add SecureTunneling # check that docs can still build check-docs: From 8df52c285aedb532615205838f114a23c70cb53d Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Tue, 27 Sep 2022 12:58:25 -0400 Subject: [PATCH 16/50] Add Shadow, Jobs, and Fleet Provisioning to CI run for Linux Smoke Tests --- .github/workflows/ci.yml | 55 ++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ef505eb54..a086d747a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -357,34 +357,33 @@ jobs: - name: run CustomAuthorizerConnect sample run: | python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/mqtt/custom_authorizer_connect/custom-authorizer-connect' --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' - # TODO: Add Shadows, Jobs, and Fleet Provisioning - # - name: configure AWS credentials (Shadow) - # uses: aws-actions/configure-aws-credentials@v1 - # with: - # role-to-assume: ${{ env.CI_SHADOW_ROLE }} - # aws-region: ${{ env.AWS_DEFAULT_REGION }} - # - name: run Shadow sample - # run: | - # python3 ./utils/run_sample_ci.py --language Java --sample_file 'samples/Shadow' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/Shadow/cert' --sample_secret_private_key 'ci/Shadow/key' --sample_arguments '--thing_name CI_Shadow_Thing' --sample_main_class 'shadow.ShadowSample' - # - name: configure AWS credentials (Jobs) - # uses: aws-actions/configure-aws-credentials@v1 - # with: - # role-to-assume: ${{ env.CI_JOBS_ROLE }} - # aws-region: ${{ env.AWS_DEFAULT_REGION }} - # - name: run Jobs sample - # run: | - # python3 ./utils/run_sample_ci.py --language Java --sample_file 'samples/Jobs' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/Jobs/cert' --sample_secret_private_key 'ci/Jobs/key' --sample_arguments '--thing_name CI_Jobs_Thing' --sample_main_class 'jobs.JobsSample' - # - name: configure AWS credentials (Fleet provisioning) - # uses: aws-actions/configure-aws-credentials@v1 - # with: - # role-to-assume: ${{ env.CI_FLEET_PROVISIONING_ROLE }} - # aws-region: ${{ env.AWS_DEFAULT_REGION }} - # - name: run Fleet Provisioning sample - # run: | - # echo "Generating UUID for IoT thing" - # Sample_UUID=$(python3 -c "import uuid; print (uuid.uuid4())") - # python3 ./utils/run_sample_ci.py --language Java --sample_file 'samples/Identity' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/FleetProvisioning/cert' --sample_secret_private_key 'ci/FleetProvisioning/key' --sample_arguments "--template_name CI_FleetProvisioning_Template --template_parameters '{SerialNumber:${Sample_UUID}}'" --sample_main_class 'identity.FleetProvisioningSample' - # python3 utils/delete_iot_thing_ci.py --thing_name "Fleet_Thing_${Sample_UUID}" --region "us-east-1" + - name: configure AWS credentials (Shadow) + uses: aws-actions/configure-aws-credentials@v1 + with: + role-to-assume: ${{ env.CI_SHADOW_ROLE }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: run Shadow sample + run: | + python3 ./utils/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/shadow/shadow_sync/shadow-sync' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/Shadow/cert' --sample_secret_private_key 'ci/Shadow/key' --sample_arguments '--thing_name CI_Shadow_Thing --is_ci true' + - name: configure AWS credentials (Jobs) + uses: aws-actions/configure-aws-credentials@v1 + with: + role-to-assume: ${{ env.CI_JOBS_ROLE }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: run Jobs sample + run: | + python3 ./utils/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/jobs/describe_job_execution/describe-job-execution' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/Jobs/cert' --sample_secret_private_key 'ci/Jobs/key' --sample_arguments '--thing_name CI_Jobs_Thing --job_id CI_Jobs_Thing_Job_1' + - name: configure AWS credentials (Fleet provisioning) + uses: aws-actions/configure-aws-credentials@v1 + with: + role-to-assume: ${{ env.CI_FLEET_PROVISIONING_ROLE }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: run Fleet Provisioning sample + run: | + echo "Generating UUID for IoT thing" + Sample_UUID=$(python3 -c "import uuid; print (uuid.uuid4())") + python3 ./utils/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/identity/fleet_provisioning/fleet-provisioning' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/FleetProvisioning/cert' --sample_secret_private_key 'ci/FleetProvisioning/key' --sample_arguments "--template_name CI_FleetProvisioning_Template --template_parameters '{SerialNumber:${Sample_UUID}}'" + python3 utils/delete_iot_thing_ci.py --thing_name "Fleet_Thing_${Sample_UUID}" --region "us-east-1" # TODO: Add SecureTunneling # check that docs can still build From 30bdc353703bafe73e6ad81d06c0b73854b19d92 Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Tue, 27 Sep 2022 13:30:17 -0400 Subject: [PATCH 17/50] Added DeviceDefender to CI, fixed Shadows, Jobs, and Fleet provisioning using wrong path in CI --- .github/workflows/ci.yml | 19 ++++++++++++++----- devicedefender/script/DDTestRun.py | 7 ++----- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a086d747a..f0fcfc54b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,6 +26,7 @@ env: CI_JOBS_ROLE: ${{ secrets.AWS_CI_JOBS_ROLE }} CI_FLEET_PROVISIONING_ROLE: ${{ secrets.AWS_CI_FLEET_PROVISIONING_ROLE }} CI_DEVICE_ADVISOR: ${{ secrets.AWS_CI_DEVICE_ADVISOR_ROLE }} + CI_DEVICE_DEFENDER: ${{ secrets.AWS_CI_DEVICE_DEFENDER_ROLE }} jobs: linux-compat: @@ -300,7 +301,15 @@ jobs: run: | cd ./aws-iot-device-sdk-cpp-v2 python3 ./deviceadvisor/script/DATestRun.py - # TODO - add Defender Defender! + - name: configure AWS credentials (Device Defender) + uses: aws-actions/configure-aws-credentials@v1 + with: + role-to-assume: ${{ env.CI_DEVICE_DEFENDER }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: run DeviceDefemder + run: | + cd ./aws-iot-device-sdk-cpp-v2 + python3 ./devicedefender/script/DDTestRun.py # Runs the samples and ensures that everything is working linux-smoke-tests: @@ -364,7 +373,7 @@ jobs: aws-region: ${{ env.AWS_DEFAULT_REGION }} - name: run Shadow sample run: | - python3 ./utils/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/shadow/shadow_sync/shadow-sync' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/Shadow/cert' --sample_secret_private_key 'ci/Shadow/key' --sample_arguments '--thing_name CI_Shadow_Thing --is_ci true' + python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/shadow/shadow_sync/shadow-sync' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/Shadow/cert' --sample_secret_private_key 'ci/Shadow/key' --sample_arguments '--thing_name CI_Shadow_Thing --is_ci true' - name: configure AWS credentials (Jobs) uses: aws-actions/configure-aws-credentials@v1 with: @@ -372,7 +381,7 @@ jobs: aws-region: ${{ env.AWS_DEFAULT_REGION }} - name: run Jobs sample run: | - python3 ./utils/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/jobs/describe_job_execution/describe-job-execution' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/Jobs/cert' --sample_secret_private_key 'ci/Jobs/key' --sample_arguments '--thing_name CI_Jobs_Thing --job_id CI_Jobs_Thing_Job_1' + python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/jobs/describe_job_execution/describe-job-execution' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/Jobs/cert' --sample_secret_private_key 'ci/Jobs/key' --sample_arguments '--thing_name CI_Jobs_Thing --job_id CI_Jobs_Thing_Job_1' - name: configure AWS credentials (Fleet provisioning) uses: aws-actions/configure-aws-credentials@v1 with: @@ -382,8 +391,8 @@ jobs: run: | echo "Generating UUID for IoT thing" Sample_UUID=$(python3 -c "import uuid; print (uuid.uuid4())") - python3 ./utils/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/identity/fleet_provisioning/fleet-provisioning' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/FleetProvisioning/cert' --sample_secret_private_key 'ci/FleetProvisioning/key' --sample_arguments "--template_name CI_FleetProvisioning_Template --template_parameters '{SerialNumber:${Sample_UUID}}'" - python3 utils/delete_iot_thing_ci.py --thing_name "Fleet_Thing_${Sample_UUID}" --region "us-east-1" + python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/identity/fleet_provisioning/fleet-provisioning' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/FleetProvisioning/cert' --sample_secret_private_key 'ci/FleetProvisioning/key' --sample_arguments "--template_name CI_FleetProvisioning_Template --template_parameters '{SerialNumber:${Sample_UUID}}'" + python3 ./aws-iot-device-sdk-cpp-v2/utils/delete_iot_thing_ci.py --thing_name "Fleet_Thing_${Sample_UUID}" --region "us-east-1" # TODO: Add SecureTunneling # check that docs can still build diff --git a/devicedefender/script/DDTestRun.py b/devicedefender/script/DDTestRun.py index 685c5a9ca..0ff997dfa 100644 --- a/devicedefender/script/DDTestRun.py +++ b/devicedefender/script/DDTestRun.py @@ -1,10 +1,8 @@ - import boto3 import uuid import os import subprocess import platform -from time import sleep # On something other than Linux? Pass the test instantly since Device Defender is only supported on Linux if platform.system() != "Linux": @@ -54,7 +52,6 @@ def delete_thing_with_certi(thingName, certiId, certiArn): create_thing_response = client.create_thing( thingName=thing_name ) - #print(create_thing_response) thing_arn = create_thing_response["thingArn"] client_made_thing = True @@ -170,10 +167,10 @@ def delete_thing_with_certi(thingName, certiId, certiArn): delete_thing_with_certi(thing_name, certificate_id, certificate_arn) else: client.delete_thing(thingName=thing_name) - + if client_made_policy: client.delete_policy(policyName=thing_name + "_policy") - + print("[Device Defender]Error: Failed to attach certificate.") exit(-1) From 3581ce2ec7d1dfb638c2f83fdd6164457091a198 Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Tue, 27 Sep 2022 13:52:35 -0400 Subject: [PATCH 18/50] Fix shadow sample not running and DeviceDefender failing --- .github/workflows/ci.yml | 2 +- devicedefender/script/DDTestRun.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f0fcfc54b..c03e471fb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -373,7 +373,7 @@ jobs: aws-region: ${{ env.AWS_DEFAULT_REGION }} - name: run Shadow sample run: | - python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/shadow/shadow_sync/shadow-sync' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/Shadow/cert' --sample_secret_private_key 'ci/Shadow/key' --sample_arguments '--thing_name CI_Shadow_Thing --is_ci true' + python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/shadow/shadow_sync/shadow-sync' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/Shadow/cert' --sample_secret_private_key 'ci/Shadow/key' --sample_arguments '--thing_name CI_Shadow_Thing --shadow_property color --is_ci true' - name: configure AWS credentials (Jobs) uses: aws-actions/configure-aws-credentials@v1 with: diff --git a/devicedefender/script/DDTestRun.py b/devicedefender/script/DDTestRun.py index 0ff997dfa..601cd88a1 100644 --- a/devicedefender/script/DDTestRun.py +++ b/devicedefender/script/DDTestRun.py @@ -144,6 +144,8 @@ def delete_thing_with_certi(thingName, certiId, certiArn): ############################################## # attach certification to thing +certificate_id = None +certificate_arn = None try: print("[Device Defender]Info: Attach policy to certificate...") # attach policy to thing From d63f8faaf49c6ae3ecc677bd78368f2b62c791af Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Tue, 27 Sep 2022 14:11:17 -0400 Subject: [PATCH 19/50] Add number to shadow payload --- samples/shadow/shadow_sync/main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/samples/shadow/shadow_sync/main.cpp b/samples/shadow/shadow_sync/main.cpp index 83737160d..14096628c 100644 --- a/samples/shadow/shadow_sync/main.cpp +++ b/samples/shadow/shadow_sync/main.cpp @@ -455,7 +455,8 @@ int main(int argc, char *argv[]) int messagesSent = 0; while (messagesSent < 5) { - String input = "Shadow_Value_CPP"; + String input = "Shadow_Value_"; + input.append(std::to_string(messagesSent).c_str()); s_changeShadowValue(shadowClient, thingName, shadowProperty, input); /* Sleep so there is a gap between shadow updates */ std::this_thread::sleep_for(std::chrono::milliseconds(1000)); From 1dd959e5102b9d1d56267ddef57cab578724c0f9 Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Tue, 27 Sep 2022 15:23:46 -0400 Subject: [PATCH 20/50] Add print statements around setting promises to see where the double set is coming from --- samples/shadow/shadow_sync/main.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/samples/shadow/shadow_sync/main.cpp b/samples/shadow/shadow_sync/main.cpp index 14096628c..3776f2cfd 100644 --- a/samples/shadow/shadow_sync/main.cpp +++ b/samples/shadow/shadow_sync/main.cpp @@ -131,11 +131,13 @@ int main(int argc, char *argv[]) if (errorCode) { fprintf(stdout, "Connection failed with error %s\n", ErrorDebugString(errorCode)); + fprintf(stdout, "\n About to set connectionCompletedPromise to false \n"); connectionCompletedPromise.set_value(false); } else { fprintf(stdout, "Connection completed with return code %d\n", returnCode); + fprintf(stdout, "\n About to set connectionCompletedPromise to true \n"); connectionCompletedPromise.set_value(true); } }; @@ -146,6 +148,7 @@ int main(int argc, char *argv[]) auto onDisconnect = [&](Mqtt::MqttConnection & /*conn*/) { { fprintf(stdout, "Disconnect completed\n"); + fprintf(stdout, "\n About to set connectionCompletedPromise to true \n"); connectionCompletedPromise.set_value(true); } }; @@ -181,6 +184,7 @@ int main(int argc, char *argv[]) fprintf(stderr, "Error subscribing to shadow delta: %s\n", ErrorDebugString(ioErr)); exit(-1); } + fprintf(stdout, "\n About to set subscribeDeltaCompletedPromise \n"); subscribeDeltaCompletedPromise.set_value(); }; @@ -190,6 +194,7 @@ int main(int argc, char *argv[]) fprintf(stderr, "Error subscribing to shadow delta accepted: %s\n", ErrorDebugString(ioErr)); exit(-1); } + fprintf(stdout, "\n About to set subscribeDeltaAcceptedCompletedPromise \n"); subscribeDeltaAcceptedCompletedPromise.set_value(); }; @@ -199,6 +204,7 @@ int main(int argc, char *argv[]) fprintf(stderr, "Error subscribing to shadow delta rejected: %s\n", ErrorDebugString(ioErr)); exit(-1); } + fprintf(stdout, "\n About to set subscribeDeltaRejectedCompletedPromise \n"); subscribeDeltaRejectedCompletedPromise.set_value(); }; @@ -321,6 +327,7 @@ int main(int argc, char *argv[]) fprintf(stderr, "Error subscribing to get shadow document accepted: %s\n", ErrorDebugString(ioErr)); exit(-1); } + fprintf(stdout, "\n About to set subscribeGetShadowAcceptedCompletedPromise \n"); subscribeGetShadowAcceptedCompletedPromise.set_value(); }; @@ -330,6 +337,7 @@ int main(int argc, char *argv[]) fprintf(stderr, "Error subscribing to get shadow document rejected: %s\n", ErrorDebugString(ioErr)); exit(-1); } + fprintf(stdout, "\n About to set subscribeGetShadowRejectedCompletedPromise \n"); subscribeGetShadowRejectedCompletedPromise.set_value(); }; @@ -339,6 +347,7 @@ int main(int argc, char *argv[]) fprintf(stderr, "Error getting shadow document: %s\n", ErrorDebugString(ioErr)); exit(-1); } + fprintf(stdout, "\n About to set onGetShadowRequestCompletedPromise \n"); onGetShadowRequestCompletedPromise.set_value(); }; @@ -374,6 +383,7 @@ int main(int argc, char *argv[]) fprintf(stdout, "Shadow currently does not contain \"%s\".\n", shadowProperty.c_str()); currentShadowValue = ""; } + fprintf(stdout, "\n About to set gotInitialShadowPromise \n"); gotInitialShadowPromise.set_value(); } }; From e7cde692e434fac5ff4beac912175a983c0df4d0 Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Tue, 27 Sep 2022 15:44:26 -0400 Subject: [PATCH 21/50] Adjust shadow sample to use correct promise for disconnecting --- samples/shadow/shadow_sync/main.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/samples/shadow/shadow_sync/main.cpp b/samples/shadow/shadow_sync/main.cpp index 3776f2cfd..1212f9e27 100644 --- a/samples/shadow/shadow_sync/main.cpp +++ b/samples/shadow/shadow_sync/main.cpp @@ -148,8 +148,8 @@ int main(int argc, char *argv[]) auto onDisconnect = [&](Mqtt::MqttConnection & /*conn*/) { { fprintf(stdout, "Disconnect completed\n"); - fprintf(stdout, "\n About to set connectionCompletedPromise to true \n"); - connectionCompletedPromise.set_value(true); + fprintf(stdout, "\n About to set connectionClosedPromise to true \n"); + connectionClosedPromise.set_value(); } }; @@ -399,6 +399,7 @@ int main(int argc, char *argv[]) "Getting shadow document failed with message %s and code %d.\n", error->Message->c_str(), *error->Code); + fprintf(stdout, "\n About to set gotInitialShadowPromise \n"); gotInitialShadowPromise.set_value(); }; From 092fa26a94cf66ac406e3970c2c58765011435d4 Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Tue, 27 Sep 2022 16:10:30 -0400 Subject: [PATCH 22/50] Remove debug prints on Shadow, do not stop Windows CI in progress so Device Advisor can clean up correctly, and hopefully fix Fleet-Provisioning CI --- .github/workflows/ci.yml | 3 ++- samples/shadow/shadow_sync/main.cpp | 10 ---------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c03e471fb..56a4c4e9e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -149,6 +149,7 @@ jobs: strategy: matrix: arch: [Win32, x64] + fail-fast: false permissions: id-token: write # This is required for requesting the JWT steps: @@ -391,7 +392,7 @@ jobs: run: | echo "Generating UUID for IoT thing" Sample_UUID=$(python3 -c "import uuid; print (uuid.uuid4())") - python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/identity/fleet_provisioning/fleet-provisioning' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/FleetProvisioning/cert' --sample_secret_private_key 'ci/FleetProvisioning/key' --sample_arguments "--template_name CI_FleetProvisioning_Template --template_parameters '{SerialNumber:${Sample_UUID}}'" + python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/identity/fleet_provisioning/fleet-provisioning' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/FleetProvisioning/cert' --sample_secret_private_key 'ci/FleetProvisioning/key' --sample_arguments "--template_name CI_FleetProvisioning_Template --template_parameters '{SerialNumber:${{ Sample_UUID }} }'" python3 ./aws-iot-device-sdk-cpp-v2/utils/delete_iot_thing_ci.py --thing_name "Fleet_Thing_${Sample_UUID}" --region "us-east-1" # TODO: Add SecureTunneling diff --git a/samples/shadow/shadow_sync/main.cpp b/samples/shadow/shadow_sync/main.cpp index 1212f9e27..968ecea2a 100644 --- a/samples/shadow/shadow_sync/main.cpp +++ b/samples/shadow/shadow_sync/main.cpp @@ -131,13 +131,11 @@ int main(int argc, char *argv[]) if (errorCode) { fprintf(stdout, "Connection failed with error %s\n", ErrorDebugString(errorCode)); - fprintf(stdout, "\n About to set connectionCompletedPromise to false \n"); connectionCompletedPromise.set_value(false); } else { fprintf(stdout, "Connection completed with return code %d\n", returnCode); - fprintf(stdout, "\n About to set connectionCompletedPromise to true \n"); connectionCompletedPromise.set_value(true); } }; @@ -148,7 +146,6 @@ int main(int argc, char *argv[]) auto onDisconnect = [&](Mqtt::MqttConnection & /*conn*/) { { fprintf(stdout, "Disconnect completed\n"); - fprintf(stdout, "\n About to set connectionClosedPromise to true \n"); connectionClosedPromise.set_value(); } }; @@ -184,7 +181,6 @@ int main(int argc, char *argv[]) fprintf(stderr, "Error subscribing to shadow delta: %s\n", ErrorDebugString(ioErr)); exit(-1); } - fprintf(stdout, "\n About to set subscribeDeltaCompletedPromise \n"); subscribeDeltaCompletedPromise.set_value(); }; @@ -194,7 +190,6 @@ int main(int argc, char *argv[]) fprintf(stderr, "Error subscribing to shadow delta accepted: %s\n", ErrorDebugString(ioErr)); exit(-1); } - fprintf(stdout, "\n About to set subscribeDeltaAcceptedCompletedPromise \n"); subscribeDeltaAcceptedCompletedPromise.set_value(); }; @@ -204,7 +199,6 @@ int main(int argc, char *argv[]) fprintf(stderr, "Error subscribing to shadow delta rejected: %s\n", ErrorDebugString(ioErr)); exit(-1); } - fprintf(stdout, "\n About to set subscribeDeltaRejectedCompletedPromise \n"); subscribeDeltaRejectedCompletedPromise.set_value(); }; @@ -337,7 +331,6 @@ int main(int argc, char *argv[]) fprintf(stderr, "Error subscribing to get shadow document rejected: %s\n", ErrorDebugString(ioErr)); exit(-1); } - fprintf(stdout, "\n About to set subscribeGetShadowRejectedCompletedPromise \n"); subscribeGetShadowRejectedCompletedPromise.set_value(); }; @@ -347,7 +340,6 @@ int main(int argc, char *argv[]) fprintf(stderr, "Error getting shadow document: %s\n", ErrorDebugString(ioErr)); exit(-1); } - fprintf(stdout, "\n About to set onGetShadowRequestCompletedPromise \n"); onGetShadowRequestCompletedPromise.set_value(); }; @@ -383,7 +375,6 @@ int main(int argc, char *argv[]) fprintf(stdout, "Shadow currently does not contain \"%s\".\n", shadowProperty.c_str()); currentShadowValue = ""; } - fprintf(stdout, "\n About to set gotInitialShadowPromise \n"); gotInitialShadowPromise.set_value(); } }; @@ -399,7 +390,6 @@ int main(int argc, char *argv[]) "Getting shadow document failed with message %s and code %d.\n", error->Message->c_str(), *error->Code); - fprintf(stdout, "\n About to set gotInitialShadowPromise \n"); gotInitialShadowPromise.set_value(); }; From 693598054904033ef3267c752d9684158dab01ae Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Tue, 27 Sep 2022 16:15:01 -0400 Subject: [PATCH 23/50] Fix inserting UUID --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 56a4c4e9e..a7997f68d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -392,7 +392,7 @@ jobs: run: | echo "Generating UUID for IoT thing" Sample_UUID=$(python3 -c "import uuid; print (uuid.uuid4())") - python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/identity/fleet_provisioning/fleet-provisioning' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/FleetProvisioning/cert' --sample_secret_private_key 'ci/FleetProvisioning/key' --sample_arguments "--template_name CI_FleetProvisioning_Template --template_parameters '{SerialNumber:${{ Sample_UUID }} }'" + python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/identity/fleet_provisioning/fleet-provisioning' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/FleetProvisioning/cert' --sample_secret_private_key 'ci/FleetProvisioning/key' --sample_arguments "--template_name CI_FleetProvisioning_Template --template_parameters '{SerialNumber:${Sample_UUID} }'" python3 ./aws-iot-device-sdk-cpp-v2/utils/delete_iot_thing_ci.py --thing_name "Fleet_Thing_${Sample_UUID}" --region "us-east-1" # TODO: Add SecureTunneling From 5d5e237329cb7acaa4f602d383b38265c78380c8 Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Tue, 27 Sep 2022 16:31:10 -0400 Subject: [PATCH 24/50] Print the template parameters to see what is being passed --- .github/workflows/ci.yml | 2 +- samples/identity/fleet_provisioning/main.cpp | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a7997f68d..5394d47d0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -392,7 +392,7 @@ jobs: run: | echo "Generating UUID for IoT thing" Sample_UUID=$(python3 -c "import uuid; print (uuid.uuid4())") - python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/identity/fleet_provisioning/fleet-provisioning' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/FleetProvisioning/cert' --sample_secret_private_key 'ci/FleetProvisioning/key' --sample_arguments "--template_name CI_FleetProvisioning_Template --template_parameters '{SerialNumber:${Sample_UUID} }'" + python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/identity/fleet_provisioning/fleet-provisioning' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/FleetProvisioning/cert' --sample_secret_private_key 'ci/FleetProvisioning/key' --sample_arguments "--template_name CI_FleetProvisioning_Template --template_parameters '{SerialNumber:${Sample_UUID}}'" python3 ./aws-iot-device-sdk-cpp-v2/utils/delete_iot_thing_ci.py --thing_name "Fleet_Thing_${Sample_UUID}" --region "us-east-1" # TODO: Add SecureTunneling diff --git a/samples/identity/fleet_provisioning/main.cpp b/samples/identity/fleet_provisioning/main.cpp index 00e0eff38..b9dd8aac3 100644 --- a/samples/identity/fleet_provisioning/main.cpp +++ b/samples/identity/fleet_provisioning/main.cpp @@ -87,6 +87,9 @@ int main(int argc, char *argv[]) csrFile = getFileData(cmdUtils.GetCommand("csr").c_str()).c_str(); } + // Print template parameters + fprintf(stdout, "Template parameters output: %s", templateParameters.c_str()); + /* Get a MQTT client connection from the command parser */ auto connection = cmdUtils.BuildMQTTConnection(); From 7d394b8cdf98921f1e107451168f2d8e3f68746f Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Tue, 27 Sep 2022 16:49:32 -0400 Subject: [PATCH 25/50] Try formatting JSON different for fleet provisioning sample --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5394d47d0..1c3524fdb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -392,7 +392,7 @@ jobs: run: | echo "Generating UUID for IoT thing" Sample_UUID=$(python3 -c "import uuid; print (uuid.uuid4())") - python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/identity/fleet_provisioning/fleet-provisioning' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/FleetProvisioning/cert' --sample_secret_private_key 'ci/FleetProvisioning/key' --sample_arguments "--template_name CI_FleetProvisioning_Template --template_parameters '{SerialNumber:${Sample_UUID}}'" + python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/identity/fleet_provisioning/fleet-provisioning' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/FleetProvisioning/cert' --sample_secret_private_key 'ci/FleetProvisioning/key' --sample_arguments "--template_name CI_FleetProvisioning_Template --template_parameters '{\"SerialNumber\":\"${Sample_UUID}\"}'" python3 ./aws-iot-device-sdk-cpp-v2/utils/delete_iot_thing_ci.py --thing_name "Fleet_Thing_${Sample_UUID}" --region "us-east-1" # TODO: Add SecureTunneling From 440268c59efc5555f0262f035045921a96376fb0 Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Tue, 27 Sep 2022 16:57:51 -0400 Subject: [PATCH 26/50] Another attempt at fixing the JSON for fleet provisioning --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1c3524fdb..adc6f02d5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -392,7 +392,7 @@ jobs: run: | echo "Generating UUID for IoT thing" Sample_UUID=$(python3 -c "import uuid; print (uuid.uuid4())") - python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/identity/fleet_provisioning/fleet-provisioning' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/FleetProvisioning/cert' --sample_secret_private_key 'ci/FleetProvisioning/key' --sample_arguments "--template_name CI_FleetProvisioning_Template --template_parameters '{\"SerialNumber\":\"${Sample_UUID}\"}'" + python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/identity/fleet_provisioning/fleet-provisioning' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/FleetProvisioning/cert' --sample_secret_private_key 'ci/FleetProvisioning/key' --sample_arguments "--template_name CI_FleetProvisioning_Template --template_parameters {\"SerialNumber\":\"${Sample_UUID}\"}" python3 ./aws-iot-device-sdk-cpp-v2/utils/delete_iot_thing_ci.py --thing_name "Fleet_Thing_${Sample_UUID}" --region "us-east-1" # TODO: Add SecureTunneling From 315c49dd8772034ec662a514213b0db8411e2d4c Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Tue, 27 Sep 2022 17:16:19 -0400 Subject: [PATCH 27/50] Remove debug print in fleet provisioning, add back PKCS11 to CI --- .github/workflows/ci.yml | 19 +++++++++---------- samples/identity/fleet_provisioning/main.cpp | 3 --- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index adc6f02d5..bff100fd6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -349,16 +349,15 @@ jobs: - name: run PubSub sample run: | python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/pub_sub/basic_pub_sub/basic-pub-sub' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' - # TODO: Fix and run PKCS11! Currently has issue loading PKCS11 library - # - name: run PKCS11 Connect sample - # run: | - # sudo apt-get update -y - # sudo apt-get install softhsm -y - # softhsm2-util --version - # mkdir -p /tmp/tokens - # export SOFTHSM2_CONF=/tmp/softhsm2.conf - # echo "directories.tokendir = /tmp/tokens" > /tmp/softhsm2.conf - # python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/mqtt/pkcs11_connect/pkcs11-connect' --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"' + - name: run PKCS11 Connect sample + run: | + sudo apt-get update -y + sudo apt-get install softhsm -y + softhsm2-util --version + mkdir -p /tmp/tokens + export SOFTHSM2_CONF=/tmp/softhsm2.conf + echo "directories.tokendir = /tmp/tokens" > /tmp/softhsm2.conf + python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/mqtt/pkcs11_connect/pkcs11-connect' --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' - name: configure AWS credentials (Custom Authorizer) uses: aws-actions/configure-aws-credentials@v1 with: diff --git a/samples/identity/fleet_provisioning/main.cpp b/samples/identity/fleet_provisioning/main.cpp index b9dd8aac3..00e0eff38 100644 --- a/samples/identity/fleet_provisioning/main.cpp +++ b/samples/identity/fleet_provisioning/main.cpp @@ -87,9 +87,6 @@ int main(int argc, char *argv[]) csrFile = getFileData(cmdUtils.GetCommand("csr").c_str()).c_str(); } - // Print template parameters - fprintf(stdout, "Template parameters output: %s", templateParameters.c_str()); - /* Get a MQTT client connection from the command parser */ auto connection = cmdUtils.BuildMQTTConnection(); From a45292d275a1f94a951941ce61f9ba5bea7bcc88 Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Wed, 28 Sep 2022 10:08:09 -0400 Subject: [PATCH 28/50] Initial attempt at adding secure tunnel sample to CI --- .github/workflows/ci.yml | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bff100fd6..83dac14f7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,6 +27,7 @@ env: CI_FLEET_PROVISIONING_ROLE: ${{ secrets.AWS_CI_FLEET_PROVISIONING_ROLE }} CI_DEVICE_ADVISOR: ${{ secrets.AWS_CI_DEVICE_ADVISOR_ROLE }} CI_DEVICE_DEFENDER: ${{ secrets.AWS_CI_DEVICE_DEFENDER_ROLE }} + CI_SECURE_TUNNEL: $ {{ secrets.AWS_CI_SECURE_TUNNEL_ROLE }} jobs: linux-compat: @@ -393,7 +394,27 @@ jobs: Sample_UUID=$(python3 -c "import uuid; print (uuid.uuid4())") python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/identity/fleet_provisioning/fleet-provisioning' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/FleetProvisioning/cert' --sample_secret_private_key 'ci/FleetProvisioning/key' --sample_arguments "--template_name CI_FleetProvisioning_Template --template_parameters {\"SerialNumber\":\"${Sample_UUID}\"}" python3 ./aws-iot-device-sdk-cpp-v2/utils/delete_iot_thing_ci.py --thing_name "Fleet_Thing_${Sample_UUID}" --region "us-east-1" - # TODO: Add SecureTunneling + + - name: configure AWS credentials (Secure tunneling) + uses: aws-actions/configure-aws-credentials@v1 + with: + role-to-assume: ${{ env.CI_SECURE_TUNNEL }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: run Secure Tunneling samples + run: | + echo "Opening Secure Tunnel for testing..." + RESPONSE=$(aws iotsecuretunneling open-tunnel) + array=(${RESPONSE//:/ }) + echo "Assigning SOURCETOKEN" + SOURCETOKEN="${array[11]}" + echo "Assigning DESTINATIONTOKEN" + DESTINATIONTOKEN="${array[13]}" + + echo "Secure Tunnel Destination test" + python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/secure_tunneling/secure_tunnel/secure-tunnel' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_arguments "--test --region ${{ env.AWS_DEFAULT_REGION }} --access_token ${DESTINATIONTOKEN}" + sleep 10 + echo "Secure Tunnel Source test" + python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/secure_tunneling/secure_tunnel/secure-tunnel' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_arguments "--localProxyModeSource --region ${{ env.AWS_DEFAULT_REGION }} --access_token ${SOURCETOKEN}" # check that docs can still build check-docs: From d3b7f77fd968b23c5c279bf981372d5b250d277a Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Wed, 28 Sep 2022 10:43:12 -0400 Subject: [PATCH 29/50] Remove space so role secret is correct for secure tunneling --- .github/workflows/ci.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 83dac14f7..a163f644a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,7 +27,7 @@ env: CI_FLEET_PROVISIONING_ROLE: ${{ secrets.AWS_CI_FLEET_PROVISIONING_ROLE }} CI_DEVICE_ADVISOR: ${{ secrets.AWS_CI_DEVICE_ADVISOR_ROLE }} CI_DEVICE_DEFENDER: ${{ secrets.AWS_CI_DEVICE_DEFENDER_ROLE }} - CI_SECURE_TUNNEL: $ {{ secrets.AWS_CI_SECURE_TUNNEL_ROLE }} + CI_SECURE_TUNNEL: ${{ secrets.AWS_CI_SECURE_TUNNEL_ROLE }} jobs: linux-compat: @@ -394,13 +394,12 @@ jobs: Sample_UUID=$(python3 -c "import uuid; print (uuid.uuid4())") python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/identity/fleet_provisioning/fleet-provisioning' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/FleetProvisioning/cert' --sample_secret_private_key 'ci/FleetProvisioning/key' --sample_arguments "--template_name CI_FleetProvisioning_Template --template_parameters {\"SerialNumber\":\"${Sample_UUID}\"}" python3 ./aws-iot-device-sdk-cpp-v2/utils/delete_iot_thing_ci.py --thing_name "Fleet_Thing_${Sample_UUID}" --region "us-east-1" - - name: configure AWS credentials (Secure tunneling) uses: aws-actions/configure-aws-credentials@v1 with: role-to-assume: ${{ env.CI_SECURE_TUNNEL }} aws-region: ${{ env.AWS_DEFAULT_REGION }} - - name: run Secure Tunneling samples + - name: run Secure Tunneling sample run: | echo "Opening Secure Tunnel for testing..." RESPONSE=$(aws iotsecuretunneling open-tunnel) From 22b4111eaa348643524b6f9a47b72f67d330e057 Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Wed, 28 Sep 2022 11:12:15 -0400 Subject: [PATCH 30/50] Add print statements to see where the hang is in the Secure Tunnel sample when running in CI --- .github/workflows/ci.yml | 8 ++++---- samples/secure_tunneling/secure_tunnel/main.cpp | 7 ++++++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a163f644a..90e969e62 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -410,10 +410,10 @@ jobs: DESTINATIONTOKEN="${array[13]}" echo "Secure Tunnel Destination test" - python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/secure_tunneling/secure_tunnel/secure-tunnel' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_arguments "--test --region ${{ env.AWS_DEFAULT_REGION }} --access_token ${DESTINATIONTOKEN}" - sleep 10 - echo "Secure Tunnel Source test" - python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/secure_tunneling/secure_tunnel/secure-tunnel' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_arguments "--localProxyModeSource --region ${{ env.AWS_DEFAULT_REGION }} --access_token ${SOURCETOKEN}" + python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/secure_tunneling/secure_tunnel/secure-tunnel' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_arguments "--test true --region ${{ env.AWS_DEFAULT_REGION }} --access_token ${DESTINATIONTOKEN}" & + sleep 10 & + echo "Secure Tunnel Source test" & + python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/secure_tunneling/secure_tunnel/secure-tunnel' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_arguments "--localProxyModeSource true --region ${{ env.AWS_DEFAULT_REGION }} --access_token ${SOURCETOKEN}" # check that docs can still build check-docs: diff --git a/samples/secure_tunneling/secure_tunnel/main.cpp b/samples/secure_tunneling/secure_tunnel/main.cpp index 891cc4b46..a3013887c 100644 --- a/samples/secure_tunneling/secure_tunnel/main.cpp +++ b/samples/secure_tunneling/secure_tunnel/main.cpp @@ -292,12 +292,14 @@ int main(int argc, char *argv[]) .Build(); } + fprintf(stdout, "\n About to check if we have a secure tunnel \n"); if (!secureTunnel) { fprintf(stderr, "Secure Tunnel Creation failed: %s\n", ErrorDebugString(LastError())); exit(-1); } + fprintf(stdout, "\n About to connect the secure tunnel \n"); if (secureTunnel->Connect() == AWS_OP_ERR) { fprintf(stderr, "Secure Tunnel Connect call failed: %s\n", ErrorDebugString(LastError())); @@ -305,10 +307,13 @@ int main(int argc, char *argv[]) } int messageCount = 0; + fprintf(stdout, "\n About to start waiting on connectionCompletePromise \n"); if (connectionCompletedPromise.get_future().get()) { - while (1) + fprintf(stdout, "\n About to wait in loop after connection complete \n"); + while (true) { + fprintf(stdout, "\n Loop call \n"); std::this_thread::sleep_for(3000ms); if (localProxyMode == AWS_SECURE_TUNNELING_SOURCE_MODE) From ff2633da773b3cfbdb63541c0b19b8070fde6d7b Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Wed, 28 Sep 2022 11:26:00 -0400 Subject: [PATCH 31/50] Print to stderr, run sample directly instead of via Python --- .github/workflows/ci.yml | 4 ++-- samples/secure_tunneling/secure_tunnel/main.cpp | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 90e969e62..e95bea597 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -410,10 +410,10 @@ jobs: DESTINATIONTOKEN="${array[13]}" echo "Secure Tunnel Destination test" - python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/secure_tunneling/secure_tunnel/secure-tunnel' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_arguments "--test true --region ${{ env.AWS_DEFAULT_REGION }} --access_token ${DESTINATIONTOKEN}" & + ./aws-iot-device-sdk-cpp-v2/build/samples/secure_tunneling/secure_tunnel/secure-tunnel --test --region ${{ env.AWS_DEFAULT_REGION }} --access_token ${DESTINATIONTOKEN} & sleep 10 & echo "Secure Tunnel Source test" & - python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/secure_tunneling/secure_tunnel/secure-tunnel' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_arguments "--localProxyModeSource true --region ${{ env.AWS_DEFAULT_REGION }} --access_token ${SOURCETOKEN}" + ./aws-iot-device-sdk-cpp-v2/build/samples/secure_tunneling/secure_tunnel/secure-tunnel --localProxyModeSource --region ${{ env.AWS_DEFAULT_REGION }} --access_token ${SOURCETOKEN} # check that docs can still build check-docs: diff --git a/samples/secure_tunneling/secure_tunnel/main.cpp b/samples/secure_tunneling/secure_tunnel/main.cpp index a3013887c..bca96a134 100644 --- a/samples/secure_tunneling/secure_tunnel/main.cpp +++ b/samples/secure_tunneling/secure_tunnel/main.cpp @@ -203,7 +203,7 @@ int main(int argc, char *argv[]) if (isTest) { expectedMessageCount--; - if (expectedMessageCount == 0) + if (expectedMessageCount <= 0) { exit(0); } @@ -292,14 +292,14 @@ int main(int argc, char *argv[]) .Build(); } - fprintf(stdout, "\n About to check if we have a secure tunnel \n"); + fprintf(stderr, "\n About to check if we have a secure tunnel \n"); if (!secureTunnel) { fprintf(stderr, "Secure Tunnel Creation failed: %s\n", ErrorDebugString(LastError())); exit(-1); } - fprintf(stdout, "\n About to connect the secure tunnel \n"); + fprintf(stderr, "\n About to connect the secure tunnel \n"); if (secureTunnel->Connect() == AWS_OP_ERR) { fprintf(stderr, "Secure Tunnel Connect call failed: %s\n", ErrorDebugString(LastError())); @@ -307,13 +307,13 @@ int main(int argc, char *argv[]) } int messageCount = 0; - fprintf(stdout, "\n About to start waiting on connectionCompletePromise \n"); + fprintf(stderr, "\n About to start waiting on connectionCompletePromise \n"); if (connectionCompletedPromise.get_future().get()) { - fprintf(stdout, "\n About to wait in loop after connection complete \n"); + fprintf(stderr, "\n About to wait in loop after connection complete \n"); while (true) { - fprintf(stdout, "\n Loop call \n"); + fprintf(stderr, "\n Loop call \n"); std::this_thread::sleep_for(3000ms); if (localProxyMode == AWS_SECURE_TUNNELING_SOURCE_MODE) From 6a33d6f57fcd21b82bf0ca4d56e08203b7e1d9c7 Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Wed, 28 Sep 2022 13:50:30 -0400 Subject: [PATCH 32/50] Run secure tunnel sample via Python and Boto3 client --- .github/workflows/ci.yml | 14 +----- utils/run_secure_tunnel_ci.py | 86 +++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+), 13 deletions(-) create mode 100644 utils/run_secure_tunnel_ci.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e95bea597..3a04028f7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -401,19 +401,7 @@ jobs: aws-region: ${{ env.AWS_DEFAULT_REGION }} - name: run Secure Tunneling sample run: | - echo "Opening Secure Tunnel for testing..." - RESPONSE=$(aws iotsecuretunneling open-tunnel) - array=(${RESPONSE//:/ }) - echo "Assigning SOURCETOKEN" - SOURCETOKEN="${array[11]}" - echo "Assigning DESTINATIONTOKEN" - DESTINATIONTOKEN="${array[13]}" - - echo "Secure Tunnel Destination test" - ./aws-iot-device-sdk-cpp-v2/build/samples/secure_tunneling/secure_tunnel/secure-tunnel --test --region ${{ env.AWS_DEFAULT_REGION }} --access_token ${DESTINATIONTOKEN} & - sleep 10 & - echo "Secure Tunnel Source test" & - ./aws-iot-device-sdk-cpp-v2/build/samples/secure_tunneling/secure_tunnel/secure-tunnel --localProxyModeSource --region ${{ env.AWS_DEFAULT_REGION }} --access_token ${SOURCETOKEN} + python3 ./aws-iot-device-sdk-cpp-v2/utils/run_secure_tunnel.py --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/secure_tunneling/secure_tunnel/secure-tunnel' --sample_region ${{ env.AWS_DEFAULT_REGION }} # check that docs can still build check-docs: diff --git a/utils/run_secure_tunnel_ci.py b/utils/run_secure_tunnel_ci.py new file mode 100644 index 000000000..be3339ff4 --- /dev/null +++ b/utils/run_secure_tunnel_ci.py @@ -0,0 +1,86 @@ +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0. + +# Built-in +import argparse +import subprocess +import pathlib +import sys +from time import sleep +# Needs to be installed via pip +import boto3 # - for launching sample + + +current_folder = pathlib.Path(__file__).resolve() + + +def getSecretsAndLaunch(parsed_commands): + global tmp_certificate_file_path + global tmp_private_key_path + exit_code = 0 + + print ("Creating secure tunnel client using Boto3") + tunnel_client = None + try: + tunnel_client = boto3.client("IoTSecureTunneling", region_name=parsed_commands.sample_region) + except Exception: + print ("Could not create tunnel client!") + exit(-1) + + tunnel_data = None + try: + tunnel_client.open_tunnel() + except Exception: + print ("Could not open tunnel!") + exit(-1) + + print ("Launching Secure Tunnel samples...") + exit_code = launch_samples(parsed_commands, tunnel_data) + + print ("Closing tunnel...") + try: + tunnel_client.close_tunnel(tunnel_data["tunnelId"]) + except Exception: + print ("Could not close tunnel!") + exit(-1) + + return exit_code + + +def launch_samples(parsed_commands, tunnel_data): + exit_code = 0 + + # Right now secure tunneling is only in C++, so we only support C++ + launch_arguments_destination = ["test", "region", parsed_commands.sample_region, "access_token", tunnel_data["destinationAccessToken"]] + launch_arguments_source = ["localProxyModeSource", "region", parsed_commands.sample_region, "access_token", tunnel_data["sourceAccessToken"]] + + destination_run = subprocess.Popen(args=launch_arguments_destination, executable=parsed_commands.sample_file) + sleep(10) # Sleep to give the destination some time to run + source_run = subprocess.Popen(args=launch_arguments_source, executable=parsed_commands.sample_file) + + # Wait for the source to finish + source_run.wait() + # Once finished, stop the destination run + destination_run.kill() + + # finish! + return exit_code + + +def main(): + argument_parser = argparse.ArgumentParser( + description="Utility to run Secure Tunneling sample in CI") + argument_parser.add_argument("--sample_file", + metavar="", + required=True, default="", help="Sample to launch. Format varies based on programming language") + argument_parser.add_argument("--sample_region", metavar="", + required=True, default="us-east-1", help="The name of the region to use for accessing secrets") + parsed_commands = argument_parser.parse_args() + + print("Starting to launch Secure Tunneling sample...") + sample_result = getSecretsAndLaunch(parsed_commands) + sys.exit(sample_result) + + +if __name__ == "__main__": + main() From b022365f2db7350e8e72f993f7a371e47b285d8c Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Wed, 28 Sep 2022 13:56:45 -0400 Subject: [PATCH 33/50] Use the right filename for the Python secure tunnel utility --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3a04028f7..dde9486d9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -401,7 +401,7 @@ jobs: aws-region: ${{ env.AWS_DEFAULT_REGION }} - name: run Secure Tunneling sample run: | - python3 ./aws-iot-device-sdk-cpp-v2/utils/run_secure_tunnel.py --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/secure_tunneling/secure_tunnel/secure-tunnel' --sample_region ${{ env.AWS_DEFAULT_REGION }} + python3 ./aws-iot-device-sdk-cpp-v2/utils/run_secure_tunnel_ci.py --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/secure_tunneling/secure_tunnel/secure-tunnel' --sample_region ${{ env.AWS_DEFAULT_REGION }} # check that docs can still build check-docs: From 7e3934d33ddfb3c6f7fe953da8efa5718ba8df20 Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Wed, 28 Sep 2022 15:31:26 -0400 Subject: [PATCH 34/50] Check why a secure tunnel client cannot be created --- .github/workflows/ci.yml | 1 + utils/run_secure_tunnel_ci.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dde9486d9..c306b8843 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -394,6 +394,7 @@ jobs: Sample_UUID=$(python3 -c "import uuid; print (uuid.uuid4())") python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/identity/fleet_provisioning/fleet-provisioning' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/FleetProvisioning/cert' --sample_secret_private_key 'ci/FleetProvisioning/key' --sample_arguments "--template_name CI_FleetProvisioning_Template --template_parameters {\"SerialNumber\":\"${Sample_UUID}\"}" python3 ./aws-iot-device-sdk-cpp-v2/utils/delete_iot_thing_ci.py --thing_name "Fleet_Thing_${Sample_UUID}" --region "us-east-1" + - name: configure AWS credentials (Secure tunneling) uses: aws-actions/configure-aws-credentials@v1 with: diff --git a/utils/run_secure_tunnel_ci.py b/utils/run_secure_tunnel_ci.py index be3339ff4..889142f66 100644 --- a/utils/run_secure_tunnel_ci.py +++ b/utils/run_secure_tunnel_ci.py @@ -23,7 +23,8 @@ def getSecretsAndLaunch(parsed_commands): tunnel_client = None try: tunnel_client = boto3.client("IoTSecureTunneling", region_name=parsed_commands.sample_region) - except Exception: + except Exception as ex: + print (ex) print ("Could not create tunnel client!") exit(-1) From 6f2e01cee3cb600ceec43f333f03f8165eb6ace0 Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Wed, 28 Sep 2022 15:42:08 -0400 Subject: [PATCH 35/50] Use the right Boto3 client name --- utils/run_secure_tunnel_ci.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/utils/run_secure_tunnel_ci.py b/utils/run_secure_tunnel_ci.py index 889142f66..7f2cfb55b 100644 --- a/utils/run_secure_tunnel_ci.py +++ b/utils/run_secure_tunnel_ci.py @@ -22,9 +22,8 @@ def getSecretsAndLaunch(parsed_commands): print ("Creating secure tunnel client using Boto3") tunnel_client = None try: - tunnel_client = boto3.client("IoTSecureTunneling", region_name=parsed_commands.sample_region) - except Exception as ex: - print (ex) + tunnel_client = boto3.client("iotsecuretunneling", region_name=parsed_commands.sample_region) + except Exception: print ("Could not create tunnel client!") exit(-1) From 836033fce1c5238dff0c6e17030704d4ec1340b8 Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Wed, 28 Sep 2022 16:05:59 -0400 Subject: [PATCH 36/50] Remove debug print statements in Secure Tunnel sample, fix running secure tunnel sample in CI --- samples/secure_tunneling/secure_tunnel/main.cpp | 5 ----- utils/run_secure_tunnel_ci.py | 13 ++++++------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/samples/secure_tunneling/secure_tunnel/main.cpp b/samples/secure_tunneling/secure_tunnel/main.cpp index bca96a134..19f06a1d6 100644 --- a/samples/secure_tunneling/secure_tunnel/main.cpp +++ b/samples/secure_tunneling/secure_tunnel/main.cpp @@ -292,14 +292,12 @@ int main(int argc, char *argv[]) .Build(); } - fprintf(stderr, "\n About to check if we have a secure tunnel \n"); if (!secureTunnel) { fprintf(stderr, "Secure Tunnel Creation failed: %s\n", ErrorDebugString(LastError())); exit(-1); } - fprintf(stderr, "\n About to connect the secure tunnel \n"); if (secureTunnel->Connect() == AWS_OP_ERR) { fprintf(stderr, "Secure Tunnel Connect call failed: %s\n", ErrorDebugString(LastError())); @@ -307,13 +305,10 @@ int main(int argc, char *argv[]) } int messageCount = 0; - fprintf(stderr, "\n About to start waiting on connectionCompletePromise \n"); if (connectionCompletedPromise.get_future().get()) { - fprintf(stderr, "\n About to wait in loop after connection complete \n"); while (true) { - fprintf(stderr, "\n Loop call \n"); std::this_thread::sleep_for(3000ms); if (localProxyMode == AWS_SECURE_TUNNELING_SOURCE_MODE) diff --git a/utils/run_secure_tunnel_ci.py b/utils/run_secure_tunnel_ci.py index 7f2cfb55b..baa33997f 100644 --- a/utils/run_secure_tunnel_ci.py +++ b/utils/run_secure_tunnel_ci.py @@ -15,8 +15,6 @@ def getSecretsAndLaunch(parsed_commands): - global tmp_certificate_file_path - global tmp_private_key_path exit_code = 0 print ("Creating secure tunnel client using Boto3") @@ -29,7 +27,7 @@ def getSecretsAndLaunch(parsed_commands): tunnel_data = None try: - tunnel_client.open_tunnel() + tunnel_data = tunnel_client.open_tunnel() except Exception: print ("Could not open tunnel!") exit(-1) @@ -39,7 +37,7 @@ def getSecretsAndLaunch(parsed_commands): print ("Closing tunnel...") try: - tunnel_client.close_tunnel(tunnel_data["tunnelId"]) + tunnel_client.close_tunnel(tunnelId=tunnel_data["tunnelId"], delete=True) except Exception: print ("Could not close tunnel!") exit(-1) @@ -50,11 +48,12 @@ def getSecretsAndLaunch(parsed_commands): def launch_samples(parsed_commands, tunnel_data): exit_code = 0 - # Right now secure tunneling is only in C++, so we only support C++ - launch_arguments_destination = ["test", "region", parsed_commands.sample_region, "access_token", tunnel_data["destinationAccessToken"]] - launch_arguments_source = ["localProxyModeSource", "region", parsed_commands.sample_region, "access_token", tunnel_data["sourceAccessToken"]] + # Right now secure tunneling is only in C++, so we only support launching the sample in the C++ way + launch_arguments_destination = ["--test", "--region", parsed_commands.sample_region, "--access_token", tunnel_data["destinationAccessToken"]] + launch_arguments_source = ["--local_proxy_mode_source", "--region", parsed_commands.sample_region, "--access_token", tunnel_data["sourceAccessToken"]] destination_run = subprocess.Popen(args=launch_arguments_destination, executable=parsed_commands.sample_file) + print ("About to sleep before running source part of sample...") sleep(10) # Sleep to give the destination some time to run source_run = subprocess.Popen(args=launch_arguments_source, executable=parsed_commands.sample_file) From 4aed884ac3d98189886ac557eb90c85991aba376 Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Wed, 28 Sep 2022 16:06:20 -0400 Subject: [PATCH 37/50] Format fix --- .github/workflows/ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c306b8843..dde9486d9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -394,7 +394,6 @@ jobs: Sample_UUID=$(python3 -c "import uuid; print (uuid.uuid4())") python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/identity/fleet_provisioning/fleet-provisioning' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/FleetProvisioning/cert' --sample_secret_private_key 'ci/FleetProvisioning/key' --sample_arguments "--template_name CI_FleetProvisioning_Template --template_parameters {\"SerialNumber\":\"${Sample_UUID}\"}" python3 ./aws-iot-device-sdk-cpp-v2/utils/delete_iot_thing_ci.py --thing_name "Fleet_Thing_${Sample_UUID}" --region "us-east-1" - - name: configure AWS credentials (Secure tunneling) uses: aws-actions/configure-aws-credentials@v1 with: From 87a5c1373c9686989cfc38a888c56cb5405c3498 Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Wed, 28 Sep 2022 16:20:12 -0400 Subject: [PATCH 38/50] Description correction for utility scripts --- utils/delete_iot_thing_ci.py | 2 +- utils/run_sample_ci.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/delete_iot_thing_ci.py b/utils/delete_iot_thing_ci.py index 0a4d46f95..b3d30a358 100644 --- a/utils/delete_iot_thing_ci.py +++ b/utils/delete_iot_thing_ci.py @@ -49,7 +49,7 @@ def DeleteIoTThing(parsed_commands): def main(): argument_parser = argparse.ArgumentParser( - description="AppVerifier XML output util") + description="Delete IoT Thing") argument_parser.add_argument("--thing_name", metavar="", required=True, help="The name of the IoT thing to delete") argument_parser.add_argument("--region", metavar="", diff --git a/utils/run_sample_ci.py b/utils/run_sample_ci.py index 720bbf150..0d17a25f7 100644 --- a/utils/run_sample_ci.py +++ b/utils/run_sample_ci.py @@ -160,7 +160,7 @@ def launch_sample(parsed_commands, sample_endpoint, sample_certificate, sample_p def main(): argument_parser = argparse.ArgumentParser( - description="AppVerifier XML output util") + description="Run Sample in CI") argument_parser.add_argument("--language", metavar="", required=True, help="The name of the programming language. Used to determine how to launch the sample") argument_parser.add_argument("--sample_file", From bb07106b5f9d2aee4d07779c846d45c22acb195e Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Wed, 28 Sep 2022 16:44:10 -0400 Subject: [PATCH 39/50] Only run PubSub in Codebuild now that we are using GitHub actions, update sample README --- .../connect-custom-authorizer-linux.sh | 21 -------- codebuild/samples/connect-websocket-linux.sh | 19 ------- codebuild/samples/linux-smoke-tests.yml | 4 -- codebuild/samples/pkcs11-connect-linux.sh | 42 --------------- codebuild/samples/securetunnel-linux.sh | 29 ----------- samples/README.md | 51 ++++++++----------- 6 files changed, 21 insertions(+), 145 deletions(-) delete mode 100755 codebuild/samples/connect-custom-authorizer-linux.sh delete mode 100755 codebuild/samples/connect-websocket-linux.sh delete mode 100755 codebuild/samples/pkcs11-connect-linux.sh delete mode 100755 codebuild/samples/securetunnel-linux.sh diff --git a/codebuild/samples/connect-custom-authorizer-linux.sh b/codebuild/samples/connect-custom-authorizer-linux.sh deleted file mode 100755 index d1c81c0b8..000000000 --- a/codebuild/samples/connect-custom-authorizer-linux.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -set -e - -env - -pushd $CODEBUILD_SRC_DIR/samples/mqtt/custom_authorizer_connect - -mkdir _build -cd _build -cmake -DCMAKE_PREFIX_PATH=/tmp/install .. -make -j - -ENDPOINT=$(aws secretsmanager get-secret-value --secret-id "unit-test/endpoint" --query "SecretString" | cut -f2 -d":" | sed -e 's/[\\\"\}]//g') -AUTH_NAME=$(aws secretsmanager get-secret-value --secret-id "unit-test/authorizer-name" --query "SecretString" | cut -f2 -d":" | sed -e 's/[\\\"\}]//g') -AUTH_PASSWORD=$(aws secretsmanager get-secret-value --secret-id "unit-test/authorizer-password" --query "SecretString" | cut -f2 -d":" | sed -e 's/[\\\"\}]//g') - -echo "Custom authorizer connect test" -./custom-authorizer-connect --endpoint $ENDPOINT --custom_auth_authorizer_name $AUTH_NAME --custom_auth_password $AUTH_PASSWORD - -popd diff --git a/codebuild/samples/connect-websocket-linux.sh b/codebuild/samples/connect-websocket-linux.sh deleted file mode 100755 index e3fbaa7f0..000000000 --- a/codebuild/samples/connect-websocket-linux.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -set -e - -env - -pushd $CODEBUILD_SRC_DIR/samples/mqtt/websocket_connect - -mkdir _build -cd _build -cmake -DCMAKE_PREFIX_PATH=/tmp/install .. -make -j - -ENDPOINT=$(aws secretsmanager get-secret-value --secret-id "unit-test/endpoint" --query "SecretString" | cut -f2 -d":" | sed -e 's/[\\\"\}]//g') - -echo "Websocket test" -./websocket-connect --endpoint $ENDPOINT --use_websocket --signing_region us-east-1 - -popd diff --git a/codebuild/samples/linux-smoke-tests.yml b/codebuild/samples/linux-smoke-tests.yml index 6a8fe3a67..087f32d76 100644 --- a/codebuild/samples/linux-smoke-tests.yml +++ b/codebuild/samples/linux-smoke-tests.yml @@ -16,10 +16,6 @@ phases: - echo Build started on `date` - $CODEBUILD_SRC_DIR/codebuild/samples/setup-linux.sh - $CODEBUILD_SRC_DIR/codebuild/samples/pubsub-linux.sh - - $CODEBUILD_SRC_DIR/codebuild/samples/connect-websocket-linux.sh - - $CODEBUILD_SRC_DIR/codebuild/samples/pkcs11-connect-linux.sh - - $CODEBUILD_SRC_DIR/codebuild/samples/securetunnel-linux.sh - - $CODEBUILD_SRC_DIR/codebuild/samples/connect-custom-authorizer-linux.sh post_build: commands: - echo Build completed on `date` diff --git a/codebuild/samples/pkcs11-connect-linux.sh b/codebuild/samples/pkcs11-connect-linux.sh deleted file mode 100755 index 43d1c51bb..000000000 --- a/codebuild/samples/pkcs11-connect-linux.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash - -set -e -set -o pipefail - -ENDPOINT=$(aws secretsmanager get-secret-value --secret-id "unit-test/endpoint" --query "SecretString" | cut -f2 -d":" | sed -e 's/[\\\"\}]//g') - -# from hereon commands are echoed. don't leak secrets -set -x - -softhsm2-util --version - -# SoftHSM2's default tokendir path might be invalid on this machine -# so set up a conf file that specifies a known good tokendir path -mkdir -p /tmp/tokens -export SOFTHSM2_CONF=/tmp/softhsm2.conf -echo "directories.tokendir = /tmp/tokens" > /tmp/softhsm2.conf - -# create token -softhsm2-util --init-token --free --label my-token --pin 0000 --so-pin 0000 - -# add private key to token (must be in PKCS#8 format) -openssl pkcs8 -topk8 -in /tmp/privatekey.pem -out /tmp/privatekey.p8.pem -nocrypt -softhsm2-util --import /tmp/privatekey.p8.pem --token my-token --label my-key --id BEEFCAFE --pin 0000 - -# build and run sample -pushd $CODEBUILD_SRC_DIR/samples/mqtt/pkcs11_connect - -mkdir _build -cd _build -cmake -DCMAKE_PREFIX_PATH=/tmp/install .. -make -j - -./pkcs11-connect \ - --endpoint $ENDPOINT \ - --cert /tmp/certificate.pem \ - --pkcs11_lib /usr/lib/softhsm/libsofthsm2.so \ - --pin 0000 \ - --token_label my-token \ - --key_label my-key - -popd diff --git a/codebuild/samples/securetunnel-linux.sh b/codebuild/samples/securetunnel-linux.sh deleted file mode 100755 index e6e34e58c..000000000 --- a/codebuild/samples/securetunnel-linux.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash - -set -e - -env - -pushd $CODEBUILD_SRC_DIR/samples/secure_tunneling/secure_tunnel - -mkdir _build -cd _build -cmake -DCMAKE_PREFIX_PATH=/tmp/install .. -make -j - -echo "aws iotsecuretunneling open-tunnel" -RESPONSE=$(aws iotsecuretunneling open-tunnel) -array=(${RESPONSE//:/ }) - -echo "Assigning SOURCETOKEN" -SOURCETOKEN="${array[11]}" - -echo "Assigning DESTINATIONTOKEN" -DESTINATIONTOKEN="${array[13]}" - -echo "Secure Tunnel Destination test" -./secure-tunnel --test --region us-east-1 --access_token $DESTINATIONTOKEN & -sleep 10 & - -echo "Secure Tunnel Source test" -./secure-tunnel --localProxyModeSource --region us-east-1 --access_token $SOURCETOKEN & diff --git a/samples/README.md b/samples/README.md index 9a2a4332f..634d5c333 100644 --- a/samples/README.md +++ b/samples/README.md @@ -554,28 +554,30 @@ Your Thing's [Policy](https://docs.aws.amazon.com/iot/latest/developerguide/iot- "Statement": [ { "Effect": "Allow", - "Action": "iot:Connect", + "Action": "iot:Publish", "Resource": [ - "arn:aws:iot:region:account:client/thingname", - "arn:aws:iot:region:account:client/test-*" + "arn:aws:iot:region:account:topic/$aws/things/thingname/jobs/start-next", + "arn:aws:iot:region:account:topic/$aws/things/thingname/jobs/*/update", + "arn:aws:iot:region:account:topic/$aws/things/thingname/jobs/*/get", + "arn:aws:iot:region:account:topic/$aws/things/thingname/jobs/get" ] }, { "Effect": "Allow", - "Action": "iot:Publish", + "Action": "iot:Receive", "Resource": [ - "arn:aws:iot:region:account:topic/$aws/events/job/*", - "arn:aws:iot:region:account:topic/$aws/events/jobExecution/*", - "arn:aws:iot:region:account:topic/$aws/things/thingname/jobs/*/update", - "arn:aws:iot:region:account:topic/$aws/things/thingname/jobs/*/get", - "arn:aws:iot:region:account:topic/$aws/things/thingname/jobs/get" + "arn:aws:iot:region:account:topic/$aws/things/thingname/jobs/notify-next", + "arn:aws:iot:region:account:topic/$aws/things/thingname/jobs/start-next/*", + "arn:aws:iot:region:account:topic/$aws/things/thingname/jobs/*/update/*", + "arn:aws:iot:region:account:topic/$aws/things/thingname/jobs/get/*", + "arn:aws:iot:region:account:topic/$aws/things/thingname/jobs/*/get/*" ] }, { "Effect": "Allow", "Action": "iot:Subscribe", "Resource": [ - "arn:aws:iot:region:account:topicfilter/$aws/events/jobExecution/*", + "arn:aws:iot:region:account:topicfilter/$aws/things/thingname/jobs/notify-next", "arn:aws:iot:region:account:topicfilter/$aws/things/thingname/jobs/start-next/*", "arn:aws:iot:region:account:topicfilter/$aws/things/thingname/jobs/*/update/*", "arn:aws:iot:region:account:topicfilter/$aws/things/thingname/jobs/get/*", @@ -584,23 +586,8 @@ Your Thing's [Policy](https://docs.aws.amazon.com/iot/latest/developerguide/iot- }, { "Effect": "Allow", - "Action": "iot:Receive", - "Resource": [ - "arn:aws:iot:region:account:topic/$aws/things/thingname/jobs/start-next/*", - "arn:aws:iot:region:account:topic/$aws/things/thingname/jobs/*/update/*", - "arn:aws:iot:region:account:topic/$aws/things/thingname/jobs/get/*", - "arn:aws:iot:region:account:topic/$aws/things/thingname/jobs/*/get/*" - ] - }, - { - "Effect": "Allow", - "Action": [ - "iot:DescribeJobExecution", - "iot:GetPendingJobExecutions", - "iot:StartNextPendingJobExecution", - "iot:UpdateJobExecution" - ], - "Resource": "arn:aws:iot:region:account:topic/$aws/things/thingname" + "Action": "iot:Connect", + "Resource": "arn:aws:iot:region:account:client/test-*" } ] } @@ -656,7 +643,7 @@ Your Thing's [Policy](https://docs.aws.amazon.com/iot/latest/developerguide/iot- "Statement": [ { "Effect": "Allow", - "Action": "iot:Publish" + "Action": "iot:Publish", "Resource": [ "arn:aws:iot:region:account:topic/$aws/certificates/create/json", "arn:aws:iot:region:account:topic/$aws/certificates/create-from-csr/json", @@ -665,7 +652,9 @@ Your Thing's [Policy](https://docs.aws.amazon.com/iot/latest/developerguide/iot- }, { "Effect": "Allow", - "Action": "iot:Receive" + "Action": [ + "iot:Receive" + ], "Resource": [ "arn:aws:iot:region:account:topic/$aws/certificates/create/json/accepted", "arn:aws:iot:region:account:topic/$aws/certificates/create/json/rejected", @@ -677,7 +666,9 @@ Your Thing's [Policy](https://docs.aws.amazon.com/iot/latest/developerguide/iot- }, { "Effect": "Allow", - "Action": "iot:Subscribe" + "Action": [ + "iot:Subscribe" + ], "Resource": [ "arn:aws:iot:region:account:topicfilter/$aws/certificates/create/json/accepted", "arn:aws:iot:region:account:topicfilter/$aws/certificates/create/json/rejected", From ba17227aa146bd03af5657a572bd7e935b5da54d Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Thu, 29 Sep 2022 13:33:09 -0400 Subject: [PATCH 40/50] Code Review Changes --- .github/workflows/ci.yml | 72 +++++++++---------- builder.json | 2 - samples/device_defender/basic_report/main.cpp | 44 +++++------- samples/greengrass/basic_discovery/main.cpp | 6 +- samples/greengrass/ipc/main.cpp | 14 ++-- samples/identity/fleet_provisioning/main.cpp | 18 ++--- samples/jobs/describe_job_execution/main.cpp | 12 ++-- samples/mqtt/basic_connect/main.cpp | 18 ++--- .../mqtt/custom_authorizer_connect/main.cpp | 18 ++--- samples/mqtt/pkcs11_connect/main.cpp | 18 ++--- samples/mqtt/raw_connect/main.cpp | 16 ++--- samples/mqtt/websocket_connect/main.cpp | 18 ++--- samples/mqtt/windows_cert_connect/main.cpp | 12 ++-- .../main.cpp | 16 ++--- samples/pub_sub/basic_pub_sub/main.cpp | 16 ++--- samples/pub_sub/cycle_pub_sub/main.cpp | 10 +-- .../secure_tunneling/secure_tunnel/main.cpp | 16 ++--- .../tunnel_notification/main.cpp | 10 +-- samples/shadow/shadow_sync/main.cpp | 30 ++++---- samples/utils/CommandLineUtils.cpp | 18 ++--- samples/utils/CommandLineUtils.h | 4 +- utils/run_sample_ci.py | 3 + 22 files changed, 171 insertions(+), 220 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dde9486d9..ff654057f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,6 +18,8 @@ env: DA_SHADOW_PROPERTY: datest DA_SHADOW_VALUE_SET: ON DA_SHADOW_VALUE_DEFAULT: OFF + CI_FOLDER: D:\a\work + CI_UTILS_FOLDER: ./aws-iot-device-sdk-cpp-v2/utils CI_IOT_CONTAINERS: ${{ secrets.AWS_CI_IOT_CONTAINERS }} CI_PUBSUB_ROLE: ${{ secrets.AWS_CI_PUBSUB_ROLE }} CI_CYCLEPUBSUB_ROLE: ${{ secrets.AWS_CI_CYCLEPUBSUB_ROLE }} @@ -121,8 +123,8 @@ jobs: steps: - name: Build ${{ env.PACKAGE_NAME }} + consumers run: | - md D:\a\work - cd D:\a\work + md ${{ env.CI_FOLDER }} + cd ${{ env.CI_FOLDER }} python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz', 'builder.pyz')" python builder.pyz build -p ${{ env.PACKAGE_NAME }} - name: configure AWS credentials (PubSub) @@ -132,9 +134,9 @@ jobs: aws-region: ${{ env.AWS_DEFAULT_REGION }} - name: run PubSub sample run: | - cd D:\a\work + cd ${{ env.CI_FOLDER }} python -m pip install boto3 - python ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file '.\aws-iot-device-sdk-cpp-v2\build\samples\pub_sub\basic_pub_sub\RelWithDebInfo\basic-pub-sub.exe' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' + python ${{ CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file '.\aws-iot-device-sdk-cpp-v2\build\samples\pub_sub\basic_pub_sub\RelWithDebInfo\basic-pub-sub.exe' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' - name: configure AWS credentials (Device Advisor) uses: aws-actions/configure-aws-credentials@v1 with: @@ -142,7 +144,7 @@ jobs: aws-region: ${{ env.AWS_DEFAULT_REGION }} - name: run DeviceAdvisor run: | - cd D:\a\work\aws-iot-device-sdk-cpp-v2 + cd ${{ env.CI_FOLDER }}\aws-iot-device-sdk-cpp-v2 python3 ./deviceadvisor/script/DATestRun.py windows-vs14: @@ -156,8 +158,8 @@ jobs: steps: - name: Build ${{ env.PACKAGE_NAME }} + consumers run: | - md D:\a\work - cd D:\a\work + md ${{ env.CI_FOLDER }} + cd ${{ env.CI_FOLDER }} python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder.pyz')" python builder.pyz build -p ${{ env.PACKAGE_NAME }} --cmake-extra=-Tv140 --cmake-extra=-A${{ matrix.arch }} - name: configure AWS credentials (PubSub) @@ -167,9 +169,9 @@ jobs: aws-region: ${{ env.AWS_DEFAULT_REGION }} - name: run PubSub sample run: | - cd D:\a\work + cd ${{ env.CI_FOLDER }} python -m pip install boto3 - python ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file '.\aws-iot-device-sdk-cpp-v2\build\samples\pub_sub\basic_pub_sub\RelWithDebInfo\basic-pub-sub.exe' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' + python ${{ CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file '.\aws-iot-device-sdk-cpp-v2\build\samples\pub_sub\basic_pub_sub\RelWithDebInfo\basic-pub-sub.exe' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' - name: configure AWS credentials (Device Advisor) uses: aws-actions/configure-aws-credentials@v1 with: @@ -177,7 +179,7 @@ jobs: aws-region: ${{ env.AWS_DEFAULT_REGION }} - name: run DeviceAdvisor run: | - cd D:\a\work\aws-iot-device-sdk-cpp-v2 + cd ${{ env.CI_FOLDER }}\aws-iot-device-sdk-cpp-v2 python3 ./deviceadvisor/script/DATestRun.py windows-no-cpu-extensions: @@ -187,8 +189,8 @@ jobs: steps: - name: Build ${{ env.PACKAGE_NAME }} + consumers run: | - md D:\a\work - cd D:\a\work + md ${{ env.CI_FOLDER }} + cd ${{ env.CI_FOLDER }} python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz', 'builder.pyz')" python builder.pyz build -p ${{ env.PACKAGE_NAME }} --cmake-extra=-DUSE_CPU_EXTENSIONS=OFF - name: configure AWS credentials (PubSub) @@ -198,9 +200,9 @@ jobs: aws-region: ${{ env.AWS_DEFAULT_REGION }} - name: run PubSub sample run: | - cd D:\a\work + cd ${{ env.CI_FOLDER }} python -m pip install boto3 - python ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file '.\aws-iot-device-sdk-cpp-v2\build\samples\pub_sub\basic_pub_sub\RelWithDebInfo\basic-pub-sub.exe' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' + python ${{ CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file '.\aws-iot-device-sdk-cpp-v2\build\samples\pub_sub\basic_pub_sub\RelWithDebInfo\basic-pub-sub.exe' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' - name: configure AWS credentials (Device Advisor) uses: aws-actions/configure-aws-credentials@v1 with: @@ -208,7 +210,7 @@ jobs: aws-region: ${{ env.AWS_DEFAULT_REGION }} - name: run DeviceAdvisor run: | - cd D:\a\work\aws-iot-device-sdk-cpp-v2 + cd ${{ env.CI_FOLDER }}\aws-iot-device-sdk-cpp-v2 python3 ./deviceadvisor/script/DATestRun.py windows-app-verifier: @@ -218,8 +220,8 @@ jobs: steps: - name: Build ${{ env.PACKAGE_NAME }} + consumers run: | - md D:\a\work - cd D:\a\work + md ${{ env.CI_FOLDER }} + cd ${{ env.CI_FOLDER }} python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz', 'builder.pyz')" python builder.pyz build -p ${{ env.PACKAGE_NAME }} --cmake-extra=-DUSE_CPU_EXTENSIONS=OFF - name: configure AWS credentials (CyclePubSub) @@ -229,10 +231,10 @@ jobs: aws-region: ${{ env.AWS_DEFAULT_REGION }} - name: Run and check AppVerifier run: | - cd D:\a\work + cd ${{ env.CI_FOLDER }} echo "Starting to run AppVerifier with cycle pub-sub sample" python -m pip install boto3 - python .\aws-iot-device-sdk-cpp-v2\utils\appverifier_launch_sample.py --sample_file .\aws-iot-device-sdk-cpp-v2\build\samples\pub_sub\cycle_pub_sub\RelWithDebInfo\cycle-pub-sub.exe --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/CyclePubSub/cert' --sample_secret_private_key 'ci/CyclePubSub/key' + python ${{ CI_UTILS_FOLDER }}\appverifier_launch_sample.py --sample_file .\aws-iot-device-sdk-cpp-v2\build\samples\pub_sub\cycle_pub_sub\RelWithDebInfo\cycle-pub-sub.exe --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/CyclePubSub/cert' --sample_secret_private_key 'ci/CyclePubSub/key' osx: runs-on: macos-latest @@ -271,18 +273,8 @@ jobs: permissions: id-token: write # This is required for requesting the JWT steps: - - name: Setup C++ - run: | - sudo apt-get -qq update -y - sudo apt-get -qq install -y build-essential - sudo apt install cmake - gcc --version - cmake --version - name: Build ${{ env.PACKAGE_NAME }} + consumers run: | - echo "Downloading source" - git clone --recursive https://github.com/aws/aws-iot-device-sdk-cpp-v2.git --branch ${{ github.head_ref || github.ref_name }} - echo "Running builder" python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder.pyz')" python builder.pyz build -p ${{ env.PACKAGE_NAME }} - name: configure AWS credentials (PubSub) @@ -293,7 +285,7 @@ jobs: - name: run PubSub sample run: | python3 -m pip install boto3 - python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/pub_sub/basic_pub_sub/basic-pub-sub' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' + python3 ${{ CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/pub_sub/basic_pub_sub/basic-pub-sub' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' - name: configure AWS credentials (Device Advisor) uses: aws-actions/configure-aws-credentials@v1 with: @@ -343,13 +335,13 @@ jobs: - name: run Basic Connect sample run: | python3 -m pip install boto3 - python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/mqtt/basic_connect/basic-connect' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' + python3 ${{ CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/mqtt/basic_connect/basic-connect' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' - name: run Websocket Connect sample run: | - python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/mqtt/websocket_connect/websocket-connect' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_arguments '--signing_region us-east-1' + python3 ${{ CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/mqtt/websocket_connect/websocket-connect' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_arguments '--signing_region us-east-1' - name: run PubSub sample run: | - python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/pub_sub/basic_pub_sub/basic-pub-sub' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' + python3 ${{ CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/pub_sub/basic_pub_sub/basic-pub-sub' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' - name: run PKCS11 Connect sample run: | sudo apt-get update -y @@ -358,7 +350,7 @@ jobs: mkdir -p /tmp/tokens export SOFTHSM2_CONF=/tmp/softhsm2.conf echo "directories.tokendir = /tmp/tokens" > /tmp/softhsm2.conf - python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/mqtt/pkcs11_connect/pkcs11-connect' --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' + python3 ${{ CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/mqtt/pkcs11_connect/pkcs11-connect' --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' - name: configure AWS credentials (Custom Authorizer) uses: aws-actions/configure-aws-credentials@v1 with: @@ -366,7 +358,7 @@ jobs: aws-region: ${{ env.AWS_DEFAULT_REGION }} - name: run CustomAuthorizerConnect sample run: | - python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/mqtt/custom_authorizer_connect/custom-authorizer-connect' --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' + python3 ${{ CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/mqtt/custom_authorizer_connect/custom-authorizer-connect' --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' - name: configure AWS credentials (Shadow) uses: aws-actions/configure-aws-credentials@v1 with: @@ -374,7 +366,7 @@ jobs: aws-region: ${{ env.AWS_DEFAULT_REGION }} - name: run Shadow sample run: | - python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/shadow/shadow_sync/shadow-sync' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/Shadow/cert' --sample_secret_private_key 'ci/Shadow/key' --sample_arguments '--thing_name CI_Shadow_Thing --shadow_property color --is_ci true' + python3 ${{ CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/shadow/shadow_sync/shadow-sync' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/Shadow/cert' --sample_secret_private_key 'ci/Shadow/key' --sample_arguments '--thing_name CI_Shadow_Thing --shadow_property color --is_ci true' - name: configure AWS credentials (Jobs) uses: aws-actions/configure-aws-credentials@v1 with: @@ -382,7 +374,7 @@ jobs: aws-region: ${{ env.AWS_DEFAULT_REGION }} - name: run Jobs sample run: | - python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/jobs/describe_job_execution/describe-job-execution' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/Jobs/cert' --sample_secret_private_key 'ci/Jobs/key' --sample_arguments '--thing_name CI_Jobs_Thing --job_id CI_Jobs_Thing_Job_1' + python3 ${{ CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/jobs/describe_job_execution/describe-job-execution' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/Jobs/cert' --sample_secret_private_key 'ci/Jobs/key' --sample_arguments '--thing_name CI_Jobs_Thing --job_id CI_Jobs_Thing_Job_1' - name: configure AWS credentials (Fleet provisioning) uses: aws-actions/configure-aws-credentials@v1 with: @@ -392,8 +384,8 @@ jobs: run: | echo "Generating UUID for IoT thing" Sample_UUID=$(python3 -c "import uuid; print (uuid.uuid4())") - python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/identity/fleet_provisioning/fleet-provisioning' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/FleetProvisioning/cert' --sample_secret_private_key 'ci/FleetProvisioning/key' --sample_arguments "--template_name CI_FleetProvisioning_Template --template_parameters {\"SerialNumber\":\"${Sample_UUID}\"}" - python3 ./aws-iot-device-sdk-cpp-v2/utils/delete_iot_thing_ci.py --thing_name "Fleet_Thing_${Sample_UUID}" --region "us-east-1" + python3 ${{ CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/identity/fleet_provisioning/fleet-provisioning' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/FleetProvisioning/cert' --sample_secret_private_key 'ci/FleetProvisioning/key' --sample_arguments "--template_name CI_FleetProvisioning_Template --template_parameters {\"SerialNumber\":\"${Sample_UUID}\"}" + python3 ${{ CI_UTILS_FOLDER }}/delete_iot_thing_ci.py --thing_name "Fleet_Thing_${Sample_UUID}" --region "us-east-1" - name: configure AWS credentials (Secure tunneling) uses: aws-actions/configure-aws-credentials@v1 with: @@ -401,7 +393,7 @@ jobs: aws-region: ${{ env.AWS_DEFAULT_REGION }} - name: run Secure Tunneling sample run: | - python3 ./aws-iot-device-sdk-cpp-v2/utils/run_secure_tunnel_ci.py --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/secure_tunneling/secure_tunnel/secure-tunnel' --sample_region ${{ env.AWS_DEFAULT_REGION }} + python3 ${{ CI_UTILS_FOLDER }}/run_secure_tunnel_ci.py --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/secure_tunneling/secure_tunnel/secure-tunnel' --sample_region ${{ env.AWS_DEFAULT_REGION }} # check that docs can still build check-docs: diff --git a/builder.json b/builder.json index 4f1667327..2a014ee07 100644 --- a/builder.json +++ b/builder.json @@ -23,10 +23,8 @@ "build", "build-samples" ], - "test_steps": [], "variants" : { "skip_sample": { - "!test_steps": [], "!build_steps": [ "build" ] diff --git a/samples/device_defender/basic_report/main.cpp b/samples/device_defender/basic_report/main.cpp index fd01877a4..927ad74c0 100644 --- a/samples/device_defender/basic_report/main.cpp +++ b/samples/device_defender/basic_report/main.cpp @@ -62,7 +62,7 @@ int main(int argc, char *argv[]) { /************************ Setup the Lib ****************************/ - /** + /* * Do the global initialization for the API. */ ApiHandle apiHandle; @@ -109,11 +109,9 @@ int main(int argc, char *argv[]) } } - /** - * Make a MQTT client and create a connection using a certificate and key - * Note: The data for the connection is gotten from cmdUtils - * (see BuildDirectMQTTConnection for implementation) - */ + // Make a MQTT client and create a connection using a certificate and key + // Note: The data for the connection is gotten from cmdUtils + // (see BuildDirectMQTTConnection for implementation) Aws::Iot::MqttClient mqttClient = Aws::Iot::MqttClient(); std::shared_ptr connection = cmdUtils.BuildDirectMQTTConnection(&mqttClient); @@ -123,16 +121,12 @@ int main(int argc, char *argv[]) exit(-1); } - /** - * In a real world application you probably don't want to enforce synchronous behavior - * but this is a sample console application, so we'll just do that with a condition variable. - */ + // In a real world application you probably don't want to enforce synchronous behavior + // but this is a sample console application, so we'll just do that with a condition variable. std::promise connectionCompletedPromise; std::promise connectionClosedPromise; - /** - * This will execute when an MQTT connect has completed or failed. - */ + // This will execute when an MQTT connect has completed or failed. auto onConnectionCompleted = [&](Mqtt::MqttConnection &, int errorCode, Mqtt::ReturnCode returnCode, bool) { if (errorCode) { @@ -160,9 +154,7 @@ int main(int argc, char *argv[]) auto onResumed = [&](Mqtt::MqttConnection &, Mqtt::ReturnCode, bool) { fprintf(stdout, "Connection resumed\n"); }; - /** - * Invoked when a disconnect message has completed. - */ + // Invoked when a disconnect message has completed. auto onDisconnect = [&](Mqtt::MqttConnection &) { { fprintf(stdout, "Disconnect completed\n"); @@ -175,9 +167,7 @@ int main(int argc, char *argv[]) connection->OnConnectionInterrupted = std::move(onInterrupted); connection->OnConnectionResumed = std::move(onResumed); - /** - * Actually perform the connect dance. - */ + // Actually perform the connect dance. fprintf(stdout, "Connecting...\n"); if (!connection->Connect(clientId.c_str(), false /*cleanSession*/, 1000 /*keepAliveTimeSecs*/)) { @@ -187,7 +177,7 @@ int main(int argc, char *argv[]) if (connectionCompletedPromise.get_future().get()) { - /* Device defender setup and metric registration */ + // Device defender setup and metric registration /* ====================================================================== */ Aws::Crt::Allocator *allocator = Aws::Crt::DefaultAllocator(); Aws::Crt::Io::EventLoopGroup *eventLoopGroup = Aws::Crt::ApiHandle::GetOrCreateStaticDefaultEventLoopGroup(); @@ -205,10 +195,8 @@ int main(int argc, char *argv[]) .WithTaskCancellationUserData(&callbackSuccess); std::shared_ptr task = taskBuilder.Build(); - /** - * Add the custom metrics - * (Inline function example) - */ + // Add the custom metrics + // (Inline function example) Aws::Iotdevicedefenderv1::CustomMetricNumberFunction s_localGetCustomMetricNumber = [](double *output) { *output = 8.4; return AWS_OP_SUCCESS; @@ -227,7 +215,7 @@ int main(int argc, char *argv[]) s_getCustomMetricIpAddressList; task->RegisterCustomMetricIpAddressList("CustomIPList", std::move(s_getCustomMetricIpAddressListFunc)); - /* Start the Device Defender task */ + // Start the Device Defender task if (task->StartTask() != AWS_OP_SUCCESS) { fprintf(stdout, "Device Defender failed to initialize task.\n"); @@ -247,7 +235,7 @@ int main(int argc, char *argv[]) fprintf(stdout, "Device Defender task in unknown status. Status: %d\n", (int)task->GetStatus()); exit(-1); } - /* ====================================================================== */ + // ====================================================================== int publishedCount = 0; while (publishedCount < count && @@ -262,10 +250,10 @@ int main(int argc, char *argv[]) } } - /* Stop the task so we stop sending device defender metrics */ + // Stop the task so we stop sending device defender metrics task->StopTask(); - /* Disconnect */ + // Disconnect if (connection->Disconnect()) { connectionClosedPromise.get_future().wait(); diff --git a/samples/greengrass/basic_discovery/main.cpp b/samples/greengrass/basic_discovery/main.cpp index 91938b7b0..1c5d69f45 100644 --- a/samples/greengrass/basic_discovery/main.cpp +++ b/samples/greengrass/basic_discovery/main.cpp @@ -22,7 +22,7 @@ using namespace Aws::Discovery; int main(int argc, char *argv[]) { /************************ Setup the Lib ****************************/ - /** + /* * Do the global initialization for the API. */ ApiHandle apiHandle; @@ -64,7 +64,7 @@ int main(int argc, char *argv[]) proxyPort = static_cast(atoi(portString.c_str())); } - /** + /* * We're using Mutual TLS for MQTT, so we need to load our client certificates */ Io::TlsContextOptions tlsCtxOptions = @@ -89,7 +89,7 @@ int main(int argc, char *argv[]) exit(-1); } - /** + /* * Default Socket options to use. IPV4 will be ignored based on what DNS * tells us. */ diff --git a/samples/greengrass/ipc/main.cpp b/samples/greengrass/ipc/main.cpp index e70130d3f..6f121a37b 100644 --- a/samples/greengrass/ipc/main.cpp +++ b/samples/greengrass/ipc/main.cpp @@ -18,7 +18,7 @@ static std::atomic_bool s_publishReceived(false); int main(int argc, char *argv[]) { /************************ Setup the Lib ****************************/ - /** + /* * Do the global initialization for the API. */ ApiHandle apiHandle; @@ -35,7 +35,7 @@ int main(int argc, char *argv[]) String topic = cmdUtils.GetCommandOrDefault("topic", "test/topic"); String message = cmdUtils.GetCommandOrDefault("message", "Hello World"); - /** + /* * Create the default ClientBootstrap, which will create the default * EventLoopGroup (to process IO events) and HostResolver. */ @@ -48,7 +48,7 @@ int main(int argc, char *argv[]) exit(-1); } - /** + /* * Inheriting from ConnectionLifecycleHandler allows us to define callbacks that are * called upon when connection lifecycle events occur. */ @@ -77,7 +77,7 @@ int main(int argc, char *argv[]) return true; } }; - /** + /* * Note: The lifecycle handler should be declared before the client * so that it is destroyed AFTER the client is destroyed. */ @@ -91,7 +91,7 @@ int main(int argc, char *argv[]) exit(-1); } - /** + /* * Upon receiving a message on the topic, print it and set an atomic bool so that the demo can complete. */ class SubscribeStreamHandler : public SubscribeToIoTCoreStreamHandler @@ -141,7 +141,7 @@ int main(int argc, char *argv[]) if (errorType == OPERATION_ERROR) { OperationError *error = subscribeResult.GetOperationError(); - /** + /* * This pointer can be casted to any error type like so: * if(error->GetModelName() == UnauthorizedError::MODEL_NAME) * UnauthorizedError *unauthorizedError = static_cast(error); @@ -193,7 +193,7 @@ int main(int argc, char *argv[]) if (errorType == OPERATION_ERROR) { OperationError *error = publishResult.GetOperationError(); - /**a + /* * This pointer can be casted to any error type like so: * if(error->GetModelName() == UnauthorizedError::MODEL_NAME) * UnauthorizedError *unauthorizedError = static_cast(error); diff --git a/samples/identity/fleet_provisioning/main.cpp b/samples/identity/fleet_provisioning/main.cpp index 00e0eff38..fa84c41f7 100644 --- a/samples/identity/fleet_provisioning/main.cpp +++ b/samples/identity/fleet_provisioning/main.cpp @@ -36,8 +36,8 @@ using namespace Aws::Crt; using namespace Aws::Iotidentity; -using namespace std::this_thread; /* sleep_for, sleep_until */ -using namespace std::chrono; /* nanoseconds, system_clock, seconds */ +using namespace std::this_thread; // sleep_for, sleep_until +using namespace std::chrono; // nanoseconds, system_clock, seconds static void sleep(int sleeptime) { @@ -56,7 +56,7 @@ static std::string getFileData(std::string const &fileName) int main(int argc, char *argv[]) { /************************ Setup the Lib ****************************/ - /** + /* * Do the global initialization for the API. */ ApiHandle apiHandle; @@ -90,14 +90,14 @@ int main(int argc, char *argv[]) /* Get a MQTT client connection from the command parser */ auto connection = cmdUtils.BuildMQTTConnection(); - /** + /* * In a real world application you probably don't want to enforce synchronous behavior * but this is a sample console application, so we'll just do that with a condition variable. */ std::promise connectionCompletedPromise; std::promise connectionClosedPromise; - /** + /* * This will execute when an MQTT connect has completed or failed. */ auto onConnectionCompleted = [&](Mqtt::MqttConnection &, int errorCode, Mqtt::ReturnCode returnCode, bool) { @@ -113,7 +113,7 @@ int main(int argc, char *argv[]) } }; - /** + /* * Invoked when a disconnect message has completed. */ auto onDisconnect = [&](Mqtt::MqttConnection & /*conn*/) { @@ -126,7 +126,7 @@ int main(int argc, char *argv[]) connection->OnConnectionCompleted = std::move(onConnectionCompleted); connection->OnDisconnect = std::move(onDisconnect); - /** + /* * Actually perform the connect dance. */ fprintf(stdout, "Connecting...\n"); @@ -338,7 +338,7 @@ int main(int argc, char *argv[]) if (csrFile.empty()) { - /* CreateKeysAndCertificate workflow */ + // CreateKeysAndCertificate workflow std::cout << "Subscribing to CreateKeysAndCertificate Accepted and Rejected topics" << std::endl; CreateKeysAndCertificateSubscriptionRequest keySubscriptionRequest; identityClient.SubscribeToCreateKeysAndCertificateAccepted( @@ -395,7 +395,7 @@ int main(int argc, char *argv[]) } else { - /* CreateCertificateFromCsr workflow */ + // CreateCertificateFromCsr workflow std::cout << "Subscribing to CreateCertificateFromCsr Accepted and Rejected topics" << std::endl; CreateCertificateFromCsrSubscriptionRequest csrSubscriptionRequest; identityClient.SubscribeToCreateCertificateFromCsrAccepted( diff --git a/samples/jobs/describe_job_execution/main.cpp b/samples/jobs/describe_job_execution/main.cpp index 7eb227a5d..5f44fd9d3 100644 --- a/samples/jobs/describe_job_execution/main.cpp +++ b/samples/jobs/describe_job_execution/main.cpp @@ -28,7 +28,7 @@ using namespace Aws::Iotjobs; int main(int argc, char *argv[]) { /************************ Setup the Lib ****************************/ - /** + /* * Do the global initialization for the API. */ ApiHandle apiHandle; @@ -53,14 +53,14 @@ int main(int argc, char *argv[]) /* Get a MQTT client connection from the command parser */ auto connection = cmdUtils.BuildMQTTConnection(); - /** + /* * In a real world application you probably don't want to enforce synchronous behavior * but this is a sample console application, so we'll just do that with a condition variable. */ std::promise connectionCompletedPromise; std::promise connectionClosedPromise; - /** + /* * This will execute when an mqtt connect has completed or failed. */ auto onConnectionCompleted = [&](Mqtt::MqttConnection &, int errorCode, Mqtt::ReturnCode returnCode, bool) { @@ -76,7 +76,7 @@ int main(int argc, char *argv[]) } }; - /** + /* * Invoked when a disconnect message has completed. */ auto onDisconnect = [&](Mqtt::MqttConnection & /*conn*/) { @@ -89,7 +89,7 @@ int main(int argc, char *argv[]) connection->OnConnectionCompleted = std::move(onConnectionCompleted); connection->OnDisconnect = std::move(onDisconnect); - /** + /* * Actually perform the connect dance. */ fprintf(stdout, "Connecting...\n"); @@ -107,7 +107,7 @@ int main(int argc, char *argv[]) describeJobExecutionSubscriptionRequest.ThingName = thingName; describeJobExecutionSubscriptionRequest.JobId = jobId; - /** + /* * This isn't absolutely necessary but since we're doing a publish almost immediately afterwards, * to be cautious make sure the subscribe has finished before doing the publish. */ diff --git a/samples/mqtt/basic_connect/main.cpp b/samples/mqtt/basic_connect/main.cpp index 5f75a90a8..344ba592a 100644 --- a/samples/mqtt/basic_connect/main.cpp +++ b/samples/mqtt/basic_connect/main.cpp @@ -13,7 +13,7 @@ int main(int argc, char *argv[]) { /************************ Setup the Lib ****************************/ - /** + /* * Do the global initialization for the API. */ ApiHandle apiHandle; @@ -31,21 +31,17 @@ int main(int argc, char *argv[]) cmdUtils.SendArguments(const_argv, const_argv + argc); cmdUtils.StartLoggingBasedOnCommand(&apiHandle); - /** - * Make a MQTT client and create a connection using a certificate and key - * Note: The data for the connection is gotten from cmdUtils - * (see BuildDirectMQTTConnection for implementation) - */ + // Make a MQTT client and create a connection using a certificate and key + // Note: The data for the connection is gotten from cmdUtils + // (see BuildDirectMQTTConnection for implementation) Aws::Iot::MqttClient client = Aws::Iot::MqttClient(); std::shared_ptr connection = cmdUtils.BuildDirectMQTTConnection(&client); - /* Get the client ID to send with the connection */ + // Get the client ID to send with the connection String clientId = cmdUtils.GetCommandOrDefault("client_id", String("test-") + Aws::Crt::UUID().ToString()); - /** - * Connect and then disconnect using the connection we created - * (see SampleConnectAndDisconnect for implementation) - */ + // Connect and then disconnect using the connection we created + // (see SampleConnectAndDisconnect for implementation) cmdUtils.SampleConnectAndDisconnect(connection, clientId); return 0; } diff --git a/samples/mqtt/custom_authorizer_connect/main.cpp b/samples/mqtt/custom_authorizer_connect/main.cpp index ebeee7a09..b6a675c1a 100644 --- a/samples/mqtt/custom_authorizer_connect/main.cpp +++ b/samples/mqtt/custom_authorizer_connect/main.cpp @@ -13,7 +13,7 @@ int main(int argc, char *argv[]) { /************************ Setup the Lib ****************************/ - /** + /* * Do the global initialization for the API. */ ApiHandle apiHandle; @@ -30,22 +30,18 @@ int main(int argc, char *argv[]) cmdUtils.SendArguments(const_argv, const_argv + argc); cmdUtils.StartLoggingBasedOnCommand(&apiHandle); - /** - * Make a MQTT client and create a connection through a custom authorizer - * Note: The data for the connection is gotten from cmdUtils - * (see BuildDirectMQTTConnectionWithCustomAuthorizer for implementation) - */ + // Make a MQTT client and create a connection through a custom authorizer + // Note: The data for the connection is gotten from cmdUtils + // (see BuildDirectMQTTConnectionWithCustomAuthorizer for implementation) Aws::Iot::MqttClient client = Aws::Iot::MqttClient(); std::shared_ptr connection = cmdUtils.BuildDirectMQTTConnectionWithCustomAuthorizer(&client); - /* Get the client ID to send with the connection */ + // Get the client ID to send with the connection String clientId = cmdUtils.GetCommandOrDefault("client_id", String("test-") + Aws::Crt::UUID().ToString()); - /** - * Connect and then disconnect using the connection we created - * (see SampleConnectAndDisconnect for implementation) - */ + // Connect and then disconnect using the connection we created + // (see SampleConnectAndDisconnect for implementation) cmdUtils.SampleConnectAndDisconnect(connection, clientId); return 0; } diff --git a/samples/mqtt/pkcs11_connect/main.cpp b/samples/mqtt/pkcs11_connect/main.cpp index 0c134130b..bf65a0e80 100644 --- a/samples/mqtt/pkcs11_connect/main.cpp +++ b/samples/mqtt/pkcs11_connect/main.cpp @@ -13,7 +13,7 @@ int main(int argc, char *argv[]) { /************************ Setup the Lib ****************************/ - /** + /* * Do the global initialization for the API. */ ApiHandle apiHandle; @@ -34,21 +34,17 @@ int main(int argc, char *argv[]) cmdUtils.SendArguments(const_argv, const_argv + argc); cmdUtils.StartLoggingBasedOnCommand(&apiHandle); - /** - * Make a MQTT client and create a connection using a PKCS11 - * Note: The data for the connection is gotten from cmdUtils - * (see BuildPKCS11MQTTConnection for implementation) - */ + // Make a MQTT client and create a connection using a PKCS11 + // Note: The data for the connection is gotten from cmdUtils + // (see BuildPKCS11MQTTConnection for implementation) Aws::Iot::MqttClient mqttClient; std::shared_ptr connection = cmdUtils.BuildPKCS11MQTTConnection(&mqttClient); - /* Get the client ID to send with the connection */ + // Get the client ID to send with the connection String clientId = cmdUtils.GetCommandOrDefault("client_id", String("test-") + Aws::Crt::UUID().ToString()); - /** - * Connect and then disconnect using the connection we created - * (see SampleConnectAndDisconnect for implementation) - */ + // Connect and then disconnect using the connection we created + // (see SampleConnectAndDisconnect for implementation) cmdUtils.SampleConnectAndDisconnect(connection, clientId); return 0; } diff --git a/samples/mqtt/raw_connect/main.cpp b/samples/mqtt/raw_connect/main.cpp index 2b3f1748b..3f3c5905a 100644 --- a/samples/mqtt/raw_connect/main.cpp +++ b/samples/mqtt/raw_connect/main.cpp @@ -23,16 +23,14 @@ int main(int argc, char *argv[]) { /************************ Setup the Lib ****************************/ - /** + /* * Do the global initialization for the API. */ ApiHandle apiHandle; uint16_t proxyPort(8080); - /** - * Valid protocol names are documented on page: - * https://docs.aws.amazon.com/iot/latest/developerguide/protocols.html - * Use "mqtt" for Custom Authentication - */ + // Valid protocol names are documented on page: + // https://docs.aws.amazon.com/iot/latest/developerguide/protocols.html + // Use "mqtt" for Custom Authentication String protocolName("x-amzn-mqtt-ca"); /* X.509 client certificate auth */ Vector authParams; bool useWebSocket = false; @@ -187,10 +185,8 @@ int main(int argc, char *argv[]) connection->SetHttpProxyOptions(proxyOptions); } - /** - * Connect and then disconnect using the connection we created - * (see SampleConnectAndDisconnect for implementation) - */ + // Connect and then disconnect using the connection we created + // (see SampleConnectAndDisconnect for implementation) cmdUtils.SampleConnectAndDisconnect(connection, clientId); return 0; } diff --git a/samples/mqtt/websocket_connect/main.cpp b/samples/mqtt/websocket_connect/main.cpp index 196924129..7ab11d712 100644 --- a/samples/mqtt/websocket_connect/main.cpp +++ b/samples/mqtt/websocket_connect/main.cpp @@ -21,7 +21,7 @@ int main(int argc, char *argv[]) { /************************ Setup the Lib ****************************/ - /** + /* * Do the global initialization for the API. */ ApiHandle apiHandle; @@ -38,21 +38,17 @@ int main(int argc, char *argv[]) cmdUtils.SendArguments(const_argv, const_argv + argc); cmdUtils.StartLoggingBasedOnCommand(&apiHandle); - /** - * Make a MQTT client and create a connection using websockets - * Note: The data for the connection is gotten from cmdUtils - * (see BuildWebsocketMQTTConnection for implementation) - */ + // Make a MQTT client and create a connection using websockets + // Note: The data for the connection is gotten from cmdUtils + // (see BuildWebsocketMQTTConnection for implementation) Aws::Iot::MqttClient mqttClient; std::shared_ptr connection = cmdUtils.BuildWebsocketMQTTConnection(&mqttClient); - /* Get the client ID to send with the connection */ + // Get the client ID to send with the connection String clientId = cmdUtils.GetCommandOrDefault("client_id", String("test-") + Aws::Crt::UUID().ToString()); - /** - * Connect and then disconnect using the connection we created - * (see SampleConnectAndDisconnect for implementation) - */ + // Connect and then disconnect using the connection we created + // (see SampleConnectAndDisconnect for implementation) cmdUtils.SampleConnectAndDisconnect(connection, clientId); return 0; } diff --git a/samples/mqtt/windows_cert_connect/main.cpp b/samples/mqtt/windows_cert_connect/main.cpp index 6098da2af..67efb321a 100644 --- a/samples/mqtt/windows_cert_connect/main.cpp +++ b/samples/mqtt/windows_cert_connect/main.cpp @@ -14,7 +14,7 @@ int main(int argc, char *argv[]) { /************************ Setup the Lib ****************************/ - /** + /* * Do the global initialization for the API. */ ApiHandle apiHandle; @@ -58,7 +58,7 @@ int main(int argc, char *argv[]) exit(-1); } - /** + /* * Note that that remainder of this code is identical to how the other connect samples setup their connection. */ @@ -86,7 +86,7 @@ int main(int argc, char *argv[]) exit(-1); } - /** + /* * Now create a connection object. Note: This type is move only * and its underlying memory is managed by the client. */ @@ -98,10 +98,8 @@ int main(int argc, char *argv[]) exit(-1); } - /** - * Connect and then disconnect using the connection we created - * (see SampleConnectAndDisconnect for implementation) - */ + // Connect and then disconnect using the connection we created + // (see SampleConnectAndDisconnect for implementation) cmdUtils.SampleConnectAndDisconnect(connection, clientId); return 0; diff --git a/samples/mqtt/x509_credentials_provider_connect/main.cpp b/samples/mqtt/x509_credentials_provider_connect/main.cpp index 3a465fff8..10594595f 100644 --- a/samples/mqtt/x509_credentials_provider_connect/main.cpp +++ b/samples/mqtt/x509_credentials_provider_connect/main.cpp @@ -41,21 +41,17 @@ int main(int argc, char *argv[]) cmdUtils.SendArguments(const_argv, const_argv + argc); cmdUtils.StartLoggingBasedOnCommand(&apiHandle); - /** - * Make a MQTT client and create a connection using websockets and x509 - * Note: The data for the connection is gotten from cmdUtils - * (see BuildWebsocketX509MQTTConnection for implementation) - */ + // Make a MQTT client and create a connection using websockets and x509 + // Note: The data for the connection is gotten from cmdUtils + // (see BuildWebsocketX509MQTTConnection for implementation) Aws::Iot::MqttClient mqttClient; std::shared_ptr connection = cmdUtils.BuildWebsocketX509MQTTConnection(&mqttClient); - /* Get the client ID to send with the connection */ + // Get the client ID to send with the connection String clientId = cmdUtils.GetCommandOrDefault("client_id", String("test-") + Aws::Crt::UUID().ToString()); - /** - * Connect and then disconnect using the connection we created - * (see SampleConnectAndDisconnect for implementation) - */ + // Connect and then disconnect using the connection we created + // (see SampleConnectAndDisconnect for implementation) cmdUtils.SampleConnectAndDisconnect(connection, clientId); return 0; } diff --git a/samples/pub_sub/basic_pub_sub/main.cpp b/samples/pub_sub/basic_pub_sub/main.cpp index d20b49237..ccb6f8f62 100644 --- a/samples/pub_sub/basic_pub_sub/main.cpp +++ b/samples/pub_sub/basic_pub_sub/main.cpp @@ -23,7 +23,7 @@ int main(int argc, char *argv[]) { /************************ Setup the Lib ****************************/ - /** + /* * Do the global initialization for the API. */ ApiHandle apiHandle; @@ -61,14 +61,14 @@ int main(int argc, char *argv[]) /* Get a MQTT client connection from the command parser */ auto connection = cmdUtils.BuildMQTTConnection(); - /** + /* * In a real world application you probably don't want to enforce synchronous behavior * but this is a sample console application, so we'll just do that with a condition variable. */ std::promise connectionCompletedPromise; std::promise connectionClosedPromise; - /** + /* * This will execute when an MQTT connect has completed or failed. */ auto onConnectionCompleted = [&](Mqtt::MqttConnection &, int errorCode, Mqtt::ReturnCode returnCode, bool) { @@ -90,7 +90,7 @@ int main(int argc, char *argv[]) auto onResumed = [&](Mqtt::MqttConnection &, Mqtt::ReturnCode, bool) { fprintf(stdout, "Connection resumed\n"); }; - /** + /* * Invoked when a disconnect message has completed. */ auto onDisconnect = [&](Mqtt::MqttConnection &) { @@ -105,7 +105,7 @@ int main(int argc, char *argv[]) connection->OnConnectionInterrupted = std::move(onInterrupted); connection->OnConnectionResumed = std::move(onResumed); - /** + /* * Actually perform the connect dance. */ fprintf(stdout, "Connecting...\n"); @@ -121,7 +121,7 @@ int main(int argc, char *argv[]) std::condition_variable receiveSignal; uint32_t receivedCount = 0; - /** + /* * This is invoked upon the receipt of a Publish on a subscribed topic. */ auto onMessage = [&](Mqtt::MqttConnection &, @@ -142,7 +142,7 @@ int main(int argc, char *argv[]) receiveSignal.notify_all(); }; - /** + /* * Subscribe for incoming publish messages on topic. */ std::promise subscribeFinishedPromise; @@ -188,7 +188,7 @@ int main(int argc, char *argv[]) receiveSignal.wait(receivedLock, [&] { return receivedCount >= messageCount; }); } - /** + /* * Unsubscribe from the topic. */ std::promise unsubscribeFinishedPromise; diff --git a/samples/pub_sub/cycle_pub_sub/main.cpp b/samples/pub_sub/cycle_pub_sub/main.cpp index 03070bac5..488996203 100644 --- a/samples/pub_sub/cycle_pub_sub/main.cpp +++ b/samples/pub_sub/cycle_pub_sub/main.cpp @@ -565,7 +565,7 @@ int main(int argc, char *argv[]) /******************** Start the client cycle ***********************/ - /* Make the clients */ + // Make the clients for (size_t i = 0; i < config_clients; i++) { clients_holder.push_back(CycleClient()); @@ -573,13 +573,13 @@ int main(int argc, char *argv[]) fprintf(stdout, "Created client %zu\n", i); } - /* Get the current time */ + // Get the current time auto startTime = std::chrono::steady_clock::now(); - /* Seed the random number generator with the current time */ + // Seed the random number generator with the current time srand((unsigned int)time(nullptr)); - /* Start the loop */ + // Start the loop bool done = false; auto nowTime = std::chrono::steady_clock::now(); uint64_t time_difference = 0; @@ -598,7 +598,7 @@ int main(int argc, char *argv[]) /*************************** Clean up ******************************/ - /* Stop all the clients and clear the vector */ + // Stop all the clients and clear the vector for (size_t i = 0; i < config_clients; i++) { operationStop(&clients_holder.at(i), (int)i); diff --git a/samples/secure_tunneling/secure_tunnel/main.cpp b/samples/secure_tunneling/secure_tunnel/main.cpp index 19f06a1d6..f303d21eb 100644 --- a/samples/secure_tunneling/secure_tunnel/main.cpp +++ b/samples/secure_tunneling/secure_tunnel/main.cpp @@ -54,7 +54,7 @@ int main(int argc, char *argv[]) cmdUtils.SendArguments(const_argv, const_argv + argc); cmdUtils.StartLoggingBasedOnCommand(&apiHandle); - /** + /* * Generate secure tunneling endpoint using region */ String region = cmdUtils.GetCommandRequired("region"); @@ -104,7 +104,7 @@ int main(int argc, char *argv[]) String caFile = cmdUtils.GetCommandOrDefault("ca_file", ""); - /** + /* * localProxyMode is set to destination by default unless flag is set to source */ if (cmdUtils.HasCommand("local_proxy_mode_source")) @@ -118,7 +118,7 @@ int main(int argc, char *argv[]) String message = cmdUtils.GetCommandOrDefault("message", "Hello World"); - /** + /* * For internal testing */ bool isTest = cmdUtils.HasCommand("test"); @@ -133,7 +133,7 @@ int main(int argc, char *argv[]) exit(-1); } - /** + /* * In a real world application you probably don't want to enforce synchronous behavior * but this is a sample console application, so we'll just do that with a condition variable. */ @@ -215,7 +215,7 @@ int main(int argc, char *argv[]) } }; - /** + /* * This only fires in Destination Mode */ auto OnStreamStart = [&]() { fprintf(stdout, "Stream Started in Destination Mode\n"); }; @@ -225,7 +225,7 @@ int main(int argc, char *argv[]) auto OnSessionReset = [&]() { fprintf(stdout, "Session Reset\n"); }; /*********************** Proxy Connection Setup ***************************/ - /** + /* * Setup HttpClientCommectionProxyOptions for connecting through a proxy before the Secure Tunnel */ @@ -235,7 +235,7 @@ int main(int argc, char *argv[]) proxyOptions.HostName = proxyHost.c_str(); proxyOptions.Port = proxyPort; - /** + /* * Set up Proxy Strategy if a user name and password is provided */ if (proxyUserName.length() > 0 || proxyPassword.length() > 0) @@ -255,7 +255,7 @@ int main(int argc, char *argv[]) } /*********************** Secure Tunnel Setup ***************************/ - /** + /* * Create a new SecureTunnel using the SecureTunnelBuilder */ secureTunnel = diff --git a/samples/secure_tunneling/tunnel_notification/main.cpp b/samples/secure_tunneling/tunnel_notification/main.cpp index d19bc0295..5c0c22dda 100644 --- a/samples/secure_tunneling/tunnel_notification/main.cpp +++ b/samples/secure_tunneling/tunnel_notification/main.cpp @@ -32,7 +32,7 @@ using namespace Aws::Iotsecuretunneling; int main(int argc, char *argv[]) { /************************ Setup the Lib ****************************/ - /** + /* * Do the global initialization for the API. */ ApiHandle apiHandle; @@ -55,14 +55,14 @@ int main(int argc, char *argv[]) /* Get a MQTT client connection from the command parser */ auto connection = cmdUtils.BuildMQTTConnection(); - /** + /* * In a real world application you probably don't want to enforce synchronous behavior * but this is a sample console application, so we'll just do that with a condition variable. */ std::promise connectionCompletedPromise; std::promise connectionClosedPromise; - /** + /* * This will execute when an mqtt connect has completed or failed. */ auto onConnectionCompleted = [&](Mqtt::MqttConnection &, int errorCode, Mqtt::ReturnCode returnCode, bool) { @@ -78,7 +78,7 @@ int main(int argc, char *argv[]) } }; - /** + /* * Invoked when a disconnect message has completed. */ auto onDisconnect = [&](Mqtt::MqttConnection & /*conn*/) { @@ -91,7 +91,7 @@ int main(int argc, char *argv[]) connection->OnConnectionCompleted = std::move(onConnectionCompleted); connection->OnDisconnect = std::move(onDisconnect); - /** + /* * Actually perform the connect dance. */ fprintf(stdout, "Connecting...\n"); diff --git a/samples/shadow/shadow_sync/main.cpp b/samples/shadow/shadow_sync/main.cpp index 968ecea2a..2d053b6ab 100644 --- a/samples/shadow/shadow_sync/main.cpp +++ b/samples/shadow/shadow_sync/main.cpp @@ -117,14 +117,14 @@ int main(int argc, char *argv[]) /* Get a MQTT client connection from the command parser */ auto connection = cmdUtils.BuildMQTTConnection(); - /** + /* * In a real world application you probably don't want to enforce synchronous behavior * but this is a sample console application, so we'll just do that with a condition variable. */ std::promise connectionCompletedPromise; std::promise connectionClosedPromise; - /** + /* * This will execute when a mqtt connect has completed or failed. */ auto onConnectionCompleted = [&](Mqtt::MqttConnection &, int errorCode, Mqtt::ReturnCode returnCode, bool) { @@ -140,7 +140,7 @@ int main(int argc, char *argv[]) } }; - /** + /* * Invoked when a disconnect message has completed. */ auto onDisconnect = [&](Mqtt::MqttConnection & /*conn*/) { @@ -153,7 +153,7 @@ int main(int argc, char *argv[]) connection->OnConnectionCompleted = std::move(onConnectionCompleted); connection->OnDisconnect = std::move(onDisconnect); - /** + /* * Actually perform the connect dance. */ fprintf(stdout, "Connecting...\n"); @@ -167,9 +167,8 @@ int main(int argc, char *argv[]) { Aws::Iotshadow::IotShadowClient shadowClient(connection); - /* ==================== Shadow Delta Updates ==================== */ - /* This section is for when a Shadow document updates/changes, whether it is on the server side or client side. - */ + // ==================== Shadow Delta Updates ==================== + // This section is for when a Shadow document updates/changes, whether it is on the server side or client side. std::promise subscribeDeltaCompletedPromise; std::promise subscribeDeltaAcceptedCompletedPromise; @@ -307,8 +306,8 @@ int main(int argc, char *argv[]) subscribeDeltaAcceptedCompletedPromise.get_future().wait(); subscribeDeltaRejectedCompletedPromise.get_future().wait(); - /* ==================== Shadow Value Get ==================== */ - /* This section is to get the initial value of the Shadow document */ + // ==================== Shadow Value Get ==================== + // This section is to get the initial value of the Shadow document std::promise subscribeGetShadowAcceptedCompletedPromise; std::promise subscribeGetShadowRejectedCompletedPromise; @@ -321,7 +320,6 @@ int main(int argc, char *argv[]) fprintf(stderr, "Error subscribing to get shadow document accepted: %s\n", ErrorDebugString(ioErr)); exit(-1); } - fprintf(stdout, "\n About to set subscribeGetShadowAcceptedCompletedPromise \n"); subscribeGetShadowAcceptedCompletedPromise.set_value(); }; @@ -414,17 +412,15 @@ int main(int argc, char *argv[]) GetShadowRequest shadowGetRequest; shadowGetRequest.ThingName = thingName; - /* Get the current shadow document so we start with the correct value */ + // Get the current shadow document so we start with the correct value shadowClient.PublishGetShadow(shadowGetRequest, AWS_MQTT_QOS_AT_LEAST_ONCE, onGetShadowRequestSubAck); onGetShadowRequestCompletedPromise.get_future().wait(); gotInitialShadowPromise.get_future().wait(); - /* ==================== Shadow change value input loop ==================== */ - /** - * This section is to getting user input and changing the shadow value passed to that input. - * If in CI, then input is automatically passed - */ + // ==================== Shadow change value input loop ==================== + // This section is to getting user input and changing the shadow value passed to that input. + // If in CI, then input is automatically passed if (isCI == false) { @@ -459,7 +455,7 @@ int main(int argc, char *argv[]) String input = "Shadow_Value_"; input.append(std::to_string(messagesSent).c_str()); s_changeShadowValue(shadowClient, thingName, shadowProperty, input); - /* Sleep so there is a gap between shadow updates */ + // Sleep so there is a gap between shadow updates std::this_thread::sleep_for(std::chrono::milliseconds(1000)); messagesSent += 1; } diff --git a/samples/utils/CommandLineUtils.cpp b/samples/utils/CommandLineUtils.cpp index a5f71cac3..bedae57ee 100644 --- a/samples/utils/CommandLineUtils.cpp +++ b/samples/utils/CommandLineUtils.cpp @@ -13,7 +13,7 @@ namespace Utils { CommandLineUtils::CommandLineUtils() { - /* Automatically register the help command */ + // Automatically register the help command RegisterCommand(m_cmd_help, "", "Prints this message"); } @@ -66,7 +66,7 @@ namespace Utils m_beginPosition = argv; m_endPosition = argc; - /* Automatically check and print the help message if the help command is present */ + // Automatically check and print the help message if the help command is present if (HasCommand(m_cmd_help)) { PrintHelp(); @@ -239,7 +239,7 @@ namespace Utils } else { - /* If none or unknown, then do nothing */ + // If none or unknown, then do nothing } } } @@ -564,14 +564,14 @@ namespace Utils std::shared_ptr connection, Aws::Crt::String clientId) { - /** + /* * In a real world application you probably don't want to enforce synchronous behavior * but this is a sample console application, so we'll just do that with a condition variable. */ std::promise connectionCompletedPromise; std::promise connectionClosedPromise; - /** + /* * This will execute when an mqtt connect has completed or failed. */ auto onConnectionCompleted = @@ -595,7 +595,7 @@ namespace Utils fprintf(stdout, "Connection resumed\n"); }; - /** + /* * Invoked when a disconnect message has completed. */ auto onDisconnect = [&](Aws::Crt::Mqtt::MqttConnection &) { @@ -608,7 +608,7 @@ namespace Utils connection->OnConnectionInterrupted = std::move(onInterrupted); connection->OnConnectionResumed = std::move(onResumed); - /** + /* * Actually perform the connect dance. */ fprintf(stdout, "Connecting...\n"); @@ -619,7 +619,7 @@ namespace Utils exit(-1); } - /* wait for the OnConnectionCompleted callback to fire, which sets connectionCompletedPromise... */ + // wait for the OnConnectionCompleted callback to fire, which sets connectionCompletedPromise... if (connectionCompletedPromise.get_future().get() == false) { fprintf(stderr, "Connection failed\n"); @@ -633,4 +633,4 @@ namespace Utils } } -} /* namespace Utils */ +} // namespace Utils diff --git a/samples/utils/CommandLineUtils.h b/samples/utils/CommandLineUtils.h index 094d8bec8..d43ff4fe9 100644 --- a/samples/utils/CommandLineUtils.h +++ b/samples/utils/CommandLineUtils.h @@ -252,7 +252,7 @@ namespace Utils Aws::Iot::MqttClient *client, Aws::Iot::MqttClientConnectionConfigBuilder *clientConfigBuilder); - /* Constants for commonly used/needed commands */ + /** Constants for commonly used/needed commands */ const Aws::Crt::String m_cmd_endpoint = "endpoint"; const Aws::Crt::String m_cmd_ca_file = "ca_file"; const Aws::Crt::String m_cmd_cert_file = "cert"; @@ -282,4 +282,4 @@ namespace Utils const Aws::Crt::String m_cmd_custom_auth_password = "custom_auth_password"; const Aws::Crt::String m_cmd_verbosity = "verbosity"; }; -} /* namespace Utils */ +} // namespace Utils diff --git a/utils/run_sample_ci.py b/utils/run_sample_ci.py index 0d17a25f7..1b5e06540 100644 --- a/utils/run_sample_ci.py +++ b/utils/run_sample_ci.py @@ -135,6 +135,9 @@ def launch_sample(parsed_commands, sample_endpoint, sample_certificate, sample_p exit_code = sample_return.returncode elif (parsed_commands.language == "Python"): + launch_arguments.append("--is_ci") + launch_arguments.append("True") + sample_return = subprocess.run( args=[sys.executable, parsed_commands.sample_file] + launch_arguments) exit_code = sample_return.returncode From d6d0c771d306aaded537754ee66a836aa4c81fcc Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Thu, 29 Sep 2022 13:39:38 -0400 Subject: [PATCH 41/50] Some more comment changes I missed --- samples/device_defender/basic_report/main.cpp | 22 +++++++++++++------ samples/greengrass/ipc/main.cpp | 2 +- samples/jobs/describe_job_execution/main.cpp | 6 ++--- samples/mqtt/raw_connect/main.cpp | 2 +- .../secure_tunneling/secure_tunnel/main.cpp | 2 +- samples/shadow/shadow_sync/main.cpp | 2 +- samples/utils/CommandLineUtils.cpp | 2 +- 7 files changed, 22 insertions(+), 16 deletions(-) diff --git a/samples/device_defender/basic_report/main.cpp b/samples/device_defender/basic_report/main.cpp index 927ad74c0..037ed4fac 100644 --- a/samples/device_defender/basic_report/main.cpp +++ b/samples/device_defender/basic_report/main.cpp @@ -121,12 +121,16 @@ int main(int argc, char *argv[]) exit(-1); } - // In a real world application you probably don't want to enforce synchronous behavior - // but this is a sample console application, so we'll just do that with a condition variable. + /* + * In a real world application you probably don't want to enforce synchronous behavior + * but this is a sample console application, so we'll just do that with a condition variable. + */ std::promise connectionCompletedPromise; std::promise connectionClosedPromise; - // This will execute when an MQTT connect has completed or failed. + /* + * This will execute when an mqtt connect has completed or failed. + */ auto onConnectionCompleted = [&](Mqtt::MqttConnection &, int errorCode, Mqtt::ReturnCode returnCode, bool) { if (errorCode) { @@ -154,7 +158,9 @@ int main(int argc, char *argv[]) auto onResumed = [&](Mqtt::MqttConnection &, Mqtt::ReturnCode, bool) { fprintf(stdout, "Connection resumed\n"); }; - // Invoked when a disconnect message has completed. + /* + * Invoked when a disconnect message has completed. + */ auto onDisconnect = [&](Mqtt::MqttConnection &) { { fprintf(stdout, "Disconnect completed\n"); @@ -167,7 +173,9 @@ int main(int argc, char *argv[]) connection->OnConnectionInterrupted = std::move(onInterrupted); connection->OnConnectionResumed = std::move(onResumed); - // Actually perform the connect dance. + /* + * Actually perform the connect dance. + */ fprintf(stdout, "Connecting...\n"); if (!connection->Connect(clientId.c_str(), false /*cleanSession*/, 1000 /*keepAliveTimeSecs*/)) { @@ -178,7 +186,7 @@ int main(int argc, char *argv[]) if (connectionCompletedPromise.get_future().get()) { // Device defender setup and metric registration - /* ====================================================================== */ + // ====================================================================== Aws::Crt::Allocator *allocator = Aws::Crt::DefaultAllocator(); Aws::Crt::Io::EventLoopGroup *eventLoopGroup = Aws::Crt::ApiHandle::GetOrCreateStaticDefaultEventLoopGroup(); @@ -253,7 +261,7 @@ int main(int argc, char *argv[]) // Stop the task so we stop sending device defender metrics task->StopTask(); - // Disconnect + /* Disconnect */ if (connection->Disconnect()) { connectionClosedPromise.get_future().wait(); diff --git a/samples/greengrass/ipc/main.cpp b/samples/greengrass/ipc/main.cpp index 6f121a37b..c52a75aa0 100644 --- a/samples/greengrass/ipc/main.cpp +++ b/samples/greengrass/ipc/main.cpp @@ -35,7 +35,7 @@ int main(int argc, char *argv[]) String topic = cmdUtils.GetCommandOrDefault("topic", "test/topic"); String message = cmdUtils.GetCommandOrDefault("message", "Hello World"); - /* + /** * Create the default ClientBootstrap, which will create the default * EventLoopGroup (to process IO events) and HostResolver. */ diff --git a/samples/jobs/describe_job_execution/main.cpp b/samples/jobs/describe_job_execution/main.cpp index 5f44fd9d3..3008a215c 100644 --- a/samples/jobs/describe_job_execution/main.cpp +++ b/samples/jobs/describe_job_execution/main.cpp @@ -107,10 +107,8 @@ int main(int argc, char *argv[]) describeJobExecutionSubscriptionRequest.ThingName = thingName; describeJobExecutionSubscriptionRequest.JobId = jobId; - /* - * This isn't absolutely necessary but since we're doing a publish almost immediately afterwards, - * to be cautious make sure the subscribe has finished before doing the publish. - */ + // This isn't absolutely necessary but since we're doing a publish almost immediately afterwards, + // to be cautious make sure the subscribe has finished before doing the publish. std::promise subAckedPromise; auto subAckHandler = [&](int) { /* if error code returns it will be recorded by the other callback */ diff --git a/samples/mqtt/raw_connect/main.cpp b/samples/mqtt/raw_connect/main.cpp index 3f3c5905a..abc83b53d 100644 --- a/samples/mqtt/raw_connect/main.cpp +++ b/samples/mqtt/raw_connect/main.cpp @@ -31,7 +31,7 @@ int main(int argc, char *argv[]) // Valid protocol names are documented on page: // https://docs.aws.amazon.com/iot/latest/developerguide/protocols.html // Use "mqtt" for Custom Authentication - String protocolName("x-amzn-mqtt-ca"); /* X.509 client certificate auth */ + String protocolName("x-amzn-mqtt-ca"); // X.509 client certificate auth Vector authParams; bool useWebSocket = false; diff --git a/samples/secure_tunneling/secure_tunnel/main.cpp b/samples/secure_tunneling/secure_tunnel/main.cpp index f303d21eb..dd133cc1d 100644 --- a/samples/secure_tunneling/secure_tunnel/main.cpp +++ b/samples/secure_tunneling/secure_tunnel/main.cpp @@ -275,7 +275,7 @@ int main(int argc, char *argv[]) else { /*********************** Secure Tunnel Setup ***************************/ - /** + /* * Create a new SecureTunnel using the SecureTunnelBuilder */ secureTunnel = diff --git a/samples/shadow/shadow_sync/main.cpp b/samples/shadow/shadow_sync/main.cpp index 2d053b6ab..0d9675829 100644 --- a/samples/shadow/shadow_sync/main.cpp +++ b/samples/shadow/shadow_sync/main.cpp @@ -307,7 +307,7 @@ int main(int argc, char *argv[]) subscribeDeltaRejectedCompletedPromise.get_future().wait(); // ==================== Shadow Value Get ==================== - // This section is to get the initial value of the Shadow document + // This section is to get the initial value of the Shadow document. std::promise subscribeGetShadowAcceptedCompletedPromise; std::promise subscribeGetShadowRejectedCompletedPromise; diff --git a/samples/utils/CommandLineUtils.cpp b/samples/utils/CommandLineUtils.cpp index bedae57ee..a268c7dfa 100644 --- a/samples/utils/CommandLineUtils.cpp +++ b/samples/utils/CommandLineUtils.cpp @@ -209,7 +209,7 @@ namespace Utils void CommandLineUtils::StartLoggingBasedOnCommand(Aws::Crt::ApiHandle *apiHandle) { - /* Process logging command */ + // Process logging command if (HasCommand("verbosity")) { Aws::Crt::String verbosity = GetCommand(m_cmd_verbosity); From 9257a77f39785700c1f66005aef8cb46440d5036 Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Thu, 29 Sep 2022 13:44:32 -0400 Subject: [PATCH 42/50] Fix ci.yml mistake --- .github/workflows/ci.yml | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ff654057f..74d89333c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,8 +18,8 @@ env: DA_SHADOW_PROPERTY: datest DA_SHADOW_VALUE_SET: ON DA_SHADOW_VALUE_DEFAULT: OFF - CI_FOLDER: D:\a\work - CI_UTILS_FOLDER: ./aws-iot-device-sdk-cpp-v2/utils + CI_FOLDER: "D:/a/work" + CI_UTILS_FOLDER: "./aws-iot-device-sdk-cpp-v2/utils" CI_IOT_CONTAINERS: ${{ secrets.AWS_CI_IOT_CONTAINERS }} CI_PUBSUB_ROLE: ${{ secrets.AWS_CI_PUBSUB_ROLE }} CI_CYCLEPUBSUB_ROLE: ${{ secrets.AWS_CI_CYCLEPUBSUB_ROLE }} @@ -136,7 +136,7 @@ jobs: run: | cd ${{ env.CI_FOLDER }} python -m pip install boto3 - python ${{ CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file '.\aws-iot-device-sdk-cpp-v2\build\samples\pub_sub\basic_pub_sub\RelWithDebInfo\basic-pub-sub.exe' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' + python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file '.\aws-iot-device-sdk-cpp-v2\build\samples\pub_sub\basic_pub_sub\RelWithDebInfo\basic-pub-sub.exe' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' - name: configure AWS credentials (Device Advisor) uses: aws-actions/configure-aws-credentials@v1 with: @@ -171,7 +171,7 @@ jobs: run: | cd ${{ env.CI_FOLDER }} python -m pip install boto3 - python ${{ CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file '.\aws-iot-device-sdk-cpp-v2\build\samples\pub_sub\basic_pub_sub\RelWithDebInfo\basic-pub-sub.exe' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' + python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file '.\aws-iot-device-sdk-cpp-v2\build\samples\pub_sub\basic_pub_sub\RelWithDebInfo\basic-pub-sub.exe' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' - name: configure AWS credentials (Device Advisor) uses: aws-actions/configure-aws-credentials@v1 with: @@ -202,7 +202,7 @@ jobs: run: | cd ${{ env.CI_FOLDER }} python -m pip install boto3 - python ${{ CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file '.\aws-iot-device-sdk-cpp-v2\build\samples\pub_sub\basic_pub_sub\RelWithDebInfo\basic-pub-sub.exe' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' + python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file '.\aws-iot-device-sdk-cpp-v2\build\samples\pub_sub\basic_pub_sub\RelWithDebInfo\basic-pub-sub.exe' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' - name: configure AWS credentials (Device Advisor) uses: aws-actions/configure-aws-credentials@v1 with: @@ -234,7 +234,7 @@ jobs: cd ${{ env.CI_FOLDER }} echo "Starting to run AppVerifier with cycle pub-sub sample" python -m pip install boto3 - python ${{ CI_UTILS_FOLDER }}\appverifier_launch_sample.py --sample_file .\aws-iot-device-sdk-cpp-v2\build\samples\pub_sub\cycle_pub_sub\RelWithDebInfo\cycle-pub-sub.exe --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/CyclePubSub/cert' --sample_secret_private_key 'ci/CyclePubSub/key' + python ${{ env.CI_UTILS_FOLDER }}\appverifier_launch_sample.py --sample_file .\aws-iot-device-sdk-cpp-v2\build\samples\pub_sub\cycle_pub_sub\RelWithDebInfo\cycle-pub-sub.exe --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/CyclePubSub/cert' --sample_secret_private_key 'ci/CyclePubSub/key' osx: runs-on: macos-latest @@ -285,7 +285,7 @@ jobs: - name: run PubSub sample run: | python3 -m pip install boto3 - python3 ${{ CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/pub_sub/basic_pub_sub/basic-pub-sub' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/pub_sub/basic_pub_sub/basic-pub-sub' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' - name: configure AWS credentials (Device Advisor) uses: aws-actions/configure-aws-credentials@v1 with: @@ -335,13 +335,13 @@ jobs: - name: run Basic Connect sample run: | python3 -m pip install boto3 - python3 ${{ CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/mqtt/basic_connect/basic-connect' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/mqtt/basic_connect/basic-connect' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' - name: run Websocket Connect sample run: | - python3 ${{ CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/mqtt/websocket_connect/websocket-connect' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_arguments '--signing_region us-east-1' + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/mqtt/websocket_connect/websocket-connect' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_arguments '--signing_region us-east-1' - name: run PubSub sample run: | - python3 ${{ CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/pub_sub/basic_pub_sub/basic-pub-sub' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/pub_sub/basic_pub_sub/basic-pub-sub' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' - name: run PKCS11 Connect sample run: | sudo apt-get update -y @@ -350,7 +350,7 @@ jobs: mkdir -p /tmp/tokens export SOFTHSM2_CONF=/tmp/softhsm2.conf echo "directories.tokendir = /tmp/tokens" > /tmp/softhsm2.conf - python3 ${{ CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/mqtt/pkcs11_connect/pkcs11-connect' --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' + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/mqtt/pkcs11_connect/pkcs11-connect' --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' - name: configure AWS credentials (Custom Authorizer) uses: aws-actions/configure-aws-credentials@v1 with: @@ -358,7 +358,7 @@ jobs: aws-region: ${{ env.AWS_DEFAULT_REGION }} - name: run CustomAuthorizerConnect sample run: | - python3 ${{ CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/mqtt/custom_authorizer_connect/custom-authorizer-connect' --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' + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/mqtt/custom_authorizer_connect/custom-authorizer-connect' --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' - name: configure AWS credentials (Shadow) uses: aws-actions/configure-aws-credentials@v1 with: @@ -366,7 +366,7 @@ jobs: aws-region: ${{ env.AWS_DEFAULT_REGION }} - name: run Shadow sample run: | - python3 ${{ CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/shadow/shadow_sync/shadow-sync' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/Shadow/cert' --sample_secret_private_key 'ci/Shadow/key' --sample_arguments '--thing_name CI_Shadow_Thing --shadow_property color --is_ci true' + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/shadow/shadow_sync/shadow-sync' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/Shadow/cert' --sample_secret_private_key 'ci/Shadow/key' --sample_arguments '--thing_name CI_Shadow_Thing --shadow_property color --is_ci true' - name: configure AWS credentials (Jobs) uses: aws-actions/configure-aws-credentials@v1 with: @@ -374,7 +374,7 @@ jobs: aws-region: ${{ env.AWS_DEFAULT_REGION }} - name: run Jobs sample run: | - python3 ${{ CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/jobs/describe_job_execution/describe-job-execution' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/Jobs/cert' --sample_secret_private_key 'ci/Jobs/key' --sample_arguments '--thing_name CI_Jobs_Thing --job_id CI_Jobs_Thing_Job_1' + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/jobs/describe_job_execution/describe-job-execution' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/Jobs/cert' --sample_secret_private_key 'ci/Jobs/key' --sample_arguments '--thing_name CI_Jobs_Thing --job_id CI_Jobs_Thing_Job_1' - name: configure AWS credentials (Fleet provisioning) uses: aws-actions/configure-aws-credentials@v1 with: @@ -384,8 +384,8 @@ jobs: run: | echo "Generating UUID for IoT thing" Sample_UUID=$(python3 -c "import uuid; print (uuid.uuid4())") - python3 ${{ CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/identity/fleet_provisioning/fleet-provisioning' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/FleetProvisioning/cert' --sample_secret_private_key 'ci/FleetProvisioning/key' --sample_arguments "--template_name CI_FleetProvisioning_Template --template_parameters {\"SerialNumber\":\"${Sample_UUID}\"}" - python3 ${{ CI_UTILS_FOLDER }}/delete_iot_thing_ci.py --thing_name "Fleet_Thing_${Sample_UUID}" --region "us-east-1" + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/identity/fleet_provisioning/fleet-provisioning' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/FleetProvisioning/cert' --sample_secret_private_key 'ci/FleetProvisioning/key' --sample_arguments "--template_name CI_FleetProvisioning_Template --template_parameters {\"SerialNumber\":\"${Sample_UUID}\"}" + python3 ${{ env.CI_UTILS_FOLDER }}/delete_iot_thing_ci.py --thing_name "Fleet_Thing_${Sample_UUID}" --region "us-east-1" - name: configure AWS credentials (Secure tunneling) uses: aws-actions/configure-aws-credentials@v1 with: @@ -393,7 +393,7 @@ jobs: aws-region: ${{ env.AWS_DEFAULT_REGION }} - name: run Secure Tunneling sample run: | - python3 ${{ CI_UTILS_FOLDER }}/run_secure_tunnel_ci.py --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/secure_tunneling/secure_tunnel/secure-tunnel' --sample_region ${{ env.AWS_DEFAULT_REGION }} + python3 ${{ env.CI_UTILS_FOLDER }}/run_secure_tunnel_ci.py --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/secure_tunneling/secure_tunnel/secure-tunnel' --sample_region ${{ env.AWS_DEFAULT_REGION }} # check that docs can still build check-docs: From 488c6f12a4904db971a11c1120396821cab16b56 Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Thu, 29 Sep 2022 13:59:01 -0400 Subject: [PATCH 43/50] Use environment variable for samples folder --- .github/workflows/ci.yml | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 74d89333c..763843af1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,6 +20,7 @@ env: DA_SHADOW_VALUE_DEFAULT: OFF CI_FOLDER: "D:/a/work" CI_UTILS_FOLDER: "./aws-iot-device-sdk-cpp-v2/utils" + CI_SAMPLES_FOLDER: "./aws-iot-device-sdk-cpp-v2/build/samples" CI_IOT_CONTAINERS: ${{ secrets.AWS_CI_IOT_CONTAINERS }} CI_PUBSUB_ROLE: ${{ secrets.AWS_CI_PUBSUB_ROLE }} CI_CYCLEPUBSUB_ROLE: ${{ secrets.AWS_CI_CYCLEPUBSUB_ROLE }} @@ -202,7 +203,7 @@ jobs: run: | cd ${{ env.CI_FOLDER }} python -m pip install boto3 - python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file '.\aws-iot-device-sdk-cpp-v2\build\samples\pub_sub\basic_pub_sub\RelWithDebInfo\basic-pub-sub.exe' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' + python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file "${{ CI_SAMPLES_FOLDER }}\pub_sub\basic_pub_sub\RelWithDebInfo\basic-pub-sub.exe" --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' - name: configure AWS credentials (Device Advisor) uses: aws-actions/configure-aws-credentials@v1 with: @@ -234,7 +235,7 @@ jobs: cd ${{ env.CI_FOLDER }} echo "Starting to run AppVerifier with cycle pub-sub sample" python -m pip install boto3 - python ${{ env.CI_UTILS_FOLDER }}\appverifier_launch_sample.py --sample_file .\aws-iot-device-sdk-cpp-v2\build\samples\pub_sub\cycle_pub_sub\RelWithDebInfo\cycle-pub-sub.exe --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/CyclePubSub/cert' --sample_secret_private_key 'ci/CyclePubSub/key' + python ${{ env.CI_UTILS_FOLDER }}\appverifier_launch_sample.py --sample_file "${{ CI_SAMPLES_FOLDER }}\pub_sub\cycle_pub_sub\RelWithDebInfo\cycle-pub-sub.exe" --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/CyclePubSub/cert' --sample_secret_private_key 'ci/CyclePubSub/key' osx: runs-on: macos-latest @@ -254,7 +255,7 @@ jobs: - name: run PubSub sample run: | python3 -m pip install boto3 - python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/pub_sub/basic_pub_sub/basic-pub-sub' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' + python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file "${{ CI_SAMPLES_FOLDER }}/pub_sub/basic_pub_sub/basic-pub-sub" --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' - name: configure AWS credentials (Device Advisor) uses: aws-actions/configure-aws-credentials@v1 with: @@ -285,7 +286,7 @@ jobs: - name: run PubSub sample run: | python3 -m pip install boto3 - python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/pub_sub/basic_pub_sub/basic-pub-sub' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file "${{ CI_SAMPLES_FOLDER }}/pub_sub/basic_pub_sub/basic-pub-sub" --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' - name: configure AWS credentials (Device Advisor) uses: aws-actions/configure-aws-credentials@v1 with: @@ -335,13 +336,13 @@ jobs: - name: run Basic Connect sample run: | python3 -m pip install boto3 - python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/mqtt/basic_connect/basic-connect' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file "${{ CI_SAMPLES_FOLDER }}/mqtt/basic_connect/basic-connect" --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' - name: run Websocket Connect sample run: | - python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/mqtt/websocket_connect/websocket-connect' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_arguments '--signing_region us-east-1' + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file "${{ CI_SAMPLES_FOLDER }}/mqtt/websocket_connect/websocket-connect" --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_arguments '--signing_region us-east-1' - name: run PubSub sample run: | - python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/pub_sub/basic_pub_sub/basic-pub-sub' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file "${{ CI_SAMPLES_FOLDER }}/pub_sub/basic_pub_sub/basic-pub-sub" --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' - name: run PKCS11 Connect sample run: | sudo apt-get update -y @@ -350,7 +351,7 @@ jobs: mkdir -p /tmp/tokens export SOFTHSM2_CONF=/tmp/softhsm2.conf echo "directories.tokendir = /tmp/tokens" > /tmp/softhsm2.conf - python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/mqtt/pkcs11_connect/pkcs11-connect' --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' + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file "${{ CI_SAMPLES_FOLDER }}/mqtt/pkcs11_connect/pkcs11-connect" --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' - name: configure AWS credentials (Custom Authorizer) uses: aws-actions/configure-aws-credentials@v1 with: @@ -358,7 +359,7 @@ jobs: aws-region: ${{ env.AWS_DEFAULT_REGION }} - name: run CustomAuthorizerConnect sample run: | - python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/mqtt/custom_authorizer_connect/custom-authorizer-connect' --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' + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file "${{ CI_SAMPLES_FOLDER }}/mqtt/custom_authorizer_connect/custom-authorizer-connect" --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' - name: configure AWS credentials (Shadow) uses: aws-actions/configure-aws-credentials@v1 with: @@ -366,7 +367,7 @@ jobs: aws-region: ${{ env.AWS_DEFAULT_REGION }} - name: run Shadow sample run: | - python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/shadow/shadow_sync/shadow-sync' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/Shadow/cert' --sample_secret_private_key 'ci/Shadow/key' --sample_arguments '--thing_name CI_Shadow_Thing --shadow_property color --is_ci true' + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file "${{ CI_SAMPLES_FOLDER }}/shadow/shadow_sync/shadow-sync" --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/Shadow/cert' --sample_secret_private_key 'ci/Shadow/key' --sample_arguments '--thing_name CI_Shadow_Thing --shadow_property color --is_ci true' - name: configure AWS credentials (Jobs) uses: aws-actions/configure-aws-credentials@v1 with: @@ -374,7 +375,7 @@ jobs: aws-region: ${{ env.AWS_DEFAULT_REGION }} - name: run Jobs sample run: | - python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/jobs/describe_job_execution/describe-job-execution' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/Jobs/cert' --sample_secret_private_key 'ci/Jobs/key' --sample_arguments '--thing_name CI_Jobs_Thing --job_id CI_Jobs_Thing_Job_1' + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file "${{ CI_SAMPLES_FOLDER }}/jobs/describe_job_execution/describe-job-execution" --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/Jobs/cert' --sample_secret_private_key 'ci/Jobs/key' --sample_arguments '--thing_name CI_Jobs_Thing --job_id CI_Jobs_Thing_Job_1' - name: configure AWS credentials (Fleet provisioning) uses: aws-actions/configure-aws-credentials@v1 with: @@ -384,7 +385,7 @@ jobs: run: | echo "Generating UUID for IoT thing" Sample_UUID=$(python3 -c "import uuid; print (uuid.uuid4())") - python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/identity/fleet_provisioning/fleet-provisioning' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/FleetProvisioning/cert' --sample_secret_private_key 'ci/FleetProvisioning/key' --sample_arguments "--template_name CI_FleetProvisioning_Template --template_parameters {\"SerialNumber\":\"${Sample_UUID}\"}" + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file "${{ CI_SAMPLES_FOLDER }}/identity/fleet_provisioning/fleet-provisioning" --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/FleetProvisioning/cert' --sample_secret_private_key 'ci/FleetProvisioning/key' --sample_arguments "--template_name CI_FleetProvisioning_Template --template_parameters {\"SerialNumber\":\"${Sample_UUID}\"}" python3 ${{ env.CI_UTILS_FOLDER }}/delete_iot_thing_ci.py --thing_name "Fleet_Thing_${Sample_UUID}" --region "us-east-1" - name: configure AWS credentials (Secure tunneling) uses: aws-actions/configure-aws-credentials@v1 @@ -393,7 +394,7 @@ jobs: aws-region: ${{ env.AWS_DEFAULT_REGION }} - name: run Secure Tunneling sample run: | - python3 ${{ env.CI_UTILS_FOLDER }}/run_secure_tunnel_ci.py --sample_file './aws-iot-device-sdk-cpp-v2/build/samples/secure_tunneling/secure_tunnel/secure-tunnel' --sample_region ${{ env.AWS_DEFAULT_REGION }} + python3 ${{ env.CI_UTILS_FOLDER }}/run_secure_tunnel_ci.py --sample_file "${{ CI_SAMPLES_FOLDER }}/secure_tunneling/secure_tunnel/secure-tunnel" --sample_region ${{ env.AWS_DEFAULT_REGION }} # check that docs can still build check-docs: From ef690d7db1e2f471db018009c7c6435e04a8c490 Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Thu, 29 Sep 2022 14:04:29 -0400 Subject: [PATCH 44/50] Forgot to add .env --- .github/workflows/ci.yml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 763843af1..99343e9b6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -203,7 +203,7 @@ jobs: run: | cd ${{ env.CI_FOLDER }} python -m pip install boto3 - python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file "${{ CI_SAMPLES_FOLDER }}\pub_sub\basic_pub_sub\RelWithDebInfo\basic-pub-sub.exe" --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' + python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file "${{ env.CI_SAMPLES_FOLDER }}\pub_sub\basic_pub_sub\RelWithDebInfo\basic-pub-sub.exe" --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' - name: configure AWS credentials (Device Advisor) uses: aws-actions/configure-aws-credentials@v1 with: @@ -235,7 +235,7 @@ jobs: cd ${{ env.CI_FOLDER }} echo "Starting to run AppVerifier with cycle pub-sub sample" python -m pip install boto3 - python ${{ env.CI_UTILS_FOLDER }}\appverifier_launch_sample.py --sample_file "${{ CI_SAMPLES_FOLDER }}\pub_sub\cycle_pub_sub\RelWithDebInfo\cycle-pub-sub.exe" --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/CyclePubSub/cert' --sample_secret_private_key 'ci/CyclePubSub/key' + python ${{ env.CI_UTILS_FOLDER }}\appverifier_launch_sample.py --sample_file "${{ env.CI_SAMPLES_FOLDER }}\pub_sub\cycle_pub_sub\RelWithDebInfo\cycle-pub-sub.exe" --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/CyclePubSub/cert' --sample_secret_private_key 'ci/CyclePubSub/key' osx: runs-on: macos-latest @@ -255,7 +255,7 @@ jobs: - name: run PubSub sample run: | python3 -m pip install boto3 - python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file "${{ CI_SAMPLES_FOLDER }}/pub_sub/basic_pub_sub/basic-pub-sub" --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' + python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file "${{ env.CI_SAMPLES_FOLDER }}/pub_sub/basic_pub_sub/basic-pub-sub" --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' - name: configure AWS credentials (Device Advisor) uses: aws-actions/configure-aws-credentials@v1 with: @@ -286,7 +286,7 @@ jobs: - name: run PubSub sample run: | python3 -m pip install boto3 - python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file "${{ CI_SAMPLES_FOLDER }}/pub_sub/basic_pub_sub/basic-pub-sub" --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file "${{ env.CI_SAMPLES_FOLDER }}/pub_sub/basic_pub_sub/basic-pub-sub" --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' - name: configure AWS credentials (Device Advisor) uses: aws-actions/configure-aws-credentials@v1 with: @@ -336,13 +336,13 @@ jobs: - name: run Basic Connect sample run: | python3 -m pip install boto3 - python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file "${{ CI_SAMPLES_FOLDER }}/mqtt/basic_connect/basic-connect" --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file "${{ env.CI_SAMPLES_FOLDER }}/mqtt/basic_connect/basic-connect" --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' - name: run Websocket Connect sample run: | - python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file "${{ CI_SAMPLES_FOLDER }}/mqtt/websocket_connect/websocket-connect" --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_arguments '--signing_region us-east-1' + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file "${{ env.CI_SAMPLES_FOLDER }}/mqtt/websocket_connect/websocket-connect" --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_arguments '--signing_region us-east-1' - name: run PubSub sample run: | - python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file "${{ CI_SAMPLES_FOLDER }}/pub_sub/basic_pub_sub/basic-pub-sub" --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file "${{ env.CI_SAMPLES_FOLDER }}/pub_sub/basic_pub_sub/basic-pub-sub" --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' - name: run PKCS11 Connect sample run: | sudo apt-get update -y @@ -351,7 +351,7 @@ jobs: mkdir -p /tmp/tokens export SOFTHSM2_CONF=/tmp/softhsm2.conf echo "directories.tokendir = /tmp/tokens" > /tmp/softhsm2.conf - python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file "${{ CI_SAMPLES_FOLDER }}/mqtt/pkcs11_connect/pkcs11-connect" --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' + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file "${{ env.CI_SAMPLES_FOLDER }}/mqtt/pkcs11_connect/pkcs11-connect" --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' - name: configure AWS credentials (Custom Authorizer) uses: aws-actions/configure-aws-credentials@v1 with: @@ -359,7 +359,7 @@ jobs: aws-region: ${{ env.AWS_DEFAULT_REGION }} - name: run CustomAuthorizerConnect sample run: | - python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file "${{ CI_SAMPLES_FOLDER }}/mqtt/custom_authorizer_connect/custom-authorizer-connect" --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' + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file "${{ env.CI_SAMPLES_FOLDER }}/mqtt/custom_authorizer_connect/custom-authorizer-connect" --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' - name: configure AWS credentials (Shadow) uses: aws-actions/configure-aws-credentials@v1 with: @@ -367,7 +367,7 @@ jobs: aws-region: ${{ env.AWS_DEFAULT_REGION }} - name: run Shadow sample run: | - python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file "${{ CI_SAMPLES_FOLDER }}/shadow/shadow_sync/shadow-sync" --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/Shadow/cert' --sample_secret_private_key 'ci/Shadow/key' --sample_arguments '--thing_name CI_Shadow_Thing --shadow_property color --is_ci true' + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file "${{ env.CI_SAMPLES_FOLDER }}/shadow/shadow_sync/shadow-sync" --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/Shadow/cert' --sample_secret_private_key 'ci/Shadow/key' --sample_arguments '--thing_name CI_Shadow_Thing --shadow_property color --is_ci true' - name: configure AWS credentials (Jobs) uses: aws-actions/configure-aws-credentials@v1 with: @@ -375,7 +375,7 @@ jobs: aws-region: ${{ env.AWS_DEFAULT_REGION }} - name: run Jobs sample run: | - python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file "${{ CI_SAMPLES_FOLDER }}/jobs/describe_job_execution/describe-job-execution" --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/Jobs/cert' --sample_secret_private_key 'ci/Jobs/key' --sample_arguments '--thing_name CI_Jobs_Thing --job_id CI_Jobs_Thing_Job_1' + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file "${{ env.CI_SAMPLES_FOLDER }}/jobs/describe_job_execution/describe-job-execution" --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/Jobs/cert' --sample_secret_private_key 'ci/Jobs/key' --sample_arguments '--thing_name CI_Jobs_Thing --job_id CI_Jobs_Thing_Job_1' - name: configure AWS credentials (Fleet provisioning) uses: aws-actions/configure-aws-credentials@v1 with: @@ -385,7 +385,7 @@ jobs: run: | echo "Generating UUID for IoT thing" Sample_UUID=$(python3 -c "import uuid; print (uuid.uuid4())") - python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file "${{ CI_SAMPLES_FOLDER }}/identity/fleet_provisioning/fleet-provisioning" --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/FleetProvisioning/cert' --sample_secret_private_key 'ci/FleetProvisioning/key' --sample_arguments "--template_name CI_FleetProvisioning_Template --template_parameters {\"SerialNumber\":\"${Sample_UUID}\"}" + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file "${{ env.CI_SAMPLES_FOLDER }}/identity/fleet_provisioning/fleet-provisioning" --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/FleetProvisioning/cert' --sample_secret_private_key 'ci/FleetProvisioning/key' --sample_arguments "--template_name CI_FleetProvisioning_Template --template_parameters {\"SerialNumber\":\"${Sample_UUID}\"}" python3 ${{ env.CI_UTILS_FOLDER }}/delete_iot_thing_ci.py --thing_name "Fleet_Thing_${Sample_UUID}" --region "us-east-1" - name: configure AWS credentials (Secure tunneling) uses: aws-actions/configure-aws-credentials@v1 @@ -394,7 +394,7 @@ jobs: aws-region: ${{ env.AWS_DEFAULT_REGION }} - name: run Secure Tunneling sample run: | - python3 ${{ env.CI_UTILS_FOLDER }}/run_secure_tunnel_ci.py --sample_file "${{ CI_SAMPLES_FOLDER }}/secure_tunneling/secure_tunnel/secure-tunnel" --sample_region ${{ env.AWS_DEFAULT_REGION }} + python3 ${{ env.CI_UTILS_FOLDER }}/run_secure_tunnel_ci.py --sample_file "${{ env.CI_SAMPLES_FOLDER }}/secure_tunneling/secure_tunnel/secure-tunnel" --sample_region ${{ env.AWS_DEFAULT_REGION }} # check that docs can still build check-docs: From d2620ce53201b38cb66175b6c334b960eafe8a08 Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Thu, 29 Sep 2022 15:50:43 -0400 Subject: [PATCH 45/50] Attach policy to DeviceAdvisor thing, fix secret value getting --- deviceadvisor/script/DATestRun.py | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/deviceadvisor/script/DATestRun.py b/deviceadvisor/script/DATestRun.py index 64b3f2827..2e504e033 100644 --- a/deviceadvisor/script/DATestRun.py +++ b/deviceadvisor/script/DATestRun.py @@ -37,7 +37,7 @@ def process_logs(log_group, log_stream, thing_name): try: secrets_client = boto3.client( "secretsmanager", region_name=os.environ["AWS_DEFAULT_REGION"]) - s3_bucket_name = secrets_client.get_secret_value("ci/DeviceAdvisor/s3bucket")["SecretString"] + s3_bucket_name = secrets_client.get_secret_value(SecretId="ci/DeviceAdvisor/s3bucket")["SecretString"] s3.Bucket(s3_bucket_name).upload_file(log_file, log_file) print("[Device Advisor] Device Advisor Log file uploaded to "+ log_file) @@ -151,6 +151,25 @@ def sleep_with_backoff(base, max): print("[Device Advisor] Error: Failed to create certificate.") exit(-1) + certificate_arn = create_cert_response['certificateArn'] + certificate_id = create_cert_response['certificateId'] + + ############################################## + # attach policy to certificate + try: + secrets_client = boto3.client( + "secretsmanager", region_name=os.environ["AWS_DEFAULT_REGION"]) + policy_name = secrets_client.get_secret_value(SecretId="ci/DeviceAdvisor/policy_name")["SecretString"] + client.attach_policy ( + policyName= policy_name, + target = certificate_arn + ) + except Exception as ex: + print (ex) + delete_thing_with_certi(thing_name, certificate_id, certificate_arn ) + print("[Device Advisor] Error: Failed to attach policy.") + exit(-1) + ############################################## # attach certification to thing try: @@ -161,9 +180,6 @@ def sleep_with_backoff(base, max): principal = create_cert_response['certificateArn'] ) - certificate_arn = create_cert_response['certificateArn'] - certificate_id = create_cert_response['certificateId'] - except Exception: delete_thing_with_certi(thing_name, certificate_id ,certificate_arn ) print("[Device Advisor]Error: Failed to attach certificate.") From fd44f1af68f5e3f4ea45025df84cf6cfcbb21dee Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Fri, 30 Sep 2022 16:51:27 -0400 Subject: [PATCH 46/50] Sync run_sample_ci --- utils/run_sample_ci.py | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/utils/run_sample_ci.py b/utils/run_sample_ci.py index 1b5e06540..cb50560d3 100644 --- a/utils/run_sample_ci.py +++ b/utils/run_sample_ci.py @@ -144,14 +144,37 @@ def launch_sample(parsed_commands, sample_endpoint, sample_certificate, sample_p elif (parsed_commands.language == "Javascript"): os.chdir(parsed_commands.sample_file) - sample_return_one = subprocess.run(args=["npm", "install"]) - if (sample_return_one.returncode != 0): + + launch_arguments.append("--is_ci") + launch_arguments.append("true") + + sample_return_one = None + if sys.platform == "win32" or sys.platform == "cygwin": + sample_return_one = subprocess.run(args=["npm", "install"], shell=True) + else: + sample_return_one = subprocess.run(args=["npm", "install"]) + + if (sample_return_one == None or sample_return_one.returncode != 0): exit_code = sample_return_one.returncode else: - arguments = ["node", "dist/index.js"] - sample_return_two = subprocess.run( - args=arguments + launch_arguments) - exit_code = sample_return_two.returncode + sample_return_two = None + arguments = [] + if (parsed_commands.node_cmd == "" or parsed_commands.node_cmd == None): + arguments = ["node", "dist/index.js"] + else: + arguments = parsed_commands.node_cmd.split(" ") + + if sys.platform == "win32" or sys.platform == "cygwin": + sample_return_two = subprocess.run( + args=arguments + launch_arguments, shell=True) + else: + sample_return_two = subprocess.run( + args=arguments + launch_arguments) + + if (sample_return_two != None): + exit_code = sample_return_two.returncode + else: + exit_code = 1 else: print("ERROR - unknown programming language! Supported programming languages are 'Java', 'CPP', 'Python', and 'Javascript'") @@ -188,6 +211,8 @@ def main(): help="Arguments to pass to sample. In Java, these arguments will be in a double quote (\") string") argument_parser.add_argument("--sample_main_class", metavar="", required=False, default="", help="Java only: The main class to run") + argument_parser.add_argument("--node_cmd", metavar="", required=False, default="", + help="Javascript only: Overrides the default 'npm dist/index.js' with whatever you pass. Useful for launching pure Javascript samples") parsed_commands = argument_parser.parse_args() From 1bc22f3541ec09418c05a137b162799e35d62cd4 Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Mon, 3 Oct 2022 18:06:34 -0400 Subject: [PATCH 47/50] Run Windows Cert Connect in CI --- .github/workflows/ci.yml | 12 +++ utils/run_sample_ci.py | 183 ++++++++++++++++++++++++++++++++------- 2 files changed, 165 insertions(+), 30 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 99343e9b6..2b7455a1e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -138,6 +138,10 @@ jobs: cd ${{ env.CI_FOLDER }} python -m pip install boto3 python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file '.\aws-iot-device-sdk-cpp-v2\build\samples\pub_sub\basic_pub_sub\RelWithDebInfo\basic-pub-sub.exe' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' + - name: run Windows Connect + run: | + cd ${{ env.CI_FOLDER }} + python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file "${{ env.CI_SAMPLES_FOLDER }}\mqtt\windows_cert_connect\RelWithDebInfo\windows-cert-connect.exe" --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 - name: configure AWS credentials (Device Advisor) uses: aws-actions/configure-aws-credentials@v1 with: @@ -173,6 +177,10 @@ jobs: cd ${{ env.CI_FOLDER }} python -m pip install boto3 python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file '.\aws-iot-device-sdk-cpp-v2\build\samples\pub_sub\basic_pub_sub\RelWithDebInfo\basic-pub-sub.exe' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' + - name: run Windows Connect + run: | + cd ${{ env.CI_FOLDER }} + python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file "${{ env.CI_SAMPLES_FOLDER }}\mqtt\windows_cert_connect\RelWithDebInfo\windows-cert-connect.exe" --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 - name: configure AWS credentials (Device Advisor) uses: aws-actions/configure-aws-credentials@v1 with: @@ -204,6 +212,10 @@ jobs: cd ${{ env.CI_FOLDER }} python -m pip install boto3 python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file "${{ env.CI_SAMPLES_FOLDER }}\pub_sub\basic_pub_sub\RelWithDebInfo\basic-pub-sub.exe" --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' + - name: run Windows Connect + run: | + cd ${{ env.CI_FOLDER }} + python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file "${{ env.CI_SAMPLES_FOLDER }}\mqtt\windows_cert_connect\RelWithDebInfo\windows-cert-connect.exe" --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 - name: configure AWS credentials (Device Advisor) uses: aws-actions/configure-aws-credentials@v1 with: diff --git a/utils/run_sample_ci.py b/utils/run_sample_ci.py index cb50560d3..34d389290 100644 --- a/utils/run_sample_ci.py +++ b/utils/run_sample_ci.py @@ -10,15 +10,24 @@ # Needs to be installed via pip import boto3 # - for launching sample - -current_folder = pathlib.Path(__file__).resolve() +current_folder = os.path.dirname(pathlib.Path(__file__).resolve()) +if sys.platform == "win32" or sys.platform == "cygwin": + current_folder += "\\" +else: + current_folder += "/" tmp_certificate_file_path = str(current_folder) + "tmp_certificate.pem" tmp_private_key_path = str(current_folder) + "tmp_privatekey.pem.key" +tmp_pfx_file_path = str(current_folder) + "tmp_pfx_certificate.pfx" +tmp_pfx_certificate_path = "" +tmp_pfx_certificate_store_location = "CurrentUser\\My" +tmp_pfx_password = "" # Setting a password causes issues, but an empty string is valid so we use that -def getSecretsAndLaunch(parsed_commands): +def get_secrets_and_launch(parsed_commands): global tmp_certificate_file_path global tmp_private_key_path + global tmp_pfx_file_path + global tmp_pfx_certificate_path exit_code = 0 sample_endpoint = "" sample_certificate = "" @@ -26,10 +35,6 @@ def getSecretsAndLaunch(parsed_commands): sample_custom_authorizer_name = "" sample_custom_authorizer_password = "" - current_folder = pathlib.Path(__file__).resolve() - # Remove the name of the python file - current_folder = str(current_folder).replace("run_sample_ci.py", "") - print("Attempting to get credentials from secrets using Boto3...") secrets_client = boto3.client( "secretsmanager", region_name=parsed_commands.sample_region) @@ -38,17 +43,19 @@ def getSecretsAndLaunch(parsed_commands): sample_endpoint = secrets_client.get_secret_value( SecretId=parsed_commands.sample_secret_endpoint)["SecretString"] if (parsed_commands.sample_secret_certificate != ""): - sample_certificate = secrets_client.get_secret_value( + secret_data = secrets_client.get_secret_value( SecretId=parsed_commands.sample_secret_certificate) with open(tmp_certificate_file_path, "w") as file: # lgtm [py/clear-text-storage-sensitive-data] - file.write(sample_certificate["SecretString"]) + file.write(secret_data["SecretString"]) + sample_certificate = tmp_certificate_file_path if (parsed_commands.sample_secret_private_key != ""): - sample_private_key = secrets_client.get_secret_value( + secret_data = secrets_client.get_secret_value( SecretId=parsed_commands.sample_secret_private_key) with open(tmp_private_key_path, "w") as file: # lgtm [py/clear-text-storage-sensitive-data] - file.write(sample_private_key["SecretString"]) + file.write(secret_data["SecretString"]) + sample_private_key = tmp_private_key_path if (parsed_commands.sample_secret_custom_authorizer_name != ""): sample_custom_authorizer_name = secrets_client.get_secret_value( SecretId=parsed_commands.sample_secret_custom_authorizer_name)["SecretString"] @@ -59,44 +66,157 @@ def getSecretsAndLaunch(parsed_commands): except Exception: sys.exit("ERROR: Could not get secrets to launch sample!") + extra_step_return = 0 if (parsed_commands.sample_run_softhsm != ""): - print ("Setting up private key via SoftHSM") - subprocess.run("softhsm2-util --init-token --free --label my-token --pin 0000 --so-pin 0000", shell=True) - subprocess.run(f"softhsm2-util --import {tmp_private_key_path} --token my-token --label my-key --id BEEFCAFE --pin 0000", shell=True) - print ("Finished setting up private key in SoftHSM") - - print("Launching sample...") - exit_code = launch_sample(parsed_commands, sample_endpoint, sample_certificate, - sample_private_key, sample_custom_authorizer_name, sample_custom_authorizer_password) + extra_step_return = make_softhsm_key() + sample_private_key = "" # Do not use the private key + if (parsed_commands.sample_run_certutil != ""): + extra_step_return = make_windows_pfx_file() + sample_private_key = "" # Do not use the private key + sample_certificate = tmp_pfx_certificate_path # use the Windows certificate path + + exit_code = extra_step_return + if (extra_step_return == 0): + print("Launching sample...") + exit_code = launch_sample(parsed_commands, sample_endpoint, sample_certificate, + sample_private_key, sample_custom_authorizer_name, sample_custom_authorizer_password) + + if (exit_code == 0): + print("SUCCESS: Finished running sample! Exiting with success") + else: + print("ERROR: Sample did not return success! Exit code " + str(exit_code)) + else: + print ("ERROR: Could not run extra step (SoftHSM, CertUtil, etc)") print("Deleting files...") - if (sample_certificate != ""): + if (os.path.isfile(tmp_certificate_file_path)): os.remove(tmp_certificate_file_path) - if (sample_private_key != ""): + if (os.path.isfile(tmp_private_key_path)): os.remove(tmp_private_key_path) + if (os.path.isfile(tmp_pfx_file_path)): + os.remove(tmp_pfx_file_path) - if (exit_code == 0): - print("SUCCESS: Finished running sample! Exiting with success") - else: - print("ERROR: Sample did not return success! Exit code " + str(exit_code)) return exit_code +def make_softhsm_key(): + print ("Setting up private key via SoftHSM") + softhsm_run = subprocess.run("softhsm2-util --init-token --free --label my-token --pin 0000 --so-pin 0000", shell=True) + if (softhsm_run.returncode != 0): + print ("ERROR: SoftHSM could not initialize a new token") + return softhsm_run.returncode + softhsm_run = subprocess.run(f"softhsm2-util --import {tmp_private_key_path} --token my-token --label my-key --id BEEFCAFE --pin 0000", shell=True) + if (softhsm_run.returncode != 0): + print ("ERROR: SoftHSM could not import token") + print ("Finished setting up private key in SoftHSM") + return 0 + + +def make_windows_pfx_file(): + global tmp_certificate_file_path + global tmp_private_key_path + global tmp_pfx_file_path + global tmp_pfx_certificate_path + + if sys.platform == "win32" or sys.platform == "cygwin": + if os.path.isfile(tmp_certificate_file_path) != True: + print (tmp_certificate_file_path) + print("ERROR: Certificate file not found!") + return 1 + if os.path.isfile(tmp_private_key_path) != True: + print("ERROR: Private key file not found!") + return 1 + + # Delete old PFX file if it exists + if os.path.isfile(tmp_pfx_file_path): + os.remove(tmp_pfx_file_path) + + # Make a key copy + copy_path = os.path.splitext(tmp_certificate_file_path) + with open(copy_path[0] + ".key", 'w') as file: + key_file = open(tmp_private_key_path) + file.write(key_file.read()) + key_file.close() + + # Make a PFX file + certutil_error_occurred = False + arguments = ["certutil", "-mergePFX", tmp_certificate_file_path, tmp_pfx_file_path] + certutil_run = subprocess.run(args=arguments, shell=True, input=f"{tmp_pfx_password}\n{tmp_pfx_password}", encoding='ascii') + if (certutil_run.returncode != 0): + print ("ERROR: Could not make PFX file") + certutil_error_occurred = True + return 1 + else: + print ("PFX file created successfully") + + # Remove the temporary key copy + if os.path.isfile(copy_path[0] + ".key"): + os.remove(copy_path[0] + ".key") + if (certutil_error_occurred == True): + return 1 + + # Import the PFX into the Windows Certificate Store + # (Passing '$mypwd' is required even though it is empty and our certificate has no password. It fails CI otherwise) + import_pfx_arguments = ["powershell.exe", "Import-PfxCertificate", "-FilePath", tmp_pfx_file_path, "-CertStoreLocation", "Cert:\\" + tmp_pfx_certificate_store_location, "-Password", "$mypwd"] + import_pfx_run = subprocess.run(args=import_pfx_arguments, shell=True, stdout=subprocess.PIPE) + if (import_pfx_run.returncode != 0): + print ("ERROR: Could not import PFX certificate into Windows store!") + return 1 + else: + print ("Certificate imported to Windows Certificate Store successfully") + + # Get the certificate thumbprint from the output: + import_pfx_output = str(import_pfx_run.stdout) + # We know the Thumbprint will always be 40 characters long, so we can find it using that + # TODO: Extract this using a better method + thumbprint = "" + current_str = "" + # The input comes as a string with some special characters still included, so we need to remove them! + import_pfx_output = import_pfx_output.replace("\\r", " ") + import_pfx_output = import_pfx_output.replace("\\n", "\n") + for i in range(0, len(import_pfx_output)): + if (import_pfx_output[i] == " " or import_pfx_output[i] == "\n"): + if (len(current_str) == 40): + thumbprint = current_str + break + current_str = "" + else: + current_str += import_pfx_output[i] + + # Did we get a thumbprint? + if (thumbprint == ""): + print ("ERROR: Could not find certificate thumbprint") + return 1 + + # Construct the certificate path + tmp_pfx_certificate_path = tmp_pfx_certificate_store_location + "\\" + thumbprint + + # Return success + print ("PFX certificate created and imported successfully!") + return 0 + + else: + print("ERROR - Windows PFX file can only be created on a Windows platform!") + return 1 + + def launch_sample(parsed_commands, sample_endpoint, sample_certificate, sample_private_key, sample_custom_authorizer_name, sample_custom_authorizer_password): global tmp_certificate_file_path global tmp_private_key_path + global tmp_pfx_file_path exit_code = 0 print("Processing arguments...") launch_arguments = [] launch_arguments.append("--endpoint") launch_arguments.append(sample_endpoint) + if (sample_certificate != ""): launch_arguments.append("--cert") - launch_arguments.append(tmp_certificate_file_path) - if (sample_private_key != "" and parsed_commands.sample_run_softhsm == ""): + launch_arguments.append(sample_certificate) + if (sample_private_key != ""): launch_arguments.append("--key") - launch_arguments.append(tmp_private_key_path) + launch_arguments.append(sample_private_key) if (sample_custom_authorizer_name != ""): launch_arguments.append("--custom_auth_authorizer_name") launch_arguments.append(sample_custom_authorizer_name) @@ -204,8 +324,11 @@ def main(): default="", help="The name of the secret containing the custom authorizer name") argument_parser.add_argument("--sample_secret_custom_authorizer_password", metavar="", required=False, default="", help="The name of the secret containing the custom authorizer password") - argument_parser.add_argument("--sample_run_softhsm", metavar="", required=False, + argument_parser.add_argument("--sample_run_softhsm", metavar="", required=False, default="", help="Runs SoftHSM on the private key passed, storing it, rather than passing it directly to the sample. Used for PKCS11 sample") + argument_parser.add_argument("--sample_run_certutil", metavar="", required=False, + default="", help="Runs CertUtil on the private key and certificate passed and makes a certificate.pfx file, " + "which is used automatically in the --cert argument. Used for Windows Certificate Connect sample") argument_parser.add_argument("--sample_arguments", metavar="", required=False, default="", help="Arguments to pass to sample. In Java, these arguments will be in a double quote (\") string") @@ -217,7 +340,7 @@ def main(): parsed_commands = argument_parser.parse_args() print("Starting to launch sample...") - sample_result = getSecretsAndLaunch(parsed_commands) + sample_result = get_secrets_and_launch(parsed_commands) sys.exit(sample_result) From b53fd4fbf22e222bb2df8f594eb132f4c4e14a08 Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Mon, 3 Oct 2022 18:19:15 -0400 Subject: [PATCH 48/50] Windows certificate connect sample executable name adjustment --- .github/workflows/ci.yml | 6 +++--- samples/mqtt/windows_cert_connect/CMakeLists.txt | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2b7455a1e..de8d1dd65 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -138,7 +138,7 @@ jobs: cd ${{ env.CI_FOLDER }} python -m pip install boto3 python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file '.\aws-iot-device-sdk-cpp-v2\build\samples\pub_sub\basic_pub_sub\RelWithDebInfo\basic-pub-sub.exe' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' - - name: run Windows Connect + - name: run Windows Certificate Connect sample run: | cd ${{ env.CI_FOLDER }} python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file "${{ env.CI_SAMPLES_FOLDER }}\mqtt\windows_cert_connect\RelWithDebInfo\windows-cert-connect.exe" --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 @@ -177,7 +177,7 @@ jobs: cd ${{ env.CI_FOLDER }} python -m pip install boto3 python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file '.\aws-iot-device-sdk-cpp-v2\build\samples\pub_sub\basic_pub_sub\RelWithDebInfo\basic-pub-sub.exe' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' - - name: run Windows Connect + - name: run Windows Certificate Connect sample run: | cd ${{ env.CI_FOLDER }} python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file "${{ env.CI_SAMPLES_FOLDER }}\mqtt\windows_cert_connect\RelWithDebInfo\windows-cert-connect.exe" --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 @@ -212,7 +212,7 @@ jobs: cd ${{ env.CI_FOLDER }} python -m pip install boto3 python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file "${{ env.CI_SAMPLES_FOLDER }}\pub_sub\basic_pub_sub\RelWithDebInfo\basic-pub-sub.exe" --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' - - name: run Windows Connect + - name: run Windows Certificate Connect sample run: | cd ${{ env.CI_FOLDER }} python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file "${{ env.CI_SAMPLES_FOLDER }}\mqtt\windows_cert_connect\RelWithDebInfo\windows-cert-connect.exe" --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 diff --git a/samples/mqtt/windows_cert_connect/CMakeLists.txt b/samples/mqtt/windows_cert_connect/CMakeLists.txt index 6358611cd..551a5dcc1 100644 --- a/samples/mqtt/windows_cert_connect/CMakeLists.txt +++ b/samples/mqtt/windows_cert_connect/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.1) # note: cxx-17 requires cmake 3.8, cxx-20 requires cmake 3.12 -project(windows-cert-pub-sub CXX) +project(windows-cert-connect CXX) file(GLOB SRC_FILES "*.cpp" From 3135b7bc4e94e0dd25b2b8ace686c7fd44e70c9b Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Tue, 4 Oct 2022 15:06:24 -0400 Subject: [PATCH 49/50] Move installing Boto3 to independent step --- .github/workflows/ci.yml | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index de8d1dd65..4f72739f6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -128,6 +128,9 @@ jobs: cd ${{ env.CI_FOLDER }} python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz', 'builder.pyz')" python builder.pyz build -p ${{ env.PACKAGE_NAME }} + - name: Running samples in CI setup + run: | + python -m pip install boto3 - name: configure AWS credentials (PubSub) uses: aws-actions/configure-aws-credentials@v1 with: @@ -136,7 +139,6 @@ jobs: - name: run PubSub sample run: | cd ${{ env.CI_FOLDER }} - python -m pip install boto3 python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file '.\aws-iot-device-sdk-cpp-v2\build\samples\pub_sub\basic_pub_sub\RelWithDebInfo\basic-pub-sub.exe' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' - name: run Windows Certificate Connect sample run: | @@ -150,7 +152,7 @@ jobs: - name: run DeviceAdvisor run: | cd ${{ env.CI_FOLDER }}\aws-iot-device-sdk-cpp-v2 - python3 ./deviceadvisor/script/DATestRun.py + python ./deviceadvisor/script/DATestRun.py windows-vs14: runs-on: windows-2019 # windows-2019 is last env with Visual Studio 2015 (v14.0) @@ -167,6 +169,9 @@ jobs: cd ${{ env.CI_FOLDER }} python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder.pyz')" python builder.pyz build -p ${{ env.PACKAGE_NAME }} --cmake-extra=-Tv140 --cmake-extra=-A${{ matrix.arch }} + - name: Running samples in CI setup + run: | + python -m pip install boto3 - name: configure AWS credentials (PubSub) uses: aws-actions/configure-aws-credentials@v1 with: @@ -175,7 +180,6 @@ jobs: - name: run PubSub sample run: | cd ${{ env.CI_FOLDER }} - python -m pip install boto3 python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file '.\aws-iot-device-sdk-cpp-v2\build\samples\pub_sub\basic_pub_sub\RelWithDebInfo\basic-pub-sub.exe' --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' - name: run Windows Certificate Connect sample run: | @@ -189,7 +193,7 @@ jobs: - name: run DeviceAdvisor run: | cd ${{ env.CI_FOLDER }}\aws-iot-device-sdk-cpp-v2 - python3 ./deviceadvisor/script/DATestRun.py + python ./deviceadvisor/script/DATestRun.py windows-no-cpu-extensions: runs-on: windows-latest @@ -202,6 +206,9 @@ jobs: cd ${{ env.CI_FOLDER }} python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz', 'builder.pyz')" python builder.pyz build -p ${{ env.PACKAGE_NAME }} --cmake-extra=-DUSE_CPU_EXTENSIONS=OFF + - name: Running samples in CI setup + run: | + python -m pip install boto3 - name: configure AWS credentials (PubSub) uses: aws-actions/configure-aws-credentials@v1 with: @@ -210,7 +217,6 @@ jobs: - name: run PubSub sample run: | cd ${{ env.CI_FOLDER }} - python -m pip install boto3 python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file "${{ env.CI_SAMPLES_FOLDER }}\pub_sub\basic_pub_sub\RelWithDebInfo\basic-pub-sub.exe" --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' - name: run Windows Certificate Connect sample run: | @@ -224,7 +230,7 @@ jobs: - name: run DeviceAdvisor run: | cd ${{ env.CI_FOLDER }}\aws-iot-device-sdk-cpp-v2 - python3 ./deviceadvisor/script/DATestRun.py + python ./deviceadvisor/script/DATestRun.py windows-app-verifier: runs-on: windows-2022 # latest @@ -237,6 +243,9 @@ jobs: cd ${{ env.CI_FOLDER }} python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz', 'builder.pyz')" python builder.pyz build -p ${{ env.PACKAGE_NAME }} --cmake-extra=-DUSE_CPU_EXTENSIONS=OFF + - name: Running samples in CI setup + run: | + python -m pip install boto3 - name: configure AWS credentials (CyclePubSub) uses: aws-actions/configure-aws-credentials@v1 with: @@ -246,7 +255,6 @@ jobs: run: | cd ${{ env.CI_FOLDER }} echo "Starting to run AppVerifier with cycle pub-sub sample" - python -m pip install boto3 python ${{ env.CI_UTILS_FOLDER }}\appverifier_launch_sample.py --sample_file "${{ env.CI_SAMPLES_FOLDER }}\pub_sub\cycle_pub_sub\RelWithDebInfo\cycle-pub-sub.exe" --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/CyclePubSub/cert' --sample_secret_private_key 'ci/CyclePubSub/key' osx: @@ -259,6 +267,9 @@ jobs: python3 -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz', 'builder')" chmod a+x builder ./builder build -p ${{ env.PACKAGE_NAME }} --spec=downstream + - name: Running samples in CI setup + run: | + python3 -m pip install boto3 - name: configure AWS credentials (PubSub) uses: aws-actions/configure-aws-credentials@v1 with: @@ -266,7 +277,6 @@ jobs: aws-region: ${{ env.AWS_DEFAULT_REGION }} - name: run PubSub sample run: | - python3 -m pip install boto3 python3 ./aws-iot-device-sdk-cpp-v2/utils/run_sample_ci.py --language CPP --sample_file "${{ env.CI_SAMPLES_FOLDER }}/pub_sub/basic_pub_sub/basic-pub-sub" --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' - name: configure AWS credentials (Device Advisor) uses: aws-actions/configure-aws-credentials@v1 @@ -290,6 +300,9 @@ jobs: run: | python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder.pyz')" python builder.pyz build -p ${{ env.PACKAGE_NAME }} + - name: Running samples in CI setup + run: | + python3 -m pip install boto3 - name: configure AWS credentials (PubSub) uses: aws-actions/configure-aws-credentials@v1 with: @@ -297,7 +310,6 @@ jobs: aws-region: ${{ env.AWS_DEFAULT_REGION }} - name: run PubSub sample run: | - python3 -m pip install boto3 python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file "${{ env.CI_SAMPLES_FOLDER }}/pub_sub/basic_pub_sub/basic-pub-sub" --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' - name: configure AWS credentials (Device Advisor) uses: aws-actions/configure-aws-credentials@v1 @@ -340,6 +352,12 @@ jobs: echo "Running builder" python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder.pyz')" python builder.pyz build -p ${{ env.PACKAGE_NAME }} + - name: Running samples in CI setup + run: | + python3 -m pip install boto3 + sudo apt-get update -y + sudo apt-get install softhsm -y + softhsm2-util --version - name: configure AWS credentials (Connect and PubSub) uses: aws-actions/configure-aws-credentials@v1 with: @@ -347,7 +365,6 @@ jobs: aws-region: ${{ env.AWS_DEFAULT_REGION }} - name: run Basic Connect sample run: | - python3 -m pip install boto3 python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file "${{ env.CI_SAMPLES_FOLDER }}/mqtt/basic_connect/basic-connect" --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' - name: run Websocket Connect sample run: | @@ -357,9 +374,6 @@ jobs: python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --language CPP --sample_file "${{ env.CI_SAMPLES_FOLDER }}/pub_sub/basic_pub_sub/basic-pub-sub" --sample_region ${{ env.AWS_DEFAULT_REGION }} --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/PubSub/cert' --sample_secret_private_key 'ci/PubSub/key' - name: run PKCS11 Connect sample run: | - sudo apt-get update -y - sudo apt-get install softhsm -y - softhsm2-util --version mkdir -p /tmp/tokens export SOFTHSM2_CONF=/tmp/softhsm2.conf echo "directories.tokendir = /tmp/tokens" > /tmp/softhsm2.conf From 77b0e965a7a84cb1eed517fe87fd469244d2136e Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Tue, 4 Oct 2022 15:09:59 -0400 Subject: [PATCH 50/50] Fix yml format mistake --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4f72739f6..01bf47682 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -244,8 +244,8 @@ jobs: python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz', 'builder.pyz')" python builder.pyz build -p ${{ env.PACKAGE_NAME }} --cmake-extra=-DUSE_CPU_EXTENSIONS=OFF - name: Running samples in CI setup - run: | - python -m pip install boto3 + run: | + python -m pip install boto3 - name: configure AWS credentials (CyclePubSub) uses: aws-actions/configure-aws-credentials@v1 with: