> 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/yaml-reference/step-library-yaml-reference.md).

# Step library YAML reference

YAML examples for every Kubernetes, Helm, Google Cloud Run, Google Cloud Functions, AWS Lambda, AWS SAM, ECS, and Serverless Lambda step available in Harness Deployments.

Harness provides more than 16 Kubernetes steps, more than 7 Helm steps, 4 Google Cloud Run steps, 3 Google Cloud Functions steps, 5 AWS Lambda steps, 3 AWS SAM steps, more than 10 ECS steps, and 3 Serverless Lambda steps. This page collects the YAML for every step in one place, covering rolling, blue-green, and canary deployment strategies as well as utility operations for scaling, patching, traffic routing, and manifest management.

***

### Kubernetes steps <a href="#kubernetes-steps" id="kubernetes-steps"></a>

#### Kubernetes Rolling Deploy <a href="#kubernetes-rolling-deploy" id="kubernetes-rolling-deploy"></a>

Template ID: `k8sRollingDeployStep`

Prepares manifests, applies them to the cluster, and checks resource steady state. Performs a rolling update, gradually replacing old pods with new ones to ensure zero-downtime deployments.

| Input                     | Type    | Description                                                      |
| ------------------------- | ------- | ---------------------------------------------------------------- |
| `namespace`               | string  | Kubernetes namespace for deployment                              |
| `manifests`               | array   | List of manifest file paths                                      |
| `release`                 | string  | Release name                                                     |
| `skip_dry_run`            | boolean | Skip dry run (default: `false`)                                  |
| `pruning`                 | boolean | Remove old resources not in current manifests (default: `false`) |
| `server_side_apply`       | boolean | Use server-side apply (default: `false`)                         |
| `skip_steady_state_check` | boolean | Skip steady state check (default: `false`)                       |
| `flags`                   | array   | Additional command flags                                         |
| `log_level`               | select  | Log level: `warn`, `error`, `info`, `debug`, `trace`             |

For rollback, use `k8sRollingRollbackStep` to revert a rolling deployment to its previous state.

```yaml
steps:
  - name: Rolling Deploy
    uses: k8sRollingDeployStep@1.0.0
    with:
      namespace: production
      manifests:
        - k8s/deployment.yaml
        - k8s/service.yaml
      pruning: true
      log_level: info
```

***

#### Kubernetes Rolling Rollback <a href="#kubernetes-rolling-rollback" id="kubernetes-rolling-rollback"></a>

Template ID: `k8sRollingRollbackStep`

Re-applies the manifests from the last successful release stored in the cluster release history secret. Harness runs this step automatically when a rolling or canary stage fails. You can also add it manually to a rollback group.

| Input             | Type    | Description                                                                                     |
| ----------------- | ------- | ----------------------------------------------------------------------------------------------- |
| `namespace`       | string  | Target namespace                                                                                |
| `release`         | string  | Release name used to look up rollback target in the cluster secret                              |
| `enable_pruning`  | boolean | Remove resources present in current release but absent from rollback release (default: `false`) |
| `kubeconfig_path` | string  | Path to the kubeconfig file                                                                     |

```yaml
steps:
  - name: Rolling Rollback
    uses: k8sRollingRollbackStep@1.0.0
    with:
      namespace: production
      release: my-release
```

***

#### Kubernetes Blue-Green Deploy <a href="#kubernetes-blue-green-deploy" id="kubernetes-blue-green-deploy"></a>

Blue-green deployment maintains two identical environments. The new version is deployed to the inactive stage environment, tested, and traffic is switched by swapping service selectors. Provides instant rollback by re-swapping selectors.

| Step                                    | Description                                                 |
| --------------------------------------- | ----------------------------------------------------------- |
| `k8sBlueGreenDeployStep`                | Creates services and pod sets for blue-green deployment     |
| `k8sBlueGreenSwapServicesSelectorsStep` | Swaps service selectors to route traffic to the new version |
| `k8sBlueGreenStageScaleDownStep`        | Scales down the inactive stage environment                  |

Also available as a managed strategy: `k8sBlueGreenDeployStrategy`, which orchestrates all three steps automatically.

**Blue-green workflow:**

1. Deploy the new version to the stage environment alongside the active primary environment.
2. Test the stage deployment to verify the new version is healthy.
3. Swap service selectors to route production traffic to the new version.
4. Scale down the old primary environment to free resources.

```yaml
steps:
  - name: Blue-Green Deploy
    uses: k8sBlueGreenDeployStep@1.0.0
    with:
      namespace: production
      manifests:
        - k8s/deployment.yaml
        - k8s/service.yaml

  # After testing...
  - name: Swap Traffic
    uses: k8sBlueGreenSwapServicesSelectorsStep@1.0.0

  - name: Scale Down Old
    uses: k8sBlueGreenStageScaleDownStep@1.0.0
```

***

#### Kubernetes Canary Deploy <a href="#kubernetes-canary-deploy" id="kubernetes-canary-deploy"></a>

Canary deployment gradually rolls out changes by first deploying a small subset of pods with the new version. Monitor metrics and health before promoting to the full fleet or rolling back.

| Step                  | Description                                             |
| --------------------- | ------------------------------------------------------- |
| `k8sCanaryDeployStep` | Deploys a subset of pods with the new version           |
| `k8sCanaryDeleteStep` | Cleans up canary deployment after promotion or rollback |

Also available as a managed strategy: `k8sCanaryDeployStrategy`, which handles the canary lifecycle automatically.

**Canary workflow:**

1. Deploy a small percentage of pods with the new version.
2. Monitor metrics and health of the canary pods.
3. Promote (trigger a full rolling deploy) or rollback (delete the canary pods).

```yaml
steps:
  - name: Canary Deploy
    uses: k8sCanaryDeployStep@1.0.0
    with:
      namespace: production
      manifests:
        - k8s/deployment.yaml
      instances: 1

  # After validation...
  - name: Promote / Cleanup
    uses: k8sCanaryDeleteStep@1.0.0
```

***

#### Kubernetes Apply <a href="#kubernetes-apply" id="kubernetes-apply"></a>

Template ID: `k8sApplyStep`

Apply manifests directly to the cluster. Supports dry run, pruning, server-side apply, and manifest printing for debugging.

| Input               | Type    | Description                           |
| ------------------- | ------- | ------------------------------------- |
| `namespace`         | string  | Kubernetes namespace                  |
| `manifests`         | array   | List of manifest file paths           |
| `skip_dry_run`      | boolean | Skip dry run validation               |
| `pruning`           | boolean | Remove old resources not in manifests |
| `server_side_apply` | boolean | Use server-side apply                 |
| `print_manifests`   | boolean | Print rendered manifests to logs      |
| `flags`             | array   | Custom kubectl command flags          |

```yaml
steps:
  - name: Apply Manifests
    uses: k8sApplyStep@1.0.0
    with:
      namespace: production
      manifests:
        - k8s/configmap.yaml
        - k8s/secret.yaml
        - k8s/deployment.yaml
      server_side_apply: true
      print_manifests: true
```

***

#### Kubernetes Delete <a href="#kubernetes-delete" id="kubernetes-delete"></a>

Template ID: `k8sDeleteStep`

Delete Kubernetes resources by name, manifest path, or release name. Useful for cleaning up resources during teardown or rollback workflows.

```yaml
steps:
  - name: Delete Resources
    uses: k8sDeleteStep@1.0.0
    with:
      namespace: staging
      manifests:
        - k8s/deployment.yaml
        - k8s/service.yaml

  # Or delete by release name
  - name: Delete Release
    uses: k8sDeleteStep@1.0.0
    with:
      namespace: staging
      release: my-release
```

***

#### Kubernetes Scale <a href="#kubernetes-scale" id="kubernetes-scale"></a>

Template ID: `k8sScaleStep`

Scale Kubernetes workloads up or down by setting the desired replica count on a Deployment, StatefulSet, or other scalable resource.

```yaml
steps:
  - name: Scale Up
    uses: k8sScaleStep@1.0.0
    with:
      namespace: production
      workload: Deployment/my-app
      replicas: 5

  - name: Scale Down
    uses: k8sScaleStep@1.0.0
    with:
      namespace: production
      workload: Deployment/my-app
      replicas: 2
```

***

#### Kubernetes Patch <a href="#kubernetes-patch" id="kubernetes-patch"></a>

Template ID: `k8sPatchStep`

Patch workload resources using strategic merge patch, JSON merge patch, or JSON patch operations. Useful for updating specific fields without a full redeployment.

```yaml
steps:
  - name: Patch Deployment
    uses: k8sPatchStep@1.0.0
    with:
      namespace: production
      resource: Deployment/my-app
      patch: |
        spec:
          template:
            spec:
              containers:
                - name: my-app
                  resources:
                    limits:
                      memory: "512Mi"
```

***

#### Kubernetes Traffic Routing <a href="#kubernetes-traffic-routing" id="kubernetes-traffic-routing"></a>

Template ID: `k8sTrafficRoutingStep`

Shift traffic between different versions of services. Commonly used in canary and blue-green workflows to gradually route a percentage of traffic to the new version.

