> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/continuous-delivery/new-experience/use-deployments/ecs-deployments/ecs-deployment-strategies/basic.md). Agents can also search and read this documentation through its [MCP server](https://developer.harness.io/~gitbook/mcp).

# ECS basic deployment

Deploy an ECS service using the basic strategy, which creates a new service revision and scales it to the target instance count while keeping the previous service running.

The basic strategy is the simplest ECS deployment approach. Harness creates a new service with the updated task definition at zero instances, then scales it up to the target count while managing the previous service in parallel.

***

## What you will learn from this topic

* How Harness manages service versioning with the basic strategy.
* How to configure the ECS Service Setup and ECS Upgrade Container steps.

***

## Before you begin

* **An ECS service:** Go to [ECS services](https://developer.harness.io/continuous-delivery/new-experience/use-deployments/ecs-deployments/ecs-services.md) to set up a service with a task definition and artifact source.
* **An ECS infrastructure definition:** Go to [ECS infrastructure](https://developer.harness.io/continuous-delivery/new-experience/use-deployments/ecs-deployments/ecs-infrastructure.md) to connect an AWS account and configure authentication.

***

## Stage YAML

A minimal basic strategy stage looks like this:

```yaml
pipeline:
  stages:
    - name: Deploy ECS
      id: deployEcs
      service:
        type: ecs
        items:
          - <service-id>
      environment:
        items:
          - id: <environment-id>
            deploy-to: all
      runtime: cloud
      on-failure:
        errors: all
        action: stage-rollback
      steps:
        - 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
        - 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
              new_service_max_instances: ${{stage.steps.ecsServiceSetup.output.outputVariables.newServiceMaxCount}}
              old_service_max_instances: ${{stage.steps.ecsServiceSetup.output.outputVariables.oldServiceMaxCount}}
              steady_state_timeout: 5m
              steady_state_check: true
              targets: ${{serviceOutput.manifests.ecsScalableTarget.paths}}
              policies: ${{serviceOutput.manifests.ecsScalingPolicy.paths}}
              connector: ${{infra.connectorRef}}
              region: ${{infra.region}}
              cluster: ${{infra.cluster}}
              log_level: info
      rollback:
        - group:
            id: ecsBasicRollback
            name: ECS Basic Rollback
            steps:
              - name: ECS Basic Rollback
                id: ecsBasicRollback
                template:
                  uses: ecsBasicRollbackStep
                  with:
                    new_service: ${{stage.steps.ecsServiceSetup.output.outputVariables.newService}}
                    first_deployment: ${{stage.steps.ecsServiceSetup.output.outputVariables.isFirstDeployment}}
```

***

## How this deployment works

When you select the basic strategy, Harness adds the following steps to your stage execution:

1. **ECS Service Setup**: Registers a new ECS task definition revision, identifies and removes stale service versions, creates the new service at zero instances, and captures rollback data.
2. **ECS Upgrade Container**: Scales the new service to the target instance count, waits for steady state, applies auto-scaling configuration, and optionally downsizes the previous service.

Harness also adds an **ECS Basic Rollback** step to the rollback group. It runs automatically if the stage failure strategy triggers and restores the previous service configuration using the rollback data captured by ECS Service Setup.

{% hint style="info" %}
**Service naming convention**

Harness appends an incrementing suffix (`__N`) to the base service name on each deployment. For example, if the base name is `my-service`, the first deployment creates `my-service__1`, the second creates `my-service__2`, and so on. Harness keeps the two most recent versions and removes older ones automatically during ECS Service Setup.
{% endhint %}

***

## Configure the ECS Service Setup step

The ECS Service Setup step is required in this strategy. You must configure the base service name before the pipeline can run.

| Field                | Required | Description                                                                                                                   |
| -------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------- |
| **New Service Name** | Yes      | The base name for the new ECS service. Harness appends an incrementing suffix (`__N`) to generate the versioned service name. |

Go to [ECS Service Setup step](https://developer.harness.io/continuous-delivery/new-experience/use-deployments/ecs-deployments/step-library/ecs-service-setup.md) for the full field reference.

***

## Configure the ECS Upgrade Container step

The ECS Upgrade Container step is required in this strategy. **New Service Name** must resolve to a value before the pipeline can run; Harness wires it from the ECS Service Setup step's output by default.

| Field                                                           | Required | Description                                                                                                                 |
| --------------------------------------------------------------- | -------- | --------------------------------------------------------------------------------------------------------------------------- |
| **New Service Name**                                            | Yes      | Wired from the ECS Service Setup step's `newService` output. Do not change this unless you are using a custom service name. |
| **Old Service Name**                                            | No       | Wired from the ECS Service Setup step's `oldServiceName` output.                                                            |
| **New Instance Count**, **New Instance Unit**                   | No       | Control how many instances the new service scales to.                                                                       |
| **Resize Strategy**                                             | No       | Controls whether the new service scales up before or after the old service scales down.                                     |
| **Downsize Old Instance Count**, **Downsize Old Instance Unit** | No       | Optionally scale down the previous service once the new service reaches steady state.                                       |

Go to [ECS Upgrade Container step](https://developer.harness.io/continuous-delivery/new-experience/use-deployments/ecs-deployments/step-library/ecs-upgrade-container.md) for the full field reference.

***

## Rollback behavior

When the stage failure strategy triggers rollback, Harness runs the ECS Basic Rollback step automatically. Its **New Service** and **First Deployment** fields are wired from the ECS Service Setup step's outputs and do not need to be changed.

Rollback behavior differs by deployment history:

* **First deployment:** There is no previous service to restore. Harness sets the new service desired count to zero.
* **Subsequent deployments:** Harness restores the previous task definition, scaling policies, and scalable targets on the old service and deletes the new service.

Go to [ECS Basic Rollback step](https://developer.harness.io/continuous-delivery/new-experience/use-deployments/ecs-deployments/step-library/ecs-basic-rollback.md) for the full field reference.

***

## Next steps

* Go to [ECS canary deployment](https://developer.harness.io/continuous-delivery/new-experience/use-deployments/ecs-deployments/ecs-deployment-strategies/canary.md) for a phased rollout with a canary instance.
* Go to [ECS rolling deployment](https://developer.harness.io/continuous-delivery/new-experience/use-deployments/ecs-deployments/ecs-deployment-strategies/rolling.md) for an incremental update across instances.
* Go to [ECS BlueGreen Deploy With Swap Strategy](https://developer.harness.io/continuous-delivery/new-experience/use-deployments/ecs-deployments/ecs-deployment-strategies/blue-green-swap.md) or [ECS BlueGreen Deploy With Traffic Shift Strategy](https://developer.harness.io/continuous-delivery/new-experience/use-deployments/ecs-deployments/ecs-deployment-strategies/blue-green-traffic-shift.md) for a zero-downtime swap between two target groups.
