Skip to content

ECS  >  Operations  >  execute_command

execute_command

Operation

execute_command async

execute_command(input: ExecuteCommandInput, plugins: list[Plugin] | None = None) -> ExecuteCommandOutput

Runs a command remotely on a container within a task.

If you use a condition key in your IAM policy to refine the conditions for the policy statement, for example limit the actions to a specific cluster, you receive an AccessDeniedException when there is a mismatch between the condition key value and the corresponding parameter value.

For information about required permissions and considerations, see Using Amazon ECS Exec for debugging in the Amazon ECS Developer Guide.

Parameters:

Name Type Description Default
input ExecuteCommandInput

An instance of ExecuteCommandInput.

required
plugins list[Plugin] | None

A list of callables that modify the configuration dynamically. Changes made by these plugins only apply for the duration of the operation execution and will not affect any other operation invocations.

None

Returns:

Type Description
ExecuteCommandOutput

An instance of ExecuteCommandOutput.

Input

ExecuteCommandInput dataclass

Bases: _SerdeShape

Dataclass for ExecuteCommandInput structure.

Attributes

cluster class-attribute instance-attribute
cluster: str | None = ...

The Amazon Resource Name (ARN) or short name of the cluster the task is running in. If you do not specify a cluster, the default cluster is assumed.

command class-attribute instance-attribute
command: str | None = ...

The command to run on the container.

container class-attribute instance-attribute
container: str | None = ...

The name of the container to execute the command on. A container name only needs to be specified for tasks containing multiple containers.

interactive class-attribute instance-attribute
interactive: bool = ...

Use this flag to run your command in interactive mode.

task class-attribute instance-attribute
task: str | None = ...

The Amazon Resource Name (ARN) or ID of the task the container is part of.

Output

ExecuteCommandOutput dataclass

Bases: _SerdeShape

Dataclass for ExecuteCommandOutput structure.

Attributes

cluster_arn class-attribute instance-attribute
cluster_arn: str | None = ...

The Amazon Resource Name (ARN) of the cluster.

container_arn class-attribute instance-attribute
container_arn: str | None = ...

The Amazon Resource Name (ARN) of the container.

container_name class-attribute instance-attribute
container_name: str | None = ...

The name of the container.

interactive class-attribute instance-attribute
interactive: bool = ...

Determines whether the execute command session is running in interactive mode. Amazon ECS only supports initiating interactive sessions, so you must specify true for this value.

response_metadata class-attribute instance-attribute
response_metadata: ResponseMetadata = ...

Metadata about the response that produced this output. Use this to recover the request identifiers a service's support team needs in order to investigate a call. Members of the metadata are individually optional.

session class-attribute instance-attribute
session: Session | None = ...

The details of the SSM session that was created for this instance of execute-command.

task_arn class-attribute instance-attribute
task_arn: str | None = ...

The Amazon Resource Name (ARN) of the task.