```yaml
steps:
  - name: Route 10% Traffic
    uses: k8sTrafficRoutingStep@1.0.0
    with:
      namespace: production
      service: my-app-svc
      destinations:
        - host: my-app-canary
          weight: 10
        - host: my-app-primary
          weight: 90

  # After validation, shift more traffic
  - name: Route 50% Traffic
    uses: k8sTrafficRoutingStep@1.0.0
    with:
      namespace: production
      service: my-app-svc
      destinations:
        - host: my-app-canary
          weight: 50
        - host: my-app-primary
          weight: 50
```

***

#### Kubernetes Diff <a href="#kubernetes-diff" id="kubernetes-diff"></a>

Template ID: `k8sDiffStep`

Compare current cluster state with desired manifests to preview what would change before applying. Does not modify the cluster.

```yaml
steps:
  - name: Diff Manifests
    uses: k8sDiffStep@1.0.0
    with:
      namespace: production
      manifests:
        - k8s/deployment.yaml
```

***

#### Kubernetes Dry Run <a href="#kubernetes-dry-run" id="kubernetes-dry-run"></a>

Template ID: `k8sDryRunStep`

Validate manifests against the cluster API without applying any changes. Catches schema errors and misconfigured resources before they reach the cluster.

```yaml
steps:
  - name: Dry Run
    uses: k8sDryRunStep@1.0.0
    with:
      namespace: production
      manifests:
        - k8s/deployment.yaml
```

***

#### Kubernetes Steady State Check <a href="#kubernetes-steady-state-check" id="kubernetes-steady-state-check"></a>

Template ID: `k8sSteadyStateCheckStep`

Explicitly wait for workloads to reach steady state (all pods running and ready) at any point in the stage. Useful when you need a health gate between steps.

```yaml
steps:
  - name: Steady State Check
    uses: k8sSteadyStateCheckStep@1.0.0
    with:
      namespace: production
      workload: Deployment/my-app
      timeout: 5m
```

***

#### Kubernetes Rollout <a href="#kubernetes-rollout" id="kubernetes-rollout"></a>

Template ID: `k8sRolloutStep`

Run `kubectl rollout` subcommands against workloads. Use `restart` to bounce pods after a ConfigMap or Secret update, `status` to wait for a rollout to complete, `undo` to revert to the previous revision, or `pause`/`resume` to control an in-progress rollout.

| Command   | Description                                                      |
| --------- | ---------------------------------------------------------------- |
| `restart` | Triggers a rolling restart of all pods in the workload           |
| `status`  | Waits for the rollout to complete and returns success or failure |
| `undo`    | Rolls back the workload to the previous revision                 |
| `pause`   | Pauses an in-progress rollout                                    |
| `resume`  | Resumes a paused rollout                                         |
| `history` | Prints the rollout history to the step log                       |

```yaml
steps:
  # Restart pods to pick up a new ConfigMap
  - name: Kubernetes Rollout
    uses: k8sRolloutStep@1.0.0
    with:
      command: restart
      resources:
        - default/Deployment/my-app

  # Restart all workloads in a release
  - name: Kubernetes Rollout
    uses: k8sRolloutStep@1.0.0
    with:
      command: restart
      release_name: my-release
```

***

### Helm steps <a href="#helm-steps" id="helm-steps"></a>

#### Helm Basic Deploy <a href="#helm-basic-deploy" id="helm-basic-deploy"></a>

Template ID: `helmDeployBasicStep`

Deploys a Helm chart using `helm upgrade --install`, waits for all workloads to reach steady state, and optionally runs chart tests.

| Input                      | Type    | Description                                          |
| -------------------------- | ------- | ---------------------------------------------------- |
| `namespace`                | string  | Kubernetes namespace                                 |
| `release`                  | string  | Helm release name                                    |
| `manifests`                | string  | Chart path (.tgz archive or directory)               |
| `values`                   | array   | Values file paths for overrides                      |
| `ignore_failed_release`    | boolean | Proceed even if previous release is in failed state  |
| `skip_deploy_steady_check` | boolean | Skip steady state check after deploy                 |
| `upgrade_with_install`     | boolean | Always use `helm upgrade --install`                  |
| `deploy_test`              | boolean | Run `helm test` after deploy                         |
| `server_render`            | boolean | Server-side rendering of templates                   |
| `deploy_log_level`         | select  | Log level: `warn`, `error`, `info`, `debug`, `trace` |

```yaml
steps:
  - name: Deploy with Helm
    uses: helmDeployBasicStep@1.0.0
    with:
      release: my-release
      namespace: production
      values:
        - helm/values-prod.yaml
      upgrade_with_install: true
```

***

#### Helm Blue-Green <a href="#helm-blue-green" id="helm-blue-green"></a>

Helm blue-green deployment uses Helm releases to maintain two environments. The new version deploys as a separate Helm release, is tested, then traffic swaps to the new release.

| Step                      | Description                                                       |
| ------------------------- | ----------------------------------------------------------------- |
| `helmDeployBluegreenStep` | Deploy the new version as a Helm release to the stage environment |
| `helmBluegreenSwapStep`   | Swap traffic from the primary to the stage release                |

Also available as a managed strategy: `helmDeployBluegreenStrategy`.

```yaml
steps:
  - name: Helm Blue-Green Deploy
    uses: helmDeployBluegreenStep@1.0.0
    with:
      release: my-release
      namespace: production
      values:
        - helm/values-prod.yaml

  # After testing the stage release...
  - name: Swap Traffic
    uses: helmBluegreenSwapStep@1.0.0
```

***

#### Helm Canary <a href="#helm-canary" id="helm-canary"></a>

Helm canary deployment installs a canary Helm release with a subset of traffic routed to it. After validation, the canary is promoted to full deployment or rolled back.

| Step                   | Description                                           |
| ---------------------- | ----------------------------------------------------- |
| `helmDeployCanaryStep` | Deploy a canary Helm release with a subset of traffic |

Also available as a managed strategy: `helmDeployCanaryStrategy`.

```yaml
steps:
  - name: Helm Canary Deploy
    uses: helmDeployCanaryStep@1.0.0
    with:
      release: my-release-canary
      namespace: production
      values:
        - helm/values-prod.yaml
        - helm/values-canary.yaml
```

***

#### Helm Canary Delete <a href="#helm-canary-delete" id="helm-canary-delete"></a>

Template ID: `helmCanaryDeleteStep`

Uninstalls the canary Helm release after validation or on rollback. The `release` field is auto-populated from the Canary Deploy step output. The stable release is not affected.

In the rollback sequence, the step is pre-wired to `${{rollback.data.PLUGIN_CANARY_RELEASE_NAME}}` and runs only when a canary release was actually created.

```yaml
steps:
  - name: Helm Canary Delete
    uses: helmCanaryDeleteStep@1.0.0
    with:
      release: my-release-canary
      namespace: production
```

***

#### Helm Rollback <a href="#helm-rollback" id="helm-rollback"></a>

Template ID: `helmRollbackStep`

Roll back a Helm release to a previous revision. Harness automatically determines the previous healthy revision, or you can specify a target revision explicitly.

```yaml
steps:
  - name: Rollback Release
    uses: helmRollbackStep@1.0.0
    with:
      release: my-release
      namespace: production

  # Or rollback to a specific revision
  - name: Rollback to Revision 3
    uses: helmRollbackStep@1.0.0
    with:
      release: my-release
      namespace: production
      revision: 3
```

***

#### Helm Delete <a href="#helm-delete" id="helm-delete"></a>

Template ID: `helmDeleteStep`

Uninstall a Helm release and remove all associated Kubernetes resources from the cluster.

```yaml
steps:
  - name: Uninstall Release
    uses: helmDeleteStep@1.0.0
    with:
      release: my-release
      namespace: production
```

***

### Google Cloud Run steps <a href="#google-cloud-run-steps" id="google-cloud-run-steps"></a>

Google Cloud Run steps authenticate with GCP using a connector configured on each step and run `gcloud` CLI commands against your Cloud Run service or job. They use the `template:` wrapper in stage YAML rather than the short `uses:` form used by Kubernetes and Helm steps.

***

#### Google Cloud Run Deploy <a href="#google-cloud-run-deploy" id="google-cloud-run-deploy"></a>

Template ID: `googleCloudRunDeployStep`

Applies the service manifest using `gcloud run services replace`, describes the resulting revision, saves rollback data, and performs a Google Cloud Monitoring instance sync.

| Input                     | Type    | Description                                                                                  |
| ------------------------- | ------- | -------------------------------------------------------------------------------------------- |
| `gcp_connector`           | string  | GCP connector ID. Defaults to the infrastructure definition connector.                       |
| `region`                  | string  | Cloud Run service region. Default: `${{infra.region}}`.                                      |
| `project`                 | string  | GCP project. Default: `${{infra.project}}`.                                                  |
| `service_manifest_path`   | string  | Path to the service manifest. Default: `${{runtime.manifestPath}}`.                          |
| `service_container_image` | string  | Container image to deploy. Default: `${{artifact.image}}`.                                   |
| `cmd_options`             | string  | Additional flags for `gcloud run services replace`.                                          |
| `skip_traffic_update`     | boolean | When `true`, creates a new revision without shifting traffic. Use with a Traffic Shift step. |
| `cmd_timeout`             | string  | Maximum step duration. Default: `10m`.                                                       |
| `log_level`               | select  | Log verbosity: `info`, `debug`, `warn`, `error`.                                             |

