Skip to content

Commit 5fe07d2

Browse files
committed
Add README for samples
1 parent 056d3d4 commit 5fe07d2

File tree

6 files changed

+93
-62
lines changed

6 files changed

+93
-62
lines changed

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,9 @@ if(PROJECT_IS_TOP_LEVEL)
196196
if(BUILD_SAMPLES)
197197
file(GLOB SAMPLE_DIRS CONFIGURE_DEPENDS "samples/*")
198198
foreach(sample_dir ${SAMPLE_DIRS})
199+
if(NOT IS_DIRECTORY ${sample_dir})
200+
continue()
201+
endif()
199202
get_filename_component(sample_name ${sample_dir} NAME_WLE)
200203
set_property(
201204
SOURCE ${sample_dir}/main.c

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ The following Greengrass v2 IPC operations are currently supported by this SDK:
3535

3636
## Sample Generic Components
3737

38+
For deployment instructions, see the
39+
[samples deployment guide](samples/README.md).
40+
3841
- [IoT Core MQTT Pub/Sub](samples/iot_core_mqtt/)
3942
- [Update State](samples/update_state/)
4043
- [Configuration Operations](samples/config/)

cpp/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ if(aws-greengrass-sdk-lite_IS_TOP_LEVEL)
4141
if(BUILD_SAMPLES)
4242
file(GLOB SAMPLE_DIRS CONFIGURE_DEPENDS "samples/*")
4343
foreach(sample_dir ${SAMPLE_DIRS})
44+
if(NOT IS_DIRECTORY ${sample_dir})
45+
continue()
46+
endif()
4447
get_filename_component(sample_name ${sample_dir} NAME_WLE)
4548
set_property(
4649
SOURCE ${sample_dir}/main.cpp

misc/dictionary.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ cbmc
33
coverity
44
dfcc
55
EPOLLIN
6+
fileb
67
ggipc
78
greengrassv2
89
iwyu

samples/README.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Deploying Samples to Greengrass
2+
3+
> **Note:** All deployment steps can be performed through the AWS Console. The
4+
> following are CLI instructions.
5+
6+
Detailed deployment documentation can be found here:
7+
8+
- [Getting started guide (console)](https://docs.aws.amazon.com/greengrass/v2/developerguide/deploy-first-component.html)
9+
- [Developer Guide (CLI)](https://docs.aws.amazon.com/greengrass/v2/developerguide/create-deployments.html)
10+
11+
## Prerequisites
12+
13+
- Built samples (see [../docs/BUILD.md](../docs/BUILD.md))
14+
- AWS CLI configured with appropriate credentials
15+
- S3 bucket for component artifacts
16+
- Greengrass thing group
17+
18+
## Deployment Steps
19+
20+
### 1. Upload Sample Binary to S3
21+
22+
```bash
23+
aws s3 cp result/bin/sample_<name> s3://YOUR_BUCKET/ggl-sdk-samples/sample_<name>
24+
```
25+
26+
### 2. Update Recipe with S3 Location
27+
28+
Copy the sample's `recipe.yml` and update the artifact URI:
29+
30+
```bash
31+
cd samples/<sample_name>
32+
cp recipe.yml recipe-deploy.yml
33+
# Edit recipe-deploy.yml and replace:
34+
# URI: s3://EXAMPLE_BUCKET/sample_<name>
35+
# with:
36+
# URI: s3://YOUR_BUCKET/ggl-sdk-samples/sample_<name>
37+
```
38+
39+
### 3. Create Component Version
40+
41+
```bash
42+
aws greengrassv2 create-component-version \
43+
--inline-recipe fileb://recipe-deploy.yml \
44+
--region YOUR_REGION
45+
```
46+
47+
### 4. Deploy to Thing Group
48+
49+
```bash
50+
aws greengrassv2 create-deployment \
51+
--target-arn "arn:aws:iot:YOUR_REGION:ACCOUNT_ID:thinggroup/YOUR_THING_GROUP" \
52+
--deployment-name "SampleDeployment" \
53+
--components '{
54+
"COMPONENT_NAME": {
55+
"componentVersion": "VERSION"
56+
}
57+
}' \
58+
--region YOUR_REGION
59+
```

samples/subscribe_to_configuration_update/README.md

Lines changed: 24 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -5,94 +5,56 @@ Greengrass component.
55

66
## Overview
77

8-
The sample subscribes to it's own configuration updates and prints notifications
8+
The sample subscribes to its own configuration updates and prints notifications
99
whenever the configuration changes. This is useful for components that need to
1010
react to configuration changes in real-time.
1111

12-
## Building
13-
14-
Build the sample from the project root:
15-
16-
```sh
17-
cmake -B build -D CMAKE_BUILD_TYPE=MinSizeRel -D BUILD_SAMPLES=ON
18-
make -C build -j$(nproc)
19-
```
20-
21-
The binary will be available at
22-
`./build/bin/sample_subscribe_to_configuration_update`.
23-
2412
## Usage
2513

2614
### ⚠️ Important Notice ⚠️
2715

2816
Always subscribe to configuration updates before calling GetConfiguration to
2917
ensure you don't miss any updates.
3018

31-
### Deployment
19+
### Testing Configuration Updates
3220

33-
Deploy this component using the provided `recipe.yml`. Update the S3 bucket
34-
location in the recipe before deployment.
21+
After deploying the component, update its configuration to trigger the
22+
subscription callback.
3523

36-
### Step by Step guide
24+
**Using AWS Console:**
3725

38-
1. Deploy the Component to your Greengrass device. A detailed guid can be found
39-
[here](https://docs.aws.amazon.com/greengrass/v2/developerguide/create-deployments.html).
40-
41-
2. Check the initial logs:
42-
43-
```sh
44-
journalctl -fau ggl.aws-greengrass-sdk-lite.samples.subscribe_to_configuration_update.service
26+
1. Navigate to AWS IoT Greengrass console
27+
2. Select `Deployments` and find the deployment targeting your thing group
28+
3. Click `Actions` > `Revise` > `Next` > `Next`
29+
4. Find `aws-greengrass-sdk-lite.samples.SubscribeToConfigurationUpdate` in the
30+
component list
31+
5. Click `Configure component`
32+
6. Under `Configuration to merge`, add:
33+
```json
34+
{
35+
"test_str": "updated_value"
36+
}
4537
```
38+
7. Click `Confirm` > `Next` > `Deploy`
4639

47-
3. Revise the deployment to update the `test_str` configuration value in the
48-
`aws-greengrass-sdk-lite.samples.SubscribeToConfigurationUpdate` component
49-
using the AWS Console:
50-
- Navigate to AWS IoT Greengrass console
51-
- Select `Deployments` and find the deployment targeting your device/group.
52-
- Click `Actions` > `Revise` > `Revise Deployments` > `Next` > `Next`.
53-
- Find `aws-greengrass-sdk-lite.samples.SubscribeToConfigurationUpdate` in
54-
the component list
55-
- Click `Configure component`
56-
- Under `Configuration to merge`, add:
57-
58-
```json
59-
{
60-
"test_str": "updated_value"
61-
}
62-
```
63-
64-
- Click `Confirm` and then `Next` through the remaining steps
65-
- Click `Deploy` to apply the changes
40+
**Using AWS CLI:**
6641

67-
4. After the deployment completes, check the logs again. You should see the
68-
callback triggered with a message indicating the configuration update was
69-
received
70-
71-
5. The callback handler will print the component name and key paths that were
72-
updated
73-
74-
The sample subscribes to the `test_str` key path. To subscribe to all
75-
configuration updates, use an empty key path list.
76-
77-
#### Alternative: Using AWS CLI
78-
79-
To update configuration using AWS CLI:
80-
81-
```sh
42+
```bash
8243
aws greengrassv2 create-deployment \
83-
--target-arn "arn:aws:iot:REGION:ACCOUNT_ID:thinggroup/THING_GROUP_NAME" \
44+
--target-arn "arn:aws:iot:REGION:ACCOUNT_ID:thinggroup/YOUR_THING_GROUP" \
8445
--components '{
8546
"aws-greengrass-sdk-lite.samples.SubscribeToConfigurationUpdate": {
8647
"componentVersion": "VERSION",
8748
"configurationUpdate": {
8849
"merge": "{\"test_str\":\"updated_value\"}"
8950
}
9051
}
91-
}'
52+
}' \
53+
--region YOUR_REGION
9254
```
9355

94-
Replace `REGION`, `ACCOUNT_ID`, `THING_GROUP_NAME`, and `VERSION` with your
95-
values.
56+
The sample subscribes to the `test_str` key path. To subscribe to all
57+
configuration updates, use an empty key path list.
9658

9759
## Known Issues
9860

0 commit comments

Comments
 (0)