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

# ECS BlueGreen Deploy With Traffic Shift Strategy

Deploy an ECS service using the blue-green traffic shift strategy, which gradually moves ALB traffic weight from the current service to the new service using weighted target groups.

The ECS BlueGreen Deploy With Traffic Shift Strategy deploys the new version to a staging ECS service and then shifts ALB traffic weight from the current service to the new service. Unlike the swap strategy, traffic moves gradually using weighted target groups rather than an atomic listener swap.

***

## What you will learn from this topic

* What steps Harness adds to your stage when you select the ECS BlueGreen Deploy With Traffic Shift Strategy.
* How to configure gradual traffic shifting and how the two-step rollback group restores traffic and the previous service.

***

## 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.
* **An Application Load Balancer:** The ALB must have a production listener with weighted target group support. Harness uses the listener rule ARNs to route traffic between the current and new service.

***

## Stage YAML

```yaml
pipeline:
  stages:
    - name: ecs_bluegreen
      id: ecs_bluegreen
      service:
        type: ecs
        items:
          - <service-id>
      environment:
        items:
          - id: <environment-id>
            deploy-to: all
      steps:
        - name: ECS BlueGreen Deploy
          id: ecsBluegreenDeployStep
          deploy:
            uses: ecsBluegreenDeployStep
            with:
              load_balancer: my-load-balancer
              traffic_shift: true
              prod_listener_arn: arn:aws:elasticloadbalancing:<region>:<account>:listener/...
              prod_listener_rule_arn: arn:aws:elasticloadbalancing:<region>:<account>:listener-rule/...
              stage_listener_arn: arn:aws:elasticloadbalancing:<region>:<account>:listener/...
              stage_listener_rule_arn: arn:aws:elasticloadbalancing:<region>:<account>:listener-rule/...
              update_green_svc: false
              remove_autoscaling_blue_svc: false
              skip_steady_state: false
              steady_state_timeout: 10m
              task_def_mode: Task Definition
              task_def: ${{serviceOutput.manifests.ecsTaskDefinition.paths}}
              service_def: ${{serviceOutput.manifests.ecsServiceDefinition.paths}}
              connector: ${{infra.connectorRef}}
              region: ${{infra.region}}
              cluster: ${{infra.cluster}}
              log_level: info
        - 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
      rollback:
        - group:
            id: ecsBluegreenRollback
            name: ECS BlueGreen Rollback
            steps:
              - name: ECS BlueGreen Traffic Shift Rollback
                id: ecsBluegreenTrafficShiftRollbackStep
                deploy:
                  uses: ecsBluegreenTrafficShiftRollbackStep
              - name: ECS BlueGreen Rollback
                id: ecsBluegreenRollbackStep
                deploy:
                  uses: ecsBluegreenRollbackStep
      on-failure:
        errors: all
        action: stage-rollback
```

***

## How this deployment works

When you select this strategy, Harness adds the following steps to your stage by default:

1. **ECS BlueGreen Deploy**: Registers the new task definition, creates or updates the green (staging) service, waits for steady state, and captures internal rollback data used by the rollback steps. Set **Traffic Shift** to `true` on this step.
2. **ECS BlueGreen Traffic Shift**: Shifts traffic across target groups using a weighted forward configuration. Add this step multiple times with different weight distributions to implement a phased rollout (for example, 10% → 50% → 100%).

Rollback:

* **ECS BlueGreen Traffic Shift Rollback**: Restores the ALB listener's forward configuration to what it was before the traffic shift.
* **ECS BlueGreen Rollback**: Reverts the green service deployment using internal rollback data captured by ECS BlueGreen Deploy.

Both rollback steps run together in the same rollback group.

***

## Configure the ECS BlueGreen Deploy step

The ECS BlueGreen Deploy step is required in this strategy. Set **Traffic Shift** to `true` so downstream rollback steps know to restore using the traffic shift rollback path instead of the swap path.

| Field                       | Required | Description                                                                                                   |
| --------------------------- | -------- | ------------------------------------------------------------------------------------------------------------- |
| **Elastic Load Balancer**   | Yes      | The name of the Application Load Balancer.                                                                    |
| **Traffic Shift**           | Yes      | Must be set to `true` for the traffic shift variant.                                                          |
| **Prod Listener ARN**       | Yes      | ARN of the production ALB listener.                                                                           |
| **Prod Listener Rule ARN**  | Yes      | ARN of the production listener rule pointing to the current production target group.                          |
| **Stage Listener ARN**      | Yes      | ARN of the staging ALB listener.                                                                              |
| **Stage Listener Rule ARN** | No       | ARN of the staging listener rule. Required when using listener rules rather than the default listener action. |

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 full field reference.

***

## Configure the ECS BlueGreen Traffic Shift step

The ECS BlueGreen Traffic Shift step is required in this strategy. You must configure the forward configuration before the pipeline can run.

| Field                     | Required | Description                                                                                                                             |
| ------------------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------- |
| **Elastic Load Balancer** | Yes      | The name of the Application Load Balancer. Must match the value configured in the ECS BlueGreen Deploy step.                            |
| **Forward Configuration** | Yes      | Stringified JSON array of objects, each with `TargetGroupArn` and `Weight`, specifying how traffic is distributed across target groups. |
| **Listener ARN**          | Yes      | The ARN of the ALB listener to update.                                                                                                  |
| **Listener Rule ARN**     | No       | The ARN of the listener rule to update. Required when using listener rules rather than the default listener action.                     |

Go to [ECS BlueGreen Traffic Shift step](https://developer.harness.io/continuous-delivery/new-experience/use-deployments/ecs-deployments/step-library/ecs-bluegreen-traffic-shift.md) for the full field reference.

***

## Rollback behavior

Both rollback steps run in the same group when the stage failure strategy triggers, and both have optional fields that auto-resolve from internal rollback data when their `with:` block is omitted:

**ECS BlueGreen Traffic Shift Rollback** restores the ALB listener's forward configuration to what it was before the traffic shift, using the forward configuration captured by ECS BlueGreen Traffic Shift and exposed through `${{rollback.data.TRAFFIC_SHIFT_DATA}}`.

**ECS BlueGreen Rollback** reverts the green service deployment using internal rollback data captured by ECS BlueGreen Deploy, exposed through `${{rollback.data.*}}` expressions such as `${{rollback.data.LOAD_BALANCER}}` and `${{rollback.data.GREEN_SERVICE_CONFIG}}`.

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) and [ECS BlueGreen Rollback step](https://developer.harness.io/continuous-delivery/new-experience/use-deployments/ecs-deployments/step-library/ecs-bluegreen-rollback.md) for the full field references.

***

## Next steps

* Go to [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) to swap all traffic at once instead of shifting gradually.
* Go to [ECS basic deployment](https://developer.harness.io/continuous-delivery/new-experience/use-deployments/ecs-deployments/ecs-deployment-strategies/basic.md) for a simpler upgrade-in-place 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.