```yaml
steps:
- name: Google Cloud Run Deploy
  id: googleCloudRunDeployStep
  template:
    uses: googleCloudRunDeployStep
```

With overrides:

```yaml
steps:
- name: Google Cloud Run Deploy
  id: googleCloudRunDeployStep
  template:
    uses: googleCloudRunDeployStep
    with:
      skip_traffic_update: true
      cmd_options: "--port=8080"
      cmd_timeout: 15m
      log_level: debug
```

***

#### Google Cloud Run Traffic Shift <a href="#google-cloud-run-traffic-shift" id="google-cloud-run-traffic-shift"></a>

Template ID: `googleCloudRunTrafficShiftStep`

Routes traffic to specific Cloud Run revisions using `gcloud run services update-traffic`. When rollback runs, Harness uses the revision state from the last successful deployment of the stage to restore traffic to the stable revision.

| Input                   | Type   | Description                                                               |
| ----------------------- | ------ | ------------------------------------------------------------------------- |
| `metadata`              | string | JSON object describing the target traffic distribution.                   |
| `service_manifest_path` | string | Derived from service configuration. Default: `${{runtime.manifestPath}}`. |
| `gcp_connector`         | string | Derived from infrastructure configuration.                                |
| `region`                | string | Derived from infrastructure configuration.                                |
| `project`               | string | Derived from infrastructure configuration.                                |
| `command_timeout`       | string | Maximum step duration. Default: `10m`.                                    |
| `log_level`             | select | Log verbosity.                                                            |

The `metadata` field takes a JSON object that mirrors the Cloud Run service status traffic structure:

```json
{"status":{"traffic":[{"revisionName":"LATEST","percent":100}]}}
```

Route all traffic to the latest revision:

```yaml
steps:
- name: Google Cloud Run Traffic Shift
  id: googleCloudRunTrafficShiftStep
  template:
    uses: googleCloudRunTrafficShiftStep
    with:
      metadata: '{"status":{"traffic":[{"revisionName":"LATEST","percent":100}]}}'
```

Split traffic 50/50 between stable and canary:

```yaml
steps:
- name: Google Cloud Run Traffic Shift
  id: googleCloudRunTrafficShiftStep
  template:
    uses: googleCloudRunTrafficShiftStep
    with:
      metadata: '{"status":{"traffic":[{"revisionName":"my-service-00003-abc","percent":50},{"revisionName":"LATEST","percent":50}]}}'
```

***

#### Google Cloud Run Rollback <a href="#google-cloud-run-rollback" id="google-cloud-run-rollback"></a>

Template ID: `googleCloudRunRollbackStep`

Restores the traffic state from the last successful deployment of the stage. Runs `gcloud run revisions list`, reads `rollback.data.REVISION_METADATA` to identify the target revision, then runs `gcloud run services update-traffic <service> --to-revisions=<stable-revision>=100`. If no prior successful deployment exists, deletes the service using `gcloud run services delete` instead.

The Rollback step belongs in the stage `rollback:` phase, not in the main `steps:` list. No `with:` inputs are required; Harness reads rollback state from the last successful deployment automatically.

Basic strategy rollback phase:

```yaml
rollback:
- group:
    steps:
    - name: Google Cloud Run Rollback
      id: googleCloudRunRollbackStep
      template:
        uses: googleCloudRunRollbackStep
  id: googleCloudRunBasicRollback
  name: Google Cloud Run Basic Rollback
```

Canary strategy rollback phase:

```yaml
rollback:
- group:
    steps:
    - name: Google Cloud Run Rollback
      id: googleCloudRunRollbackStep
      template:
        uses: googleCloudRunRollbackStep
  id: googleCloudRunCanaryRollback
  name: Google Cloud Run Canary Rollback
```

***

#### Google Cloud Run Job <a href="#google-cloud-run-job" id="google-cloud-run-job"></a>

Template ID: `googleCloudRunJobStep`

Deploys or executes a Cloud Run Job. The step operates in one of two modes based on whether `job_name` is set. When `job_name` is set, the step runs execute only. When `job_name` is empty, the step replaces the job definition from the service manifest first, then executes.

| Input                     | Type   | Description                                                                                                                                                |
| ------------------------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `job_name`                | string | The name of the Cloud Run job to execute. When set, the step runs execute only. Leave empty to replace the job definition from the service manifest first. |
| `replace_command_options` | string | Additional flags for `gcloud run jobs replace`. Only applies when `job_name` is empty.                                                                     |
| `execute_command_options` | string | Additional flags for `gcloud run jobs execute`. Optional.                                                                                                  |

GCP Connector, GCP Region, and GCP Project are available under **+ More options** in the UI.

Execute an existing job by name (execute only):

```yaml
steps:
- name: Google Cloud Run Job
  id: googleCloudRunJobStep
  template:
    uses: googleCloudRunJobStep
    with:
      job_name: my-batch-job
      execute_command_options: "--update-env-vars=ENV=production"
```

Replace the job definition from the service manifest, then execute (job\_name empty):

```yaml
steps:
- name: Google Cloud Run Job
  id: googleCloudRunJobStep
  template:
    uses: googleCloudRunJobStep
    with:
      replace_command_options: "--async --verbosity=debug"
      execute_command_options: "--update-env-vars=key1=value1,key2=value2"
```

***

#### Google Cloud Run complete stage YAML: canary strategy <a href="#google-cloud-run-complete-stage-yaml-canary-strategy" id="google-cloud-run-complete-stage-yaml-canary-strategy"></a>

A complete canary deployment stage showing the Deploy step, Traffic Shift step, rollback phase, and failure strategy:

```yaml
- name: google-cloud-run
  id: googleCloudRun
  service:
    type: google-cloud-run
    items:
    - <service-id>
  environment:
    items:
    - id: <environment-id>
      deploy-to: all
  steps:
  - name: Google Cloud Run Deploy
    id: googleCloudRunDeployStep
    template:
      uses: googleCloudRunDeployStep
      with:
        skip_traffic_update: true
  - name: Google Cloud Run Traffic Shift 20
    id: googleCloudRunTrafficShift20
    template:
      uses: googleCloudRunTrafficShiftStep
      with:
        metadata: <provide the traffic details>
  - name: Google Cloud Run Traffic Shift 100
    id: googleCloudRunTrafficShift100
    template:
      uses: googleCloudRunTrafficShiftStep
      with:
        metadata: <provide the traffic details>
  rollback:
  - group:
      steps:
      - name: Google Cloud Run Rollback
        id: googleCloudRunRollbackStep
        template:
          uses: googleCloudRunRollbackStep
    id: googleCloudRunCanaryRollback
    name: Google Cloud Run Canary Rollback
  on-failure:
    errors: all
    action: stage-rollback
```

***

### Google Cloud Functions steps <a href="#google-cloud-functions-steps" id="google-cloud-functions-steps"></a>

Google Cloud Functions steps authenticate with GCP using a connector configured on the infrastructure definition and deploy functions as a backing Cloud Run (Gen 2) service. They use the `template:` wrapper in stage YAML rather than the short `uses:` form used by Kubernetes and Helm steps.

***

#### Google Cloud Functions Deploy <a href="#google-cloud-functions-deploy" id="google-cloud-functions-deploy"></a>

Template ID: `googleCloudFunctionDeployStep`

Creates or updates a Google Cloud Function (Gen 2) using the service's manifest and artifact source. Captures the function's pre-deployment traffic state as rollback data, and saves the function name, revision, and first-deployment flag as output variables for later steps.

| Input             | Type    | Description                                                                                                             |
| ----------------- | ------- | ----------------------------------------------------------------------------------------------------------------------- |
| `skip_traffic`    | boolean | When `true`, the deployed revision does not receive traffic until a separate traffic shift step runs. Default: `false`. |
| `command_timeout` | string  | Maximum step duration. Default: `10m`.                                                                                  |
| `log_level`       | select  | Log verbosity: `info`, `debug`, `warn`, `error`.                                                                        |

Cloud Function Manifest Path, Artifact Source, Update Field Mask, GCP Connector, GCP Region, and GCP Project are resolved automatically from the service and infrastructure definition, or available under the collapsible **Advanced** section in the UI.

```yaml
steps:
- name: Google Cloud Function Deploy
  id: googleCloudFunctionDeployStep
  template:
    uses: googleCloudFunctionDeployStep
```

With overrides:

```yaml
steps:
- name: Google Cloud Function Deploy
  id: googleCloudFunctionDeployStep
  template:
    uses: googleCloudFunctionDeployStep
    with:
      skip_traffic: true
      command_timeout: 15m
      log_level: debug
```

***

#### Google Cloud Functions Traffic Shift <a href="#google-cloud-functions-traffic-shift" id="google-cloud-functions-traffic-shift"></a>

Template ID: `googleCloudFunctionTrafficShiftStep`

Shifts a percentage of traffic to a target revision on the function's backing Cloud Run service. If `is_first_deployment` is `true`, the step skips the traffic shift because there is no previous revision to balance traffic against. Saves the resulting traffic split as rollback data for the rollback step.

