CreateCommandCommand

Creates a command. A command contains reusable configurations that can be applied before they are sent to the devices.

Example Syntax

Use a bare-bones client and the command you need to make an API call.

import { IoTClient, CreateCommandCommand } from "@aws-sdk/client-iot"; // ES Modules import
// const { IoTClient, CreateCommandCommand } = require("@aws-sdk/client-iot"); // CommonJS import
const client = new IoTClient(config);
const input = { // CreateCommandRequest
  commandId: "STRING_VALUE", // required
  namespace: "AWS-IoT" || "AWS-IoT-FleetWise",
  displayName: "STRING_VALUE",
  description: "STRING_VALUE",
  payload: { // CommandPayload
    content: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("")
    contentType: "STRING_VALUE",
  },
  mandatoryParameters: [ // CommandParameterList
    { // CommandParameter
      name: "STRING_VALUE", // required
      value: { // CommandParameterValue
        S: "STRING_VALUE",
        B: true || false,
        I: Number("int"),
        L: Number("long"),
        D: Number("double"),
        BIN: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("")
        UL: "STRING_VALUE",
      },
      defaultValue: {
        S: "STRING_VALUE",
        B: true || false,
        I: Number("int"),
        L: Number("long"),
        D: Number("double"),
        BIN: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("")
        UL: "STRING_VALUE",
      },
      description: "STRING_VALUE",
    },
  ],
  roleArn: "STRING_VALUE",
  tags: [ // TagList
    { // Tag
      Key: "STRING_VALUE", // required
      Value: "STRING_VALUE",
    },
  ],
};
const command = new CreateCommandCommand(input);
const response = await client.send(command);
// { // CreateCommandResponse
//   commandId: "STRING_VALUE",
//   commandArn: "STRING_VALUE",
// };

CreateCommandCommand Input

See CreateCommandCommandInput for more details

Parameter
Type
Description
commandId
Required
string | undefined

A unique identifier for the command. We recommend using UUID. Alpha-numeric characters, hyphens, and underscores are valid for use here.

description
string | undefined

A short text decription of the command.

displayName
string | undefined

The user-friendly name in the console for the command. This name doesn't have to be unique. You can update the user-friendly name after you define it.

mandatoryParameters
CommandParameter[] | undefined

A list of parameters that are required by the StartCommandExecution API. These parameters need to be specified only when using the AWS-IoT-FleetWise namespace. You can either specify them here or when running the command using the StartCommandExecution API.

namespace
CommandNamespace | undefined

The namespace of the command. The MQTT reserved topics and validations will be used for command executions according to the namespace setting.

payload
CommandPayload | undefined

The payload object for the command. You must specify this information when using the AWS-IoT namespace.

You can upload a static payload file from your local storage that contains the instructions for the device to process. The payload file can use any format. To make sure that the device correctly interprets the payload, we recommend you to specify the payload content type.

roleArn
string | undefined

The IAM role that you must provide when using the AWS-IoT-FleetWise namespace. The role grants IoT Device Management the permission to access IoT FleetWise resources for generating the payload for the command. This field is not required when you use the AWS-IoT namespace.

tags
Tag[] | undefined

Name-value pairs that are used as metadata to manage a command.

CreateCommandCommand Output

Parameter
Type
Description
$metadata
Required
ResponseMetadata
Metadata pertaining to this request.
commandArn
string | undefined

The Amazon Resource Number (ARN) of the command. For example, arn:aws:iot:::command/

commandId
string | undefined

The unique identifier for the command.

Throws

Name
Fault
Details
ConflictException
client

The request conflicts with the current state of the resource.

InternalServerException
server

Internal error from the service that indicates an unexpected error or that the service is unavailable.

ServiceQuotaExceededException
client

Service quota has been exceeded.

ThrottlingException
client

The rate exceeds the limit.

ValidationException
client

The request is not valid.

IoTServiceException
Base exception class for all service exceptions from IoT service.