ECS Blue-Green Traffic Shifting Step
ECS Blue-Green deployment strategy with native support for phased traffic shifting using ALB weighted target groups.
Harness now supports gradual traffic shifting during ECS Blue-Green deployments using AWS Application Load Balancer (ALB) weighted target groups. This enhancement enables you to progressively direct live traffic to a new ECS service version.
Overview
Traditionally, ECS Blue-Green deployments in Harness used two listener rules—Stage and Prod listener rules. This setup lacked the flexibility to support multiple rules or test traffic on alternate listener rules before shifting production traffic. All validation was done on the Stage listener rule before traffic was swapped to Prod.
To solve this, you can now configure traffic shifting between target groups attached to the same listener rule, giving you the flexibility to:
Use multiple target groups in a single rule with configurable traffic distribution across target groups.
Test new versions incrementally in dev and then production environments.
Perform gradual roll-outs with approval gates between steps.
Revert traffic back to the original forward configuration in case of issues.
Set up a ECS Blue-Green Traffic Shifting Step Group
Add an ECS stage to your pipeline.
Add a Harness ECS service in the stage Service. For more information, refer Adding an ECS Service
Add a Harness ECS environment and infrastructure in the stage Environment. For more information, refer Adding an ECS Environment
In the Execution strategies tab, select the Blue Green strategy and enable the checkbox Add Traffic Shifting Steps under the Enable Traffic Shifting for ECS Deployment section.
Your Execution tab now includes a Blue Green Deployment step group with the ECS Blue Green Create Service step and ECS Blue-Green Traffic Shifting step.

If you do not select the Add Traffic Shifting Steps checkbox, then you will have a Blue Green Deployment step group with steps Configure Blue Green Deployment and ECS Blue Green Swap Target Groups.
You can also use a blank canvas and manually add the ECS Blue Green Create Service step and ECS Blue-Green Traffic Shifting step to your stage.
Configure the ECS Blue Green Create Service step.

Name : Name of the step
Timeout : Execution timeout
Elastic Load Balancer : Select the AWS Load Balancer to use
Select the Use Shift Traffic checkbox to enable the ECS Blue-Green Traffic Shifting step.
In Configure your Production Service:
Prod Listener: Select the ELB listener you want to use for production.
Prod Listener Rule ARN: Select the listener rule that forwards traffic to the production and stage target groups.
Stage Target Group ARN (Optional): Select the target group where the new service version will be deployed.
The specified listener rule must reference exactly two target groups: one for the existing (production) service and one for the new (stage) service. This field identifies the stage target group in that rule.
Same as already running instances: When selected, the new ECS service uses the same instances as the old service after deployment.
Update Green Service: When selected, the green service will be updated instead of being deleted and re-created during deployment.
Automated Stage Target Group Discovery
Harness automatically detects the correct stage target group when stageTargetGroupArn is not provided, eliminating the risk of deployment failures caused by manual selection errors.
How Automatic Discovery Works
When you leave the Stage Target Group ARN field empty:
Query AWS: Harness retrieves the current traffic weights for all target groups in the specified listener rule
Validate Distribution: The system verifies that the traffic distribution follows one of these patterns:
100/0: One target group has 100% traffic (active BLUE), the other has 0% (empty STAGE)
0/100: Inverse of above
0/0: Both target groups have 0% traffic (initial state)
NULL values: Target groups with no weight assigned are treated as 0%
Select Stage Target Group: Harness automatically selects the target group with 0% traffic weight as the stage target group
Fast-Fail on Ambiguity: If weights don't match the expected patterns (e.g., 60/40, 70/30), the deployment fails immediately with a clear error message
Log Selection: The chosen stage target group ARN is displayed in the deployment console logs for verification
Benefits of Automatic Discovery
Prevents Production Outages: Eliminates the risk of accidentally deploying to the active production target group
No Manual Tracking Required: No need to remember which target group was used in the previous deployment
Safer Deployments: System validates the traffic state before proceeding
Backward Compatible: Manual selection still works if you prefer explicit control
Example Scenario
Initial State:
Target Group A: 100% traffic (active BLUE service)
Target Group B: 0% traffic (empty)
Deployment 1 (Automatic):
Harness detects Target Group B has 0% → deploys new service to Target Group B
After traffic shift to 100%: Target Group B becomes active BLUE
Deployment 2 (Automatic):
Harness detects Target Group A has 0% → deploys new service to Target Group A
After traffic shift to 100%: Target Group A becomes active BLUE
No manual intervention required between deployments.
Configure the ECS Blue-Green Traffic Shifting step
This step adjusts traffic weights between target groups.

