Skip to content

Deploy to Greengrass

This page covers deploying a GGCommons component to AWS IoT Greengrass v2, where it runs on the GREENGRASS platform and talks to the Nucleus over Greengrass IPC (the IPC transport). You build and package the component with the GDK (Greengrass Development Kit), then either deploy it locally with greengrass-cli or push it to a fleet from the cloud.

Every component the ggcommons CLI scaffolds already ships the two files the GDK needs — gdk-config.json (build + publish settings) and recipe.yaml (the component recipe) — so you rarely write either by hand.

  • A scaffolded component (ggcommons create-component with GREENGRASS among its target platforms — the default). See the Quickstart.
  • The GDK CLI (gdk) installed and on your PATH, plus AWS credentials with permission to upload artifacts to S3 and register component versions. Confirm with ggcommons doctor, which reports whether gdk and aws are present.
  • An S3 bucket for published artifacts. The CLI writes the bucket/region you pass at scaffold time into gdk-config.json (--bucket / --region, defaulting to greengrass-component-artifacts-us-east-1 in us-east-1).
  • A Greengrass v2 core device running the Nucleus, plus the Greengrass CLI component (greengrass-cli) installed on it if you want to deploy locally.

On the GREENGRASS platform the runtime resolves two defaults from the platform profile, so the launch command is short:

  • Transport defaults to IPC — you do not pass --transport. (IPC is valid only on GREENGRASS; selecting it on another platform fails fast.)
  • Config source defaults to GG_CONFIG — the component reads its configuration from the Greengrass deployment rather than a local file.

The generated recipe.yaml wires this into the component’s Run lifecycle for you. The exact launch line differs per language (and the artifact layout differs with it):

The recipe sets the CONFIG environment variable from the deployment configuration and launches the shaded JAR on the GREENGRASS platform. Config source is left to the profile default (GG_CONFIG), so no -c flag is passed:

Terminal window
# recipe.yaml -> Manifests[0].Lifecycle.Run (tokens resolved to example values)
java -cp {artifacts:path}/MyComponent-1.0.0.jar com.example.MyComponent --platform GREENGRASS
# with Setenv CONFIG: "{configuration:/ComponentConfig}"

gdk component build runs the per-language build declared in gdk-config.json and stages the artifact + recipe; gdk component publish uploads the artifact to your S3 bucket and registers a new component version in your account. These two commands are the same for every language — run them from the generated component directory:

Terminal window
cd MyComponent
gdk component build
gdk component publish

What gdk component build actually does — and the artifact it produces — is driven by the build_system in gdk-config.json:

build_system: "maven" — the GDK runs Maven to produce a shaded, self-contained JAR (target/MyComponent-1.0.0.jar). The recipe’s Manifests.Platform.os is all. The recipe also declares a HARD dependency on the Token Exchange Service (TES) so the component can obtain AWS credentials on-device.

Terminal window
# gdk-config.json -> component.<name>.build.build_system = "maven"
gdk component build

The scaffolded recipe.yaml is a complete Greengrass v2 component recipe. The parts you are most likely to touch:

  • ComponentConfiguration.DefaultConfiguration.ComponentConfig — the component’s default config (logging, heartbeat, metricEmission, tags, and the component instances block). This is the same schema the GG_CONFIG source reads; override any of it from a deployment.
  • accessControl — IPC authorization policies the component needs: aws.greengrass.ipc.pubsub (local pub/sub), aws.greengrass.ipc.mqttproxy (publish/subscribe to IoT Core), and aws.greengrass.ShadowManager (thing shadows). The defaults grant *; tighten the resources to the topics/shadows your component actually uses.
  • Manifests — the artifact URI (rewritten by gdk component publish) and the Run lifecycle shown above. os is all for Java/Python and linux for Rust/TypeScript.

gdk-config.json holds the build system, the publish bucket/region, and the NEXT_PATCH version. Edit the recipe and re-run gdk component build to pick up changes.

For a development core device you can deploy straight from the device without going through the cloud, using the Greengrass CLI. After building, copy the recipe and artifact onto the core, then create a local deployment that merges the component (<Comp>=<ver> names the component and version):

Terminal window
# Run on the core device. Point --recipeDir / --artifactDir at the recipe and the built artifact.
greengrass-cli deployment create \
--recipeDir ./recipes \
--artifactDir ./artifacts \
--merge "com.example.MyComponent=1.0.0"
# Tear the component down again:
greengrass-cli deployment create --remove "com.example.MyComponent"

Once a version is published, deploy it to a thing or thing group via the cloud. The ggcommons CLI wraps the whole flow — gdk component build, gdk component publish, then aws greengrassv2 create-deployment:

Terminal window
ggcommons deploy -p . -t arn:aws:iot:us-east-1:123456789012:thinggroup/edge-fleet
  • On the core device, check component status with the Greengrass CLI: greengrass-cli component list (and watch the Nucleus logs under /greengrass/v2/logs/).
  • Subscribe to heartbeat/+/+ to confirm the component is alive and emitting heartbeats — over IPC these surface on the local pub/sub bus (and on IoT Core if the heartbeat target is configured for it). The topic uses the {ThingName} and {ComponentName} template variables.