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

# ECS BlueGreen Rollback step

The ECS BlueGreen Rollback step reverts a blue-green swap deployment by restoring the previous service and target group configuration.

The ECS BlueGreen Rollback step runs automatically in the rollback section when the stage failure strategy triggers after the swap target groups variant. It restores state using `${{rollback.data.*}}` expressions, which reflect the state Harness persisted from the stage's last successful deployment, not output variables from the current (failed) run. Within the current run's forward execution, ECS BlueGreen Deploy and ECS BlueGreen Swap Target Groups instead reference each other's current-run state through `${{stage.steps.<id>.output.outputVariables.*}}` expressions, as shown on the [ECS BlueGreen Deploy With Swap Strategy](https://developer.harness.io/continuous-delivery/new-experience/use-deployments/ecs-deployments/ecs-deployment-strategies/blue-green-swap.md) page.

**Step Template ID:** `ecsBluegreenRollbackStep`

***

## ECS BlueGreen Rollback step YAML

With explicit overrides:

```yaml
- name: rollback
  id: rollback
  deploy:
    uses: ecsBluegreenRollbackStep
    with:
      skip_steady_state: false
      steady_state_timeout: 10m
      load_balancer: ${{rollback.data.LOAD_BALANCER}}
      prod_listener_arn: ${{rollback.data.PROD_LISTENER_ARN}}
      prod_listener_rule_arn: ${{rollback.data.PROD_LISTENER_RULE_ARN}}
      prod_target_group_arn: ${{rollback.data.PROD_TARGET_GROUP_ARN}}
      green_service_json: ${{rollback.data.GREEN_SERVICE_CONFIG}}
      new_service_created: ${{rollback.data.NEW_SERVICE_CREATED}}
      traffic_shift_started: ${{rollback.data.TRAFFIC_SHIFT_STARTED}}
      traffic_shift: ${{rollback.data.IS_TRAFFIC_SHIFT}}
      blue_service_scalable_targets_json: ${{rollback.data.SCALABLE_TARGETS}}
      blue_service_scaling_policies_json: ${{rollback.data.SCALING_POLICIES}}
      blue_service_scheduled_actions_json: ${{rollback.data.SCHEDULED_ACTIONS}}
      green_service_scalable_targets_json: ${{rollback.data.GREEN_SERVICE_SCALABLE_TARGETS}}
      green_service_scaling_policies_json: ${{rollback.data.GREEN_SERVICE_SCALING_POLICIES}}
      green_service_scheduled_actions_json: ${{rollback.data.GREEN_SERVICE_SCHEDULED_ACTIONS}}
      rollback_green_service: ${{rollback.data.GREEN_SERVICE_ROLLBACK_DATA_EXIST}}
      connector: ${{infra.connectorRef}}
      region: ${{infra.region}}
      cluster: ${{infra.cluster}}
      log_level: info
```

Minimal form, relying on auto-resolved rollback state:

```yaml
- name: ECS BlueGreen Rollback
  id: ecsBluegreenRollbackStep
  deploy:
    uses: ecsBluegreenRollbackStep
```

***

## 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 optional and auto-resolve**

All fields on this step are optional. When the `with:` block is omitted entirely, Harness auto-resolves every rollback input using `${{rollback.data.*}}` expressions, which reflect the state Harness persisted from the stage's last successful deployment, not values from the current run. Set these fields explicitly only to override that auto-resolved rollback state.
{% endhint %}

***

## ECS BlueGreen Rollback step fields

### Rollback inputs (optional, auto-resolve when omitted)

