how to auto deploy an updated greengrass component

0

Hello,

I have a greengrass deployment for just a few of my dev machines. The deployment has a few greengrass components in it: say A, B and C

When i build a new greengrass component for B for example, I auto bump the version and publish it to greengrass using

aws greengrassv2 create-component-version --inline-recipe fileb://${PROJ_ROOT_DIR}/receipes/receipe.json

which works well, but i would like to automate the auto deployment of the existing deployment with the latest version of the component as well. Is this possible ? and if so , how?

I found https://docs.aws.amazon.com/cli/latest/reference/greengrass/create-deployment.html but it doesn't talk about how to update the deployment to the latest version of B

clogwog
asked 2 years ago754 views
1 Answer
1
Accepted Answer

Hi clogwog. You can achieve it by making a call to get_deployment, modifying the result with the new component version, and then calling create_deployment.

An example, using boto3, here: https://github.com/awslabs/aws-greengrass-labs-component-for-home-assistant/blob/main/deploy_component_version.py

In that example, the component has dependencies on the Secret manager component and the Docker application manager component, which is why they're mentioned in the code.

profile pictureAWS
EXPERT
Greg_B
answered 2 years ago
  • Thanks Greg !

    looks like we will switch to python for this bit.

    Cheers, Tom

  • I notice that the search starts by searches for the latest deployment of a particular device.

    response = greengrassv2_client.list_deployments(
                targetArn=thing_arn,
                historyFilter='LATEST_ONLY',
                maxResults=1
            )
    

    We have devices with multiple deployments, so i can't assume that the latest deployment is the correct one to update.

    The list-deployments aws cli (https://docs.aws.amazon.com/cli/latest/reference/greengrass/list-deployments.html) seems to take a group-id not a Target-Arn of a thing ?

    --group-id (string) The ID of the Greengrass group.
    

    or is this a different list-deployments call ? or is that a greengrass v1 group ?

  • Hi Tom. Yes, depending on your deployments, you will need some different logic on the listing to find the right one to get and modify.

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