createComponentVersion method

Future<CreateComponentVersionResponse> createComponentVersion({
  1. Uint8List? inlineRecipe,
  2. LambdaFunctionRecipeSource? lambdaFunction,
  3. Map<String, String>? tags,
})

Creates a component. Components are software that run on AWS IoT Greengrass core devices. After you develop and test a component on your core device, you can use this operation to upload your component to AWS IoT Greengrass. Then, you can deploy the component to other core devices.

You can use this operation to do the following:

  • Create components from recipes

    Create a component from a recipe, which is a file that defines the component's metadata, parameters, dependencies, lifecycle, artifacts, and platform capability. For more information, see AWS IoT Greengrass component recipe reference in the AWS IoT Greengrass V2 Developer Guide.

    To create a component from a recipe, specify inlineRecipe when you call this operation.

  • Create components from Lambda functions

    Create a component from an AWS Lambda function that runs on AWS IoT Greengrass. This creates a recipe and artifacts from the Lambda function's deployment package. You can use this operation to migrate Lambda functions from AWS IoT Greengrass V1 to AWS IoT Greengrass V2.

    This function only accepts Lambda functions that use the following runtimes:

    • Python 2.7 – python2.7
    • Python 3.7 – python3.7
    • Python 3.8 – python3.8
    • Java 8 – java8
    • Node.js 10 – nodejs10.x
    • Node.js 12 – nodejs12.x
    To create a component from a Lambda function, specify lambdaFunction when you call this operation.

May throw ValidationException. May throw ServiceQuotaExceededException. May throw AccessDeniedException. May throw ConflictException. May throw ThrottlingException. May throw InternalServerException.

Parameter inlineRecipe : The recipe to use to create the component. The recipe defines the component's metadata, parameters, dependencies, lifecycle, artifacts, and platform compatibility.

You must specify either inlineRecipe or lambdaFunction.

Parameter lambdaFunction : The parameters to create a component from a Lambda function.

You must specify either inlineRecipe or lambdaFunction.

Parameter tags : A list of key-value pairs that contain metadata for the resource. For more information, see Tag your resources in the AWS IoT Greengrass V2 Developer Guide.

Implementation

Future<CreateComponentVersionResponse> createComponentVersion({
  Uint8List? inlineRecipe,
  LambdaFunctionRecipeSource? lambdaFunction,
  Map<String, String>? tags,
}) async {
  final $payload = <String, dynamic>{
    if (inlineRecipe != null) 'inlineRecipe': base64Encode(inlineRecipe),
    if (lambdaFunction != null) 'lambdaFunction': lambdaFunction,
    if (tags != null) 'tags': tags,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/greengrass/v2/createComponentVersion',
    exceptionFnMap: _exceptionFns,
  );
  return CreateComponentVersionResponse.fromJson(response);
}