I have a few things that are calling the same lambda function and when called I need to know which group they are in. How can I obtain which IoT thing group they are in via a python lambda function? I've tried checking if there is anything I can work with in the client and context objects, but can't find anything.
There are provisions for creating a rule that can call a Lambda function and pass in data from the MQTT message that triggered the rule. In a typical architecture, the Lambda functions are invoked via a Rule and not directly by IoT client. The AWS IoT Rules Engine ( based on SQL-based language) enable to select data from message payloads and send the data to other services, such as AWS Lambda or S3 etc.
The Rule processes a JSON based message from the topic on which it is listening and by default passes the result to the Lambda function as event parameter of your handler without adding or removing any data. Accordingly, if the message has no data of interest , then that data might be unavailable for Lambda function.
One option can be embedding the Things group name inside message from the Thing. This data can be parsed at Lambda. The event parameters can be helpful at Lambda function for fetching the Thing related information provided the Thing information is conveyed inside the MQTT message or added by Rule's SQL to the result passed to the Lambda function.
How to obtain thing group name from AWS lambda function