By using AWS re:Post, you agree to the Terms of Use

How to trigger Lambdas from outside the GG environment, for testing purpose

0

Hello!

We are developing one iot device on top of GGV2 and there are a couple of components that we have made as lambdas. We can deploy and run them run properly, but the even sources are quite limited, if I want to trigger it, I need to either:

  1. Have another component there making the calls I want. This is horrible because I need to re-deploy that component every time I want it to send different payloads to the Lambda, and it is overhead that is not helping the development of this isolated component.
  2. Trigger from IoT Core. Not ideal since I have to specify a topic and it cannot be device-specific even, because that would require each device to have its own deployment of these components.

Here are the concrete questions:

  1. What is the best way manually trigger a GG lambda? Are you planning to add a feature to trigger it as one does in the AWS console > Lambda?
  2. Are you planning on adding the option to use recipe variables inside the IOT_CORE event source? would be nice.
  3. Will it possible to create local deployments for Lambda functions? It is also very handy for the iterations to go faster.

I am only concerned with development/testing, as for the production it is the local topics.

As a final note, we are aware of IDP. We are planning on using it but it is not handy for development to force having a device ready. In fact, we usually have GG running inside a docker container.

asked 2 years ago39 views
4 Answers
0
Accepted Answer

Hi,

Thank you for your questions.

For question #1, unfortunately what you described are the only ways to trigger a GG lambda right now. We'll consider what you suggested in the future improvement. If your lambda function doesn't require a specific device to test, a better option to test it in AWS Lambda first before deploying it to Greengrass.
For question #2, what do you mean by "recipe variables"? Are you referring to deployment configuration? You can override the event source during a deployment by updating the "pubsubTopics" field in the default configuration.
For question #3, when you say "create local deployments for Lambda functions", I interpret it as updating your lambda function and deploying it to a GG device using Greengrass CLI https://docs.aws.amazon.com/greengrass/v2/developerguide/gg-cli-deployment.html . Currently Greengrass CLI only supports updating and deploying regular components. Similar to question #1, if your lambda is relatively isolated and doesn't require a specific device to test, I would recommend you to develop and test it in AWS Lambda first.

answered 2 years ago
0

Hi,

Thank you very much, all my questions were answered.

I can't test in AWS because they have interactions with the device, indeed, including IPC.
For Question #3, that is what I meant yes.

Regarding #2, I did not ask it right. Yes, I was referring to the recipe variables in https://docs.aws.amazon.com/greengrass/v2/developerguide/component-recipe-reference.html#recipe-variables , but what I actually am looking for is to have IOT_CORE pub/sub topics using variables like the thing name. I understand this is not supported at the moment.

And the solution of having another component subscribing and then triggering the lambda is totally fine.

Thank you once more!

answered 2 years ago
0

Hi QuantumLove,

For pub/sub topics, you could also pass in a template string and interpolate with the thing name in runtime with environment variables. https://docs.aws.amazon.com/greengrass/v2/developerguide/component-environment-variables.html
Let me know if this works for you.

Thanks,
Hui

answered 2 years ago
0

Hi Hui,

Thank you for your reply. But this cannot be done on the component recipe, right? Only if I manually subscribe with a pinned Lambda.
I am using non-pinned Lambdas, which would be handy to trigger them from the cloud, using the thing name to distinguish which device I am targetting

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions