AWS CLI version 2, the latest major version of AWS CLI, is now stable and recommended for general use. To view this page for the AWS CLI version 2, click here. For more information see the AWS CLI version 2 installation instructions and migration guide.
[ aws . greengrassv2 ]
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:
inlineRecipe
when you call this operation.lambdaFunction
when you call this operation.See also: AWS API Documentation
create-component-version
[--inline-recipe <value>]
[--lambda-function <value>]
[--tags <value>]
[--client-token <value>]
[--cli-input-json <value>]
[--generate-cli-skeleton <value>]
[--debug]
[--endpoint-url <value>]
[--no-verify-ssl]
[--no-paginate]
[--output <value>]
[--query <value>]
[--profile <value>]
[--region <value>]
[--version <value>]
[--color <value>]
[--no-sign-request]
[--ca-bundle <value>]
[--cli-read-timeout <value>]
[--cli-connect-timeout <value>]
--inline-recipe
(blob)
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
orlambdaFunction
.
--lambda-function
(structure)
The parameters to create a component from a Lambda function.
You must specify either
inlineRecipe
orlambdaFunction
.lambdaArn -> (string)
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 becomes3.0.0
.componentPlatforms -> (list)
The platforms that the component version supports.
(structure)
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
andarchitecture
of the platform.attributes -> (map)
A dictionary of attributes for the platform. The IoT Greengrass Core software defines the
os
andarchitecture
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 .key -> (string)
value -> (string)
componentDependencies -> (map)
The component versions on which this Lambda function component depends.
key -> (string)
value -> (structure)
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 -> (structure)
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.
(structure)
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)
The topic to which to subscribe to receive event messages.type -> (string)
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 -> (map)
The map of environment variables that are available to the Lambda function when it runs.
key -> (string)
value -> (string)
linuxProcessParams -> (structure)
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 -> (structure)
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.
(structure)
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)
The path to the physical volume in the file system.destinationPath -> (string)
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.
(structure)
Contains information about a device that Linux processes in a container can access.
path -> (string)
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
JSON Syntax:
{
"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": integer,
"maxInstancesCount": integer,
"maxIdleTimeInSeconds": integer,
"timeoutInSeconds": integer,
"statusTimeoutInSeconds": integer,
"pinned": true|false,
"inputPayloadEncodingType": "json"|"binary",
"execArgs": ["string", ...],
"environmentVariables": {"string": "string"
...},
"linuxProcessParams": {
"isolationMode": "GreengrassContainer"|"NoContainer",
"containerParams": {
"memorySizeInKB": integer,
"mountROSysfs": true|false,
"volumes": [
{
"sourcePath": "string",
"destinationPath": "string",
"permission": "ro"|"rw",
"addGroupOwner": true|false
}
...
],
"devices": [
{
"path": "string",
"permission": "ro"|"rw",
"addGroupOwner": true|false
}
...
]
}
}
}
}
--tags
(map)
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 .
key -> (string)
value -> (string)
Shorthand Syntax:
KeyName1=string,KeyName2=string
JSON Syntax:
{"string": "string"
...}
--client-token
(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.
--cli-input-json
(string)
Performs service operation based on the JSON string provided. The JSON string follows the format provided by --generate-cli-skeleton
. If other arguments are provided on the command line, the CLI values will override the JSON-provided values. It is not possible to pass arbitrary binary values using a JSON-provided value as the string will be taken literally.
--generate-cli-skeleton
(string)
Prints a JSON skeleton to standard output without sending an API request. If provided with no value or the value input
, prints a sample input JSON that can be used as an argument for --cli-input-json
. If provided with the value output
, it validates the command inputs and returns a sample output JSON for that command.
--debug
(boolean)
Turn on debug logging.
--endpoint-url
(string)
Override command's default URL with the given URL.
--no-verify-ssl
(boolean)
By default, the AWS CLI uses SSL when communicating with AWS services. For each SSL connection, the AWS CLI will verify SSL certificates. This option overrides the default behavior of verifying SSL certificates.
--no-paginate
(boolean)
Disable automatic pagination. If automatic pagination is disabled, the AWS CLI will only make one call, for the first page of results.
--output
(string)
The formatting style for command output.
--query
(string)
A JMESPath query to use in filtering the response data.
--profile
(string)
Use a specific profile from your credential file.
--region
(string)
The region to use. Overrides config/env settings.
--version
(string)
Display the version of this tool.
--color
(string)
Turn on/off color output.
--no-sign-request
(boolean)
Do not sign requests. Credentials will not be loaded if this argument is provided.
--ca-bundle
(string)
The CA certificate bundle to use when verifying SSL certificates. Overrides config/env settings.
--cli-read-timeout
(int)
The maximum socket read time in seconds. If the value is set to 0, the socket read will be blocking and not timeout. The default value is 60 seconds.
--cli-connect-timeout
(int)
The maximum socket connect time in seconds. If the value is set to 0, the socket connect will be blocking and not timeout. The default value is 60 seconds.
To use the following examples, you must have the AWS CLI installed and configured. See the Getting started guide in the AWS CLI User Guide for more information.
Unless otherwise stated, all examples have unix-like quotation rules. These examples will need to be adapted to your terminal's quoting rules. See Using quotation marks with strings in the AWS CLI User Guide .
Example 1: To create a component version from a recipe
The following create-component-version
example creates a version of a Hello World component from a recipe file.
aws greengrassv2 create-component-version \
--inline-recipe fileb://com.example.HelloWorld-1.0.0.json
Contents of com.example.HelloWorld-1.0.0.json
:
{
"RecipeFormatVersion": "2020-01-25",
"ComponentName": "com.example.HelloWorld",
"ComponentVersion": "1.0.0",
"ComponentDescription": "My first AWS IoT Greengrass component.",
"ComponentPublisher": "Amazon",
"ComponentConfiguration": {
"DefaultConfiguration": {
"Message": "world"
}
},
"Manifests": [
{
"Platform": {
"os": "linux"
},
"Lifecycle": {
"Run": "echo 'Hello {configuration:/Message}'"
}
}
]
}
Output:
{
"arn": "arn:aws:greengrass:us-west-2:123456789012:components:com.example.HelloWorld:versions:1.0.0",
"componentName": "com.example.HelloWorld",
"componentVersion": "1.0.0",
"creationTimestamp": "2021-01-07T16:24:33.650000-08:00",
"status": {
"componentState": "REQUESTED",
"message": "NONE",
"errors": {}
}
}
For more information, see Create custom components and Upload components to deploy in the AWS IoT Greengrass V2 Developer Guide.
Example 2: To create a component version from an AWS Lambda function
The following create-component-version
example creates a version of a Hello World component from an AWS Lambda function.
aws greengrassv2 create-component-version \
--cli-input-json file://lambda-function-component.json
Contents of lambda-function-component.json
:
{
"lambdaFunction": {
"lambdaArn": "arn:aws:lambda:us-west-2:123456789012:function:HelloWorldPythonLambda:1",
"componentName": "com.example.HelloWorld",
"componentVersion": "1.0.0",
"componentLambdaParameters": {
"eventSources": [
{
"topic": "hello/world/+",
"type": "IOT_CORE"
}
]
}
}
}
Output:
{
"arn": "arn:aws:greengrass:us-west-2:123456789012:components:com.example.HelloWorld:versions:1.0.0",
"componentName": "com.example.HelloWorld",
"componentVersion": "1.0.0",
"creationTimestamp": "2021-01-07T17:05:27.347000-08:00",
"status": {
"componentState": "REQUESTED",
"message": "NONE",
"errors": {}
}
}
For more information, see Run AWS Lambda functions in the AWS IoT Greengrass V2 Developer Guide.
arn -> (string)
The ARN of the component version.
componentName -> (string)
The name of the component.
componentVersion -> (string)
The version of the component.
creationTimestamp -> (timestamp)
The time at which the component was created, expressed in ISO 8601 format.
status -> (structure)
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 -> (map)
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.key -> (string)
value -> (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.