| Input                    | Type    | Description                                                                                                                                               |
| ------------------------ | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `function`               | string  | The function to shift traffic for. Default: `${{stage.steps.googleCloudFunctionDeployStep.output.outputVariables.functionName}}`.                         |
| `is_first_deployment`    | boolean | Whether this is the first deployment of the function. Default: `${{stage.steps.googleCloudFunctionDeployStep.output.outputVariables.isFirstDeployment}}`. |
| `target_revision`        | string  | The revision to shift traffic to. Default: `${{stage.steps.googleCloudFunctionDeployStep.output.outputVariables.revision}}`.                              |
| `target_traffic_percent` | string  | The percentage of traffic to shift to `target_revision`.                                                                                                  |
| `command_timeout`        | string  | Maximum step duration. Default: `10m`.                                                                                                                    |
| `log_level`              | select  | Log verbosity: `info`, `debug`, `warn`, `error`.                                                                                                          |

GCP Connector, GCP Region, and GCP Project are resolved automatically from the infrastructure definition.

Shift an initial percentage of traffic to the new revision for canary validation:

```yaml
steps:
- name: Google Cloud Function Traffic Shift Canary
  id: googleCloudFunctionTrafficShiftStepCanary
  template:
    uses: googleCloudFunctionTrafficShiftStep
    with:
      function: ${{stage.steps.googleCloudFunctionDeployStep.output.outputVariables.functionName}}
      is_first_deployment: ${{stage.steps.googleCloudFunctionDeployStep.output.outputVariables.isFirstDeployment}}
      target_revision: ${{stage.steps.googleCloudFunctionDeployStep.output.outputVariables.revision}}
      target_traffic_percent: "10"
```

Complete the cutover by shifting the remaining traffic:

```yaml
steps:
- name: Google Cloud Function Traffic Shift Final
  id: googleCloudFunctionTrafficShiftStepFinal
  template:
    uses: googleCloudFunctionTrafficShiftStep
    with:
      function: ${{stage.steps.googleCloudFunctionDeployStep.output.outputVariables.functionName}}
      is_first_deployment: ${{stage.steps.googleCloudFunctionDeployStep.output.outputVariables.isFirstDeployment}}
      target_revision: ${{stage.steps.googleCloudFunctionDeployStep.output.outputVariables.revision}}
      target_traffic_percent: "100"
```

***

#### Google Cloud Functions Rollback <a href="#google-cloud-functions-rollback" id="google-cloud-functions-rollback"></a>

Template ID: `googleCloudFunctionRollbackStep`

Restores the previous serving traffic split on the function's backing Cloud Run service, using the function name and traffic split saved as rollback data by the deploy step. For a function's first deployment, there is no previous revision to restore traffic to.

The Rollback step belongs in the stage `rollback:` phase, not in the main `steps:` list.

| Input                        | Type   | Description                                                                                                                           |
| ---------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------- |
| `function_name`              | string | The function to roll back. Default: `${{rollback.data.FUNCTION_NAME}}`.                                                               |
| `active_cloud_run_revisions` | string | The revision and traffic percentage that were active before the deployment. Default: `${{rollback.data.ACTIVE_CLOUD_RUN_REVISIONS}}`. |
| `command_timeout`            | string | Maximum step duration. Default: `10m`.                                                                                                |
| `log_level`                  | select | Log verbosity: `info`, `debug`, `warn`, `error`.                                                                                      |

Basic strategy rollback phase:

```yaml
rollback:
- group:
    steps:
    - name: Google Cloud Function Rollback
      id: googleCloudFunctionRollbackStep
      template:
        uses: googleCloudFunctionRollbackStep
        with:
          function_name: ${{rollback.data.FUNCTION_NAME}}
          active_cloud_run_revisions: ${{rollback.data.ACTIVE_CLOUD_RUN_REVISIONS}}
  id: googleCloudFunctionBasicRollback
  name: Google Cloud Function Basic Rollback
```

Canary strategy rollback phase:

```yaml
rollback:
- group:
    steps:
    - name: Google Cloud Function Rollback
      id: googleCloudFunctionRollbackStep
      template:
        uses: googleCloudFunctionRollbackStep
        with:
          function_name: ${{rollback.data.FUNCTION_NAME}}
          active_cloud_run_revisions: ${{rollback.data.ACTIVE_CLOUD_RUN_REVISIONS}}
  id: googleCloudFunctionCanaryRollback
  name: Google Cloud Function Canary Rollback
```

***

#### Google Cloud Functions complete stage YAML: canary strategy <a href="#google-cloud-functions-complete-stage-yaml-canary-strategy" id="google-cloud-functions-complete-stage-yaml-canary-strategy"></a>

A complete canary deployment stage showing the Deploy step, two Traffic Shift steps, rollback phase, and failure strategy:

```yaml
- name: Deploy Google Cloud Function
  id: Deploy_Google_Cloud_Function
  service:
    type: google-cloud-functions
    items:
    - <service-id>
  environment:
    items:
    - id: <environment-id>
      deploy-to: all
  steps:
  - name: Google Cloud Function Deploy
    id: googleCloudFunctionDeployStep
    template:
      uses: googleCloudFunctionDeployStep
      with:
        skip_traffic: true
  - name: Google Cloud Function Traffic Shift Canary
    id: googleCloudFunctionTrafficShiftStepCanary
    template:
      uses: googleCloudFunctionTrafficShiftStep
      with:
        function: ${{stage.steps.googleCloudFunctionDeployStep.output.outputVariables.functionName}}
        is_first_deployment: ${{stage.steps.googleCloudFunctionDeployStep.output.outputVariables.isFirstDeployment}}
        target_revision: ${{stage.steps.googleCloudFunctionDeployStep.output.outputVariables.revision}}
        target_traffic_percent: "10"
  - name: Google Cloud Function Traffic Shift Final
    id: googleCloudFunctionTrafficShiftStepFinal
    template:
      uses: googleCloudFunctionTrafficShiftStep
      with:
        function: ${{stage.steps.googleCloudFunctionDeployStep.output.outputVariables.functionName}}
        is_first_deployment: ${{stage.steps.googleCloudFunctionDeployStep.output.outputVariables.isFirstDeployment}}
        target_revision: ${{stage.steps.googleCloudFunctionDeployStep.output.outputVariables.revision}}
        target_traffic_percent: "100"
  rollback:
  - group:
      steps:
      - name: Google Cloud Function Rollback
        id: googleCloudFunctionRollbackStep
        template:
          uses: googleCloudFunctionRollbackStep
          with:
            function_name: ${{rollback.data.FUNCTION_NAME}}
            active_cloud_run_revisions: ${{rollback.data.ACTIVE_CLOUD_RUN_REVISIONS}}
    id: googleCloudFunctionCanaryRollback
    name: Google Cloud Function Canary Rollback
  on-failure:
    errors: all
    action: stage-rollback
```

***

### AWS Lambda steps <a href="#aws-lambda-steps" id="aws-lambda-steps"></a>

Lambda steps run inside a `runtime.kubernetes` block that routes execution through a containerized runner on your delegate cluster. All service configuration (function definition path, alias path) and infrastructure configuration (AWS connector, region) are resolved automatically from the stage context; Lambda steps do not take those as explicit `with:` inputs.

#### AWS Lambda Rolling Deploy <a href="#aws-lambda-rolling-deploy" id="aws-lambda-rolling-deploy"></a>

Template ID: `awsLambdaRollingDeployStep`

Publishes a new Lambda function version and immediately routes all traffic to it. When the service includes an `AwsLambdaFunctionAliasDefinition` manifest, the step also updates the named alias to point to the new version at 100% weight.

**Output variables**

| Variable       | Expression                                                                                           | Description                                               |
| -------------- | ---------------------------------------------------------------------------------------------------- | --------------------------------------------------------- |
| `functionName` | `<+pipeline.stages.<stage-id>.steps.awsLambdaRollingDeployStep.output.outputVariables.functionName>` | Name of the deployed function.                            |
| `version`      | `<+pipeline.stages.<stage-id>.steps.awsLambdaRollingDeployStep.output.outputVariables.version>`      | Version number published by this deployment.              |
| `runtime`      | `<+pipeline.stages.<stage-id>.steps.awsLambdaRollingDeployStep.output.outputVariables.runtime>`      | Lambda runtime identifier. Empty for ECR image functions. |
| `functionArn`  | `<+pipeline.stages.<stage-id>.steps.awsLambdaRollingDeployStep.output.outputVariables.functionArn>`  | Full ARN of the deployed function version.                |

```yaml
steps:
  - name: AWS Lambda Rolling Deploy
    id: awsLambdaRollingDeployStep
    template:
      uses: awsLambdaRollingDeployStep
```

***

#### AWS Lambda Rolling Rollback <a href="#aws-lambda-rolling-rollback" id="aws-lambda-rolling-rollback"></a>

Template ID: `awsLambdaRollingRollbackStep`

Restores the Lambda function to the version from the last successful rolling deployment. When the original deploy updated an alias, rollback also repoints the alias to the previous version. Harness adds this step automatically to the rollback section of a rolling stage.

```yaml
rollback:
  - group:
      steps:
        - name: AWS Lambda Rolling Rollback
          id: awsLambdaRollingRollbackStep
          template:
            uses: awsLambdaRollingRollbackStep
```

***

#### AWS Lambda Canary Deploy <a href="#aws-lambda-canary-deploy" id="aws-lambda-canary-deploy"></a>

Template ID: `awsLambdaCanaryDeployStep`

Publishes a new Lambda function version and creates or updates a weighted alias to begin splitting traffic between the previous version and the new one. Use this as the first step in a canary stage, followed by one or more Traffic Shift steps.

