Industrial IoT/ML Workshop

Pre-processing Data at the Edge

Include a Lambda function to process the data in AWS Greengrass

Instead of sending individual events to the Cloud, we will combine them with a pre-processing lambda. Similarly to the steps above for the OPCUA extraction lambda, you will now add a second lambda function that runs on the AWS Greengrass core:

Add the existing Lambda function which has “CombineEvents” in the name e.g. “iiot-ws-CombineEvents-O2GV43BQZRYH”:


  • For the Lambda version to use select the alias “latest-version” similarly to the first lambda that we deployed.
  • The configuration of the lambda needs to be modified as well similarly to the first Lambda that was deployed:
    • Ensure you select “Make this function long-lived and keep it running indefinitely” in the Lambda configuration since the function needs to cache the data in memory.
    • Increase the memory to 160MB

Funnel all the data through the new function

Configure the Subscription so that the CombineEvents Lambda function can

  • receive events from the OPCUA function and
  • then send the processed events to the “IoT Cloud”

While executing such a lambda in the cloud is an option, for a production environment, this would reduce costs as it potentially reduces the number of messages sent to AWS IoT Core. In our setup here, we do not realize this potential for cost reduction as we do not modify the subscriptions of the OPC-UA extraction lambda, because the raw messages are useful later on for potential debugging.

The configuration of a subscription for all events of the CombineEvents Lambda to IoT Core is done analogously to the subscription configuration above and therefore not described in detail here. The subscription configuration that forwards the data from one Lambda to the next is as follows:

The filter has to be configured so that the CombineEvents listens to the right topic. In this case, the filter is opcua/server/node/# as shown below. The full subscription configuration has to be as follows (the two new subscriptions are marked):

Finally, deploy the CombineEvents lambda function to the Greengrass group:

  • Go to the Greengrass group
  • click “Actions” → “Deploy”

Analogously to the test step above, subscribe in the AWS IoT Console to the topic data/aggregated. The output should be similar to the following: