> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/continuous-delivery/new-experience/use-deployments/ecs-deployments/step-library/ecs-run-task.md). Agents can also search and read this documentation through its [MCP server](https://developer.harness.io/~gitbook/mcp).

# ECS Run Task step

The ECS Run Task step runs a standalone ECS task using a task definition, separate from any long-running ECS service deployment.

The ECS Run Task step runs a one-off ECS task using a task request definition. It is independent of the service deployment steps and does not create or modify an ECS service. Use it to run jobs, migrations, or other short-lived workloads alongside or after a deployment.

**Step Template ID:** `ecsRunTaskStep`

***

## ECS Run Task step YAML

```yaml
- name: ecs-run-task
  id: ecs_run_task
  deploy:
    uses: ecsRunTaskStep
    with:
      fetch_manifest_repo: true
      git_connector: my_git_connector
      git_branch: main
      manifest_file_path: ecs/task-definition.json
      task_def_mode: ECS Run Task Definition
      task_request_def: /path/to/task-request.json
      skip_steady_state: false
      steady_state_timeout: 5m
      connector: ${{infra.connectorRef}}
      region: ${{infra.region}}
      cluster: ${{infra.cluster}}
      log_level: info
```

{% hint style="info" %}
**Uses `deploy:` not `template:`**

The ECS Run Task step uses the `deploy:` key in the stage YAML, the same as ECS Service Setup and ECS Upgrade Container. Do not use `template:` for this step.
{% endhint %}

***

## Before you begin

* **An ECS service:** Go to [ECS services](https://developer.harness.io/continuous-delivery/new-experience/use-deployments/ecs-deployments/ecs-services.md) to set up a service with a task definition and artifact source.
* **An ECS infrastructure definition:** Go to [ECS infrastructure](https://developer.harness.io/continuous-delivery/new-experience/use-deployments/ecs-deployments/ecs-infrastructure.md) to connect an AWS account and configure authentication.

***

## ECS Run Task step fields

### Task configuration

| Field                         | YAML key              | Required | Default                   | Description                                                                                                                                                                                                                                                                                                                                                                         |
| ----------------------------- | --------------------- | -------- | ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Fetch Manifest Repository** | `fetch_manifest_repo` | No       | `false`                   | When `true`, Harness fetches the manifest files into the workspace before the task runs, so the paths in **ECS Run Task Definition** and **Task Request Definition** can be read from them. Files come from a repository (using **Manifest Repository Connector**) or, if **Manifest S3 Bucket Name** is set, from S3. When `false`, the paths must already exist in the workspace. |
| **Task Definition Mode**      | `task_def_mode`       | Yes      | `ECS Run Task Definition` | The task definition format.                                                                                                                                                                                                                                                                                                                                                         |
| **ECS Run Task Definition**   | `task_def`            | No       | —                         | Path to the ECS task definition file. Shown when **Fetch Manifest Repository** is `false`.                                                                                                                                                                                                                                                                                          |
| **Task Request Definition**   | `task_request_def`    | Yes      | —                         | Path to the task request definition file, which specifies the launch type, network configuration, overrides, and other run parameters.                                                                                                                                                                                                                                              |

### Fetch manifest repository configuration

Shown when **Fetch Manifest Repository** is `true`. Use **Manifest Repository Connector** to fetch from a Git repository, or **Manifest S3 Bucket Name** as the S3 alternative.

| Field                             | YAML key             | Required                           | Default | Description                                                                                         |
| --------------------------------- | -------------------- | ---------------------------------- | ------- | --------------------------------------------------------------------------------------------------- |
| **Manifest Repository Connector** | `git_connector`      | Yes (unless using S3)              | —       | The Git connector used to fetch the manifest repository.                                            |
| **Branch**                        | `git_branch`         | No                                 | —       | The branch to fetch the manifest files from.                                                        |
| **Commit ID**                     | `git_commit_id`      | No                                 | —       | A specific commit to fetch the manifest files from, instead of a branch.                            |
| **Manifest S3 Bucket Name**       | `bucket_name`        | Yes (unless using a Git connector) | —       | The S3 bucket to fetch manifest files from, as an alternative to **Manifest Repository Connector**. |
| **Manifest S3 Bucket Region**     | `bucket_region`      | No                                 | —       | The AWS region of the S3 bucket.                                                                    |
| **Manifest File Path**            | `manifest_file_path` | Yes                                | —       | Path to the task definition file within the manifest repository or S3 bucket.                       |

### Execution configuration

| Field                    | YAML key               | Default | Description                                                               |
| ------------------------ | ---------------------- | ------- | ------------------------------------------------------------------------- |
| **Skip Steady State**    | `skip_steady_state`    | `false` | When `true`, Harness does not wait for the task to reach a stopped state. |
| **Steady State Timeout** | `steady_state_timeout` | `5m`    | How long Harness waits for the task to complete.                          |

### Infrastructure configuration

Auto-resolved from the infrastructure definition.

| Field         | YAML key    | Default value             | Description                                      |
| ------------- | ----------- | ------------------------- | ------------------------------------------------ |
| **Connector** | `connector` | `${{infra.connectorRef}}` | The AWS connector used to authenticate with ECS. |
| **Region**    | `region`    | `${{infra.region}}`       | The AWS region where the task runs.              |
| **Cluster**   | `cluster`   | `${{infra.cluster}}`      | The ECS cluster where the task runs.             |

***

## How the ECS Run Task step works

When the step runs, Harness executes the following actions in order:

1. If **Fetch Manifest Repository** is `true`, fetches the manifest files into the workspace from the Git repository (using **Manifest Repository Connector**) or from S3 (using **Manifest S3 Bucket Name**).
2. Registers or resolves the ECS task definition from the configured path.
3. Runs the ECS task using the task request definition on the configured cluster.
4. Waits for the task to reach a stopped state (unless **Skip Steady State** is `true`).

The ECS Run Task step has no rollback step.

***

## Next steps

* Go to [ECS blank canvas](https://developer.harness.io/continuous-delivery/new-experience/use-deployments/ecs-deployments/ecs-deployment-strategies/blank-canvas.md) to use this step in a custom execution sequence.
* Go to [ECS step library](https://developer.harness.io/continuous-delivery/new-experience/use-deployments/ecs-deployments/step-library.md) for the full list of available steps.
