An error occurred (ValidationException) when calling the CreateComponentVersion operation

0

I am following IoT Greengrass tutorial - https://docs.aws.amazon.com/greengrass/v2/developerguide/defer-component-updates-tutorial.html. I am stuck on the step "gdk component publish". I am unable to publish the helloworld component to cloud service from my development computer.

Issue


[2023-03-01 19:51:30] INFO - Getting project configuration from gdk-config.json [2023-03-01 19:51:30] INFO - Found component recipe file 'recipe.json' in the project directory. [2023-03-01 19:51:30] INFO - Found credentials in shared credentials file: ~/.aws/credentials [2023-03-01 19:51:34] INFO - No private version of the component 'com.example.BatteryAwareHelloWorld' exist in the account. Using '1.0.0' as the next version to create. [2023-03-01 19:51:34] INFO - Publishing the component 'com.example.BatteryAwareHelloWorld' with the given project configuration. [2023-03-01 19:51:34] INFO - Uploading the component built artifacts to s3 bucket. [2023-03-01 19:51:34] INFO - Uploading component artifacts to S3 bucket: greengrass-component-artifacts-<<region>>-<<aws account>>. If this is your first time using this bucket, add the 's3:GetObject' permission to each core device's token exchange role to allow it to download the component artifacts. For more information, see https://docs.aws.amazon.com/greengrass/v2/developerguide/device-service-role.html. [2023-03-01 19:51:34] INFO - Updating the component recipe com.example.BatteryAwareHelloWorld-1.0.0. [2023-03-01 19:51:34] INFO - Creating a new greengrass component com.example.BatteryAwareHelloWorld-1.0.0 [2023-03-01 19:51:35] ERROR - Failed to create the component using the recipe at 'D:\IOT_GG_POC\com.example.BatteryAwareHelloWorld\greengrass-build\recipes\com.example.BatteryAwareHelloWorld-1.0.0.json'. [2023-03-01 19:51:35] ERROR - Failed to publish new version of the component 'com.example.BatteryAwareHelloWorld'

=============================== ERROR =============================== Could not publish the component due to the following error. Failed to publish new version of component with the given configuration. Creating private version '1.0.0' of the component 'com.example.BatteryAwareHelloWorld' failed. An error occurred (ValidationException) when calling the CreateComponentVersion operation: Invalid Input: Encountered following errors in Artifacts: {s3://BUCKET_NAME/COMPONENT_NAME/COMPONENT_VERSION/com.example.BatteryAwareHelloWorld.zip = Specified artifact resource cannot be accessed}

Artifact is successfully created in S3 but it is failing to create component on IoT Greengrass service. I have given s3 full access to the user access keys in ~/.aws/credentials. Also given full access on role "GreengrassV2TokenExchangeRole" which Greengrass core devices use to download components from s3.

Can anyone suggest what am I missing here.

  • Hi,

    can you check that the artifact URI in the recipe file in the ./greengrass-build folder corresponds to the correct URI? From the logs it would seem that the recipe has the following URI specified s3://BUCKET_NAME/COMPONENT_NAME/COMPONENT_VERSION/com.example.BatteryAwareHelloWorld.zip which is evidently incorrect.

  • Thanks Massimiliano for your comment. When I run "gdk component build" command from my POC folder it is creating "greengrass-build/recipes/recipe.json". The recipe.json which is provided in my POC folder contains these placeholders COMPONENT_NAME, COMPONENT_VERSION, COMPONENT_AUTHOR, BUCKET_NAME. As per AWS documentation, GDK CLI will replace these placeholders with values while building component. "Placeholders, such as COMPONENT_NAME and COMPONENT_VERSION, where the GDK CLI replaces information when it builds the component recipe."

    After building greengrass-build/recipes/recipe.json, I observe that it replaces placeholders with actual values for ComponentName, ComponentVersion and ComponentPublisher. It has taken these values from gdk-config.json which is present in the same POC directory. But Artifacts Uri still has placeholders "Uri": "s3://BUCKET_NAME/COMPONENT_NAME/COMPONENT_VERSION/com.example.BatteryAwareHelloWorld.zip". It seems to be GDK CLI issue. Any thought or comments?

1 Answer
1
Accepted Answer

Hi. GDK seems to be fussy about the case of fields in the recipe. You can see GDK reporting an error if you run with the --debug switch: https://github.com/aws-greengrass/aws-greengrass-gdk-cli/blob/v1.2.1/gdk/commands/component/PublishCommand.py#L412. For now, the references to Uri in the recipe will have to be capitalized as URI. So please update the recipe and you should be good.

The AWS CLI accepts both Uri and URI. So I've reported a GDK issue here: https://github.com/aws-greengrass/aws-greengrass-gdk-cli/issues/142

profile pictureAWS
EXPERT
Greg_B
answered a year ago
  • Thanks for your answer. It worked after I changed Uri to URI in recipe.json.

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

Relevant content