BACK_TO_ROOT
/SciTech Edge Advance 1.1 – R&D Logs

Mastering Local IPC: Publisher & Subscriber on AWS IoT Greengrass v2

Implementing local Inter-Process Communication (IPC) between custom Python components on AWS Greengrass v2. A complete R&D log covering access control policies, recipe configuration, and debugging runtime failures on Raspberry Pi CM5.

TIMESTAMP
SIGNATUREJayanta Paul
Industrial IoTEdge ComputingAWS IoTIPCPythonGreengrass

Mastering Local IPC: Publisher & Subscriber on AWS IoT Greengrass v2 — SciTech Edge Advance 1.1

Executive Summary

In our previous log, we validated the Greengrass runtime using the console. Today, we move to code-driven Inter-Process Communication (IPC). This log documents the creation of a "Local Publisher" and "Local Subscriber" pipeline on the Raspberry Pi CM5.

We demonstrate how to decouple logic by having one component publish data and another consume it locally, without round-tripping to the cloud. This is essential for latency-sensitive industrial applications where edge logic must function autonomously.


Hardware Stack

  • Edge Device: Raspberry Pi
  • Compute Module: Raspberry Pi CM5
  • Architecture: ARM64
  • OS: Raspberry Pi OS (64-bit)

Software & Tooling Stack

  • AWS IoT Greengrass v2 Core
  • AWS IoT Device SDK v2 for Python (awsiot.greengrasscoreipc)
  • Greengrass CLI (for local debugging)
  • Local Debug Console

Technical Walkthrough

The "Pipeline" Concept: Local Pub/Sub

The goal is to create a local data pipeline inside the Raspberry Pi.

  • Publisher: Generates data (in this case, a timestamp) and pushes it into the pipeline.
  • Subscriber: Listens on a specific topic and processes the data immediately.

This architecture decouples message generation from message processing, allowing us to swap components without rewriting the entire system.

The Publisher Logic (local_publisher.py)

The publisher uses the awsiot.greengrasscoreipc client.

python
# Simplified logic representation
import awsiot.greengrasscoreipc
from awsiot.greengrasscoreipc.model import PublishToTopicRequest

# Create the IPC client

ipc_client = awsiot.greengrasscoreipc.connect()

# Publish a message

request = PublishToTopicRequest()
request.topic = "test/topic"
publish_handler = ipc_client.new_publish_to_topic_handler(request)

Local Publisher (Python)

Source code for the local publisher component.

Download_System

The Subscriber Logic (local_subscriber.py)

The subscriber uses a stream handler to listen for events on the topic.

python
# Simplified logic representation
class StreamHandler(client.SubscribeToTopicStreamHandler):
  def on_stream_event(self, event):
      # Handle the incoming message immediately
      print(f"Received: {event.message}")

Local Subscriber (Python)

Source code for the local subscriber component.

Download_System

Access Control & Recipe Configuration (Why It Failed)

This was the most time-consuming part of the implementation. Greengrass components are sandboxed; they cannot access topics unless explicitly allowed in the recipe.

We initially encountered crashes because the components tried to publish/subscribe without permission.

The Fix: Adding an accessControl policy to the recipe.

json
"accessControl": {
"aws.greengrass.ipc.pubsub": {
  "com.example.LocalPublisher:pubsub:1": {
    "policyDescription": "Allow access to test topic",
    "operations": [
      "aws.greengrass#PublishToTopic"
    ],
    "resources": [
      "test/topic"
    ]
  }
}
}

Detailed configuration rules we learned:

  • Policy Label: com.example.LocalPublisher:pubsub:1 — this must be unique.
  • Resources: The topic name here (test/topic) must match the code exactly.
  • Operations: Explicitly listing PublishToTopic or SubscribeToTopic.

IPC Component Recipe (Publisher)

Recipe with correct access control policies for Publisher.

Download_System

IPC Component Recipe (Subscriber)

Recipe for the Subscriber component.

Download_System

Debugging Deployment Failures

We attempted to deploy the components locally.

Symptoms:

  • Deployment status: Running -> Broken
  • local_publisher state: ERRORED
  • local_subscriber state: ERRORED
Permission Denied & Syntax Error

We faced two distinct issues: 1. Permissions: The initial recipe lacked the accessControl block shown above. 2. Code Error: The logs pointed to line 22 in local_publisher.py. It turned out to be a syntax error in the message payload formatting.

We used the Local Greengrass Debugger to view the logs in real-time. This saved us from SSH-ing into the device and manually tailing log files.


Verification

Once the recipe was fixed and the code corrected:

  1. Greengrass CLI: Verified states were RUNNING.

    bash

    sudo /greengrass/v2/bin/greengrass-cli component list

  2. Log Verification: The local_publisher.log showed successful transmission:

    text
    Successfully published message at 2026-01-20T14:30:00
    
  3. Message Test Client: We could also capture these messages in the local debug console, confirming the data was flowing through the IPC bus.


The Road Ahead

With local IPC stable, we have the foundation for modular edge applications. In the next log, we will complicate the setup:

  • Moving from IPC (Local) to MQTT (Cloud)
  • Establishing bi-directional communication with AWS IoT Core
  • Handling offline buffering and message syncing
R&D LOG CONTINUITYSCITECH_ADVANCE_V1.1

Closing Note

This experiment proves that Greengrass is not just a cloud connector—it is a robust local runtime. By mastering IPC, we can build complex, multi-process applications on the edge that are resilient, modular, and easy to debug.

— DK Swami Founder, Scitech Industries

People Behind This Work

Jayanta Paul
Jayanta Paul
IoT & Edge Engineer
Scitech Industries
This work is part of
SciTech Edge Advance 1.1 – R&D Logs
Technical deep-dives and production logs from our internal Edge Computing R&D trials on ARM-based hardware.
D K Swami

D K Swami

Founder & Technical Lead, Scitech Industries

Also documenting the founder journey at Unscripted with DK Swami → Instagram