- Neueste
- Die meisten Stimmen
- Die meisten Kommentare
Hi @rikerik
I would highly recommend creating a Greengrass v2 custom component instead of a Greengrass Lambda to run your code on Greengrass. In Greengrass V2, Lambdas are supported for backward compatibility to Greengrass v1.
To get you started, take a look at this tutorial, Step 5 of the tutorial has step-by-step instructions to create a simple python based Hello World component.
Greengrass v2 also provides a Greengrass Development Kit CLI that simplifies the creation and deployment of components to AWS Greengrass.
Compared to Lambdas, Greengrass components run as an OS process and not in a container. This makes dependency management easier. Additionally, you can add setup commands to install dependencies in the Greengrass component recipe.
Greengrass Components can also subscribe to local PubSub topics, a python code sample can be found here
Hope that helps
Hi,
The reason why this is happening is that importing those additional modules is putting your application above the memory limit and then killing it. The memory limit is configured when you create the component from a lambda, the default is 16MB. You can address this by using "NoContainer" mode instead of a container. You may also increase the memory limit or simply use a native component as suggested by @Jan_B.
If you do change the memory limit or container mode, make sure that you use "RESET": [""]
in the deployment configuration update for the component such that the new default values will be used instead of the existing values on the device. https://docs.aws.amazon.com/greengrass/v2/developerguide/update-component-configurations.html#reset-configuration-update.
Cheers, Michael
Thank you!
You were spot on, the container did indeed run out of memory. I upped the lambda component to 32MB and I am now able to import the GreengrassCoreIPCClientV2 class.
I guess this means that the container is running armv7l just as the host OS, otherwise the import should have failed, right?
Relevanter Inhalt
- AWS OFFICIALAktualisiert vor 2 Jahren
- AWS OFFICIALAktualisiert vor 3 Jahren
- AWS OFFICIALAktualisiert vor 4 Monaten
- AWS OFFICIALAktualisiert vor einem Jahr
Thank you, migrating to a custom component would definably have solved my issue since it had to do with lack of working memory in the container.
Since I am using serverless framework to build and deploy the lambda function I refrained from immediately switching over to building a custom component. Is it your opinion that lambdas will be deprecated in the future of GGv2?
And a question, you wrote: "Additionally, you can add setup commands to install dependencies in the Greengrass component recipe." in your answer.
I would still recommend creating a virtual environment per component to isolate the dependencies, here a sample recipe :