Skip to content

create_component_version async

create_component_version(
    *,
    config_overrides: Optional[AsyncGreengrassV2ClientConfig] = None,
    inline_recipe: Optional[RecipeBlob] = None,
    lambda_function: Optional[LambdaFunctionRecipeSource] = None,
    tags: Optional[TagMap] = None,
    client_token: Optional[ClientTokenString] = None,
) -> CreateComponentVersionResponse

Creates a component. Components are software that run on Greengrass core devices. After you develop and test a component on your core device, you can use this operation to upload your component to 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 IoT Greengrass component recipe reference in the 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 Lambda function that runs on 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 IoT Greengrass V1 to IoT Greengrass V2.

    This function accepts Lambda functions in all supported versions of Python, Node.js, and Java runtimes. IoT Greengrass doesn't apply any additional restrictions on deprecated Lambda runtime versions.

    To create a component from a Lambda function, specify lambdaFunction when you call this operation.

    IoT Greengrass currently supports Lambda functions on only Linux core devices.

Parameters:

  • inline_recipe (Optional[RecipeBlob], default: None ) –

    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.

  • lambda_function (Optional[LambdaFunctionRecipeSource], default: None ) –

    The parameters to create a component from a Lambda function.

    You must specify either inlineRecipe or lambdaFunction.

  • tags (Optional[TagMap], default: None ) –

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

  • client_token (Optional[ClientTokenString], default: None ) –

    A unique, case-sensitive identifier that you can provide to ensure that the request is idempotent. Idempotency means that the request is successfully processed only once, even if you send the request multiple times. When a request succeeds, and you specify the same client token for subsequent successful requests, the IoT Greengrass V2 service returns the successful response that it caches from the previous request. IoT Greengrass V2 caches successful responses for idempotent requests for up to 8 hours.

Raises:

  • AccessDeniedException –

    You don't have permission to perform the action.

  • ConflictException –

    Your request has conflicting operations. This can occur if you're trying to perform more than one operation on the same resource at the same time.

  • InternalServerException –

    IoT Greengrass can't process your request right now. Try again later.

  • RequestAlreadyInProgressException –

    The request is already in progress. This exception occurs when you use a client token for multiple requests while IoT Greengrass is still processing an earlier request that uses the same client token.

  • ServiceQuotaExceededException –

    Your request exceeds a service quota. For example, you might have the maximum number of components that you can create.

  • ThrottlingException –

    Your request exceeded a request rate quota. For example, you might have exceeded the amount of times that you can retrieve device or deployment status per second.

  • ValidationException –

    The request isn't valid. This can occur if your request contains malformed JSON or unsupported characters.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_greengrassv2/_services/async_greengrass_v2.py
