Skip to content

Commit 2239209

Browse files
committed
Add support for gdk-build
1 parent bd00ab8 commit 2239209

File tree

11 files changed

+192
-44
lines changed

11 files changed

+192
-44
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
build/
22
.cache/
3+
# GDK
4+
zip-build/
5+
greengrass-build/

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ HTTPS, RDP, and VNC.
1212
1. [Build localproxy](docs/localproxy.md)
1313
2. [Build the component](docs/BUILD.md)
1414
3. [Set up AWS permissions](docs/deployment.md#prerequisites)
15-
4. [Deploy to your device](docs/deployment.md#local-deployment)
15+
4. Deploy to your device:
16+
- [Local deployment](docs/deployment.md#local-deployment)
17+
- [GDK deployment](docs/gdk.md) (recommended)
1618
5. [Create and use tunnels](docs/usage.md)
1719

1820
## Configuration

docs/BUILD.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,21 @@ Or use the build script:
5151
### Test Standalone
5252

5353
```sh
54-
./build/bin/secure-tunnel --help
54+
./build/bin/aws-greengrass-secure-tunnel --help
5555
```
5656

5757
## Component Structure
5858

59+
### For GDK deployment (recommended)
60+
61+
Use the [GDK CLI](../docs/gdk.md) to build and publish:
62+
63+
```sh
64+
gdk component build
65+
./gdk-build.sh
66+
gdk component publish
67+
```
68+
5969
### For local deployment
6070

6171
For Greengrass Local deployment, create this directory hierarchy:
@@ -65,7 +75,7 @@ components
6575
├── artifacts
6676
│ └── aws.greengrass.SecureTunneling
6777
│ └── 1.0.0
68-
│ ├── secure-tunnel
78+
│ ├── aws-greengrass-secure-tunnel
6979
│ └── localproxy
7080
└── recipes
7181
└── aws.greengrass.SecureTunneling-2.0.0.yaml
@@ -77,12 +87,12 @@ For Greengrass Cloud deployment, create a zip file with this structure:
7787

7888
```
7989
aws.greengrass.SecureTunneling-2.0.0.zip
80-
├── secure-tunnel
90+
├── aws-greengrass-secure-tunnel
8191
└── localproxy
8292
```
8393

8494
and then you can upload the zip to a S3 bucket.
8595

86-
- `secure-tunnel`: Built binary from `./build/bin`
96+
- `aws-greengrass-secure-tunnel`: Built binary from `./build/bin`
8797
- `localproxy`: Binary from [localproxy.md](localproxy.md)
8898
- Recipe: Component configuration file

docs/deployment.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ journalctl -afu 'ggl.*'
7979

8080
## Cloud Deployment
8181

82-
1. Use `recipe-all.yaml` (or `recipe.yaml` for architecture-specific builds) to
83-
create a private component
82+
1. Use `recipe-prod.yaml` (gdk-cli to create and publish component) to create a
83+
private component
8484
2. Create a new deployment in AWS IoT Greengrass
8585
3. Deploy to target devices
8686

docs/gdk.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# GDK Deployment
2+
3+
This guide covers deploying the component using the Greengrass Development Kit
4+
(GDK).
5+
6+
## Prerequisites
7+
8+
- [GDK CLI](https://github.com/aws-greengrass/aws-greengrass-gdk-cli) installed
9+
- AWS credentials configured
10+
- S3 bucket for component artifacts
11+
- Built binaries (see [BUILD.md](BUILD.md))
12+
13+
Install GDK:
14+
15+
```sh
16+
pip3 install git+https://github.com/aws-greengrass/aws-greengrass-gdk-cli.git@v1.6.0
17+
```
18+
19+
## Configuration
20+
21+
Edit `gdk-config.json`:
22+
23+
```json
24+
{
25+
"component": {
26+
"aws.greengrass.SecureTunneling": {
27+
"publish": {
28+
"bucket": "your-bucket-name",
29+
"region": "us-east-1"
30+
}
31+
}
32+
}
33+
}
34+
```
35+
36+
## Build
37+
38+
Build the component and create the artifact zip:
39+
40+
```sh
41+
gdk component build
42+
./gdk-build.sh
43+
```
44+
45+
## Publish
46+
47+
Upload to S3 and create the component version:
48+
49+
```sh
50+
gdk component publish
51+
```
52+
53+
## Deploy
54+
55+
Create a deployment:
56+
57+
```sh
58+
gdk component list # Verify component is published
59+
```
60+
61+
Then deploy via AWS Console or CLI:
62+
63+
```sh
64+
aws greengrassv2 create-deployment \
65+
--target-arn "arn:aws:iot:REGION:ACCOUNT:thing/THING_NAME" \
66+
--components '{
67+
"aws.greengrass.SecureTunneling": {
68+
"componentVersion": "2.0.0"
69+
}
70+
}'
71+
```
72+
73+
## Local Testing
74+
75+
Test locally before publishing:
76+
77+
```sh
78+
gdk test-e2e build
79+
gdk test-e2e run
80+
```
File renamed without changes.

gdk-build.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Get version
5+
VERSION=$(cat version | tr -d '\n')
6+
7+
# Check for localproxy
8+
if [ ! -f run/localproxy ]; then
9+
echo "Error: run/localproxy not found. Please build localproxy first."
10+
exit 1
11+
fi
12+
13+
# Create artifact directory
14+
mkdir -p greengrass-build/artifacts/aws.greengrass.SecureTunneling/NEXT_PATCH
15+
16+
# Copy binaries
17+
cp build/bin/aws-greengrass-secure-tunnel greengrass-build/artifacts/aws.greengrass.SecureTunneling/NEXT_PATCH/
18+
cp run/localproxy greengrass-build/artifacts/aws.greengrass.SecureTunneling/NEXT_PATCH/
19+
20+
# Create zip
21+
cd greengrass-build/artifacts/aws.greengrass.SecureTunneling/NEXT_PATCH
22+
zip aws.greengrass.SecureTunneling.zip aws-greengrass-secure-tunnel localproxy
23+
rm aws-greengrass-secure-tunnel localproxy
24+
cd ../../../..
25+
26+
# Generate recipe
27+
sed -e "s/{COMPONENT_NAME}/aws.greengrass.SecureTunneling/g" \
28+
-e "s/{COMPONENT_VERSION}/$VERSION/g" \
29+
-e "s|BUCKET_NAME|$(jq -r '.component."aws.greengrass.SecureTunneling".publish.bucket' gdk-config.json)|g" \
30+
-e "s|COMPONENT_NAME|aws.greengrass.SecureTunneling|g" \
31+
-e "s|COMPONENT_VERSION|$VERSION|g" \
32+
recipe.yaml > greengrass-build/recipes/recipe.yaml
33+
34+
echo "Build complete: greengrass-build/artifacts/aws.greengrass.SecureTunneling/NEXT_PATCH/aws.greengrass.SecureTunneling.zip"

gdk-config.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"component": {
3+
"aws.greengrass.SecureTunneling": {
4+
"author": "AWS",
5+
"version": "NEXT_PATCH",
6+
"build": {
7+
"build_system": "custom",
8+
"custom_build_command": [
9+
"bash",
10+
"-c",
11+
"cmake -B build -DCMAKE_BUILD_TYPE=MinSizeRel && make -C build -j$(nproc) && ./gdk-build.sh"
12+
]
13+
},
14+
"publish": {
15+
"bucket": "BUCKET_NAME",
16+
"region": "us-east-1"
17+
}
18+
}
19+
},
20+
"gdk_version": "1.6.0"
21+
}

recipe-dev.yaml

Lines changed: 0 additions & 37 deletions
This file was deleted.

recipe.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
RecipeFormatVersion: "2020-01-25"
3+
ComponentName: "{COMPONENT_NAME}"
4+
ComponentVersion: "{COMPONENT_VERSION}"
5+
ComponentType: "aws.greengrass.generic"
6+
ComponentDescription:
7+
"Enables AWS IoT Secure Tunneling connections that you can use to establish
8+
secure bidirectional communications with Greengrass core devices that are
9+
behind restricted firewalls."
10+
ComponentPublisher: "AWS"
11+
ComponentConfiguration:
12+
DefaultConfiguration:
13+
maxConcurrentTunnels: 20
14+
tunnelTimeoutSeconds: 43200
15+
accessControl:
16+
aws.greengrass.ipc.mqttproxy:
17+
"aws.greengrass.SecureTunneling:mqttproxy:1":
18+
policyDescription: "Access to tunnel notification pubsub topic"
19+
operations:
20+
- "aws.greengrass#SubscribeToIoTCore"
21+
resources:
22+
- "$aws/things/+/tunnels/notify"
23+
Manifests:
24+
- Platform:
25+
os: "linux"
26+
runtime: "*"
27+
Lifecycle:
28+
run: |
29+
{artifacts:decompressedPath}/aws.greengrass.SecureTunneling/aws-greengrass-secure-tunnel --thing-name {iot:thingName} --max-tunnels {configuration:/maxConcurrentTunnels} --timeout {configuration:/tunnelTimeoutSeconds} --artifact-path {artifacts:decompressedPath}/aws.greengrass.SecureTunneling/
30+
Artifacts:
31+
- URI: "s3://BUCKET_NAME/COMPONENT_NAME/COMPONENT_VERSION/aws.greengrass.SecureTunneling.zip"
32+
Unarchive: "ZIP"
33+
Permission:
34+
Read: "OWNER"
35+
Execute: "OWNER"

0 commit comments

Comments
 (0)