Step parameters
Name : Name of the step.
Timeout : Execution timeout.
In the Traffic Shifting configuration, you have the option to either:
Inherit the configuration from the previous ECS Blue-Green Create Service step using the Inherit checkbox, or
Select the Standalone checkbox to define a new configuration.
Inherit
When Inherit is selected:
Provide the New ECS Weight.
Configuration such as Elastic Load Balancer, Listener, and Listener Rule ARN is inherited from the ECS Blue Green Create Service step.
The step adjusts traffic distribution between the Stage Target Group (where the new service version is deployed) and the Prod Target Group (where the existing version is running):
Weight
50→ 50% traffic to Stage Target Group, 50% to Prod Target Group.Weight
70→ 70% to Stage Target Group, 30% to Prod Target Group.Weight
100→ Suppose you provide the weight as100, the step will route100%traffic to the Stage target group.
The Inherit step updates blue and green tags only when 100% of the traffic is shifted to the Stage Target Group. In this case, the new service deployed is tagged as BLUE. For any lower weight, tagging does not occur.
Downsize old service after traffic shift
When ECS Blue/Green Traffic Shift (Inherit mode) shifts 100% of traffic to the new service, the old ECS service continues running at its original desired task count. Idle containers remain registered with ECS and accrue infrastructure costs even though they receive no live traffic. The Downsize old service option instructs Harness to automatically downsize the old service once the traffic shift reaches 100%.
The Inherit configuration includes two optional fields:
Downsize old service: Select this checkbox to downsize the old ECS service after traffic reaches 100%. When enabled, Harness removes the auto-scaling policies, deregisters the scalable target, and sets the desired task count on the old service to zero. This checkbox is cleared by default.
Downsize Old Service Delay (Seconds): Optionally specify a grace period in seconds between the 100% traffic shift and the start of the downsize sequence. This gives in-flight requests time to complete before the old service stops. When not set or set to zero, the downsize begins immediately.
Rollback behavior:
Rollback works correctly regardless of whether downsizing is enabled. The ECS Blue Green Rollback step restores the old service's desired count and auto-scaling configuration from a snapshot that Harness captures at the very start of deployment, before any traffic shifting or downsizing occurs. Whether downsizeOldService is true or false, triggering a rollback (for example, by rejecting an approval step or failing a shell script step) restores the old service to its pre-deployment state.
Standalone
When the Standalone checkbox is selected:
You can provide a new set of Elastic Load Balancer, Listener, and Listener Rule ARN values.
This allows you to set the forward configuration for the specified listener rule, which defines how traffic is distributed across multiple target groups.
A common use case is to validate the new service independently in lower environments by referencing the same target groups used in the production rule from the Blue-Green Create step.
You must not reuse the same listener rule that is specified in the ECS Blue Green Create Service step. Doing so will result in a failure during execution.
Elastic Load Balancer: Click here and select the AWS load balancer to use.
Harness uses the delegate to locate the load balancers and list them in Elastic Load Balancer. If you do not see your load balancer, ensure that the delegate can connect to ECS.
Listener: Select the ELB listener to associate with this deployment.
Listener Rule ARN: Choose the Listener Rule ARN that defines the routing of traffic to the appropriate target group.
In Target Group Tuples, specify:
Target Group ARN: Select the target group to which traffic should be shifted.
Weight: Specify the weight to be associated with the target group in the listener rule.
For details on how weights work and supported values, refer to the AWS ALB Listener Rule documentation.
You can provide one or more Target Group Tuples, and the forward configuration for the listener rule will be set accordingly based on the weights specified in each tuple.
The Standalone step does not assign blue or green tags to the associated ECS services.
Rollback Behavior
When you run the ECS Blue Green Create Service step, the system stores the initial configuration as Prepare Rollback Data before execution begins.
In Inherit mode, if the step fails mid-execution, the rollback is handled by the ECS Blue Green Rollback step, which restores the traffic weights and blue/green tag assignments using the stored rollback data.
In Standalone mode, during the first execution of each listener rule, the system captures the original forward configuration as part of the rollback data. If a failure occurs, the Standalone Traffic Shift Rollback step restores the original forward configuration for all affected listener rules.
In both cases, rollback steps ensure that traffic is routed back to the original setup in the event of a failure.
Rollback behavior depends on the mode used:

