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

# ECS Rolling Rollback step

The ECS Rolling Rollback step restores an ECS service to the task definition and configuration captured before the ECS Rolling Deploy step ran.

The ECS Rolling Rollback step runs automatically as part of the rollback group when the stage failure strategy triggers. It restores the ECS service to the task definition, desired count, and scaling configuration that were captured by the ECS Rolling Deploy step before deployment began.

**Step Template ID:** `ecsRollingRollbackStep`

***

## ECS Rolling Rollback step YAML

```yaml
- name: ECS Rolling Rollback
  id: ecsRollingRollbackStep
  template:
    uses: ecsRollingRollbackStep
    with:
      curr_service: ${{stage.steps.ecsRollingDeployStep.output.outputVariables.currService}}
      first_deployment: ${{stage.steps.ecsRollingDeployStep.output.outputVariables.firstDeployment}}
      skip_app_scaling: ${{stage.steps.ecsRollingDeployStep.output.outputVariables.scalingSkipped}}
```

{% hint style="info" %}
**Template version pinning**

You can pin a specific template version with `uses: ecsRollingRollbackStep@<version>`, for example `ecsRollingRollbackStep@1.0.5`. Omitting the version resolves the latest available template.
{% 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.

***

{% hint style="info" %}
**Fields are wired by default**

When Harness generates the default rollback step, it wires **Current Service**, **First Deployment**, and **Skip App Scaling** from the ECS Rolling Deploy step's output variables. Leave this wiring in place unless you have a reason to override it.
{% endhint %}

***

## ECS Rolling Rollback step fields

| Field                | YAML key           | Value                                                                          | Description                                                                           |
| -------------------- | ------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------- |
| **Current Service**  | `curr_service`     | `${{stage.steps.ecsRollingDeployStep.output.outputVariables.currService}}`     | The ECS service configuration captured by ECS Rolling Deploy before deployment began. |
| **First Deployment** | `first_deployment` | `${{stage.steps.ecsRollingDeployStep.output.outputVariables.firstDeployment}}` | Whether the paired ECS Rolling Deploy step was the first deployment of the service.   |
| **Skip App Scaling** | `skip_app_scaling` | `${{stage.steps.ecsRollingDeployStep.output.outputVariables.scalingSkipped}}`  | Whether **Skip App Scaling** was enabled on the paired ECS Rolling Deploy step.       |

### Other configuration

| Field           | YAML key      | Default | Description                                                     |
| --------------- | ------------- | ------- | --------------------------------------------------------------- |
| **Modify Tags** | `modify_tags` | `false` | When `true`, Harness applies tag modifications during rollback. |
| **Log Level**   | `log_level`   | `info`  | Log verbosity for the step execution.                           |

***

## How the ECS Rolling Rollback step works

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

1. Reads the previous service configuration, deployment history, and scaling state from the **Current Service**, **First Deployment**, and **Skip App Scaling** inputs, wired from ECS Rolling Deploy's output variables.
2. Updates the service to the previous task definition and desired count.
3. Waits for the service to reach steady state.
4. Restores scalable targets and scaling policies to their pre-deployment state, unless **Skip App Scaling** is enabled.

Rollback behavior differs by deployment history:

* **First deployment:** There is no previous service to restore. Harness deletes the service that was created by ECS Rolling Deploy and waits for it to drain.
* **Subsequent deployments:** Harness restores the previous task definition and scaling configuration.

***

## Next steps

* 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 deploy step paired with this rollback.
* 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.