async def create_component_version(
    self,
    *,
    config_overrides: Optional[AsyncGreengrassV2ClientConfig] = None,
    inline_recipe: Optional[
        "capo_greengrassv2.types.recipe_blob.RecipeBlob"
    ] = None,
    lambda_function: Optional[
        "capo_greengrassv2.types.lambda_function_recipe_source.LambdaFunctionRecipeSource"
    ] = None,
    tags: Optional["capo_greengrassv2.types.tag_map.TagMap"] = None,
    client_token: Optional[
        "capo_greengrassv2.types.client_token_string.ClientTokenString"
    ] = None,
) -> "capo_greengrassv2.types.create_component_version_response.CreateComponentVersionResponse":
    """<p>Creates a component. Components are software that run on Greengrass core devices. After you develop and test a component on your core device, you can use this operation to upload your component to IoT Greengrass. Then, you can deploy the component to other core devices.</p> <p>You can use this operation to do the following:</p> <ul> <li> <p> <b>Create components from recipes</b> </p> <p>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 <a href="https://docs.aws.amazon.com/greengrass/v2/developerguide/component-recipe-reference.html">IoT Greengrass component recipe reference</a> in the <i>IoT Greengrass V2 Developer Guide</i>.</p> <p>To create a component from a recipe, specify <code>inlineRecipe</code> when you call this operation.</p> </li> <li> <p> <b>Create components from Lambda functions</b> </p> <p>Create a component from an Lambda function that runs on 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 IoT Greengrass V1 to IoT Greengrass V2.</p> <p>This function accepts Lambda functions in all supported versions of Python, Node.js, and Java runtimes. IoT Greengrass doesn't apply any additional restrictions on deprecated Lambda runtime versions.</p> <p>To create a component from a Lambda function, specify <code>lambdaFunction</code> when you call this operation.</p> <note> <p>IoT Greengrass currently supports Lambda functions on only Linux core devices.</p> </note> </li> </ul>

    Args:
        inline_recipe: <p>The recipe to use to create the component. The recipe defines the component's metadata, parameters, dependencies, lifecycle, artifacts, and platform compatibility.</p> <p>You must specify either <code>inlineRecipe</code> or <code>lambdaFunction</code>.</p>
        lambda_function: <p>The parameters to create a component from a Lambda function.</p> <p>You must specify either <code>inlineRecipe</code> or <code>lambdaFunction</code>.</p>
        tags: <p>A list of key-value pairs that contain metadata for the resource. For more information, see <a href="https://docs.aws.amazon.com/greengrass/v2/developerguide/tag-resources.html">Tag your resources</a> in the <i>IoT Greengrass V2 Developer Guide</i>.</p>
        client_token: <p>A unique, case-sensitive identifier that you can provide to ensure that the request is idempotent. Idempotency means that the request is successfully processed only once, even if you send the request multiple times. When a request succeeds, and you specify the same client token for subsequent successful requests, the IoT Greengrass V2 service returns the successful response that it caches from the previous request. IoT Greengrass V2 caches successful responses for idempotent requests for up to 8 hours.</p>

    Raises:
        capo_greengrassv2.errors.access_denied_exception.AccessDeniedException: <p>You don't have permission to perform the action.</p>
        capo_greengrassv2.errors.conflict_exception.ConflictException: <p>Your request has conflicting operations. This can occur if you're trying to perform more than one operation on the same resource at the same time.</p>
        capo_greengrassv2.errors.internal_server_exception.InternalServerException: <p>IoT Greengrass can't process your request right now. Try again later.</p>
        capo_greengrassv2.errors.request_already_in_progress_exception.RequestAlreadyInProgressException: <p>The request is already in progress. This exception occurs when you use a client token for multiple requests while IoT Greengrass is still processing an earlier request that uses the same client token.</p>
        capo_greengrassv2.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>Your request exceeds a service quota. For example, you might have the maximum number of components that you can create.</p>
        capo_greengrassv2.errors.throttling_exception.ThrottlingException: <p>Your request exceeded a request rate quota. For example, you might have exceeded the amount of times that you can retrieve device or deployment status per second.</p>
        capo_greengrassv2.errors.validation_exception.ValidationException: <p>The request isn't valid. This can occur if your request contains malformed JSON or unsupported characters.</p>
        capo_greengrassv2.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_greengrassv2.types.create_component_version_request.CreateComponentVersionRequest]",
    ) -> AsyncOperationResponse[
        "capo_greengrassv2.types.create_component_version_response.CreateComponentVersionResponse"
    ]:
        import capo_greengrassv2._operations.greengrass_v2.create_component_version

        (
            output,
            http_response,
        ) = await capo_greengrassv2._operations.greengrass_v2.create_component_version.async_create_component_version(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateComponentVersion")
    )
    input_: capo_greengrassv2.types.create_component_version_request.CreateComponentVersionRequest = {}
    if inline_recipe is not None:
        input_["inline_recipe"] = inline_recipe
    if lambda_function is not None:
        input_["lambda_function"] = lambda_function
    if tags is not None:
        input_["tags"] = tags
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output