| Field                                    | YAML key                               | Value                                                  | Description                                                                                                     |
| ---------------------------------------- | -------------------------------------- | ------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------- |
| **Elastic Load Balancer**                | `load_balancer`                        | `${{rollback.data.LOAD_BALANCER}}`                     | The load balancer used during the forward deployment.                                                           |
| **Prod Listener ARN**                    | `prod_listener_arn`                    | `${{rollback.data.PROD_LISTENER_ARN}}`                 | The production listener ARN before the swap.                                                                    |
| **Prod Listener Rule ARN**               | `prod_listener_rule_arn`               | `${{rollback.data.PROD_LISTENER_RULE_ARN}}`            | The production listener rule ARN before the swap.                                                               |
| **Prod Target Group ARN**                | `prod_target_group_arn`                | `${{rollback.data.PROD_TARGET_GROUP_ARN}}`             | The target group ARN that was receiving production traffic before the swap.                                     |
| **Green Service JSON**                   | `green_service_json`                   | `${{rollback.data.GREEN_SERVICE_CONFIG}}`              | Stringified JSON of the `CreateServiceRequest` object used to create or update the green service.               |
| **New Service Created**                  | `new_service_created`                  | `${{rollback.data.NEW_SERVICE_CREATED}}`               | Whether the green service was newly created during this deployment.                                             |
| **Traffic Shift Started**                | `traffic_shift_started`                | `${{rollback.data.TRAFFIC_SHIFT_STARTED}}`             | Whether a traffic shift had started before rollback was triggered.                                              |
| **Traffic Shift**                        | `traffic_shift`                        | `${{rollback.data.IS_TRAFFIC_SHIFT}}`                  | Whether this deployment paired ECS BlueGreen Deploy with the traffic shift variant instead of the swap variant. |
| **Blue Service Scalable Targets JSON**   | `blue_service_scalable_targets_json`   | `${{rollback.data.SCALABLE_TARGETS}}`                  | Stringified JSON array of `RegisterScalableTargetRequest` objects for the blue service.                         |
| **Blue Service Scaling Policies JSON**   | `blue_service_scaling_policies_json`   | `${{rollback.data.SCALING_POLICIES}}`                  | Stringified JSON array of `PutScalingPolicyRequest` objects for the blue service.                               |
| **Blue Service Scheduled Actions JSON**  | `blue_service_scheduled_actions_json`  | `${{rollback.data.SCHEDULED_ACTIONS}}`                 | Stringified JSON array of `PutScheduledActionRequest` objects for the blue service.                             |
| **Green Service Scalable Targets JSON**  | `green_service_scalable_targets_json`  | `${{rollback.data.GREEN_SERVICE_SCALABLE_TARGETS}}`    | Stringified JSON array of `RegisterScalableTargetRequest` objects for the green service.                        |
| **Green Service Scaling Policies JSON**  | `green_service_scaling_policies_json`  | `${{rollback.data.GREEN_SERVICE_SCALING_POLICIES}}`    | Stringified JSON array of `PutScalingPolicyRequest` objects for the green service.                              |
| **Green Service Scheduled Actions JSON** | `green_service_scheduled_actions_json` | `${{rollback.data.GREEN_SERVICE_SCHEDULED_ACTIONS}}`   | Stringified JSON array of `PutScheduledActionRequest` objects for the green service.                            |
| **Rollback Green Service**               | `rollback_green_service`               | `${{rollback.data.GREEN_SERVICE_ROLLBACK_DATA_EXIST}}` | Whether the green service has rollback data available.                                                          |

### Other configuration

| Field                    | YAML key               | Default | Description                                                                  |
| ------------------------ | ---------------------- | ------- | ---------------------------------------------------------------------------- |
| **Skip Steady State**    | `skip_steady_state`    | `false` | When `true`, Harness does not wait for steady state after the rollback.      |
| **Steady State Timeout** | `steady_state_timeout` | `10m`   | How long Harness waits for the service to reach steady state after rollback. |
| **Log Level**            | `log_level`            | `info`  | Log verbosity for the step execution.                                        |

### Infrastructure configuration

These fields are derived from the infrastructure definition. Harness resolves them automatically.

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

***

## How the ECS BlueGreen Rollback step works

When the step runs, Harness executes the following actions:

1. Reads the load balancer, listener, and target group ARNs, the blue and green service configurations, and the traffic-shift and new-service-created flags, using `${{rollback.data.*}}` expressions that reflect the state from the stage's last successful deployment.
2. If a swap or traffic shift had already occurred, reverses it on the ALB listeners.
3. Restores the blue service's scalable targets, scaling policies, and scheduled actions.
4. Downsizes or removes the green service, depending on whether it existed before the deployment and whether it has rollback data.
5. Waits for the restored service to reach steady state (unless **Skip Steady State** is enabled).

***

## Next steps

* Go to [ECS BlueGreen Deploy step](https://developer.harness.io/continuous-delivery/new-experience/use-deployments/ecs-deployments/step-library/ecs-bluegreen-deploy.md) for the deploy step that this step rolls back.
* Go to [ECS BlueGreen Swap Target Groups step](https://developer.harness.io/continuous-delivery/new-experience/use-deployments/ecs-deployments/step-library/ecs-bluegreen-swap-target-groups.md) for the swap step in this strategy.
* 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.
