Skip to content

Add client for IoT command service #790

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 75 commits into from
May 1, 2025
Merged
Show file tree
Hide file tree
Changes from 64 commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
359a793
Checkpoint
bretambrose Sep 16, 2024
aa12ba8
Checkpoint
bretambrose Sep 18, 2024
0327dcf
Updates
bretambrose Sep 19, 2024
f8567cd
Checkpoint pre gen diff
Oct 16, 2024
8f357e1
V2 Codegen Building
Oct 17, 2024
4632528
Shadow tests
Oct 18, 2024
1548624
Fix and refactor tests
Oct 18, 2024
a561ae9
Checkpoint
Oct 21, 2024
b6276dd
Regen
Oct 21, 2024
7f8dac8
Identity tests
bretambrose Oct 21, 2024
c802893
Merge branch 'main' into RequestResponseWorkspace
Oct 29, 2024
ba0ef19
Codegen and format updates
Oct 29, 2024
e519763
V2ServiceError -> V2ErrorResponse
Nov 11, 2024
88889a5
unreferenced params
bretambrose Nov 11, 2024
be267e3
Trivial change to invoke fresh CI
bretambrose Nov 11, 2024
20a9fe2
Will this setup the env variables?
bretambrose Nov 11, 2024
634aea8
Manual test invoke of cli
bretambrose Nov 11, 2024
ec5fb72
Revert "Manual test invoke of cli"
bretambrose Nov 11, 2024
421baab
Does the build have credentials injected?
bretambrose Nov 11, 2024
f04dfd6
Check for session
bretambrose Nov 11, 2024
d799ec9
non-change to trigger CI
bretambrose Nov 11, 2024
bd03d8a
Updated builder to a version that passes session credentials to the c…
bretambrose Nov 11, 2024
3fd6892
Non-change
bretambrose Nov 11, 2024
1799c1a
Non change
bretambrose Nov 11, 2024
5fa7606
Update CI jobs with CI-test credentials
bretambrose Nov 11, 2024
c57dec7
Basic CI Prep
Nov 12, 2024
bc9273e
Skip service tests on macs where keychain access/code-signing is nece…
Nov 12, 2024
2fb685f
Can't have empty test exe
Nov 12, 2024
8876976
Provison second parameter
Nov 12, 2024
278a5e1
Temporarily allow mac service testing
Nov 12, 2024
272cf93
Device location csr
Nov 12, 2024
5881ac3
Builder with fleet provisioning env
Nov 13, 2024
31e556d
Use credentials with smoke tests too
Nov 13, 2024
0e9dc45
Released CRT
bretambrose Nov 14, 2024
ae2d4bc
Merge branch 'main' into RequestResponseWorkspacePreFormat
Feb 27, 2025
60b947c
Update submodule
Feb 27, 2025
3bfee21
Merge branch 'main' into RequestResponseWorkspacePreFormat
bretambrose Mar 4, 2025
25358b0
Updated codegen
Mar 10, 2025
1a0902f
Get some credentials before building
Mar 10, 2025
23c0c06
Add command
sfodagain Apr 14, 2025
d4cd259
Update crt
sfodagain Apr 4, 2025
e4d6354
Move init helpers
sfodagain Apr 8, 2025
c862e3b
Update other services
sfodagain Apr 8, 2025
cd321a6
Fix status update
sfodagain Apr 14, 2025
94c33ca
Fix errors
sfodagain Apr 14, 2025
3c2df76
Use enum for device types
sfodagain Apr 10, 2025
c299a1e
Use enum for device type
sfodagain Apr 14, 2025
da5c54e
Add missing streams
sfodagain Apr 14, 2025
4deacf9
Fix topic for json stream
sfodagain Apr 11, 2025
ee75249
Rename CommandExecutionsEvent to CommandExecutionEvent
sfodagain Apr 11, 2025
8e342e9
Renaming command to commands
sfodagain Apr 14, 2025
e32c408
Fix cmake
sfodagain Apr 14, 2025
7fc0ac3
Fix naming
sfodagain Apr 14, 2025
18a9ba6
Remove v1 client
sfodagain Apr 15, 2025
3201087
Add docs
sfodagain Apr 15, 2025
52cf0fa
Use custom branch in aws-crt-cpp
sfodagain Apr 16, 2025
e970c1e
Add tests
sfodagain Apr 24, 2025
6a800a8
Fix race condition in service tests
sfodagain Apr 28, 2025
edaad93
Merge branch 'main' into RequestResponseWorkspacePreFormat
sfodagain Apr 28, 2025
ef1a389
More data race fixes
sfodagain Apr 28, 2025
7be99cf
Apply clang-format
sfodagain Apr 28, 2025
b716a2f
Remove ServiceStreamingOperation from Identity
sfodagain Apr 28, 2025
37a2906
Fix typo
sfodagain Apr 28, 2025
f43b70b
Merge branch 'RequestResponseWorkspacePreFormat' into iot-command
sfodagain Apr 29, 2025
4953a99
Remove extra semicolon
sfodagain Apr 30, 2025
0cc6387
Update cmake file
sfodagain Apr 30, 2025
29ad002
Fix doxygen comments
sfodagain Apr 30, 2025
7653915
Use stable ordering
sfodagain Apr 30, 2025
b44ffb1
Apply changes from RequestResponseWorkspace
sfodagain May 1, 2025
1242e24
Remove extra credentials
sfodagain May 1, 2025
caf8ca8
Update aws-crt-cpp
sfodagain May 1, 2025
e322482
Merge branch 'RequestResponseWorkspacePreFormat' into iot-command
sfodagain May 1, 2025
383323b
IoT command client sample (#791)
sfod May 1, 2025
3cbe796
Merge branch 'main' into iot-command
sfodagain May 1, 2025
fa15132
Rename sample to commands-sandbox
sfodagain May 1, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .builder/actions/sdk-ci-prep.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import Builder
import os

class SdkCiPrep(Builder.Action):
def run(self, env):
if os.environ.get('AWS_ACCESS_KEY_ID') != None:
print(f"Local credentials exist")
if os.environ.get('AWS_SESSION_TOKEN') != None:
print(f"Local credentials are session based")
else:
print(f"No Local credentials")


actions = [
Builder.SetupCrossCICrtEnvironment()
]
return Builder.Script(actions, name='sdk-ci-prep')
85 changes: 65 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- 'docs'

env:
BUILDER_VERSION: v0.9.56
BUILDER_VERSION: v0.9.72
BUILDER_SOURCE: releases
BUILDER_HOST: https://d19elf31gohf1l.cloudfront.net
PACKAGE_NAME: aws-iot-device-sdk-cpp-v2
Expand Down Expand Up @@ -153,6 +153,11 @@ jobs:
permissions:
id-token: write # This is required for requesting the JWT
steps:
- name: configure AWS credentials (containers)
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ env.CI_IOT_CONTAINERS }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- name: Build ${{ env.PACKAGE_NAME }} + consumers
run: |
md ${{ env.CI_FOLDER }}
Expand Down Expand Up @@ -202,6 +207,11 @@ jobs:
permissions:
id-token: write # This is required for requesting the JWT
steps:
- name: configure AWS credentials (containers)
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ env.CI_IOT_CONTAINERS }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- name: Build ${{ env.PACKAGE_NAME }} + consumers
run: |
md ${{ env.CI_FOLDER }}
Expand Down Expand Up @@ -247,6 +257,11 @@ jobs:
permissions:
id-token: write # This is required for requesting the JWT
steps:
- name: configure AWS credentials (containers)
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ env.CI_IOT_CONTAINERS }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- name: Build ${{ env.PACKAGE_NAME }} + consumers
run: |
md ${{ env.CI_FOLDER }}
Expand Down Expand Up @@ -292,30 +307,40 @@ jobs:
permissions:
id-token: write # This is required for requesting the JWT
steps:
- name: Build ${{ env.PACKAGE_NAME }} + consumers
run: |
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: Running samples in CI setup
run: |
python -m pip install boto3
- name: configure AWS credentials (CyclePubSub)
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ env.CI_CYCLEPUBSUB_ROLE }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- name: Run and check AppVerifier
run: |
cd ${{ env.CI_FOLDER }}
echo "Starting to run AppVerifier with cycle pub-sub sample"
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'
- name: configure AWS credentials (containers)
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ env.CI_IOT_CONTAINERS }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- name: Build ${{ env.PACKAGE_NAME }} + consumers
run: |
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: Running samples in CI setup
run: |
python -m pip install boto3
- name: configure AWS credentials (CyclePubSub)
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ env.CI_CYCLEPUBSUB_ROLE }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- name: Run and check AppVerifier
run: |
cd ${{ env.CI_FOLDER }}
echo "Starting to run AppVerifier with cycle pub-sub sample"
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'
windows-shared-lib:
runs-on: windows-latest
permissions:
id-token: write # This is required for requesting the JWT
steps:
- name: configure AWS credentials (containers)
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ env.CI_IOT_CONTAINERS }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- name: Build ${{ env.PACKAGE_NAME }} + consumers
run: |
md ${{ env.CI_FOLDER }}
Expand All @@ -334,6 +359,11 @@ jobs:
id-token: write # This is required for requesting the JWT
security-events: write # This is required for pkcs12 sample to sign the key
steps:
- name: configure AWS credentials (containers)
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ env.CI_IOT_CONTAINERS }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- name: Build ${{ env.PACKAGE_NAME }} + consumers
run: |
python3 -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz', 'builder')"
Expand Down Expand Up @@ -398,6 +428,11 @@ jobs:
permissions:
id-token: write # This is required for requesting the JWT
steps:
- name: configure AWS credentials (containers)
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ env.CI_IOT_CONTAINERS }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- 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')"
Expand Down Expand Up @@ -458,6 +493,11 @@ jobs:
sudo apt install cmake
gcc --version
cmake --version
- name: configure AWS credentials (containers)
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ env.CI_IOT_CONTAINERS }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- name: Build ${{ env.PACKAGE_NAME }} + consumers
run: |
echo "Downloading source"
Expand Down Expand Up @@ -694,6 +734,11 @@ jobs:
permissions:
id-token: write # This is required for requesting the JWT
steps:
- name: configure AWS credentials (containers)
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ env.CI_IOT_CONTAINERS }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- name: Build ${{ env.PACKAGE_NAME }} + consumers
run: |
echo "Downloading source"
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ add_subdirectory(jobs)
add_subdirectory(shadow)
add_subdirectory(discovery)
add_subdirectory(identity)
add_subdirectory(commands)
add_subdirectory(eventstream_rpc)
add_subdirectory(greengrass_ipc)
if (NOT BYO_CRYPTO)
Expand Down
11 changes: 11 additions & 0 deletions builder.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
"build",
"build-samples"
],
"test_steps": [
"sdk-ci-prep",
"test"
],
"variants" : {
"skip_sample": {
"!build_steps": [
Expand All @@ -47,5 +51,12 @@
"build-gg-samples"
]
}
},
"targets" : {
"macos" : {
"!test_steps": [
"test"
]
}
}
}
127 changes: 127 additions & 0 deletions commands/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# This file is generated

