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
已提問 2 年前檢視次數 767 次
1 個回答
1
已接受的答案

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
專家
Greg_B
已回答 2 年前
  • 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.

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南