For ZIP artifact functions (S3, Artifactory, Nexus), the service must include an `AwsLambdaFunctionAliasDefinition` manifest; the step reads it to determine the alias name. For ECR image functions, no alias manifest is required; the step manages the alias automatically.

**Output variables** (auto-populate the Traffic Shift step inputs)

| Variable       | Expression                                                                     | Description                                  |
| -------------- | ------------------------------------------------------------------------------ | -------------------------------------------- |
| `functionName` | `<+stage.steps.awsLambdaCanaryDeployStep.output.outputVariables.functionName>` | Name of the deployed function.               |
| `version`      | `<+stage.steps.awsLambdaCanaryDeployStep.output.outputVariables.version>`      | Version number published by this deployment. |

```yaml
steps:
  - name: AWS Lambda Canary Deploy
    id: awsLambdaCanaryDeployStep
    template:
      uses: awsLambdaCanaryDeployStep
```

***

#### AWS Lambda Traffic Shift <a href="#aws-lambda-traffic-shift" id="aws-lambda-traffic-shift"></a>

Template ID: `awsLambdaTrafficShiftStep`

Updates the weighted alias to route a specified percentage of invocations to the new function version. Add multiple Traffic Shift steps to progressively increase traffic.

| Input                | Type   | Description                                                                            |
| -------------------- | ------ | -------------------------------------------------------------------------------------- |
| `traffic_percentage` | string | Percentage of traffic to route to the new version. Must be between `"0"` and `"100"`.  |
| `function_name`      | string | Lambda function name. Auto-populated from the Canary Deploy step output.               |
| `function_version`   | string | Version number of the new function. Auto-populated from the Canary Deploy step output. |

```yaml
steps:
  - 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>

  - 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>
```

The `function_name` and `function_version` inputs are wired to the Canary Deploy step's output variables. Do not change these unless you are using a custom step to publish the version.

To add an intermediate shift (for example, 50%), copy the 10% step, change the `id`, and set `traffic_percentage: "50"`.

***

#### AWS Lambda Canary Rollback <a href="#aws-lambda-canary-rollback" id="aws-lambda-canary-rollback"></a>

Template ID: `awsLambdaCanaryRollbackStep`

Resets the weighted alias to route 100% of traffic back to the previous function version and deletes the newly published version. Harness adds this step automatically to the rollback section of a canary stage. It applies to both ZIP and ECR image canary deployments.

```yaml
rollback:
  - group:
      steps:
        - name: AWS Lambda Canary Rollback
          id: awsLambdaCanaryRollbackStep
          template:
            uses: awsLambdaCanaryRollbackStep
```

***

#### AWS Lambda stage runtime block <a href="#aws-lambda-stage-runtime-block" id="aws-lambda-stage-runtime-block"></a>

All Lambda steps require the stage to declare a `runtime.kubernetes` block that provides the containerized execution environment. This is a stage-level setting, not a per-step setting.

```yaml
stages:
  - name: Stage
    id: stage
    service: <your-service-id>
    environment:
      id: <your-environment-id>
      deploy-to: <your-infrastructure-id>
    steps:
      # ... your Lambda steps here
    runtime:
      kubernetes:
        namespace: <your-delegate-namespace>
        connector: <your-k8s-connector>
        automount-service-token: true
        pull: always
```

***

### AWS SAM steps <a href="#aws-sam-steps" id="aws-sam-steps"></a>

AWS SAM stages run three steps automatically: a Docker in Docker background step, an AWS SAM Build step, and an AWS SAM Deploy step. All AWS connector and region values are resolved from the stage infrastructure definition.

***

#### Docker in Docker <a href="#docker-in-docker" id="docker-in-docker"></a>

A background step that starts a Docker daemon inside the Kubernetes pod for the duration of the stage. SAM Build connects to this daemon when `--use-container` is set in the build command options.

```yaml
- name: Docker in Docker
  id: dind
  background:
    shell: sh
    container:
      image: docker:dind
      connector: account.harnessImage
      privileged: true
      pull: always
```

***

#### AWS SAM Build <a href="#aws-sam-build" id="aws-sam-build"></a>

Template ID: `awsSamBuildStep`

Runs `sam build` against the SAM directory downloaded from the service manifest. The AWS connector and region are resolved from the infrastructure definition.

| Input                 | Type   | Description                                                                                                |
| --------------------- | ------ | ---------------------------------------------------------------------------------------------------------- |
| `connector`           | string | Harness AWS connector ID. Resolved from infrastructure definition.                                         |
| `region`              | string | AWS region, for example `us-east-1`. Resolved from infrastructure definition.                              |
| `stack`               | string | CloudFormation stack name.                                                                                 |
| `cmd_opts`            | string | Flags passed to `sam build`. Default: `--use-container`.                                                   |
| `template_file_path`  | string | Override the template file path relative to the SAM directory root. Defaults to the service configuration. |
| `pre_execute_command` | string | Shell command to run before `sam build`, for example `npm install`.                                        |
| `working_dir`         | string | Working directory for the build.                                                                           |
| `docker_retry_count`  | string | Number of times to poll for a running Docker daemon before starting. Default: `3`.                         |
| `registry_url`        | string | Registry URL for pulling the Lambda build container.                                                       |
| `registry_username`   | string | Username for the container registry.                                                                       |
| `registry_pwd`        | string | Secret reference for the container registry password.                                                      |
| `command_timeout`     | string | Maximum time the step can run, for example `10m`.                                                          |
| `log_level`           | string | Logging verbosity. Default: `info`.                                                                        |

```yaml
- name: AWS SAM Build
  id: awsSamBuildStep
  template:
    uses: awsSamBuildStep
    with:
      connector: <aws-connector>
      region: <aws-region>
      stack: <cloudformation-stack-name>
      cmd_opts: --use-container
      docker_retry_count: '3'
      registry_url: https://index.docker.io/v2/
      registry_username: <registry-username>
      registry_pwd: <registry-password-secret>
```

***

#### AWS SAM Deploy <a href="#aws-sam-deploy" id="aws-sam-deploy"></a>

Template ID: `awsSamDeployStep`

Packages the build output to S3 and creates or updates the CloudFormation stack. Waits for the stack to reach a stable state and prints CloudFormation events and stack outputs to the step log.

| Input                 | Type   | Description                                                                                                          |
| --------------------- | ------ | -------------------------------------------------------------------------------------------------------------------- |
| `connector`           | string | Harness AWS connector ID. Resolved from infrastructure definition.                                                   |
| `region`              | string | AWS region. Resolved from infrastructure definition.                                                                 |
| `stack`               | string | CloudFormation stack name to create or update. Required.                                                             |
| `cmd_opts`            | string | Flags passed to `sam deploy`, for example `--capabilities CAPABILITY_IAM --resolve-s3 --no-fail-on-empty-changeset`. |
| `template_file_path`  | string | Override the template file path relative to the SAM directory root. Defaults to the service configuration.           |
| `pre_execute_command` | string | Shell command to run before `sam deploy`.                                                                            |
| `working_dir`         | string | Working directory for the deploy.                                                                                    |
| `registry_url`        | string | Registry URL, for example `https://index.docker.io/v2/`.                                                             |
| `registry_username`   | string | Username for the container registry.                                                                                 |
| `registry_pwd`        | string | Secret reference for the container registry password.                                                                |
| `command_timeout`     | string | Maximum time the step can run, for example `10m`.                                                                    |
| `log_level`           | string | Logging verbosity. Default: `info`.                                                                                  |

```yaml
- name: AWS SAM Deploy
  id: awsSamDeployStep
  template:
    uses: awsSamDeployStep
    with:
      connector: <aws-connector>
      region: <aws-region>
      stack: <cloudformation-stack-name>
      cmd_opts: --capabilities CAPABILITY_IAM --resolve-s3 --no-fail-on-empty-changeset
      registry_url: https://index.docker.io/v2/
      registry_username: <registry-username>
      registry_pwd: <registry-password-secret>
```

***

#### AWS SAM complete stage YAML <a href="#aws-sam-stage-yaml" id="aws-sam-stage-yaml"></a>

Complete reference YAML for an AWS SAM stage using the unified platform pipeline format.

```yaml
stages:
  - name: SAM stage
    id: sam_stage
    service: <your-service-id>
    environment:
      id: <your-environment-id>
      deploy-to: <your-infrastructure-id>
    steps:
      - name: Docker in Docker
        id: dind
        background:
          shell: sh
          container:
            image: docker:dind
            connector: account.harnessImage
            privileged: true
            pull: always
      - name: AWS SAM Build
        id: awsSamBuildStep
        template:
          uses: awsSamBuildStep
          with:
            connector: <aws-connector>
            region: <aws-region>
            stack: <cloudformation-stack-name>
            cmd_opts: --use-container
            docker_retry_count: '3'
            registry_url: https://index.docker.io/v2/
            registry_username: <registry-username>
            registry_pwd: <registry-password-secret>
      - name: AWS SAM Deploy
        id: awsSamDeployStep
        template:
          uses: awsSamDeployStep
          with:
            connector: <aws-connector>
            region: <aws-region>
            stack: <cloudformation-stack-name>
            cmd_opts: --capabilities CAPABILITY_IAM --resolve-s3 --no-fail-on-empty-changeset
            registry_url: https://index.docker.io/v2/
            registry_username: <registry-username>
            registry_pwd: <registry-password-secret>
    runtime:
      kubernetes:
        namespace: <kubernetes-namespace>
        connector: <kubernetes-connector>
        automount-service-token: true
        pull: always
    on-failure:
      errors: all
      action: stage-rollback
    timeout: 20m
    shared-paths:
      - /var/lib/docker
      - /var/run
```

