Skip to main content

command_executions

Creates, updates, deletes, gets or lists a command_executions resource.

Overview

Namecommand_executions
TypeResource
Idaws.iot.command_executions

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
command_arnstringThe Amazon Resource Number (ARN) of the command. For example, arn:aws:iot:<region>:<accountid>:command/<commandId>
completed_atstring (date-time)The timestamp, when the command execution was completed.
created_atstring (date-time)The timestamp, when the command execution was created.
execution_idstringThe unique identifier of the command execution. (pattern: <code>[a-zA-Z0-9_-]+</code>)
execution_timeout_secondsinteger (int64)Specifies the amount of time in seconds that the device can take to finish a command execution. A timer starts when the command execution is created. If the command execution status is not set to another terminal state before the timer expires, it will automatically update to TIMED_OUT.
last_updated_atstring (date-time)The timestamp, when the command execution was last updated.
parametersobjectThe list of parameters that the StartCommandExecution API used when performing the command on the device.
resultobjectThe result value for the current state of the command execution. The status provides information about the progress of the command execution. The device can use the result field to share additional details about the execution such as a return value of a remote function call. If you use the AWS-IoT-FleetWise namespace, then this field is not applicable in the API response.
started_atstring (date-time)The timestamp, when the command execution was started.
statusstringThe status of the command execution. After your devices receive the command and start performing the operations specified in the command, it can use the UpdateCommandExecution MQTT API to update the status information. (CREATED, IN_PROGRESS, SUCCEEDED, FAILED, REJECTED, TIMED_OUT)
status_reasonobjectYour devices can use this parameter to provide additional context about the status of a command execution using a reason code and description.
target_arnstringThe Amazon Resource Number (ARN) of the device on which the command execution is being performed.
time_to_livestring (date-time)The time to live (TTL) parameter that indicates the duration for which executions will be retained in your account. The default value is six months.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
get_command_executionselectexecution_id, targetArn, regionincludeResultGets information about the specific command execution on a single device.
list_command_executionsselectregionmaxResults, nextTokenList all command executions. You must provide only the startedTimeFilter or the completedTimeFilter information. If you provide both time filters, the API will generate an error. You can use this information to retrieve a list of command executions within a specific timeframe. You must provide only the commandArn or the thingArn information depending on whether you want to list executions for a specific command or an IoT thing. If you provide both fields, the API will generate an error. For more information about considerations for using this API, see List command executions in your account (CLI).
delete_command_executiondeleteexecution_id, targetArn, regionDelete a command execution. Only command executions that enter a terminal state can be deleted from your account.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
execution_idstringThe unique identifier of the command execution that you want to delete from your account.
regionstringAWS region (default: us-east-1)
targetArnstringThe Amazon Resource Number (ARN) of the target device for which you want to delete command executions.
includeResultbooleanCan be used to specify whether to include the result of the command execution in the GetCommandExecution API response. Your device can use this field to provide additional information about the command execution. You only need to specify this field when using the AWS-IoT namespace.
maxResultsintegerThe maximum number of results to return in this operation.
nextTokenstringTo retrieve the next set of results, the nextToken value from a previous response; otherwise null to receive the first set of results.

SELECT examples

Gets information about the specific command execution on a single device.

SELECT
command_arn,
completed_at,
created_at,
execution_id,
execution_timeout_seconds,
last_updated_at,
parameters,
result,
started_at,
status,
status_reason,
target_arn,
time_to_live
FROM aws.iot.command_executions
WHERE execution_id = '{{ execution_id }}' -- required
AND targetArn = '{{ targetArn }}' -- required
AND region = '{{ region }}' -- required
AND includeResult = '{{ includeResult }}'
;

DELETE examples

Delete a command execution. Only command executions that enter a terminal state can be deleted from your account.

DELETE FROM aws.iot.command_executions
WHERE execution_id = '{{ execution_id }}' --required
AND targetArn = '{{ targetArn }}' --required
AND region = '{{ region }}' --required
;