End of support notice: On October 31, 2025, AWS
will discontinue support for Amazon Lookout for Vision. After October 31, 2025, you will
no longer be able to access the Lookout for Vision console or Lookout for Vision resources.
For more information, visit this
blog post
Creating the client application component
You can create the client application component once you have generated your gRPC stubs and you have your client application code ready. The component you create is a custom component that you deploy to an AWS IoT Greengrass Version 2 core device with AWS IoT Greengrass V2. A recipe that you create describes your custom component. The recipe includes any dependencies that also need to be deployed. In this case, you specify the model component that you create in Packaging your Amazon Lookout for Vision model. For more information about component recipes, see AWS IoT Greengrass Version 2 component recipe reference.
The procedures on this topic show you how to create the client application component from a recipe file and publish it as an AWS IoT Greengrass V2 custom component. You can use the AWS IoT Greengrass V2 console or the AWS SDK to publish the component.
For detailed information about creating a custom component, see the following in the AWS IoT Greengrass V2 documentation.
Topics
IAM permissions for publishing a client application component
To create and publish your client application component, you need the following IAM permissions:
greengrass:CreateComponentVersion
greengrass:DescribeComponent
s3:PutObject
Creating the recipe
In this procedure, you create the recipe for a simple client application component. The code in lookoutvision_edge_agent_example.py
lists the models that are deployed to the device and is automatically run after you deploy the component to the core device. To view the output,
check the component log after you deploy the component. For more information, see
Deploying your components to a device. When you are ready,
use this procedure to create the recipe for code that implements your business logic.
You create the recipe as a JSON or YAML format file. You also upload the client application code to an Amazon S3 bucket.
To create the client application component recipe
If you haven't already, create the gRPC stub files. For more information, see Setting up gRPC.
Save the following code to a file named
lookoutvision_edge_agent_example.py
import grpc from edge_agent_pb2_grpc import EdgeAgentStub import edge_agent_pb2 as pb2 # Creating stub. with grpc.insecure_channel("unix:///tmp/aws.iot.lookoutvision.EdgeAgent.sock") as channel: stub = EdgeAgentStub(channel) # Add additional code that works with Edge Agent in this block to prevent resources leakage models_list_response = stub.ListModels( pb2.ListModelsRequest() ) for model in models_list_response.models: print(f"Model Details {model}")
-
Create an Amazon S3 bucket (or use an existing bucket) to store the source files for your client application component. The bucket must in your AWS account and in the same AWS Region in which you use AWS IoT Greengrass Version 2 and Amazon Lookout for Vision.
-
Upload
lookoutvision_edge_agent_example.py
,edge_agent_pb2_grpc.py and edge_agent_pb2.py
to the Amazon S3 bucket that you created in the previous step. Note the Amazon S3 path of each file. You creatededge_agent_pb2_grpc.py
andedge_agent_pb2.py
in Setting up gRPC. -
In an editor create the following JSON or YAML recipe file.
-
model_component
to the name of your model component. For more information, see Component settings. -
Change the URI entries to the S3 paths of
lookoutvision_edge_agent_example.py
,edge_agent_pb2_grpc.py
, andedge_agent_pb2.py
.
-
Save the JSON or YAML file to your computer.
Create the client application component by doing one of the following:
If you want to use the AWS IoT Greengrass console, do Publishing the client application component (Console).
If you want use the AWS SDK, do Publishing the client application component (SDK).
Publishing the client application component (Console)
You can use the AWS IoT Greengrass V2 console to publish the client application component.
To publish the client application component
If you haven't already, create the recipe for your client appication component by doing Creating the recipe.
Open the AWS IoT Greengrass console at https://console.aws.amazon.com/iot/
In the left navigation pane, under Greengrass choose Components.
Under My components choose Create component.
On the Create component page choose Enter recipe as JSON if you want to use a JSON format recipe. Choose Enter recipe as YAML if you want to use a YAML format recipe.
Under Recipe replace the existing recipe with the JSON or YAML recipe that you created in Creating the recipe.
Choose Create component.
Next, deploy your client application component.
Publishing the client application component (SDK)
You can publish the client application component by using the CreateComponentVersion API.
To publish the client application component (SDK)
If you haven't already, create the recipe for your client appication component by doing Creating the recipe.
At the command prompt, enter the following command to create the client application component. Replace
recipe-file
with the name of the recipe file you created in Creating the recipe.aws greengrassv2 create-component-version --inline-recipe fileb://
recipe-file
Note the ARN of the component in the response. You need it in the next step.
Use the following command to get the status of the client application component. Replace
component-arn
with the ARN that you noted in the previous step. The client application component is ready if the value ofcomponentState
isDEPLOYABLE
.aws greengrassv2 describe-component --arn
component-arn
Next, deploy your client application component.