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

# ECS BlueGreen Traffic Shift step

The ECS BlueGreen Traffic Shift step gradually moves a percentage of ALB traffic to the new ECS service using weighted target groups.

The ECS BlueGreen Traffic Shift step runs after ECS BlueGreen Deploy (with **Traffic Shift** set to `true`) in the traffic shift variant. It sets the traffic weight distribution across the production and new service target groups on an ALB listener rule, using an explicit, weighted list of target group ARNs. Add this step multiple times with different weight distributions to implement a phased rollout.

**Step Template ID:** `ecsBluegreenTrafficShiftStep`

***

## ECS BlueGreen Traffic Shift step YAML

Shift 25% of traffic to the new service, 75% remaining on production:

```yaml
- name: ECS BlueGreen Traffic Shift
  id: ecsBluegreenTrafficShiftStep
  deploy:
    uses: ecsBluegreenTrafficShiftStep
    with:
      load_balancer: my-load-balancer
      forward_config: '[{"TargetGroupArn":"arn:aws:elasticloadbalancing:<region>:<account>:targetgroup/new-service-tg/...","Weight":25},{"TargetGroupArn":"arn:aws:elasticloadbalancing:<region>:<account>:targetgroup/prod-service-tg/...","Weight":75}]'
      config_type: new
      listener_arn: arn:aws:elasticloadbalancing:<region>:<account>:listener/...
      listener_rule_arn: arn:aws:elasticloadbalancing:<region>:<account>:listener-rule/...
      steady_state_timeout: 10m
      connector: ${{infra.connectorRef}}
      region: ${{infra.region}}
      cluster: ${{infra.cluster}}
      log_level: info
      output_alias: ecsBluegreenTrafficShift
```

***

## 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 BlueGreen Traffic Shift step fields

| Field                         | YAML key               | Required | Default | Description                                                                                                                                        |
| ----------------------------- | ---------------------- | -------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Elastic Load Balancer**     | `load_balancer`        | Yes      | —       | The name of the Application Load Balancer. Must match the value configured in the ECS BlueGreen Deploy step.                                       |
| **Forward Configuration**     | `forward_config`       | Yes      | —       | Stringified JSON array of objects, each with `TargetGroupArn` and `Weight`, specifying how traffic is distributed across target groups.            |
| **Traffic Shift Config Type** | `config_type`          | No       | `new`   | The kind of configuration being applied. Set to `new` to replace the listener rule's current forward configuration with **Forward Configuration**. |
| **Listener ARN**              | `listener_arn`         | Yes      | —       | The ARN of the ALB listener to update.                                                                                                             |
| **Listener Rule ARN**         | `listener_rule_arn`    | No       | —       | The ARN of the listener rule to update. Required when using listener rules rather than the default listener action.                                |
| **Steady State Timeout**      | `steady_state_timeout` | No       | `10m`   | How long Harness waits for the service to stabilize after the traffic shift.                                                                       |

### Other configuration

| Field            | YAML key       | Default | Description                                                                                                                                                                                                  |
| ---------------- | -------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **Log Level**    | `log_level`    | `info`  | Log verbosity for the step execution.                                                                                                                                                                        |
| **Output Alias** | `output_alias` | —       | An alias for this step's output and rollback data. Set a unique alias on each ECS BlueGreen Traffic Shift step when a stage has more than one, so each step's rollback data can be referenced independently. |

### 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 Traffic Shift step works

When the step runs, Harness executes the following actions:

1. Captures the listener rule's current forward configuration internally as rollback data (available to ECS BlueGreen Traffic Shift Rollback through the `${{rollback.data.TRAFFIC_SHIFT_DATA}}` expression).
2. Updates the ALB listener (or listener rule, when **Listener Rule ARN** is set) to forward traffic according to the weights specified in **Forward Configuration**.
3. Waits for the service to reach steady state, up to **Steady State Timeout**.

A **Forward Configuration** that assigns `100` to the new service's target group and `0` to the production target group moves all traffic to the new service and completes the rollout.

***

## 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 step that precedes traffic shift.
* Go to [ECS BlueGreen Traffic Shift Rollback step](https://developer.harness.io/continuous-delivery/new-experience/use-deployments/ecs-deployments/step-library/ecs-bluegreen-traffic-shift-rollback.md) for the rollback step for this variant.
* 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.
