install command will be run every time Greengrass starts up and anytime the component version changes. Since a version of boto3/awsiotsdk already exists, pip's logic should be to simply move on. So yes, while the command will be run, it shouldn't actually be installing anything unless it is missing.
Using the --user flag with pip is the right thing to do as it will install the library for the current user. The user will be ggc_user or whatever user that component is configured to run as. Components be default will run as ggc_user, but they can be set in a deployment to run as any other user on the system.
My suggestion would be to use a virtual environment in the work directory of the component. This has 2 advantages:
- you can easily check for the existence of the virtual environment and skip the installation
- with the
--userflag, if you deploy other components using conflicting libraries, the last component installed will win. By using virtual environments you avoid such situations.
You can see this approach applied here https://github.com/awslabs/aws-greengrass-labs-jupyterlab/blob/main/recipes/aws.greengrass.labs.jupyterlab.yaml
The component recipe also allow the use of a "skipif" key, so the script may be skipped if an executable is found or if a file exists. This could be use to skip the installation if the pip package file exists. Doc: https://docs.aws.amazon.com/greengrass/v2/developerguide/component-recipe-reference.html
My recipe skips awsiot because its already installed. I am trying to upgrade from 1.11.2 to 1.11.3. Is there a way to force an update?
AWS Greengrass lambda component hangs on python import of GreengrassCoreIPCClientV2Accepted Answerasked 2 months ago
Why can't I install python logging library on Linux2 instanceAccepted Answerasked 10 months ago
Greengrass Python Lambda using awsiotsdk: No module named '_awscrt'Accepted Answerasked 7 months ago
Creating python greengrass scripts that depend on other packagesasked 3 months ago
find file location sent as a non-compressed artifactAccepted Answerasked 9 months ago
Greengrass Install Script Re-installs pip3 components every timeasked a year ago
finer grained install checks on greengrass lifecycleAccepted Answerasked 2 months ago
V2 greengrass deployment error in lifecyclemanager.GenericExternalServiceasked a year ago
Stream Manager cannot load cbor2 moduleAccepted Answerasked 2 years ago
Greengrass install between partition based upgradesasked 6 months ago