greengrass lambda to be triggered by shadow update

0

I've created a Lambda that does something when a named shadow updates

#greengrass-cli component list

....
Component Name: mtdshadowconfiglambda-dev-sync_remote_config#2
Version: 1.0.18
State: RUNNING
Configuration: {"containerMode":"NoContainer","containerParams":{"devices":{},"memorySize":16000.0,"mountROSysfs":false,"volumes":{}},"inputPayloadEncodingType":"json","lambdaExecutionParameters":{"EnvironmentVariables":{}},"maxIdleTimeInSeconds":60.0,"maxInstancesCount":100.0,"maxQueueSize":1000.0,"pinned":false,"pubsubTopics":{"0":{"topic":"$aws/things/+/shadow/name/#","type":"IOT_CORE"}},"statusTimeoutInSeconds":60.0,"timeoutInSeconds":30.0}
......

i'm trying to lock down the trigger a bit more to:
{"topic":"$aws/things/${AWS_IOT_THING_NAME}/shadow/name/config#","type":"IOT_CORE"}
(side question, is this how you do this with the environment variable AWS_IOT_THING_NAME ? )

so that's what i enter in the console when i create a new version of the lambda, however after everything is pushed to the device the same topic is retained even though the version number has updated:

Component Name: mtdshadowconfiglambda-dev-sync_remote_config
Version: 1.0.23
State: FINISHED
Configuration: {"containerMode":"NoContainer","containerParams":{"devices":{},"memorySize":16000.0,"mountROSysfs":false,"volumes":{}},"inputPayloadEncodingType":"json","lambdaExecutionParameters":{"EnvironmentVariables":{}},"maxIdleTimeInSeconds":60.0,"maxInstancesCount":100.0,"maxQueueSize":1000.0,"pinned":false,"pubsubTopics":{"0":{"topic":"$aws/things/+/shadow/name/#","type":"IOT_CORE"}},"statusTimeoutInSeconds":60.0,"timeoutInSeconds":30.0}

is there a way to change a lambda's trigger once it is installed ?

Edited by: clogwog on Oct 6, 2021 3:30 AM

Edited by: clogwog on Oct 6, 2021 3:42 AM

clogwog
질문됨 3년 전292회 조회
2개 답변
0
수락된 답변

Hello,
Thank you for your interested in Greengrass V2. The issue you are having is because you must use a RESET configuration inside the deployment in order to have the lambda use the updated default configuration. See https://docs.aws.amazon.com/greengrass/v2/developerguide/update-component-configurations.html#reset-configuration-update and https://forums.aws.amazon.com/thread.jspa?messageID=972603#972603 for more information.

Answering your side question, subscribing to topics is entirely configuration driven for Lambdas, so you cannot use environment variables. If you wish to have programatic subscriptions then you must use a native Greengrass V2 component (non-lambda) and use our IPC SDK https://docs.aws.amazon.com/greengrass/v2/developerguide/ipc-iot-core-mqtt.html#ipc-operation-subscribetoiotcore.

Cheers,
Michael

AWS
전문가
답변함 3년 전
0

Thank you @MichaelDombrowski-AWS !!, that all worked out.

It's a shame the environment variables aren't available at that time for the trigger. The server side lambda's have it available and they are very handy.

Kind regards,
Tom

clogwog
답변함 3년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