Inherit Mode: Restores the initial traffic weights using the ECS BG Rollback step.

Click to view full size image Standalone Mode: Resets the original forward configuration for all listener rules used in the stage using the Standalone Traffic Shift Rollback step.

Click to view full size image
In both cases, the original forward configuration is restored in the event of a failure or rollback trigger, using the appropriate rollback step for each mode.
Comparison: Traditional Blue-Green vs. Traffic Shifting
Traditional Blue-Green Deployment (Pre-Traffic Shifting)
Requires two separate listener rules (typically configured on different ports)
New version is deployed to the Stage target group associated with a different listener rule (commonly mapped to a separate port)
After manual/automated validation, a Swap Target Groups step is used to direct 100% traffic to the new version
You cannot test the new version on live production traffic until after the swap
Swap is atomic—no gradual rollout or partial traffic shift
Blue-Green Deployment with Traffic Shifting (New Flow)
Uses a single listener rule with weighted target groups
New version is deployed to a target group under the same listener rule as the old version
Allows progressive traffic rollout (e.g., 10% → 50% → 100%) using ECS Traffic Shift step
Eliminates need for separate ports or manual AWS CLI scripts
Enables staged rollout with approval gates, monitoring, and rollback safety
No Swap step needed—transition to full traffic is handled by adjusting target group weights
Note: This new traffic-shifting approach makes Blue-Green deployments safer, more controlled, and production-traffic-aware.
General Solution Pattern for Traffic Shifting
For customers who want to implement progressive traffic shifting (e.g., 10% → 30% → 100%) across environments:
Attach two target groups to a single ALB listener rule designated as the production rule.
Create a separate listener rule for the dev environment that uses the same two target groups.
In the ECS Blue Green Create Service step, specify the production listener rule.
In lower environments, shift traffic to the stage target group using the Standalone Traffic Shift step with the dev listener rule.
In production, use Inherit mode to gradually increase traffic to the new service version via the stage target group.
Use ECS Traffic Shift steps to adjust traffic incrementally (e.g., 10%, 50%, 100%) with optional approval gates between shifts.
Finalize with a full cut-over to the stage target group, which is tagged as BLUE when traffic reaches 100%.
Limitations
For supported target group weights and configuration options, refer to the AWS ALB Listener Rules documentation.
Maximum of 5 target groups per rule (AWS limitation).
Swap step and Auto Scaling during swap are not supported.
For automatic stage target group discovery, the listener rule must have a clear traffic distribution pattern (100/0, 0/100, or 0/0). Ambiguous weight distributions (e.g., 60/40) will cause the deployment to fail.
Example Use Case: Controlled Traffic Shifting Across Environments
You can use ECS traffic shifting to gradually roll out and validate a new version of your service across different environments before promoting it to production:
Deploy the new version of the service once and attach it to the Stage Target Group.
Keep the prod target group mapped to the existing (old) service.
In lower environments, incrementally shift traffic to the new service version and validate using CV (Continuous Verification), approval steps, or custom scripts.
Once validated, deploy the new version in the production environment and mark the new service as the blue version.
Example Use Case: Step-by-Step Flow for Gradual Traffic Shifting
This example outlines the basic flow you can follow when implementing ECS Blue-Green deployments with traffic shifting:
Add the ECS Blue-Green Create Service step with
isTrafficShift: true. Optionally leavestageTargetGroupArnempty for automatic discovery (recommended), or provide a specific target group ARN for manual control.Add an ECS Traffic Shift step (inherit or standalone) to begin shifting traffic incrementally.
(Optional) Add an approval step to control progression between shifts.
Repeat the ECS Traffic Shift steps to gradually increase traffic to 100%.
Sample pipeline YAML for Inherit traffic shifting step
Below is a ready-to-use pipeline YAML that demonstrates how to configure the Inherit traffic shifting mode in an ECS Blue-Green deployment with automatic stage target group discovery.
Sample pipeline YAML for Standalone traffic shifting step
Below is a ready-to-use pipeline YAML that demonstrates how to configure the Standalone traffic shifting mode in an ECS Blue-Green deployment.
See also
Last updated
Was this helpful?