Hello, we're in the process of migrating a long running Lambda function from Greengrass v1 to v2.
So far it all works well and we eventually managed to get it to run in Greengrass v2 without exceptions.
With Greengrass v1 based on a subscription all changes made to the shadow led to calls to the Lambda handler with the JSON delta as a parameter.
With Greengrass v2 we're not getting these calls anymore. I guess I could explicitly subscribe for the delta in my pinned Lambda function but that feels wrong as it would make the handler obsolete.
Can you please help with the best approach to get to process the shadow deltas in Greengrass v2?
For the record, the ShadowManager configuration is
"aws.greengrass.ShadowManager": {
"componentVersion": "2.3.5",
"configurationUpdate": {
"merge": "{\"synchronize\":{\"coreThing\":{}}}"
}
}
and my understanding is that both direction
= betweenDeviceAndCloud
and coreThing.classic
= true
are defaults.
Thank you for pointing me in the right direction. For the record in my lambda config I've added
and in the access control section of the deployment recipe I have
The lambda handler does indeed get now called although I still have a little issue with parsing the input as I get
Failed to parse input payload: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of
java.lang.Stringout of START_OBJECT token.
My handler is
RequestHandler<String, Unit>
(this is Kotlin, in Java it would be Void)May I ask what type the input is and please point me to some documentation for the conversion?
With an event source you do not need any access control to subscribe. Lambda will subscribe for you.
If you set your lambda's inputPayloadEncodingType to JSON instead of BINARY then the input will be a map
Thank you very much for your help. It's much appreciated. I finally got it to work by setting
inputPayloadEncodingType
tobinary
and implementingRequestHandler<InputStream, Unit>
.