ec2.instances.send-commandRun a shell command on the instance through Deutsche Cloud Connect, without waiting for it
Runs with `exec` (no terminal) as `user` (root or the image’s default user), logged in with a 2-minute certificate: the machine’s sshd log names it `ews:<commandId>:<you>`. `stdin` is passed to the machine and never stored or logged; the command is recorded in the audit log, with its exit code when it ends. On an instance without Connect: 409 with what is possible. `dcloud ec2 instances run-command` sends, waits and exits with the command’s exit code.
Request syntax
POST /ec2/api/instances/{id}/commands
{
"command": "string",
"user": "string",
"timeoutSeconds": "number",
"stdin": "string"
}Path parameters
idRequiredstring
Constraints: /^i-[0-9a-f]{6,32}$/
Request body
commandRequiredstring
The shell command, run by the login user’s shell (`sh -c` semantics). It is recorded in the audit log: pass secrets on stdin, never in the command
Constraints: 1-16384 chars
userOptionalstring
Run as root (the default) or the image’s default user
Constraints: /^[a-z_][a-z0-9_-]{0,31}$/
timeoutSecondsOptionalnumber
Stop the command after this many seconds (1-3600, default 600): status timed_out
Constraints: integer, 1-3600
stdinOptionalstring
Bytes for the command’s standard input, base64, at most 1 MiB decoded. Passed through to the machine only: never stored or logged
Constraints: max 1398104 chars
Response
202: `data` is the command record: `commandId`, `instanceId`, `command`, `user`, `status` (`running`), `timeoutSeconds`, `createdAt`. Poll `get-command` for the result.
A JSON response is wrapped as { "success": true, "data": … }; the CLI prints the whole body with --json.
Errors
- 400The request does not pass the schema above. The body is { "error": …, "issues": […] }, one issue per field.
- 401No credentials, or an access key that is unknown, revoked or expired.
- 403The caller's policies do not allow ec2:RunCommand on this resource. The body names the action and the resource, and the refusal is recorded in the audit log.
- 404The resource does not exist in your organization.
Examples
The required parameters only, with example values. Replace id and the other placeholders with your own.
dcloud ec2 instances send-command id --command examplecurl -X POST "https://console.platform.deutschecloud.app/ec2/api/instances/id/commands" \
-H "Authorization: EWS-ACCESS-KEY $ACCESS_KEY" \
-H "Content-Type: application/json" \
-d '{"command":"example"}'import { DcloudClient } from '@dcloud/sdk';
const client = new DcloudClient();
const result = await client.ec2.instances.sendCommand({ id: "id", command: "example" });from dcloud import Client
client = Client()
result = client.ec2.instances.send_command(id="id", command="example")Generated from the API description, the same one the API checks requests against and the CLI is built from. MCP tool: dcloud_ec2_instances_send-command.