> 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-canary-deploy.md). Agents can also search and read this documentation through its [MCP server](https://developer.harness.io/~gitbook/mcp).

# ECS Canary Deploy step

The ECS Canary Deploy step creates a canary version of an ECS service with the new task definition at a small instance count for validation before full rollout.

The ECS Canary Deploy step is the first step in the canary strategy. It registers a new ECS task definition revision, creates a canary service alongside the production service, waits for it to reach steady state, and applies auto-scaling configuration to the canary. The ECS Canary Delete step runs next to remove the canary, followed by ECS Rolling Deploy for the full rollout.

**Step Template ID:** `ecsCanaryDeployStep`

***

## ECS Canary Deploy step YAML

Minimal form, uses all defaults:

```yaml
- name: ECS Canary Deploy
  id: ecsCanaryDeployStep
  template:
    uses: ecsCanaryDeployStep
```

With explicit canary count and suffix:

```yaml
- name: ECS Canary Deploy
  id: ecsCanaryDeployStep
  template:
    uses: ecsCanaryDeployStep
    with:
      desired_count: 1
      service_suffix: Canary
      steady_state_timeout: 10m
      log_level: info
```

***

## 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 Canary Deploy step fields

| Field                          | YAML key         | Required | Default  | Description                                                                                                                                                                                 |
| ------------------------------ | ---------------- | -------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Desired Count Override**     | `desired_count`  | No       | —        | The number of canary instances to run. When empty, Harness uses the `desiredCount` from the service definition manifest.                                                                    |
| **Canary Service Name Suffix** | `service_suffix` | No       | `Canary` | The string appended to the base service name to form the canary service name. For example, with base name `my-service` and suffix `Canary`, the canary service is named `my-serviceCanary`. |

### Service configuration

Auto-resolved from the service and artifact configuration.

| Field                  | YAML key             | Default value                                             | Description                               |
| ---------------------- | -------------------- | --------------------------------------------------------- | ----------------------------------------- |
| **Task Definition**    | `task_definition`    | `${{serviceOutput.manifests.ecsTaskDefinition.paths}}`    | Path to the task definition file.         |
| **Service Definition** | `service_definition` | `${{serviceOutput.manifests.ecsServiceDefinition.paths}}` | Path to the service definition file.      |
| **Scalable Targets**   | `scalable_targets`   | `${{serviceOutput.manifests.ecsScalableTarget.paths}}`    | Path to the scalable target definition.   |
| **Scaling Policies**   | `scaling_policies`   | `${{serviceOutput.manifests.ecsScalingPolicy.paths}}`     | Path to the scaling policy definition.    |
| **Scheduled Actions**  | `scheduled_actions`  | `${{serviceOutput.manifests.ecsScheduledActions.paths}}`  | Path to the scheduled actions definition. |

### Infrastructure configuration

Auto-resolved from the infrastructure definition.

| Field         | YAML key    | Default value             | Description                                       |
| ------------- | ----------- | ------------------------- | ------------------------------------------------- |
| **Connector** | `connector` | `${{infra.connectorRef}}` | AWS connector from the infrastructure definition. |
| **Region**    | `region`    | `${{infra.region}}`       | AWS region from the infrastructure definition.    |
| **Cluster**   | `cluster`   | `${{infra.cluster}}`      | ECS cluster from the infrastructure definition.   |

### Other configuration

| Field                    | YAML key               | Default | Description                                                          |
| ------------------------ | ---------------------- | ------- | -------------------------------------------------------------------- |
| **Steady State Timeout** | `steady_state_timeout` | `10m`   | How long Harness waits for the canary service to reach steady state. |
| **Log Level**            | `log_level`            | `info`  | Log verbosity for the step execution.                                |

***

## How the ECS Canary Deploy step works

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

1. Registers a new ECS task definition revision from the task definition manifest.
2. If a canary service with the same name already exists (from a previous failed deployment), deletes it and waits for it to drain.
3. Creates a new canary service using the service name with the configured suffix appended. The service starts at the specified desired count.
4. Waits for the canary service to reach steady state.
5. Registers scalable targets and scaling policies on the canary service from the service manifests.
6. Emits the canary service name as an output variable (`canaryService`) for the ECS Canary Delete step.

***

## Step outputs

| Output                  | Expression                                                                  | Description                                                                      |
| ----------------------- | --------------------------------------------------------------------------- | -------------------------------------------------------------------------------- |
| **Canary service name** | `${{stage.steps.ecsCanaryDeployStep.output.outputVariables.canaryService}}` | The full name of the created canary service. Used by the ECS Canary Delete step. |

***

## Next steps

* Go to [ECS Canary Delete step](https://developer.harness.io/continuous-delivery/new-experience/use-deployments/ecs-deployments/step-library/ecs-canary-delete.md) for the step that removes the canary service after validation.
* Go to [ECS Rolling Deploy step](https://developer.harness.io/continuous-delivery/new-experience/use-deployments/ecs-deployments/step-library/ecs-rolling-deploy.md) for the full rollout step that follows canary deletion.
* 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.