***

### ECS steps <a href="#ecs-steps" id="ecs-steps"></a>

ECS steps use either the `deploy:` key (ECS Service Setup, ECS Upgrade Container, ECS Run Task) or the `template:` key (all other ECS steps). Infrastructure values (AWS connector, region, and cluster) are resolved automatically from the stage infrastructure definition.

***

#### ECS Service Setup <a href="#ecs-service-setup" id="ecs-service-setup"></a>

Template ID: `ecsServiceSetupStep`

Registers a new ECS task definition revision, removes stale versioned service copies, and creates the new service at zero instances. Used as the first step in a basic ECS deployment.

```yaml
- name: ECS Service Setup
  id: ecsServiceSetup
  deploy:
    uses: ecsServiceSetupStep
    with:
      new_service: my-service
      resize_strategy: RESIZE_NEW_FIRST
      steady_state_timeout: 5m
      match_running_instances: false
      task_type: task_definition
      task_definition: ${{serviceOutput.manifests.ecsTaskDefinition.paths}}
      service_definition: ${{serviceOutput.manifests.ecsServiceDefinition.paths}}
      connector: ${{infra.connectorRef}}
      region: ${{infra.region}}
      cluster: ${{infra.cluster}}
      log_level: info
```

***

#### ECS Upgrade Container <a href="#ecs-upgrade-container" id="ecs-upgrade-container"></a>

Template ID: `ecsUpgradeContainerStep`

Scales the new service from zero to the target instance count, waits for steady state, registers auto-scaling, and optionally downsizes the previous service. Used after ECS Service Setup in a basic deployment.

```yaml
- name: ECS Upgrade Container
  id: ecsUpgradeContainer
  deploy:
    uses: ecsUpgradeContainerStep
    with:
      new_instances: 100
      new_instance_unit: PERCENTAGE
      new_service: my-service
      resize_strategy: RESIZE_NEW_FIRST
      new_service_max_instances: 0
      old_service_max_instances: 0
      steady_state_timeout: 5m
      steady_state_check: true
      targets: ${{serviceOutput.manifests.ecsScalableTarget.paths}}
      policies: ${{serviceOutput.manifests.ecsScalingPolicy.paths}}
      scheduled_actions: ${{serviceOutput.manifests.ecsScheduledActions.paths}}
      connector: ${{infra.connectorRef}}
      region: ${{infra.region}}
      cluster: ${{infra.cluster}}
      log_level: info
```

***

#### ECS Rolling Deploy <a href="#ecs-rolling-deploy" id="ecs-rolling-deploy"></a>

Template ID: `ecsRollingDeployStep`

Updates an ECS service in place with the new task definition, waits for steady state, and applies auto-scaling. Used as the sole deploy step in the rolling strategy and as the final step in the canary strategy.

```yaml
- name: ECS Rolling Deploy
  id: ecsRollingDeployStep
  template:
    uses: ecsRollingDeployStep
    with:
      match_running_instances: false
      force_new_deployment: false
      modify_tags: false
      skip_app_scaling: false
      steady_state_timeout: 10m
      log_level: info
```

***

#### ECS Rolling Rollback <a href="#ecs-rolling-rollback" id="ecs-rolling-rollback"></a>

Template ID: `ecsRollingRollbackStep`

Restores the ECS service to the task definition, desired count, and scaling configuration captured before ECS Rolling Deploy ran, wired from its `currService`, `firstDeployment`, and `scalingSkipped` output variables.

```yaml
- group:
    id: ecsRollingRollbackStep
    name: ECS Rolling Rollback
    steps:
      - name: ECS Rolling Rollback
        id: ecsRollingRollbackStep
        template:
          uses: ecsRollingRollbackStep
          with:
            curr_service: ${{stage.steps.ecsRollingDeployStep.output.outputVariables.currService}}
            first_deployment: ${{stage.steps.ecsRollingDeployStep.output.outputVariables.firstDeployment}}
            skip_app_scaling: ${{stage.steps.ecsRollingDeployStep.output.outputVariables.scalingSkipped}}
```

***

#### ECS Canary Deploy <a href="#ecs-canary-deploy" id="ecs-canary-deploy"></a>

Template ID: `ecsCanaryDeployStep`

Creates a canary ECS service alongside the production service at the specified instance count and emits the canary service name as `canaryService` output.

```yaml
- name: ECS Canary Deploy
  id: ecsCanaryDeployStep
  template:
    uses: ecsCanaryDeployStep
    with:
      desired_count: 1
      service_suffix: Canary
      steady_state_timeout: 10m
      log_level: info
```

***

#### ECS Canary Delete <a href="#ecs-canary-delete" id="ecs-canary-delete"></a>

Template ID: `ecsCanaryDeleteStep`

Deletes the canary ECS service after validation. Uses the `canaryService` output from ECS Canary Deploy to resolve the service name.

```yaml
- name: ECS Canary Delete
  id: ecsCanaryDeleteStep
  template:
    uses: ecsCanaryDeleteStep
    with:
      service: ${{stage.steps.ecsCanaryDeployStep.output.outputVariables.canaryService}}
      steady_state_timeout: 10m
      log_level: info
```

***

#### ECS BlueGreen Deploy <a href="#ecs-bluegreen-deploy" id="ecs-bluegreen-deploy"></a>

Template ID: `ecsBluegreenDeployStep`

Registers the new task definition, creates or updates the green (staging) ECS service, waits for steady state, and captures internal rollback data used by the swap or traffic shift, and rollback, steps. Set `traffic_shift: true` to pair this step with ECS BlueGreen Traffic Shift instead of ECS BlueGreen Swap Target Groups.

| Output variable                                                                                                                                   | Expression                                                                           |
| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ |
| `serviceName`                                                                                                                                     | `${{stage.steps.ecsBluegreenDeployStep.output.outputVariables.serviceName}}`         |
| `greenServiceName`                                                                                                                                | `${{stage.steps.ecsBluegreenDeployStep.output.outputVariables.greenServiceName}}`    |
| `firstDeployment`                                                                                                                                 | `${{stage.steps.ecsBluegreenDeployStep.output.outputVariables.firstDeployment}}`     |
| `greenServiceExisted`                                                                                                                             | `${{stage.steps.ecsBluegreenDeployStep.output.outputVariables.greenServiceExisted}}` |
| `loadBalancer`, `prodListenerArn`, `prodListenerRuleArn`, `prodTargetGroupArn`, `stageListenerArn`, `stageListenerRuleArn`, `stageTargetGroupArn` | `${{stage.steps.ecsBluegreenDeployStep.output.outputVariables.<name>}}`              |

```yaml
- name: ECS BlueGreen Deploy
  id: ecsBluegreenDeployStep
  deploy:
    uses: ecsBluegreenDeployStep
    with:
      load_balancer: my-alb
      traffic_shift: false
      prod_listener_arn: arn:aws:elasticloadbalancing:<region>:<account>:listener/<alb-id>/<listener-id>
      prod_listener_rule_arn: arn:aws:elasticloadbalancing:<region>:<account>:listener-rule/<alb-id>/<listener-id>/<rule-id>
      stage_listener_arn: arn:aws:elasticloadbalancing:<region>:<account>:listener/<alb-id>/<stage-listener-id>
      stage_listener_rule_arn: arn:aws:elasticloadbalancing:<region>:<account>:listener-rule/<alb-id>/<stage-listener-id>/<rule-id>
      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
```

***

#### ECS BlueGreen Swap Target Groups <a href="#ecs-bluegreen-swap-target-groups" id="ecs-bluegreen-swap-target-groups"></a>

Template ID: `ecsBluegreenSwapTargetGroupsStep`

Swaps the production and staging ALB listener target groups in a single operation so the new service receives all production traffic. Most inputs are wired from the ECS BlueGreen Deploy step's outputs.

```yaml
- name: ECS BlueGreen Swap Target Groups
  id: ecsBluegreenSwapTargetGroupsStep
  deploy:
    uses: ecsBluegreenSwapTargetGroupsStep
    with:
      not_downsize_old: false
      downsize_delay: 0s
      skip_steady_state: false
      steady_state_timeout: 10m
      load_balancer: ${{stage.steps.ecsBluegreenDeployStep.output.outputVariables.loadBalancer}}
      prod_listener_arn: ${{stage.steps.ecsBluegreenDeployStep.output.outputVariables.prodListenerArn}}
      prod_listener_rule_arn: ${{stage.steps.ecsBluegreenDeployStep.output.outputVariables.prodListenerRuleArn}}
      prod_target_group_arn: ${{stage.steps.ecsBluegreenDeployStep.output.outputVariables.prodTargetGroupArn}}
      stage_listener_arn: ${{stage.steps.ecsBluegreenDeployStep.output.outputVariables.stageListenerArn}}
      stage_listener_rule_arn: ${{stage.steps.ecsBluegreenDeployStep.output.outputVariables.stageListenerRuleArn}}
      stage_target_group_arn: ${{stage.steps.ecsBluegreenDeployStep.output.outputVariables.stageTargetGroupArn}}
      blue_service: ${{stage.steps.ecsBluegreenDeployStep.output.outputVariables.serviceName}}
      green_service: ${{stage.steps.ecsBluegreenDeployStep.output.outputVariables.greenServiceName}}
      first_deployment: ${{stage.steps.ecsBluegreenDeployStep.output.outputVariables.firstDeployment}}
      connector: ${{infra.connectorRef}}
      region: ${{infra.region}}
      cluster: ${{infra.cluster}}
      log_level: info
```

