AWS SDK Version 3 for .NET
API Reference

AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.

Container for the parameters to the ExecuteCommand operation. 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.

Inheritance Hierarchy

System.Object
  Amazon.Runtime.AmazonWebServiceRequest
    Amazon.ECS.AmazonECSRequest
      Amazon.ECS.Model.ExecuteCommandRequest

Namespace: Amazon.ECS.Model
Assembly: AWSSDK.ECS.dll
Version: 3.x.y.z

Syntax

C#
public class ExecuteCommandRequest : AmazonECSRequest
         IAmazonWebServiceRequest

The ExecuteCommandRequest type exposes the following members

Constructors

NameDescription
Public Method ExecuteCommandRequest()

Properties

NameTypeDescription
Public Property Cluster System.String

Gets and sets the property Cluster.

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.

Public Property Command System.String

Gets and sets the property Command.

The command to run on the container.

Public Property Container System.String

Gets and sets the property Container.

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

Public Property Interactive System.Boolean

Gets and sets the property Interactive.

Use this flag to run your command in interactive mode.

Public Property Task System.String

Gets and sets the property Task.

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

Examples

This example runs an interactive /bin/sh command on a container MyContainer.

To run a command remotely on a container in a task


var client = new AmazonECSClient();
var response = client.ExecuteCommand(new ExecuteCommandRequest 
{
    Cluster = "MyCluster",
    Command = "/bin/sh",
    Container = "MyContainer",
    Interactive = true,
    Task = "arn:aws:ecs:us-east-1:123456789012:task/MyCluster/d789e94343414c25b9f6bd59eEXAMPLE"
});

string clusterArn = response.ClusterArn;
string containerArn = response.ContainerArn;
string containerName = response.ContainerName;
bool interactive = response.Interactive;
Session session = response.Session;
string taskArn = response.TaskArn;

            

Version Information

.NET:
Supported in: 8.0 and newer, Core 3.1

.NET Standard:
Supported in: 2.0

.NET Framework:
Supported in: 4.5 and newer, 3.5