Skip to content

Run a command on one or more instances (non-interactive).

POST
/v1/projects/{projectId}/compute/run-command
Code sample: Shell / cURL
curl --request POST \
--url https://stratum.example.com/v1/projects/example/compute/run-command \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "instanceIds": [ "i-a8c2d4e6f0", "i-b7e3c5f7g1" ], "command": "uptime; df -h /", "timeoutSeconds": 60 }'

The aws ssm send-command equivalent. Executes the given command on each target instance over its live Session Manager agent channel (outbound-only; no inbound port or floating IP), captures combined stdout+stderr (truncated to 64 KiB per instance), and returns per-instance results including the exit code. Up to 100 instances per call. Per-instance reachability failures (not running, agent unavailable, timeout) are reported in-band in each result’s error, so the call returns 200 as long as the request is well-formed. Gates on the compute:RunCommand Cedar action in the project.

projectId
required
string
/^p-[a-z0-9-]+$/
Media typeapplication/json

Request to run a command on instances.

object
instanceIds
required

Target instance ids (i-…). Up to 100 per call.

Array<string>
>= 1 items <= 100 items

Example

[
"i-a8c2d4e6f0",
"i-b7e3c5f7g1"
]
command
required

The shell command line to run on each instance.

string
>= 1 characters

Example

uptime; df -h /
timeoutSeconds

Per-command deadline in seconds. Defaults to 60; clamped to 600.

integer
>= 1 <= 600

Example

60

Per-instance run-command results.

Media typeapplication/json
object
results
required
Array<object>

One instance’s run-command outcome.

object
instanceId
required
string
exitCode
required

Shell exit status (valid when error is absent).

integer
output
required

Combined stdout+stderr, truncated to 64 KiB.

string
truncated
required

True when output was truncated at the 64 KiB cap.

boolean
error

Set when the invocation couldn’t run on this instance (not running, agent unavailable, channel busy, timeout). When present, exitCode is not meaningful.

string

Example

{
"results": [
{
"instanceId": "i-a8c2d4e6f0",
"exitCode": 0
}
]
}

Bad request.

Media typeapplication/problem+json
object
type
required
string format: uri
title
required
string
status
required
integer
>= 400 <= 599
detail
string
instance
string format: uri-reference
requestId
required
string
code
required
string
issues

The findings of a rejected IAM policy document (custom and resource policies).

Array<object>

One finding of a rejected IAM policy document. A rejection lists every finding, so the author fixes the document in one round trip.

object
code
required

The finding, e.g. INVALID_DOCUMENT, UNKNOWN_ACTION, ACTION_NOT_APPLICABLE.

string
statement
required

Index of the statement at fault; -1 for the document as a whole.

integer
>= -1
detail
required
string
action

The offending action, where one is at fault (ACTION_NOT_APPLICABLE).

string
errors

Field errors, for codes that carry them: each problem at its field (see FieldError). Documented on the responses that set it, e.g. approveNodeJoin’s INVALID_INPUT and JOIN_APPROVAL_REFUSED. Absent otherwise.

Array<object>

One field’s problem, the stage-2 installer API’s shape. field is the field’s path, message what is wrong with it.

object
field
required

The field’s path, e.g. links[0].interface, disks[1].confirm, mgmt.address or role; empty for the whole request.

string
message
required
string
details

Structured facts about the refusal, for codes that carry them. The shape is fixed per code and documented on the response that answers it, e.g. IMAGE_POOL_MISMATCH (see ImagePoolMismatchDetails) and IMAGE_IN_USE. Absent for codes that carry none.

object
key
additional properties
any

Example

{
"issues": [
{
"code": "ACTION_NOT_APPLICABLE",
"action": "compute:CreateVpc"
}
]
}

Authenticated but not authorized.

Media typeapplication/problem+json
object
type
required
string format: uri
title
required
string
status
required
integer
>= 400 <= 599
detail
string
instance
string format: uri-reference
requestId
required
string
code
required
string
issues

The findings of a rejected IAM policy document (custom and resource policies).

Array<object>

One finding of a rejected IAM policy document. A rejection lists every finding, so the author fixes the document in one round trip.

object
code
required

The finding, e.g. INVALID_DOCUMENT, UNKNOWN_ACTION, ACTION_NOT_APPLICABLE.

string
statement
required

Index of the statement at fault; -1 for the document as a whole.

integer
>= -1
detail
required
string
action

The offending action, where one is at fault (ACTION_NOT_APPLICABLE).

string
errors

Field errors, for codes that carry them: each problem at its field (see FieldError). Documented on the responses that set it, e.g. approveNodeJoin’s INVALID_INPUT and JOIN_APPROVAL_REFUSED. Absent otherwise.

Array<object>

One field’s problem, the stage-2 installer API’s shape. field is the field’s path, message what is wrong with it.

object
field
required

The field’s path, e.g. links[0].interface, disks[1].confirm, mgmt.address or role; empty for the whole request.

string
message
required
string
details

Structured facts about the refusal, for codes that carry them. The shape is fixed per code and documented on the response that answers it, e.g. IMAGE_POOL_MISMATCH (see ImagePoolMismatchDetails) and IMAGE_IN_USE. Absent for codes that carry none.

object
key
additional properties
any

Example

{
"issues": [
{
"code": "ACTION_NOT_APPLICABLE",
"action": "compute:CreateVpc"
}
]
}