***

#### ECS BlueGreen Traffic Shift <a href="#ecs-bluegreen-traffic-shift" id="ecs-bluegreen-traffic-shift"></a>

Template ID: `ecsBluegreenTrafficShiftStep`

Sets the traffic weight distribution across target groups on an ALB listener, using an explicit, weighted `forward_config` list of target group ARNs. Add multiple instances with different weight distributions to implement a phased rollout.

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

***

#### ECS BlueGreen Rollback <a href="#ecs-bluegreen-rollback" id="ecs-bluegreen-rollback"></a>

Template ID: `ecsBluegreenRollbackStep`

Reverts the green service deployment, restoring the blue service's scalable targets, scaling policies, and scheduled actions, and reversing a swap or traffic shift if one had occurred. All fields are optional and auto-resolve from internal rollback state captured during ECS BlueGreen Deploy and ECS BlueGreen Swap Target Groups when `with:` is omitted.

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

To override the auto-resolved values explicitly, using `${{rollback.data.*}}` expressions:

```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
```

***

#### ECS BlueGreen Traffic Shift Rollback <a href="#ecs-bluegreen-traffic-shift-rollback" id="ecs-bluegreen-traffic-shift-rollback"></a>

Template ID: `ecsBluegreenTrafficShiftRollbackStep`

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. Run before ECS BlueGreen Rollback in the same rollback group for the traffic shift variant.

```yaml
- name: ECS BlueGreen Traffic Shift Rollback
  id: ecsBluegreenTrafficShiftRollbackStep
  deploy:
    uses: ecsBluegreenTrafficShiftRollbackStep
```

To override the auto-resolved value explicitly:

```yaml
- name: rollback
  id: rollback
  deploy:
    uses: ecsBluegreenTrafficShiftRollbackStep
    with:
      steady_state_timeout: 10m
      traffic_shift_data: ${{rollback.data.TRAFFIC_SHIFT_DATA}}
      connector: ${{infra.connectorRef}}
      region: ${{infra.region}}
      cluster: ${{infra.cluster}}
      log_level: info
```

***

#### ECS Run Task <a href="#ecs-run-task" id="ecs-run-task"></a>

Template ID: `ecsRunTaskStep`

Runs a standalone ECS task using a task request definition. Independent of service deployment steps. No rollback step. Uses the `deploy:` key.

```yaml
- name: ECS Run Task
  id: ecsRunTask
  deploy:
    uses: ecsRunTaskStep
    with:
      fetch_manifest_repo: false
      task_def_mode: ECS Run Task Definition
      task_request_def: /path/to/task-request.json
      skip_steady_state: false
      steady_state_timeout: 5m
      connector: ${{infra.connectorRef}}
      region: ${{infra.region}}
      cluster: ${{infra.cluster}}
      log_level: info
```

***

#### ECS complete stage YAML: basic strategy <a href="#ecs-basic-stage-yaml" id="ecs-basic-stage-yaml"></a>

```yaml
pipeline:
  stages:
    - name: Deploy ECS
      id: deployEcs
      service:
        type: ecs
        items:
          - <service-id>
      environment:
        items:
          - id: <environment-id>
            deploy-to: all
      steps:
        - name: ECS Service Setup
          id: ecsServiceSetup
          deploy:
            uses: ecsServiceSetupStep
            with:
              new_service: my-service
              resize_strategy: RESIZE_NEW_FIRST
              steady_state_timeout: 5m
              task_type: task_definition
              task_definition: ${{serviceOutput.manifests.ecsTaskDefinition.paths}}
              service_definition: ${{serviceOutput.manifests.ecsServiceDefinition.paths}}
              connector: ${{infra.connectorRef}}
              region: ${{infra.region}}
              cluster: ${{infra.cluster}}
        - name: ECS Upgrade Container
          id: ecsUpgradeContainer
          deploy:
            uses: ecsUpgradeContainerStep
            with:
              new_instances: 100
              new_instance_unit: PERCENTAGE
              new_service: ${{stage.steps.ecsServiceSetup.output.outputVariables.newService}}
              old_service: ${{stage.steps.ecsServiceSetup.output.outputVariables.oldServiceName}}
              resize_strategy: RESIZE_NEW_FIRST
              steady_state_timeout: 5m
              connector: ${{infra.connectorRef}}
              region: ${{infra.region}}
              cluster: ${{infra.cluster}}
      rollback:
        - group:
            steps:
              - name: ECS Basic Rollback
                id: ecsBasicRollback
                template:
                  uses: ecsBasicRollbackStep
                  with:
                    old_service: ${{stage.steps.ecsServiceSetup.output.outputVariables.oldServiceName}}
                    first_deployment: ${{stage.steps.ecsServiceSetup.output.outputVariables.isFirstDeployment}}
      on-failure:
        errors: all
        action: stage-rollback
```

***

#### ECS complete stage YAML: rolling strategy <a href="#ecs-rolling-stage-yaml" id="ecs-rolling-stage-yaml"></a>

```yaml
pipeline:
  stages:
    - name: Deploy ECS
      id: deployEcs
      service:
        type: ecs
        items:
          - <service-id>
      environment:
        items:
          - id: <environment-id>
            deploy-to: all
      runtime: cloud
      steps:
        - name: ECS Rolling Deploy
          id: ecsRollingDeployStep
          template:
            uses: ecsRollingDeployStep
      rollback:
        - group:
            id: ecsRollingRollbackStep
            name: ECS Rolling Rollback
            steps:
              - name: ECS Rolling Rollback
                id: ecsRollingRollbackStep
                template:
                  uses: ecsRollingRollbackStep
                  with:
                    curr_service: ${{stage.steps.ecsRollingDeployStep.output.outputVariables.currService}}
                    first_deployment: ${{stage.steps.ecsRollingDeployStep.output.outputVariables.firstDeployment}}
                    skip_app_scaling: ${{stage.steps.ecsRollingDeployStep.output.outputVariables.scalingSkipped}}
      on-failure:
        errors: all
        action: stage-rollback
```

***

#### ECS complete stage YAML: canary strategy <a href="#ecs-canary-stage-yaml" id="ecs-canary-stage-yaml"></a>

```yaml
pipeline:
  stages:
    - name: Deploy ECS
      id: deployEcs
      service:
        type: ecs
        items:
          - <service-id>
      environment:
        items:
          - id: <environment-id>
            deploy-to: all
      runtime: cloud
      steps:
        - name: ECS Canary Deploy
          id: ecsCanaryDeployStep
          template:
            uses: ecsCanaryDeployStep
        - name: ECS Canary Delete
          id: ecsCanaryDeleteStep
          template:
            uses: ecsCanaryDeleteStep
            with:
              service: ${{stage.steps.ecsCanaryDeployStep.output.outputVariables.canaryService}}
        - name: ECS Rolling Deploy
          id: ecsRollingDeployStep
          template:
            uses: ecsRollingDeployStep
      rollback:
        - group:
            id: ecsRollbackGroup
            name: ECS Rollback Group
            steps:
              - name: ECS Canary Delete Rollback
                id: ecsCanaryDeleteRollback
                template:
                  uses: ecsCanaryDeleteStep
                  with:
                    service: ${{stage.steps.ecsCanaryDeployStep.output.outputVariables.canaryService}}
              - name: ECS Rolling Rollback
                id: ecsRollingRollbackStep
                template:
                  uses: ecsRollingRollbackStep
                  with:
                    curr_service: ${{stage.steps.ecsRollingDeployStep.output.outputVariables.currService}}
                    first_deployment: ${{stage.steps.ecsRollingDeployStep.output.outputVariables.firstDeployment}}
                    skip_app_scaling: ${{stage.steps.ecsRollingDeployStep.output.outputVariables.scalingSkipped}}
      on-failure:
        errors: all
        action: stage-rollback
```

***

#### ECS complete stage YAML: blue-green swap strategy <a href="#ecs-bluegreen-swap-stage-yaml" id="ecs-bluegreen-swap-stage-yaml"></a>

