> 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/3.0/use-deployments/overview-4/lambda-canary-deploy/lambda-traffic-shift.md).

# AWS Lambda Traffic Shift

Route a percentage of Lambda function traffic to a new version via a weighted alias.

The AWS Lambda Traffic Shift step updates the weighted alias created by the Canary Deploy step to route a specified percentage of traffic to the new function version. Add multiple Traffic Shift steps in sequence to progressively increase traffic — for example, 10% then 100%.

***

## Step YAML

```yaml
- name: AWS Lambda Traffic Shift 10
  id: awsLambdaTrafficShift10
  template:
    uses: awsLambdaTrafficShiftStep
    with:
      traffic_percentage: "10"
      function_name: <+stage.steps.awsLambdaCanaryDeployStep.output.outputVariables.functionName>
      function_version: <+stage.steps.awsLambdaCanaryDeployStep.output.outputVariables.version>
```

The `function_name` and `function_version` inputs are wired to the Canary Deploy step's output variables. These expressions ensure each traffic shift targets the exact version published in the same stage execution.

For the final 100% shift:

```yaml
- name: AWS Lambda Traffic Shift 100
  id: awsLambdaTrafficShift100
  template:
    uses: awsLambdaTrafficShiftStep
    with:
      traffic_percentage: "100"
      function_name: <+stage.steps.awsLambdaCanaryDeployStep.output.outputVariables.functionName>
      function_version: <+stage.steps.awsLambdaCanaryDeployStep.output.outputVariables.version>
```

***

## Before you begin

* **An AWS Lambda Canary Deploy step** earlier in the same stage. The Traffic Shift step requires the function name and version from the Canary Deploy step output.
* **A Lambda infrastructure.** Go to [Lambda infrastructure](/continuous-delivery/3.0/use-deployments/overview-4/lambda-infrastructure.md).
* For ZIP artifact canary deployments, ensure your service includes an alias definition. For ECR image canary deployments, no alias definition is required — the canary deploy step manages the alias automatically. Go to [Lambda services](/continuous-delivery/3.0/use-deployments/overview-4/lambda-services.md).

***

## Configure the step

### Top-level fields

| Field                  | Description                                                                                                                                                        | Required |
| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------- |
| **Name**               | Display name for this step in the stage canvas.                                                                                                                    | Yes      |
| **Traffic Percentage** | The percentage of invocations to route to the new function version. Must be between `0` and `100`. Set to `100` on the final shift step to complete the promotion. | Yes      |

### Service Configuration

These fields are auto-populated from the Canary Deploy step output. You do not need to change them when the Traffic Shift step follows a Canary Deploy step in the same stage.

| Field                | `with:` key        | Expression                                                                     | Description                                                                                  |
| -------------------- | ------------------ | ------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------- |
| **Function Name**    | `function_name`    | `<+stage.steps.awsLambdaCanaryDeployStep.output.outputVariables.functionName>` | The Lambda function name, passed from the Canary Deploy step output.                         |
| **Function Version** | `function_version` | `<+stage.steps.awsLambdaCanaryDeployStep.output.outputVariables.version>`      | The published version number of the new function, passed from the Canary Deploy step output. |

### Infrastructure Configuration

| Field             | Value                     | Description                                                    |
| ----------------- | ------------------------- | -------------------------------------------------------------- |
| **AWS Connector** | `${{infra.connectorRef}}` | The AWS connector resolved from the infrastructure definition. |
| **AWS Region**    | `${{infra.region}}`       | The AWS region resolved from the infrastructure definition.    |

***

## Add intermediate shifts

The default canary stage includes two Traffic Shift steps: 10% and 100%. To add an intermediate step (for example, 50%), click **+** between the existing shift steps on the stage canvas and add another Traffic Shift step. Set **Traffic Percentage** to the desired value.

You can also insert approval gates or verification steps between any two traffic shift steps to validate the canary before increasing traffic further.

***

## Advanced settings

* **Timeout duration:** Maximum time the step is allowed to run before being terminated.
* **On failure:** Define what happens if the step fails.
* **Strategy:** Configure a looping strategy.
* **Conditional execution:** Run this step only when a condition is true.

***

## Next steps

* Go to [AWS Lambda Canary Deploy](/continuous-delivery/3.0/use-deployments/overview-4/lambda-canary-deploy.md) for the step that publishes the new version and creates the alias.
* Go to [AWS Lambda Canary Rollback](/continuous-delivery/3.0/use-deployments/overview-4/lambda-canary-deploy/lambda-canary-rollback.md) for the step that resets traffic on failure.
* Go to [Lambda canary deployment](/continuous-delivery/3.0/use-deployments/overview-4/canary.md) for the full canary flow walkthrough.

{% @harness-feedback/feedback %}
