create_component_version

GreengrassV2.Client.create_component_version(**kwargs)

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 only accepts Lambda functions that use the following runtimes:
    • Python 2.7 – python2.7
    • Python 3.7 – python3.7
    • Python 3.8 – python3.8
    • Python 3.9 – python3.9
    • Java 8 – java8
    • Java 11 – java11
    • Node.js 10 – nodejs10.x
    • Node.js 12 – nodejs12.x
    • Node.js 14 – nodejs14.x

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

Note

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

See also: AWS API Documentation

Request Syntax

response = client.create_component_version(
    inlineRecipe=b'bytes',
    lambdaFunction={
        'lambdaArn': 'string',
        'componentName': 'string',
        'componentVersion': 'string',
        'componentPlatforms': [
            {
                'name': 'string',
                'attributes': {
                    'string': 'string'
                }
            },
        ],
        'componentDependencies': {
            'string': {
                'versionRequirement': 'string',
                'dependencyType': 'HARD'|'SOFT'
            }
        },
        'componentLambdaParameters': {
            'eventSources': [
                {
                    'topic': 'string',
                    'type': 'PUB_SUB'|'IOT_CORE'
                },
            ],
            'maxQueueSize': 123,
            'maxInstancesCount': 123,
            'maxIdleTimeInSeconds': 123,
            'timeoutInSeconds': 123,
            'statusTimeoutInSeconds': 123,
            'pinned': True|False,
            'inputPayloadEncodingType': 'json'|'binary',
            'execArgs': [
                'string',
            ],
            'environmentVariables': {
                'string': 'string'
            },
            'linuxProcessParams': {
                'isolationMode': 'GreengrassContainer'|'NoContainer',
                'containerParams': {
                    'memorySizeInKB': 123,
                    'mountROSysfs': True|False,
                    'volumes': [
                        {
                            'sourcePath': 'string',
                            'destinationPath': 'string',
                            'permission': 'ro'|'rw',
                            'addGroupOwner': True|False
                        },
                    ],
                    'devices': [
                        {
                            'path': 'string',
                            'permission': 'ro'|'rw',
                            'addGroupOwner': True|False
                        },
                    ]
                }
            }
        }
    },
    tags={
        'string': 'string'
    },
    clientToken='string'
)
Parameters
  • inlineRecipe (bytes) --

    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 .

  • lambdaFunction (dict) --

    The parameters to create a component from a Lambda function.

    You must specify either inlineRecipe or lambdaFunction .

    • lambdaArn (string) -- [REQUIRED]

      The ARN of the Lambda function. The ARN must include the version of the function to import. You can't use version aliases like $LATEST .

    • componentName (string) --

      The name of the component.

      Defaults to the name of the Lambda function.

    • componentVersion (string) --

      The version of the component.

      Defaults to the version of the Lambda function as a semantic version. For example, if your function version is 3 , the component version becomes 3.0.0 .

    • componentPlatforms (list) --

      The platforms that the component version supports.

      • (dict) --

        Contains information about a platform that a component supports.

        • name (string) --

          The friendly name of the platform. This name helps you identify the platform.

          If you omit this parameter, IoT Greengrass creates a friendly name from the os and architecture of the platform.

        • attributes (dict) --

          A dictionary of attributes for the platform. The IoT Greengrass Core software defines the os and architecture by default. You can specify additional platform attributes for a core device when you deploy the Greengrass nucleus component. For more information, see the Greengrass nucleus component in the IoT Greengrass V2 Developer Guide .

          • (string) --
            • (string) --
    • componentDependencies (dict) --

      The component versions on which this Lambda function component depends.

      • (string) --
        • (dict) --

          Contains information about a component dependency for a Lambda function component.

          • versionRequirement (string) --

            The component version requirement for the component dependency.

            IoT Greengrass V2 uses semantic version constraints. For more information, see Semantic Versioning.

          • dependencyType (string) --

            The type of this dependency. Choose from the following options:

            • SOFT – The component doesn't restart if the dependency changes state.
            • HARD – The component restarts if the dependency changes state.

            Default: HARD

    • componentLambdaParameters (dict) --

      The system and runtime parameters for the Lambda function as it runs on the Greengrass core device.

      • eventSources (list) --

        The list of event sources to which to subscribe to receive work messages. The Lambda function runs when it receives a message from an event source. You can subscribe this function to local publish/subscribe messages and Amazon Web Services IoT Core MQTT messages.

        • (dict) --

          Contains information about an event source for an Lambda function. The event source defines the topics on which this Lambda function subscribes to receive messages that run the function.

          • topic (string) -- [REQUIRED]

            The topic to which to subscribe to receive event messages.

          • type (string) -- [REQUIRED]

            The type of event source. Choose from the following options:

            • PUB_SUB – Subscribe to local publish/subscribe messages. This event source type doesn't support MQTT wildcards ( + and # ) in the event source topic.
            • IOT_CORE – Subscribe to Amazon Web Services IoT Core MQTT messages. This event source type supports MQTT wildcards ( + and # ) in the event source topic.
      • maxQueueSize (integer) --

        The maximum size of the message queue for the Lambda function component. The IoT Greengrass core stores messages in a FIFO (first-in-first-out) queue until it can run the Lambda function to consume each message.

      • maxInstancesCount (integer) --

        The maximum number of instances that a non-pinned Lambda function can run at the same time.

      • maxIdleTimeInSeconds (integer) --

        The maximum amount of time in seconds that a non-pinned Lambda function can idle before the IoT Greengrass Core software stops its process.

      • timeoutInSeconds (integer) --

        The maximum amount of time in seconds that the Lambda function can process a work item.

      • statusTimeoutInSeconds (integer) --

        The interval in seconds at which a pinned (also known as long-lived) Lambda function component sends status updates to the Lambda manager component.

      • pinned (boolean) --

        Whether or not the Lambda function is pinned, or long-lived.

        • A pinned Lambda function starts when IoT Greengrass starts and keeps running in its own container.
        • A non-pinned Lambda function starts only when it receives a work item and exists after it idles for maxIdleTimeInSeconds . If the function has multiple work items, the IoT Greengrass Core software creates multiple instances of the function.

        Default: true

      • inputPayloadEncodingType (string) --

        The encoding type that the Lambda function supports.

        Default: json

      • execArgs (list) --

        The list of arguments to pass to the Lambda function when it runs.

        • (string) --
      • environmentVariables (dict) --

        The map of environment variables that are available to the Lambda function when it runs.

        • (string) --
          • (string) --
      • linuxProcessParams (dict) --

        The parameters for the Linux process that contains the Lambda function.

        • isolationMode (string) --

          The isolation mode for the process that contains the Lambda function. The process can run in an isolated runtime environment inside the IoT Greengrass container, or as a regular process outside any container.

          Default: GreengrassContainer

        • containerParams (dict) --

          The parameters for the container in which the Lambda function runs.

          • memorySizeInKB (integer) --

            The memory size of the container, expressed in kilobytes.

            Default: 16384 (16 MB)

          • mountROSysfs (boolean) --

            Whether or not the container can read information from the device's /sys folder.

            Default: false

          • volumes (list) --

            The list of volumes that the container can access.

            • (dict) --

              Contains information about a volume that Linux processes in a container can access. When you define a volume, the IoT Greengrass Core software mounts the source files to the destination inside the container.

              • sourcePath (string) -- [REQUIRED]

                The path to the physical volume in the file system.

              • destinationPath (string) -- [REQUIRED]

                The path to the logical volume in the file system.

              • permission (string) --

                The permission to access the volume: read/only ( ro ) or read/write ( rw ).

                Default: ro

              • addGroupOwner (boolean) --

                Whether or not to add the IoT Greengrass user group as an owner of the volume.

                Default: false

          • devices (list) --

            The list of system devices that the container can access.

            • (dict) --

              Contains information about a device that Linux processes in a container can access.

              • path (string) -- [REQUIRED]

                The mount path for the device in the file system.

              • permission (string) --

                The permission to access the device: read/only ( ro ) or read/write ( rw ).

                Default: ro

              • addGroupOwner (boolean) --

                Whether or not to add the component's system user as an owner of the device.

                Default: false

  • tags (dict) --

    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 .

    • (string) --
      • (string) --
  • clientToken (string) --

    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.

    This field is autopopulated if not provided.

Return type

dict

Returns

Response Syntax

{
    'arn': 'string',
    'componentName': 'string',
    'componentVersion': 'string',
    'creationTimestamp': datetime(2015, 1, 1),
    'status': {
        'componentState': 'REQUESTED'|'INITIATED'|'DEPLOYABLE'|'FAILED'|'DEPRECATED',
        'message': 'string',
        'errors': {
            'string': 'string'
        },
        'vendorGuidance': 'ACTIVE'|'DISCONTINUED'|'DELETED',
        'vendorGuidanceMessage': 'string'
    }
}

Response Structure

  • (dict) --

    • arn (string) --

      The ARN of the component version.

    • componentName (string) --

      The name of the component.

    • componentVersion (string) --

      The version of the component.

    • creationTimestamp (datetime) --

      The time at which the component was created, expressed in ISO 8601 format.

    • status (dict) --

      The status of the component version in IoT Greengrass V2. This status is different from the status of the component on a core device.

      • componentState (string) --

        The state of the component version.

      • message (string) --

        A message that communicates details, such as errors, about the status of the component version.

      • errors (dict) --

        A dictionary of errors that communicate why the component version is in an error state. For example, if IoT Greengrass can't access an artifact for the component version, then errors contains the artifact's URI as a key, and the error message as the value for that key.

        • (string) --
          • (string) --
      • vendorGuidance (string) --

        The vendor guidance state for the component version. This state indicates whether the component version has any issues that you should consider before you deploy it. The vendor guidance state can be:

        • ACTIVE – This component version is available and recommended for use.
        • DISCONTINUED – This component version has been discontinued by its publisher. You can deploy this component version, but we recommend that you use a different version of this component.
        • DELETED – This component version has been deleted by its publisher, so you can't deploy it. If you have any existing deployments that specify this component version, those deployments will fail.
      • vendorGuidanceMessage (string) --

        A message that communicates details about the vendor guidance state of the component version. This message communicates why a component version is discontinued or deleted.

Exceptions

  • GreengrassV2.Client.exceptions.ValidationException
  • GreengrassV2.Client.exceptions.ServiceQuotaExceededException
  • GreengrassV2.Client.exceptions.AccessDeniedException
  • GreengrassV2.Client.exceptions.ConflictException
  • GreengrassV2.Client.exceptions.ThrottlingException
  • GreengrassV2.Client.exceptions.InternalServerException
  • GreengrassV2.Client.exceptions.RequestAlreadyInProgressException