cmake_minimum_required(VERSION 3.9...3.31)

project(IotCommands-cpp LANGUAGES CXX VERSION ${SIMPLE_VERSION})

set(GENERATED_ROOT_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated")
set(GENERATED_INCLUDE_DIR "${GENERATED_ROOT_DIR}/include")
set(GENERATED_CONFIG_HEADER "${GENERATED_INCLUDE_DIR}/aws/iotcommands/Config.h")
configure_file(include/aws/iotcommands/Config.h.in ${GENERATED_CONFIG_HEADER} @ONLY)

if (NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 11)
endif()

file(GLOB AWS_IOTCOMMANDS_HEADERS
"include/aws/iotcommands/*.h"
${GENERATED_CONFIG_HEADER}
)

file(GLOB AWS_IOTCOMMANDS_SRC
"source/*.cpp"
)

file(GLOB AWS_IOTCOMMANDS_CPP_SRC
${AWS_IOTCOMMANDS_SRC}
)

if (WIN32)
if (MSVC)
source_group("Header Files\\aws\\iotcommands\\" FILES ${AWS_IOTCOMMANDS_HEADERS})

source_group("Source Files" FILES ${AWS_IOTCOMMANDS_SRC})
endif ()
endif()

add_library(IotCommands-cpp ${AWS_IOTCOMMANDS_CPP_SRC})

set_target_properties(IotCommands-cpp PROPERTIES LINKER_LANGUAGE CXX)

set(CMAKE_C_FLAGS_DEBUGOPT "")

#set warnings
if (MSVC)
target_compile_options(IotCommands-cpp PRIVATE /W4 /WX)
else ()
target_compile_options(IotCommands-cpp PRIVATE -Wall -Wno-long-long -pedantic -Werror)
endif ()

target_compile_definitions(IotCommands-cpp PRIVATE $<$<CONFIG:Debug>:DEBUG_BUILD>)

if (BUILD_SHARED_LIBS)
target_compile_definitions(IotCommands-cpp PUBLIC "-DAWS_IOTCOMMANDS_USE_IMPORT_EXPORT")
target_compile_definitions(IotCommands-cpp PRIVATE "-DAWS_IOTCOMMANDS_EXPORTS")

install(TARGETS IotCommands-cpp
EXPORT IotCommands-cpp-targets
ARCHIVE
DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT Development
LIBRARY
DESTINATION ${CMAKE_INSTALL_LIBDIR}
NAMELINK_SKIP
COMPONENT Runtime
RUNTIME
DESTINATION ${CMAKE_INSTALL_BINDIR}
COMPONENT Runtime)

install(TARGETS IotCommands-cpp
EXPORT IotCommands-cpp-targets
LIBRARY
DESTINATION ${CMAKE_INSTALL_LIBDIR}
NAMELINK_ONLY
COMPONENT Development)
else()
install(TARGETS IotCommands-cpp
EXPORT IotCommands-cpp-targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT Development)
endif()

target_include_directories(IotCommands-cpp PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)

if (BUILD_DEPS)
if (NOT IS_SUBDIRECTORY_INCLUDE)
aws_use_package(aws-crt-cpp)
endif()
endif()

target_link_libraries(IotCommands-cpp ${DEP_AWS_LIBS})

install(FILES ${AWS_IOTCOMMANDS_HEADERS} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/aws/iotcommands/" COMPONENT Development)

if (BUILD_SHARED_LIBS)
set(TARGET_DIR "shared")
else()
set(TARGET_DIR "static")
endif()

include(CMakePackageConfigHelpers)
if (DEFINED SIMPLE_VERSION)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/iotcommands-cpp-config-version.cmake"
COMPATIBILITY SameMajorVersion
)
endif()

install(EXPORT "IotCommands-cpp-targets"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/IotCommands-cpp/${TARGET_DIR}"
NAMESPACE AWS::
COMPONENT Development)

configure_file("cmake/iotcommands-cpp-config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/iotcommands-cpp-config.cmake"
@ONLY)

install(FILES "${CMAKE_CURRENT_BINARY_DIR}/iotcommands-cpp-config.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/IotCommands-cpp/"
COMPONENT Development)

if(NOT CMAKE_CROSSCOMPILING)
if (BUILD_TESTING AND NOT BYO_CRYPTO)
add_subdirectory(tests)
endif()
endif()
25 changes: 25 additions & 0 deletions commands/cmake/iotcommands-cpp-config.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# This file is generated

include(CMakeFindDependencyMacro)

find_dependency(aws-crt-cpp)

macro(aws_load_targets type)
include(${CMAKE_CURRENT_LIST_DIR}/${type}/@[email protected])
endmacro()

# Allow static or shared lib to be used.
# If both are installed, choose based on BUILD_SHARED_LIBS.
if (BUILD_SHARED_LIBS)
if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/shared")
aws_load_targets(shared)
else()
aws_load_targets(static)
endif()
else()
if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/static")
aws_load_targets(static)
else()
aws_load_targets(shared)
endif()
endif()
Loading
Loading