```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-alb
              traffic_shift: false
              prod_listener_arn: arn:aws:elasticloadbalancing:<region>:<account>:listener/<alb-id>/<listener-id>
              prod_listener_rule_arn: arn:aws:elasticloadbalancing:<region>:<account>:listener-rule/<alb-id>/<listener-id>/<rule-id>
              stage_listener_arn: arn:aws:elasticloadbalancing:<region>:<account>:listener/<alb-id>/<stage-listener-id>
              stage_listener_rule_arn: arn:aws:elasticloadbalancing:<region>:<account>:listener-rule/<alb-id>/<stage-listener-id>/<rule-id>
              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 Swap Target Groups
          id: ecsBluegreenSwapTargetGroupsStep
          deploy:
            uses: ecsBluegreenSwapTargetGroupsStep
            with:
              not_downsize_old: false
              downsize_delay: 0s
              skip_steady_state: false
              steady_state_timeout: 10m
              load_balancer: ${{stage.steps.ecsBluegreenDeployStep.output.outputVariables.loadBalancer}}
              prod_listener_arn: ${{stage.steps.ecsBluegreenDeployStep.output.outputVariables.prodListenerArn}}
              prod_listener_rule_arn: ${{stage.steps.ecsBluegreenDeployStep.output.outputVariables.prodListenerRuleArn}}
              prod_target_group_arn: ${{stage.steps.ecsBluegreenDeployStep.output.outputVariables.prodTargetGroupArn}}
              stage_listener_arn: ${{stage.steps.ecsBluegreenDeployStep.output.outputVariables.stageListenerArn}}
              stage_listener_rule_arn: ${{stage.steps.ecsBluegreenDeployStep.output.outputVariables.stageListenerRuleArn}}
              stage_target_group_arn: ${{stage.steps.ecsBluegreenDeployStep.output.outputVariables.stageTargetGroupArn}}
              blue_service: ${{stage.steps.ecsBluegreenDeployStep.output.outputVariables.serviceName}}
              green_service: ${{stage.steps.ecsBluegreenDeployStep.output.outputVariables.greenServiceName}}
              first_deployment: ${{stage.steps.ecsBluegreenDeployStep.output.outputVariables.firstDeployment}}
              connector: ${{infra.connectorRef}}
              region: ${{infra.region}}
              cluster: ${{infra.cluster}}
              log_level: info
      rollback:
        - name: rollback
          id: rollback
          deploy:
            uses: ecsBluegreenRollbackStep
      on-failure:
        errors: all
        action: stage-rollback
```

***

#### ECS complete stage YAML: blue-green traffic shift strategy <a href="#ecs-bluegreen-traffic-shift-stage-yaml" id="ecs-bluegreen-traffic-shift-stage-yaml"></a>

```yaml
pipeline:
  stages:
    - name: ECS BlueGreen Traffic Shift
      id: ecs_bluegreen_traffic_shift
      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-alb
              traffic_shift: true
              prod_listener_arn: arn:aws:elasticloadbalancing:<region>:<account>:listener/<alb-id>/<listener-id>
              prod_listener_rule_arn: arn:aws:elasticloadbalancing:<region>:<account>:listener-rule/<alb-id>/<listener-id>/<rule-id>
              stage_listener_arn: arn:aws:elasticloadbalancing:<region>:<account>:listener/<alb-id>/<stage-listener-id>
              stage_listener_rule_arn: arn:aws:elasticloadbalancing:<region>:<account>:listener-rule/<alb-id>/<stage-listener-id>/<rule-id>
              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-alb
              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/<alb-id>/<listener-id>
              listener_rule_arn: arn:aws:elasticloadbalancing:<region>:<account>:listener-rule/<alb-id>/<listener-id>/<rule-id>
              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
```

***

### Serverless Lambda steps <a href="#serverless-lambda-steps" id="serverless-lambda-steps"></a>

#### Serverless Package <a href="#serverless-package" id="serverless-package"></a>

Template ID: `serverlessPackageStep`

Runs `serverless package` to bundle Lambda functions and prepare the stack template for upload to S3. Runs before the Deploy step. Harness adds this step automatically when you select the **Serverless Deployment With Rollback** strategy.

| Input                | Type   | Description                                                                                                                      |
| -------------------- | ------ | -------------------------------------------------------------------------------------------------------------------------------- |
| `container_registry` | string | Connector to the registry that hosts the step image.                                                                             |
| `image`              | string | The `harness/serverless-plugin` image and tag, for example `harness/serverless-plugin:nodejs20.x-3.39.0-1.1.0-beta-linux-amd64`. |
| `cmd_opts`           | string | Additional flags appended to `serverless package`, for example `--verbose`.                                                      |
| `pre_exec_cmd`       | string | Shell command that runs before the step logic.                                                                                   |
| `env`                | object | Environment variables injected into the container.                                                                               |

```yaml
steps:
  - name: Package
    uses: serverlessPackageStep@1.0.0
    with:
      container_registry: <your-registry-connector>
      image: harness/serverless-plugin:nodejs20.x-3.39.0-1.1.0-beta-linux-amd64
```

***

#### Serverless Deploy <a href="#serverless-deploy" id="serverless-deploy"></a>

Template ID: `serverlessDeployStep`

Runs `serverless deploy` to create or update the AWS stack and activate the new Lambda function versions. Before deploying, captures the current stack state automatically for use by the Rollback step. Harness adds this step automatically when you select the **Serverless Deployment With Rollback** strategy.

| Input                | Type   | Description                                                                                             |
| -------------------- | ------ | ------------------------------------------------------------------------------------------------------- |
| `container_registry` | string | Connector to the registry that hosts the step image.                                                    |
| `image`              | string | The `harness/serverless-plugin` image and tag. Use the same image as the Package step.                  |
| `cmd_opts`           | string | Additional flags appended to `serverless deploy`, for example `--aws-s3-accelerate`.                    |
| `pre_exec_cmd`       | string | Shell command that runs before the step logic.                                                          |
| `env`                | object | Environment variables injected into the container. For Serverless V4, add `SERVERLESS_ACCESS_KEY` here. |

```yaml
steps:
  - name: Deploy
    uses: serverlessDeployStep@1.0.0
    with:
      container_registry: <your-registry-connector>
      image: harness/serverless-plugin:nodejs20.x-3.39.0-1.1.0-beta-linux-amd64
      cmd_opts: --aws-s3-accelerate
      env:
        SERVERLESS_ACCESS_KEY: <+secrets.getValue("serverless_access_key")>
```

***

#### Serverless Rollback <a href="#serverless-rollback" id="serverless-rollback"></a>

Template ID: `serverlessRollbackStep`

Restores the AWS stack to the state captured before the Deploy step ran. Harness adds this step to the rollback section of the stage automatically. Toggle **Rollback** in the stage execution view to see and configure it.

| Input                | Type   | Description                                                                           |
| -------------------- | ------ | ------------------------------------------------------------------------------------- |
| `container_registry` | string | Connector to the registry that hosts the step image.                                  |
| `image`              | string | The `harness/serverless-plugin` image and tag. Use the same image as the Deploy step. |
| `pre_exec_cmd`       | string | Shell command that runs before the step logic.                                        |
| `env`                | object | Environment variables injected into the container.                                    |

```yaml
rollback:
  - group:
      steps:
        - name: Rollback
          uses: serverlessRollbackStep@1.0.0
          with:
            container_registry: <your-registry-connector>
            image: harness/serverless-plugin:nodejs20.x-3.39.0-1.1.0-beta-linux-amd64
```

Full stage example with all three steps and the rollback failure strategy:

```yaml
stages:
  - name: Deploy Lambda
    service: <your-service-id>
    environment:
      id: <your-environment-id>
      deploy-to: <your-infra-id>
    steps:
      - name: Package
        uses: serverlessPackageStep@1.0.0
        with:
          container_registry: <your-registry-connector>
          image: harness/serverless-plugin:nodejs20.x-3.39.0-1.1.0-beta-linux-amd64
      - name: Deploy
        uses: serverlessDeployStep@1.0.0
        with:
          container_registry: <your-registry-connector>
          image: harness/serverless-plugin:nodejs20.x-3.39.0-1.1.0-beta-linux-amd64
    rollback:
      - group:
          steps:
            - name: Rollback
              uses: serverlessRollbackStep@1.0.0
              with:
                container_registry: <your-registry-connector>
                image: harness/serverless-plugin:nodejs20.x-3.39.0-1.1.0-beta-linux-amd64
    on-failure:
      errors: all
      action: stage-rollback
    runtime:
      kubernetes:
        namespace: <your-k8s-namespace>
        connector: <your-k8s-connector>
```

***

### Infrastructure inheritance <a href="#infrastructure-inheritance" id="infrastructure-inheritance"></a>

Steps automatically inherit infrastructure settings from the stage infrastructure configuration.

**Kubernetes and Helm**

| Inherited value | CEL expression                | JEXL expression             |
| --------------- | ----------------------------- | --------------------------- |
| Kubeconfig path | `${{infra.kube_config_path}}` | `<+infra.kube_config_path>` |
| Namespace       | `${{infra.namespace}}`        | `<+infra.namespace>`        |
| Release name    | `${{infra.releaseName}}`      | `<+infra.releaseName>`      |

**AWS Lambda**

| Inherited value | CEL expression            | JEXL expression         |
| --------------- | ------------------------- | ----------------------- |
| AWS connector   | `${{infra.connectorRef}}` | `<+infra.connectorRef>` |
| AWS region      | `${{infra.region}}`       | `<+infra.region>`       |

**AWS SAM**

| Inherited value | CEL expression            | JEXL expression         |
| --------------- | ------------------------- | ----------------------- |
| AWS connector   | `${{infra.connectorRef}}` | `<+infra.connectorRef>` |
| AWS region      | `${{infra.region}}`       | `<+infra.region>`       |

Override these values in individual step inputs when you need to target a different connector or region within the same stage.

{% @harness-feedback/feedback %}
