> 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/3.0/use-deployments/ecs-deployments.md).

# AWS ECS

Deploy container images to Amazon ECS clusters using Harness-managed deployment strategies including basic, canary, rolling, and blue-green.

An Amazon Elastic Container Service (ECS) stage in Harness deploys container images to an ECS cluster. You define the service (task definition, service definition, and artifact source), the target infrastructure (AWS connector, region, and cluster), and the deployment strategy. Harness manages step execution, rollback data capture, auto-scaling registration, and steady-state checks.

***

## Set up an ECS deployment

Follow these steps to create a pipeline stage that deploys to ECS.

1. Go to **Pipelines** and click **Create Pipeline**.
2. Enter a pipeline name. Under **Storage**, select **Inline** or a Git repository. Click **Create**.
3. A default **Stage 1** is added. You can edit it directly, but the deployment strategy selection step will be skipped. To choose a strategy, delete **Stage 1** and click **+** to add a new stage.
4. Select **Deploy** and click **Set Up Stage**.
5. Enter a stage name and set **Deployment Target** to **ECS**. Click **Next**.

The wizard walks you through configuring the service, environment, and execution strategy in sequence.

***

## Service

A **service** represents what you deploy. For ECS, it holds a task definition, service definition, artifact source, and optional auto-scaling configuration (scalable target, scaling policy, and scheduled actions). Services are independent of pipelines. Configure one once and reuse it across stages and pipelines.

Go to [ECS services](https://developer.harness.io/continuous-delivery/3.0/use-deployments/ecs-deployments/ecs-services.md) to configure a service with a task definition, artifact source, and optional auto-scaling manifests.

***

## Environment and infrastructure

An **environment** is a logical deployment target such as development, staging, or production. An **infrastructure definition** within an environment points to the specific target where Harness deploys.

Go to [ECS infrastructure](https://developer.harness.io/continuous-delivery/3.0/use-deployments/ecs-deployments/ecs-infrastructure.md) to configure environments, infrastructure definitions, and authentication.

***

## Deployment strategies

Harness supports the following strategies for ECS:

| Strategy                                             | What it does                                                                                                                                                |
| ---------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Basic**                                            | Creates a new versioned ECS service at zero instances and scales it to the target count, keeping the previous version running until the new one is healthy. |
| **Canary**                                           | Deploys a small canary service alongside the production service for validation, then runs a full rolling deploy to update the production service.           |
| **Rolling**                                          | Updates the existing ECS service in place with the new task definition and waits for steady state.                                                          |
| **ECS BlueGreen Deploy With Swap Strategy**          | Deploys to a staging slot and swaps the production and staging ALB target groups atomically, moving all traffic at once.                                    |
| **ECS BlueGreen Deploy With Traffic Shift Strategy** | Deploys to a staging slot and gradually shifts traffic weight from the current service to the new service using weighted target groups.                     |
| **Blank canvas**                                     | No managed step sequence. Compose steps manually using any combination of ECS steps.                                                                        |

Go to [Deployment strategies](https://developer.harness.io/continuous-delivery/3.0/use-deployments/ecs-deployments/ecs-deployment-strategies.md) to configure each strategy.

***

## Stage settings

Each stage has settings accessible from the stage editor: **Inputs & outputs**, **Execution controls**, and **Runtime Environment**.

### Inputs & outputs

The **Inputs & outputs** section defines the stage's inputs, environment variables, and outputs. Use this section to declare values the stage accepts as runtime inputs, environment variables available to step containers during execution, and outputs the stage exposes to downstream stages.

### Execution controls

The **Execution controls** section sets conditions, looping strategy, concurrency, failure strategy, and timeout for the stage.

**On failure** defines what Harness does when the stage fails. For ECS, `stage-rollback` triggers the rollback step and restores the previous state.

```yaml
on-failure:
  errors: all
  action: stage-rollback
```

**Strategy** configures a looping strategy so the stage runs multiple times across a matrix of values.

```yaml
strategy:
  matrix:
    <dimension>: [<value1>, <value2>]
  max-concurrency: 2
```

### Runtime Environment

The **Runtime Environment** section configures where the stage's steps execute. ECS steps do not require a delegate. All three runtime options are supported:

| Runtime           | Description                                                                                                                                  |
| ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| **Harness Cloud** | Steps run on Harness-hosted infrastructure. No delegate or cluster setup required.                                                           |
| **Delegate**      | Steps run on any available installed delegate. Harness selects one automatically, or you can target a specific delegate using selector tags. |
| **Kubernetes**    | Steps run as containers on a Kubernetes cluster you specify. Requires a Kubernetes connector and a namespace.                                |

***

## Next steps

* Go to [ECS services](https://developer.harness.io/continuous-delivery/3.0/use-deployments/ecs-deployments/ecs-services.md) to configure a service with a task definition and artifact source.
* Go to [ECS infrastructure](https://developer.harness.io/continuous-delivery/3.0/use-deployments/ecs-deployments/ecs-infrastructure.md) to connect an AWS account and configure authentication.
* Go to [Deployment strategies](https://developer.harness.io/continuous-delivery/3.0/use-deployments/ecs-deployments/ecs-deployment-strategies.md) to configure Basic, Canary, Rolling, or BlueGreen.
